X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=elpher.el;h=531b2da071c23a68cadd8d26a6b80b4b06bd6db9;hb=14f8d5cd99838da14b292fe4992ed0a4aa70af41;hp=a24d0569914ffe740674bcf7fb1d1d6fac7afd28;hpb=006a983c5e051bdda257cc6a5bc39ba82be5faf9;p=elpher.git diff --git a/elpher.el b/elpher.el index a24d056..531b2da 100644 --- a/elpher.el +++ b/elpher.el @@ -216,6 +216,9 @@ special address types, such as 'start for the start page." "Retrieve port from ADDRESS." (elt address 3)) +(defun elpher-address-special-p (address) + (not (elpher-address-host address))) + ;; Node (defun elpher-make-node (display-string parent address) @@ -373,7 +376,7 @@ and PORT." (let ((address (elpher-make-address type selector host port)) (type-map-entry (alist-get type elpher-type-map))) (if type-map-entry - (let* ((margin-code (cadr type-map-entry)) + (let* ((margin-code (elt type-map-entry 1)) (face (elt type-map-entry 2)) (node (elpher-make-node display-string elpher-current-node address))) (elpher-insert-margin margin-code) @@ -765,7 +768,9 @@ If ADDRESS is already bookmarked, update the label only." (push-button)) (defun elpher-go () - "Go to a particular gopher site." + "Go to a particular gopher site read from the minibuffer. +The site may be specified via a URL or explicitly in terms of +host, selector and port." (interactive) (let ((node (let ((host-or-url (read-string "Gopher host or URL: "))) @@ -798,11 +803,13 @@ If ADDRESS is already bookmarked, update the label only." (message "No current site."))) (defun elpher-view-raw () - "View current page as plain text." + "View raw server response for current page." (interactive) (if elpher-current-node - (elpher-visit-node elpher-current-node - #'elpher-get-node-raw) + (if (elpher-address-special-p (elpher-node-address elpher-current-node)) + (error "This page was not generated by a server.") + (elpher-visit-node elpher-current-node + #'elpher-get-node-raw)) (message "No current site."))) (defun elpher-back () @@ -818,10 +825,10 @@ If ADDRESS is already bookmarked, update the label only." (let ((button (button-at (point)))) (if button (let ((node (button-get button 'elpher-node))) - (if node - (elpher-visit-node (button-get button 'elpher-node) - #'elpher-get-node-download) - (error "Can only download gopher links, not general URLs"))) + (if (elpher-address-special-p (elpher-node-address node)) + (error "Cannot download this link") + (elpher-visit-node (button-get button 'elpher-node) + #'elpher-get-node-download))) (error "No link selected")))) (defun elpher-build-link-map () @@ -839,7 +846,7 @@ If ADDRESS is already bookmarked, update the label only." (let* ((link-map (elpher-build-link-map))) (if link-map (let ((key (let ((completion-ignore-case t)) - (completing-read "Directory entry/link (tab to autocomplete): " + (completing-read "Directory item/link: " link-map nil t)))) (if (and key (> (length key) 0)) (let ((b (cdr (assoc key link-map))))