X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=56c5996c16ebc26a805ad441e318ff3d9a68f75d;hp=08b27949c26a8a8ce23b70cf54b9ac6808fd760a;hb=e8c010a9f70321b2671c2cf6b4cba2db8320e319;hpb=2af9aa28edc5f7be667eb7a64af9e416bccb052a diff --git a/elpher.el b/elpher.el index 08b2794..56c5996 100644 --- a/elpher.el +++ b/elpher.el @@ -161,6 +161,12 @@ May be empty." "Specify the name of the file where elpher bookmarks will be saved." :type '(file)) +(defcustom elpher-ipv4-always nil + "If non-nil, elpher will always use IPv4 to establish network connections. +This can be useful when browsing from a computer that supports IPv6, because +some servers which do not support IPv6 can take a long time to time-out." + :type '(boolean)) + ;; Face customizations (defgroup elpher-faces nil @@ -558,6 +564,7 @@ to ADDRESS." (error "Cannot retrieve TLS gopher selector: GnuTLS not available"))) (unless (< (elpher-address-port address) 65536) (error "Cannot retrieve gopher selector: port number > 65536")) + (defvar gnutls-verify-error) (condition-case nil (let* ((kill-buffer-query-functions nil) (gnutls-verify-error nil) ; We use the NSM for verification @@ -568,7 +575,9 @@ to ADDRESS." (hkbytes-received 0) (proc (open-network-stream "elpher-process" nil - (if force-ipv4 (dns-query host) host) + (if (or elpher-ipv4-always force-ipv4) + (dns-query host) + host) (if (> port 0) port 70) :type (if elpher-use-tls 'tls 'plain) :nowait t)) @@ -589,7 +598,7 @@ to ADDRESS." (elpher-network-error address "Could not establish encrypted connection"))) ('connect (elpher-process-cleanup) - (unless force-ipv4 + (unless (or elpher-ipv4-always force-ipv4) (message "Connection timed out. Retrying with IPv4 address.") (elpher-get-selector address renderer t)))))))) (setq elpher-network-timer timer) @@ -905,14 +914,16 @@ to ADDRESS." (hkbytes-received 0) (proc (open-network-stream "elpher-process" nil - (if force-ipv4 (dns-query host) host) + (if (or elpher-ipv4-always force-ipv4) + (dns-query host) + host) (if (> port 0) port 1965) :type 'tls :nowait t)) (timer (run-at-time elpher-connection-timeout nil (lambda () (elpher-process-cleanup) - (unless force-ipv4 + (unless (or elpher-ipv4-always force-ipv4) ; Try again with IPv4 (message "Connection timed out. Retrying with IPv4.") (elpher-get-gemini-response address renderer t)))))) @@ -949,7 +960,7 @@ to ADDRESS." "\r\n")))) ((string-prefix-p "deleted" event)) ; do nothing ((and (not response-string-parts) - (not force-ipv4)) + (not (or elpher-ipv4-always force-ipv4))) ; Try again with IPv4 (message "Connection failed. Retrying with IPv4.") (cancel-timer timer) @@ -1213,8 +1224,9 @@ width defined by elpher-gemini-max-fill-width." (defun elpher-get-finger-page (renderer &optional force-ipv4) "Opens a finger connection to the current page address. The result is rendered using RENDERER. When the optional argument -FORCE-IPV4 is non-nil, the IPv4 address returned by a DNS lookup will -be used explicitly in making the connection." +FORCE-IPV4 or the variable `elpher-ipv4-always' are non-nil, the +IPv4 address returned by a DNS lookup will be used explicitly in +making the connection." (let* ((address (elpher-page-address elpher-current-page)) (content (elpher-get-cached-content address))) (if (and content (funcall renderer nil)) @@ -1235,7 +1247,9 @@ be used explicitly in making the connection." (selector-string-parts nil) (proc (open-network-stream "elpher-process" nil - (if force-ipv4 (dns-query host) host) + (if (or elpher-ipv4-always force-ipv4) + (dns-query host) + host) port :type 'plain :nowait t)) @@ -1245,7 +1259,7 @@ be used explicitly in making the connection." (pcase (process-status proc) ('connect (elpher-process-cleanup) - (unless force-ipv4 + (unless (or elpher-ipv4-always force-ipv4) (message "Connection timed out. Retrying with IPv4 address.") (elpher-get-finger-page renderer t)))))))) (setq elpher-network-timer timer) @@ -1670,7 +1684,8 @@ When run interactively HOST-OR-URL is read from the minibuffer." "Remove bookmark for the current page." (interactive) (let ((address (elpher-page-address elpher-current-page))) - (unless (elpher-address-special-p address) + (when (and (not (elpher-address-special-p address)) + (y-or-n-p "Really remove bookmark for the current page? ")) (elpher-remove-address-bookmark address) (message "Bookmark removed.")))) @@ -1679,10 +1694,11 @@ When run interactively HOST-OR-URL is read from the minibuffer." (interactive) (let ((button (button-at (point)))) (if button - (let ((page (button-get button 'elpher-page))) - (elpher-remove-address-bookmark (elpher-page-address page)) - (elpher-reload-bookmarks) - (message "Bookmark removed.")) + (when (y-or-n-p "Really remove bookmark for this link? ") + (let ((page (button-get button 'elpher-page))) + (elpher-remove-address-bookmark (elpher-page-address page)) + (elpher-reload-bookmarks) + (message "Bookmark removed."))) (error "No link selected")))) (defun elpher-bookmarks ()