From: plugd Date: Thu, 29 Jul 2021 10:08:05 +0000 (+0200) Subject: Merge. X-Git-Tag: v3.2.0~13 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=commitdiff_plain;h=3035057fb699a56b7ea89108d26d046213ee5cd0;hp=a2f3bd8f2f6344ab43d4dfd201b6ef8adafd2ea2 Merge. --- diff --git a/config.mk b/config.mk index 1a08e4a..197706e 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ PKG = elpher -VERSION = 3.0.0 +VERSION = 3.1.0 INSTALLINFO = install-info MAKEINFO = makeinfo diff --git a/elpher-pkg.el b/elpher-pkg.el index 920951e..045b3ff 100644 --- a/elpher-pkg.el +++ b/elpher-pkg.el @@ -1,4 +1,4 @@ -(define-package "elpher" "3.0.0" "A friendly gopher and gemini client" +(define-package "elpher" "3.1.0" "A friendly gopher and gemini client" '((emacs "27.1")) :keywords ("convenience") :authors (("Tim Vaughan" . "plugd@thelambdalab.xyz")) diff --git a/elpher.el b/elpher.el index cfa13b9..f47dfa0 100644 --- a/elpher.el +++ b/elpher.el @@ -19,7 +19,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 3.0.0 +;; Version: 3.1.0 ;; Keywords: comm gopher ;; Homepage: https://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "27.1")) @@ -73,19 +73,18 @@ ;; (require 'seq) -(require 'pp) (require 'shr) (require 'url-util) (require 'subr-x) -(require 'dns) (require 'nsm) (require 'gnutls) (require 'socks) +(require 'bookmark) ;;; Global constants ;; -(defconst elpher-version "3.0.0" +(defconst elpher-version "3.1.0" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -110,6 +109,7 @@ (telnet elpher-get-telnet-page nil "tel" elpher-telnet) (other-url elpher-get-other-url-page nil "url" elpher-other-url) ((special start) elpher-get-start-page nil "E" elpher-index) + ((special bookmarks) elpher-get-bookmarks-page nil "E" elpher-index) ((special history) elpher-get-history-page nil "E" elpher-index) ((special visited-pages) elpher-get-visited-pages-page nil "E" elpher-index)) "Association list from types to getters, renderers, margin codes and index faces.") @@ -127,7 +127,8 @@ (defvar ansi-color-context) (defvar bookmark-make-record-function) (defvar mu4e~view-beginning-of-url-regexp) - (defvar thing-at-point-uri-schemes)) + (defvar thing-at-point-uri-schemes) + (defvar xterm-color-preserve-properties)) ;;; Customization group @@ -215,6 +216,12 @@ some servers which do not support IPv6 can take a long time to time-out." Otherwise, the SOCKS proxy is only used for connections to onion services." :type '(boolean)) +(defcustom elpher-use-emacs-bookmark-menu nil + "If non-nil, elpher will only use the native Emacs bookmark menu. +Otherwise, \\[elpher-show-bookmarks] will visit a special elpher bookmark +page within which all of the standard elpher keybindings are active." + :type '(boolean)) + ;; Face customizations (defgroup elpher-faces nil @@ -580,6 +587,7 @@ previously-visited pages,unless NO-HISTORY is non-nil." (defmacro elpher-with-clean-buffer (&rest args) "Evaluate ARGS with a clean *elpher* buffer as current." + (declare (debug (body))) ;; Allow edebug to step through body `(with-current-buffer elpher-buffer-name (unless (eq major-mode 'elpher-mode) ;; avoid resetting buffer-local variables @@ -714,7 +722,7 @@ ERROR can be either an error object or a string." (cancel-timer elpher-network-timer))) (defun elpher-make-network-timer (thunk) - "Creates a timer to run the THUNK after `elpher-connection-timeout' seconds. + "Create a timer to run the THUNK after `elpher-connection-timeout' seconds. This is just a wraper around `run-at-time' which additionally sets the buffer-local variable `elpher-network-timer' to allow `elpher-process-cleanup' to also clear the timer." @@ -1665,12 +1673,12 @@ The result is rendered using RENDERER." (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")) - (insert-text-button "Emacs bookmark list" + (let ((help-string "RET,mouse-1: Open bookmark list")) + (insert-text-button "bookmark list" 'face 'link 'action (lambda (_) (interactive) - (call-interactively #'elpher-open-bookmarks)) + (call-interactively #'elpher-show-bookmarks)) 'follow-link t 'help-echo help-string)) (insert ".\n") @@ -1705,8 +1713,8 @@ The result is rendered using RENDERER." 'help-echo help-string)) (insert "\n") (insert (propertize - (concat " (These documents should be available if you have installed Elpher \n" - " using MELPA. Otherwise you may have to install the manual yourself.)\n") + (concat "(These documents should be available if you have installed Elpher \n" + " using MELPA. Otherwise you may have to install the manual yourself.)\n") 'face 'shadow)) (elpher-restore-pos))) @@ -1750,7 +1758,7 @@ This is rendered using `elpher-get-visited-pages-page' via `elpher-type-map'." (defun elpher-display-history-links (pages title) "Show all PAGES in an Elpher buffer with a given TITLE." - (let* ((title-line (concat "---- " title " ----")) + (let* ((title-line (concat " ---- " title " ----")) (footer-line (make-string (length title-line) ?-))) (elpher-with-clean-buffer (insert title-line "\n\n") @@ -1761,8 +1769,8 @@ This is rendered using `elpher-get-visited-pages-page' via `elpher-type-map'." (address (elpher-page-address page))) (elpher-insert-index-record display-string address)))) (insert "No history items found.\n")) - (insert "\n" footer-line "\n" - "Select and entry or press 'u' to return to the previous page.") + (insert "\n " footer-line "\n" + "Select an entry or press 'u' to return to the previous page.") (elpher-restore-pos)))) @@ -1837,7 +1845,6 @@ To bookmark the link at point use \\[elpher-bookmark-link]." (read-file-name "Old Elpher bookmarks: " user-emacs-directory nil t "elpher-bookmarks")))) - (require 'bookmark) (dolist (bookmark (with-temp-buffer (insert-file-contents file) (read (current-buffer)))) @@ -1849,10 +1856,38 @@ To bookmark the link at point use \\[elpher-bookmark-link]." (bookmark-store display-string (cdr record) t))) (bookmark-save)) -(defun elpher-open-bookmarks () +(defun elpher-get-bookmarks-page (renderer) + "Getter which displays the history page (RENDERER must be nil)." + (when renderer + (elpher-visit-previous-page) + (error "Command not supported for bookmarks page")) + (elpher-with-clean-buffer + (insert " ---- Elpher Bookmarks ---- \n\n") + (bookmark-maybe-load-default-file) + (dolist (bookmark (bookmark-maybe-sort-alist)) + (when (eq #'elpher-bookmark-jump (alist-get 'handler (cdr bookmark))) + (let* ((name (car bookmark)) + (url (alist-get 'location (cdr bookmark))) + (address (elpher-address-from-url url))) + (elpher-insert-index-record name address)))) + (when (<= (line-number-at-pos) 3) + (insert "No bookmarked pages found.\n")) + (insert "\n --------------------------\n\n" + "Select an entry or press 'u' to return to the previous page.\n\n" + "Bookmarks can be renamed or deleted via the ") + (insert-text-button "Emacs bookmark menu" + 'action (lambda (_) + (interactive) + (call-interactively #'bookmark-bmenu-list)) + 'follow-link t + 'help-echo "RET,mouse-1: open Emacs bookmark menu") + (insert (substitute-command-keys + ",\nwhich can also be opened from anywhere using '\\[bookmark-bmenu-list]'.")) + (elpher-restore-pos))) + +(defun elpher-show-bookmarks () "Display the current list of elpher bookmarks. -This is just a call to `bookmark-bmenu-list', but we also check for a legacy -bookmark file and offer to import it." +This will also check for a legacy bookmark file and offer to import it." (interactive) (let ((old-bookmarks-file (or (and (boundp 'elpher-bookmarks-file) elpher-bookmarks-file) @@ -1863,7 +1898,11 @@ bookmark file and offer to import it." "\" found. Import now?"))) (elpher-bookmark-import old-bookmarks-file) (rename-file old-bookmarks-file (concat old-bookmarks-file "-legacy")))) - (call-interactively #'bookmark-bmenu-list)) + (if elpher-use-emacs-bookmark-menu + (call-interactively #'bookmark-bmenu-list) + (elpher-visit-page + (elpher-make-page "Elpher Bookmarks" + (elpher-make-special-address 'bookmarks))))) ;;; Integrations @@ -2211,7 +2250,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (define-key map (kbd "C") 'elpher-copy-current-url) (define-key map (kbd "a") 'elpher-bookmark-link) (define-key map (kbd "A") 'elpher-bookmark-current) - (define-key map (kbd "B") 'elpher-open-bookmarks) + (define-key map (kbd "B") 'elpher-show-bookmarks) (define-key map (kbd "!") 'elpher-set-gopher-coding-system) (define-key map (kbd "F") 'elpher-forget-current-certificate) (when (fboundp 'evil-define-key*) @@ -2243,7 +2282,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (kbd "C") 'elpher-copy-current-url (kbd "a") 'elpher-bookmark-link (kbd "A") 'elpher-bookmark-current - (kbd "B") 'elpher-open-bookmarks + (kbd "B") 'elpher-show-bookmarks (kbd "!") 'elpher-set-gopher-coding-system (kbd "F") 'elpher-forget-current-certificate)) map) diff --git a/elpher.texi b/elpher.texi index 498e1bb..54eea80 100644 --- a/elpher.texi +++ b/elpher.texi @@ -1,7 +1,7 @@ \input texinfo @c -*-texinfo-*- @setfilename elpher.info -@settitle Elpher Manual v3.0.0 +@settitle Elpher Manual v3.1.0 @dircategory Emacs @direntry @@ -283,7 +283,7 @@ Moving to a different page can be accomplished in several ways, described by the following command: @table @asis -@keycmd{@key{RET}\, @kbd{mouse-1}, elpher-follow-link} +@keycmd{@key{RET}\, @key{mouse-1}, elpher-follow-link} Follow the menu item or link at point (or selected with the mouse). Exactly what is meant by ``follow'' depends on the kind of item selected: @@ -337,7 +337,7 @@ structure of selectors. @keycmd{@key{O}, elpher-root-dir} Open the root page (empty selector) on the current host. -@keycmd{@key{u}\, @key{-}\, @key{^}\, @kbd{mouse-3}, elpher-back} +@keycmd{@key{u}\, @key{-}\, @key{^}\, @key{mouse-3}, elpher-back} Return to the previous page, where ``previous'' means the page where the page which was displayed immediately before the current page. @end table @@ -396,9 +396,9 @@ pages you visited in your current Emacs session. @node Bookmarks, Gopher character encodings, Navigation, Top @chapter Bookmarks -Elpher makes use of standard Emacs bookmarks. @xref{Bookmarks, , , -emacs, The Emacs Editor}. The following commands are perhaps the most -useful ones: +Elpher makes use of standard Emacs bookmarks. +@xref{Bookmarks, , , emacs, The Emacs Editor}. +The following commands are used to add new bookmarks: @table @asis @keycmd{@key{a}, elpher-bookmark-link} @@ -410,9 +410,20 @@ Add a bookmark for the current page. The minibuffer will prompt for a name for the bookmark, defaulting to the display string associated with the link that was followed to reach the current page. + @keycmd{@key{B}, elpher-open-bookmarks} -Open a page displaying all current bookmarks. This is where you can -delete and search bookmarks, for example. +Visit a page displaying all elpher bookmarks. +The behaviour of the this function depends on the customization variable +@code{elpher-use-emacs-bookmark-menu}. If nil (the default), the +command will visit a special elpher page listing all elpher-specific +bookmarks. If non-nil, the command will simply open the standard Emacs +bookmark list displaying all current bookmarks (including non-elpher +bookmarks). + +@keycmd{@kbd{C-x r l}, bookmark-bmenu-list} +This command opens the standard Emacs bookmark menu, with which bookmarks +can be renamed, deleted or annotated. + @end table On opening the bookmarks page, elpher will offer to import any legacy @@ -683,6 +694,28 @@ See the customization group itself for details. This chapter documents the major changes introduced by Elpher releases. +@section v3.1.0 + +@subsection Bookmarks system + +While Elpher bookmarks are still handled by the Emacs bookmark +system, this release introduces the option to retain the +original elpher bookmark page for the purpose of visiting those +bookmarks. In v3.1.0, @key{B} visits this page (and adds it to +the history stack, as in previous versions), which can be interacted +with using the standard elpher key bindings. + +Of course you can still view the bookmarks in the Emacs bookmark +menu, which you can access from anywhere using the default +binding @kbd{C-x r l} (or by following the link from the Elpher bookmarks +page). Indeed you will need to use this to rename, delete or otherwise +edit your bookmarks. + +If you prefer to avoid using the Elpher bookmark page entirely, you +use the customization variable @code{elpher-use-emacs-bookmark-menu} +to have the @key{B} key open the Emacs bookmark menu directly, as in +the previous release. + @section v3.0.0 @subsection Bookmarks system @@ -698,7 +731,7 @@ bookmark list with the new version. A suffix will be added to your old bookmarks file so that Elpher knows that the import is complete. Secondly, the old Elpher bookmark menu has been removed in the new -version. Instead, @kbd{B} brings up the menu provided by the Emacs +version. Instead, @key{B} brings up the menu provided by the Emacs function @code{bookmark-bmenu-list}. This has different key and mouse bindings to Elpher's old menu, but is much more functional. Bookmarks can be renamed, deleted in groups, and much more. (Use @kbd{C-h m} with @@ -706,9 +739,9 @@ the menu open to see the complete list.) @subsection History -Browsing history can now be accessed via new bindings to @kbd{s} and @kbd{S}. +Browsing history can now be accessed via new bindings to @key{s} and @key{S}. The former shows the current history ``stack'' (pages accessible with -the @kbd{u} key), while the latter shows a list of all pages which have +the @key{u} key), while the latter shows a list of all pages which have been visited in the current session. @subsection Socks connections