X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=de21b640057f641d98b85ca4bc45c42ff463be5e;hp=5762afafd3caefee1eefed8edbef5ca0d95770fd;hb=329bded18811e816d1f4cddfa5ecd8cb82acc41a;hpb=b16e94dbedea9a69045c5825274df548d22d1bfa diff --git a/elpher.el b/elpher.el index 5762afa..de21b64 100644 --- a/elpher.el +++ b/elpher.el @@ -286,9 +286,23 @@ some servers which do not support IPv6 can take a long time to time-out." ;; Gemini defaults (if (equal (url-filename url) "") (setf (url-filename url) "/")))) - url) + (elpher-remove-redundant-ports url)) (set-match-data data)))) +(defun elpher-remove-redundant-ports (address) + "Remove redundant port specifiers from ADDRESS. +Here 'redundant' means that the specified port matches the default +for that protocol, eg 70 for gopher." + (if (and (not (elpher-address-special-p address)) + (eq (url-portspec address) ; (url-port) is too slow! + (pcase (url-type address) + ("gemini" 1965) + ((or "gopher" "gophers") 70) + ("finger" 79) + (_ -1)))) + (setf (url-portspec address) nil)) + address) + (defun elpher-make-gopher-address (type selector host port &optional tls) "Create an ADDRESS object using gopher directory record attributes. The basic attributes include: TYPE, SELECTOR, HOST and PORT. @@ -650,7 +664,8 @@ the host operating system and the local network capabilities." (t (elpher-network-error address "Connection time-out."))))))) (setq elpher-network-timer timer) - (elpher-buffer-message (concat "Connecting to " host "...")) + (elpher-buffer-message (concat "Connecting to " host "..." + " (press 'u' to abort)")) (set-process-filter proc (lambda (_proc string) (when timer @@ -675,7 +690,8 @@ the host operating system and the local network capabilities." (cond ((string-prefix-p "open" event) ; request URL (elpher-buffer-message - (concat "Connected to " host ". Receiving data...")) + (concat "Connected to " host ". Receiving data..." + " (press 'u' to abort)")) (let ((inhibit-eol-conversion t)) (process-send-string proc query-string))) ((string-prefix-p "deleted" event)) ; do nothing @@ -1258,7 +1274,10 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (string-join (reverse path-reversed-normalized) "/"))) (defun elpher-address-from-gemini-url (url) - "Extract address from URL with defaults as per gemini map files." + "Extract address from URL with defaults as per gemini map files. +While there's obviously some redundancy here between this function and +`elpher-address-from-url', gemini map file URLs require enough special +treatment that a separate function is warranted." (let ((address (url-generic-parse-url url)) (current-address (elpher-page-address elpher-current-page))) (unless (and (url-type address) (not (url-fullness address))) ;avoid mangling mailto: urls @@ -1274,10 +1293,10 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (url-filename address))))) (unless (url-type address) (setf (url-type address) "gemini")) - (if (equal (url-type address) "gemini") - (setf (url-filename address) - (elpher-collapse-dot-sequences (url-filename address))))) - address)) + (when (equal (url-type address) "gemini") + (setf (url-filename address) + (elpher-collapse-dot-sequences (url-filename address))))) + (elpher-remove-redundant-ports address))) (defun elpher-gemini-insert-link (link-line) "Insert link described by LINK-LINE into a text/gemini document."