;;; Gopher selector retrieval
;;
+(defvar elpher-network-timer nil
+ "Timer used for network connections.")
+
(defun elpher-process-cleanup ()
"Immediately shut down any extant elpher process and timers."
(let ((p (get-process "elpher-process")))
(defvar elpher-use-tls nil
"If non-nil, use TLS to communicate with gopher servers.")
-(defvar elpher-network-timer)
-
(defun elpher-get-selector (address renderer &optional force-ipv4)
"Retrieve selector specified by ADDRESS, then render it using RENDERER.
If FORCE-IPV4 is non-nil, explicitly look up and use IPv4 address corresponding
(message "Disabling TLS mode.")
(setq elpher-use-tls nil)
(elpher-get-selector address renderer))
- (elpher-network-error "Could not establish encrypted connection.")))
+ (elpher-network-error address "Could not establish encrypted connection")))
('connect
(elpher-process-cleanup)
(unless force-ipv4
(error "Cannot establish gemini connection: GnuTLS not available")
(unless (< (elpher-address-port address) 65536)
(error "Cannot establish gemini connection: port number > 65536"))
- (condition-case the-error
+ (condition-case _the-error
(let* ((kill-buffer-query-functions nil)
- (network-security-level 'medium)
(port (elpher-address-port address))
(host (elpher-address-host address))
(response-string "")
(message "Connection failed. Retrying with IPv4.")
(cancel-timer timer)
(elpher-get-gemini-response address renderer t))
- (t
+ (t
(funcall #'elpher-process-gemini-response
response-string
renderer)
(elpher-restore-pos)))
- (error the-error
+ (error
(elpher-network-error address the-error))))))
(error
(error "Error initiating connection to server")))))
(defun elpher-parse-gemini-response (response)
- "Parse the RESPONSE string and return a list of components
-The list is of the form (code meta body). A response of nil implies
+ "Parse the RESPONSE string and return a list of components.
+The list is of the form (code meta body). A response of nil implies
that the response was malformed."
(let ((header-end-idx (string-match "\r\n" response)))
(if header-end-idx
(let ((address (url-generic-parse-url url)))
(unless (and (url-type address) (not (url-fullness address))) ;avoid mangling mailto: urls
(setf (url-fullness address) t)
- (unless (url-host address) ;if there is an explicit host, filenames are absolute
+ (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-node-address elpher-current-node)))
(unless (string-prefix-p "/" (url-filename address)) ;deal with relative links
(setf (url-filename address)
(address (elpher-address-from-url (elpher-bookmark-url bookmark))))
(elpher-insert-index-record display-string address)))
(insert "No bookmarks found.\n")))
- (insert "\n-----------------------\n\n"
+ (insert "\n-----------------------\n"
+ "\n"
"- u: return to previous page\n"
"- x: delete selected bookmark\n"
- "- a: rename selected bookmark\n\n"
- "Bookmarks are stored in the file "
- (locate-user-emacs-file "elpher-bookmarks"))
+ "- a: rename selected bookmark\n"
+ "\n"
+ "Bookmarks are stored in the file ")
+ (let ((filename (locate-user-emacs-file "elpher-bookmarks"))
+ (help-string "RET,mouse-1: Open bookmarks file in new buffer for editing."))
+ (insert-text-button filename
+ 'face 'link
+ 'action (lambda (_)
+ (interactive)
+ (find-file filename))
+ 'follow-link t
+ 'help-echo help-string))
+ (insert "\n")
(elpher-restore-pos)))