X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=53ca1e4470a54c79739f7d319dfedb29f729c800;hp=882ed2aac9d6e678d416b02ab3353fc0f749ac8f;hb=b5269970249871a8889950a3e47bdff51eb0420c;hpb=78ea2a7bcbe79ab4a775d245f97c2f24e15ac9e0 diff --git a/elpher.el b/elpher.el index 882ed2a..53ca1e4 100644 --- a/elpher.el +++ b/elpher.el @@ -66,6 +66,7 @@ (require 'gnutls) (require 'socks) (require 'bookmark) +(require 'rx) ;;; Global constants ;; @@ -1804,10 +1805,10 @@ Assumes UTF-8 encoding for all text files." (filename (elpher-address-filename address))) (unless (file-exists-p filename) (elpher-visit-previous-page) - (error "File not found")) + (error "File not found")) (unless (file-readable-p filename) (elpher-visit-previous-page) - (error "Could not read from file")) + (error "Could not read from file")) (let ((body (with-temp-buffer (let ((coding-system-for-read 'binary) (coding-system-for-write 'binary)) @@ -2266,7 +2267,8 @@ supports the old protocol elpher, where the link is self-contained." "Go to a particular gopher site HOST-OR-URL. When run interactively HOST-OR-URL is read from the minibuffer." (interactive (list - (read-string (format "Visit URL (default scheme %s): " (elpher-get-default-url-scheme))))) + (read-string (format "Visit URL (default scheme %s): " + (elpher-get-default-url-scheme))))) (let ((trimmed-host-or-url (string-trim host-or-url))) (unless (string-empty-p trimmed-host-or-url) (let ((page (elpher-page-from-url trimmed-host-or-url @@ -2283,10 +2285,14 @@ Unlike `elpher-go', the reader is initialized with the URL of the current page." (interactive) (let* ((address (elpher-page-address elpher-current-page)) - (url (read-string (format "Visit URL (default scheme %s): " (elpher-get-default-url-scheme)) + (url (read-string (format "Visit URL (default scheme %s): " + (elpher-get-default-url-scheme)) (elpher-address-to-url address)))) - (unless (string-empty-p (string-trim url)) - (elpher-visit-page (elpher-page-from-url url))))) + (let ((trimmed-url (string-trim url))) + (unless (string-empty-p trimmed-url) + (elpher-with-clean-buffer + (elpher-visit-page + (elpher-page-from-url trimmed-url (elpher-get-default-url-scheme)))))))) (defun elpher-redraw () "Redraw current page." @@ -2349,9 +2355,7 @@ current page." (if (elpher-address-about-p (elpher-page-address elpher-current-page)) (error "Cannot download %s" (elpher-page-display-string elpher-current-page)) - (elpher-visit-page (elpher-make-page - (elpher-page-display-string elpher-current-page) - (elpher-page-address elpher-current-page)) + (elpher-visit-page elpher-current-page #'elpher-render-download t)))