X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=5af81210ebb09f4e40b0cfe992f160b8260a9c78;hp=be60abf586491024c50124f8f0c8ef109368e124;hb=a247f9f44f2dfd0b135ba310a8a9fe770a94ce8a;hpb=2cd88ac58b9f3e0d4d92db3f18ac80455dd71588 diff --git a/elpher.el b/elpher.el index be60abf..5af8121 100644 --- a/elpher.el +++ b/elpher.el @@ -4,7 +4,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 2.7.9 +;; Version: 2.7.10 ;; Keywords: comm gopher ;; Homepage: http://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "26")) @@ -70,7 +70,7 @@ ;;; Global constants ;; -(defconst elpher-version "2.7.9" +(defconst elpher-version "2.7.10" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -307,9 +307,9 @@ requiring gopher-over-TLS." (defun elpher-address-to-url (address) "Get string representation of ADDRESS, or nil if ADDRESS is special." - (if (not (elpher-address-special-p address)) - (url-encode-url (url-recreate-url address)) - nil)) + (if (elpher-address-special-p address) + nil + (url-encode-url (url-recreate-url address)))) (defun elpher-address-type (address) "Retrieve type of ADDRESS object. @@ -1116,18 +1116,18 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (defun elpher-address-from-gemini-url (url) "Extract address from URL with defaults as per gemini map files." - (let ((address (url-generic-parse-url url))) + (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 (setf (url-fullness address) t) (if (url-host address) ;if there is an explicit host, filenames are absolute (if (string-empty-p (url-filename address)) (setf (url-filename address) "/")) ;ensure empty filename is marked as absolute - (setf (url-host address) (url-host (elpher-page-address elpher-current-page))) - (setf (url-port address) (url-port (elpher-page-address elpher-current-page))) + (setf (url-host address) (url-host current-address)) + (setf (url-port address) (url-port current-address)) (unless (string-prefix-p "/" (url-filename address)) ;deal with relative links (setf (url-filename address) - (concat (file-name-directory - (url-filename (elpher-page-address elpher-current-page))) + (concat (file-name-directory (url-filename current-address)) (url-filename address))))) (unless (url-type address) (setf (url-type address) "gemini")) @@ -1522,11 +1522,12 @@ If ADDRESS is already bookmarked, update the label only." "Go to a particular gopher site HOST-OR-URL. When run interactively HOST-OR-URL is read from the minibuffer." (interactive "sGopher or Gemini URL: ") - (let ((page (elpher-make-page host-or-url - (elpher-address-from-url host-or-url)))) + (let* ((cleaned-host-or-url (string-trim host-or-url)) + (address (elpher-address-from-url cleaned-host-or-url)) + (page (elpher-make-page cleaned-host-or-url address))) (switch-to-buffer "*elpher*") (elpher-visit-page page) - '())) + nil)) (defun elpher-go-current () "Go to a particular site read from the minibuffer, initialized with the current URL."