X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=a7a3e541b8211973ba7abc7db6a503339f40eb45;hp=65309498b68ac45418631068b618a7b76c7f98c5;hb=85f0cd00dee97c5c50614ca965c5b302ac04f515;hpb=91cf7b969ff2342a604e152b6c5547118f0b292c diff --git a/elpher.el b/elpher.el index 6530949..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 @@ -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." @@ -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" @@ -2050,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."