X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=722027663cc10e4f57f62e94ce07325c2630a4d1;hp=deb7fe88d2db6b3b9c639bf9a7f78f113f3e40ca;hb=285a073c36cad19dbf2e157d0314128f67473d4c;hpb=0e8eb2e0c919a07aa5db733d02e7669ccfb4276d diff --git a/elpher.el b/elpher.el index deb7fe8..7220276 100644 --- a/elpher.el +++ b/elpher.el @@ -4,10 +4,10 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 1.4.6 +;; Version: 1.4.7 ;; Keywords: comm gopher ;; Homepage: https://github.com/tgvaughan/elpher -;; Package-Requires: ((emacs "25")) +;; Package-Requires: ((emacs "26")) ;; This file is not part of GNU Emacs. @@ -50,14 +50,20 @@ ;;; Code: (provide 'elpher) + +;;; Dependencies +;; + (require 'seq) (require 'pp) (require 'shr) +(require 'url-util) + ;;; Global constants ;; -(defconst elpher-version "1.4.6" +(defconst elpher-version "1.4.7" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -209,21 +215,22 @@ before attempting to connect to the server." (selector (elpher-address-selector address)) (bare-host (elpher-address-host address)) (port (elpher-address-port address))) - (let ((host (if (string-match-p ":" bare-host) - (concat "[" bare-host "]") - bare-host))) - (if (and (equal type ?h) - (string-prefix-p "URL:" selector)) - (elt (split-string selector "URL:") 1) - (concat "gopher" - (if (elpher-address-use-tls-p address) "s" "") - "://" - host - (if (equal port 70) - "" - (format ":%d" port)) - "/" (string type) - selector))))) + (url-encode-url + (let ((host (if (string-match-p ":" bare-host) + (concat "[" bare-host "]") + bare-host))) + (if (and (equal type ?h) + (string-prefix-p "URL:" selector)) + (elt (split-string selector "URL:") 1) + (concat "gopher" + (if (elpher-address-use-tls-p address) "s" "") + "://" + host + (if (equal port 70) + "" + (format ":%d" port)) + "/" (string type) + selector)))))) ;; Node @@ -297,8 +304,12 @@ unless PRESERVE-PARENT is non-nil." (if getter (funcall getter) (let* ((address (elpher-node-address node)) - (type (elpher-address-type address))) - (funcall (car (alist-get type elpher-type-map)))))) + (type (elpher-address-type address)) + (type-record (alist-get type elpher-type-map))) + (if type-record + (funcall (car type-record)) + (elpher-visit-parent-node) + (error "Unsupported gopher selector type '%c'" type))))) (defun elpher-visit-parent-node () "Visit the parent of the current node." @@ -554,9 +565,11 @@ calls, as is necessary if the match is performed by `string-match'." (type (if (> (length type-and-selector) 1) (elt type-and-selector 1) ?1)) - (selector (if (> (length type-and-selector) 1) - (substring type-and-selector 2) - "")) + (selector (decode-coding-string + (url-unhex-string + (if (> (length type-and-selector) 1) + (substring type-and-selector 2) + "")) 'utf-8)) (use-tls (string= protocol "gophers")) (address (elpher-make-address type selector host port use-tls))) (elpher-make-node url address)) @@ -793,7 +806,7 @@ calls, as is necessary if the match is performed by `string-match'." " - R: reload current page (regenerates cache)\n" " - T: toggle TLS mode\n" " - d/D: download item under cursor or current page\n" - " - w: display the raw server response for the current page\n" + " - .: display the raw server response for the current page\n" " - S: set an explicit character coding system (default is to autodetect)\n" "\n" "Start your exploration of gopher space:\n") @@ -1191,7 +1204,7 @@ host, selector and port." (define-key map (kbd "r") 'elpher-redraw) (define-key map (kbd "R") 'elpher-reload) (define-key map (kbd "T") 'elpher-toggle-tls) - (define-key map (kbd "w") 'elpher-view-raw) + (define-key map (kbd ".") 'elpher-view-raw) (define-key map (kbd "d") 'elpher-download) (define-key map (kbd "D") 'elpher-download-current) (define-key map (kbd "m") 'elpher-jump) @@ -1217,7 +1230,7 @@ host, selector and port." (kbd "r") 'elpher-redraw (kbd "R") 'elpher-reload (kbd "T") 'elpher-toggle-tls - (kbd "w") 'elpher-view-raw + (kbd ".") 'elpher-view-raw (kbd "d") 'elpher-download (kbd "D") 'elpher-download-current (kbd "m") 'elpher-jump