X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=a7a3e541b8211973ba7abc7db6a503339f40eb45;hp=41d4a83a90e234ddf221a3962c59b3460acfb325;hb=85f0cd00dee97c5c50614ca965c5b302ac04f515;hpb=9180c8e75a3439779b4d1c471771d78935936047 diff --git a/elpher.el b/elpher.el index 41d4a83..a7a3e54 100644 --- a/elpher.el +++ b/elpher.el @@ -21,7 +21,7 @@ ;; Created: 11 April 2019 ;; Version: 2.11.0 ;; Keywords: comm gopher -;; Homepage: https://alexschroeder.ch/cgit/elpher +;; Homepage: https://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "27.1")) ;; This file is not part of GNU Emacs. @@ -62,7 +62,8 @@ ;; Elpher is under active development. Any suggestions for ;; improvements are welcome, and can be made on the official -;; project page, https://alexschroeder.ch/cgit/elpher. +;; project page, gopher://thelambdalab.xyz/elpher, or via the +;; project mailing list at https://lists.sr.ht/~michel-slm/elpher. ;;; Code: @@ -89,10 +90,11 @@ (defalias 'elpher-color-filter-apply (if (fboundp 'xterm-color-filter) (lambda (s) - (let ((xterm-color-render nil)) + (let ((_xterm-color-render nil)) (xterm-color-filter s))) 'ansi-color-filter-apply) "A function to filter out ANSI escape sequences.") + (defalias 'elpher-color-apply (if (fboundp 'xterm-color-filter) 'xterm-color-filter @@ -531,8 +533,7 @@ unless NO-HISTORY is non-nil." (setq-local elpher-current-page page) (let* ((address (elpher-page-address page)) (type (elpher-address-type address)) - (type-record (cdr (assoc type elpher-type-map))) - (page-links nil)) + (type-record (cdr (assoc type elpher-type-map)))) (if type-record (funcall (car type-record) (if renderer @@ -690,7 +691,7 @@ unless `elpher-gemini-TLS-cert-checks' is non-nil. If non-nil, FORCE-IPV4 causes the network connection to be made over ipv4 only. (The default behaviour when this is not set depends on -the host operating system and the local network capabilities." +the host operating system and the local network capabilities.)" (if (and use-tls (not (gnutls-available-p))) (error "Use of TLS requires Emacs to be compiled with GNU TLS support") (unless (< (elpher-address-port address) 65536) @@ -1007,12 +1008,14 @@ displayed. The _WINDOW argument is currently unused." address (elpher-address-to-url address)))))))) -(defvar elpher--link-number-counter 0) +(defvar elpher--link-number-counter 0 + "Used to number links on elpher pages.") (defun elpher-reset-link-number-counter () + "Reset the link number counter." (setq-local elpher--link-number-counter 0)) (defun elpher--insert-text-button (label &rest properties) - "Inserts a potentially-numbered button into the current buffer. + "Insert a potentially-numbered button into the current buffer. The text for the button is provided by LABEL, while the button properties in PROPERTIES are as per `insert-text-button'." @@ -1288,10 +1291,15 @@ that the response was malformed." (error "Gemini server response unknown: %s %s" response-code response-meta)))))) -(unless (fboundp 'read-answer) - (defun read-answer (question answers) - "Backfill for the new read-answer code." - (completing-read question (mapcar 'identity answers)))) +(defun elpher--read-answer-polyfill (question answers) + "Polyfill for `read-answer' in Emacs 26.1. +QUESTION is a string containing a question, and ANSWERS +is a list of possible answers." + (completing-read question (mapcar 'identity answers))) + +(if (fboundp 'read-answer) + (defalias 'elpher-read-answer 'read-answer) + (defalias 'elpher-read-answer 'elpher--read-answer-polyfill)) (defun elpher-choose-client-certificate () "Prompt for a client certificate to use to establish a TLS connection." @@ -1633,10 +1641,10 @@ The result is rendered using RENDERER." " - c/C: copy URL representation of item under cursor or current page\n" " - a/A: bookmark the item under cursor or current page\n" " - B: list all bookmarks\n" - " - h/H: show history of current buffer or for all buffers\n" + " - s/S: show history of current buffer or for all buffers\n" " - r: redraw current page (using cached contents if available)\n" " - R: reload current page (regenerates cache)\n" - " - S: set character coding system for gopher (default is to autodetect)\n" + " - !: set character coding system for gopher (default is to autodetect)\n" " - T: toggle TLS gopher mode\n" " - F: forget/discard current TLS client certificate\n" " - .: display the raw server response for the current page\n" @@ -1652,6 +1660,20 @@ The result is rendered using RENDERER." (elpher-make-gopher-address ?7 "/v2/vs" "gopher.floodgap.com" 70)) (elpher-insert-index-record "Gemini Search Engine (geminispace.info)" (elpher-address-from-url "gemini://geminispace.info/search")) + (insert "\n" + "Your bookmarks are stored in your ") + (let ((help-string "RET,mouse-1: Open Emacs bookmark list")) + (elpher--insert-text-button "Emacs bookmark list" + 'face 'link + 'action (lambda (_) + (interactive) + (call-interactively #'bookmark-bmenu-list)) + 'follow-link t + 'help-echo help-string)) + (insert ".\n") + (insert (propertize + "(Bookmarks from legacy elpher-bookmarks files will be automatically imported.)\n" + 'face 'shadow)) (insert "\n" "For Elpher release news or to leave feedback, visit:\n") (elpher-insert-index-record "The Elpher Project Page" @@ -1713,13 +1735,16 @@ This is rendered using `elpher-get-history-all-page' via `elpher-type-map'." (defun elpher-show-history (pages) "Show all PAGES in the Elpher buffer." (elpher-with-clean-buffer + (insert "---- Visited link history ----\n\n") (if pages (dolist (page pages) (when page (let ((display-string (elpher-page-display-string page)) (address (elpher-page-address page))) (elpher-insert-index-record display-string address)))) - (insert "No history items found.\n")))) + (insert "No history items found.\n")) + (insert "\n----------------------------"))) + ;;; Bookmarks @@ -2047,7 +2072,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (let ((b (cdr (elt link-map (- n 1))))) (goto-char (button-start b)) (button-activate b)) - (error "No link with that number."))))) + (error "No link with that number"))))) (defun elpher-root-dir () "Visit root of current server." @@ -2133,8 +2158,8 @@ When run interactively HOST-OR-URL is read from the minibuffer." (define-key map (kbd "O") 'elpher-root-dir) (define-key map (kbd "g") 'elpher-go) (define-key map (kbd "o") 'elpher-go-current) - (define-key map (kbd "h") 'elpher-history) - (define-key map (kbd "H") 'elpher-history-all) + (define-key map (kbd "s") 'elpher-history) + (define-key map (kbd "S") 'elpher-history-all) (define-key map (kbd "r") 'elpher-redraw) (define-key map (kbd "R") 'elpher-reload) (define-key map (kbd "T") 'elpher-toggle-tls) @@ -2150,7 +2175,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (define-key map (kbd "a") 'elpher-set-bookmark-no-overwrite) (define-key map (kbd "A") 'bookmark-set-no-overwrite) (define-key map (kbd "B") 'bookmark-bmenu-list) - (define-key map (kbd "S") 'elpher-set-gopher-coding-system) + (define-key map (kbd "!") 'elpher-set-gopher-coding-system) (define-key map (kbd "F") 'elpher-forget-current-certificate) (when (fboundp 'evil-define-key*) (evil-define-key* @@ -2180,7 +2205,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (kbd "a") 'elpher-set-bookmark-no-overwrite (kbd "A") 'bookmark-set-no-overwrite (kbd "B") 'bookmark-bmenu-list - (kbd "S") 'elpher-set-gopher-coding-system + (kbd "!") 'elpher-set-gopher-coding-system (kbd "F") 'elpher-forget-current-certificate)) map) "Keymap for gopher client.")