From fa1d9bd99e08b50e0aed3b42e5f8d4bf64039b8e Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Thu, 27 Jun 2019 10:24:02 +0200 Subject: [PATCH] Added elpher-go-current. --- elpher.el | 17 ++++++++++++++++- elpher.texi | 12 ++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/elpher.el b/elpher.el index d225d03..2afe674 100644 --- a/elpher.el +++ b/elpher.el @@ -760,7 +760,7 @@ calls, as is necessary if the match is performed by `string-match'." " - RET/mouse-1: open item under cursor\n" " - m: select an item on current page by name (autocompletes)\n" " - u: return to previous page\n" - " - O: visit the root menu of the current server\n" + " - o/O: visit different selector or the root menu of the current server\n" " - g: go to a particular gopher address\n" " - i/I: info on item under cursor or current page\n" " - c/C: copy URL representation of item under cursor or current page\n" @@ -914,6 +914,19 @@ host, selector and port." (switch-to-buffer "*elpher*") (elpher-visit-node node))) +(defun elpher-go-current () + "Go to a particular site read from the minibuffer, initialized with the current URL." + (interactive) + (let ((address (elpher-node-address elpher-current-node))) + (if (elpher-address-special-p address) + (error "Command not valid for this page") + (let ((url (read-string "URL: " (elpher-get-address-url address)))) + (if (string-match elpher-url-regex url) + (let ((new-node (elpher-make-node-from-matched-url url))) + (unless (equal (elpher-node-address new-node) address) + (elpher-visit-node new-node))) + (error "Could not parse URL %s" url)))))) + (defun elpher-redraw () "Redraw current page." (interactive) @@ -1169,6 +1182,7 @@ host, selector and port." (define-key map (kbd "u") 'elpher-back) (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 "r") 'elpher-redraw) (define-key map (kbd "R") 'elpher-reload) (define-key map (kbd "T") 'elpher-toggle-tls) @@ -1194,6 +1208,7 @@ host, selector and port." (kbd "u") 'elpher-back (kbd "O") 'elpher-root-dir (kbd "g") 'elpher-go + (kbd "o") 'elpher-go-current (kbd "r") 'elpher-redraw (kbd "R") 'elpher-reload (kbd "T") 'elpher-toggle-tls diff --git a/elpher.texi b/elpher.texi index dabf745..aad71a2 100644 --- a/elpher.texi +++ b/elpher.texi @@ -292,8 +292,16 @@ cached for the duration of the Emacs session. Open a particular page by specifying either its URL or directly entering a host, port and selector. -Note that if a non-gopher protocol is used in the URL the result will be -the same as following a URL link of the same type from a gopher menu. +If a non-gopher protocol is used in the URL the result will be the same +as following a URL link of the same type from a gopher menu. + +@keycmd{@key{o}, elpher-go-current} +Prompts for a URL similar to @code{elpher-go}, but initialized to the URL +of the current page. This allows you to easily try other selectors for the +same server. + +Remember however, that the Gopher RFC 1436 provides no guarantees about the +structure of selectors. @keycmd{@key{O}, elpher-root-dir} Open the root page (empty selector) on the current host. -- 2.20.1