From: Mark Oteiza <mvoteiza@udel.edu>
To: 19902@debbugs.gnu.org
Subject: bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like
Date: Thu, 19 Feb 2015 17:55:53 -0500 [thread overview]
Message-ID: <878uftfr46.fsf_-_@udel.edu> (raw)
In-Reply-To: <87y4ntyhqu.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 19 Feb 2015 21:03:12 +0200")
---
Both `C-u M-x eww RET' and `G' (eww-goto-url) in eww prompt for URL
using `eww-suggest-uris'.
A little argument shuffling had to happen. I think I properly handled
the possible uses of `eww' and `eww-goto-url' interactively and in lisp.
Regarding the bookmark/info binding, the whole inspiration to this
change is to make the eww interface more info-like. Info is a
good manual browser, and eww benefits from assimilating features from
info to be a good web browser.
Between the familiar M-n, eww's "S" command, and the new behavior of
`M-x eww', eww's flow has improved. Eww is now a nice tabbed web
browser, where each tab's history doesn't get clobbered every time M-x
eww is invoked, and one doesn't have to switch-buffer or similar to find an
existing eww session.
I also have never felt compelled to cycle through my bookmarks, so I am
not troubled by losing the bookmark bindings.
lisp/ChangeLog | 13 +++++++++++++
lisp/net/eww.el | 47 +++++++++++++++++++++++++++++++++++------------
2 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3d15b40..fa2f252 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
+2015-02-19 Mark Oteiza <mvoteiza@udel.edu>
+
+ * net/eww.el (eww): New behavior. Pops to an existing buffer,
+ otherwise creates a new one. The buffer name is controlled by
+ numeric prefix. A non-numeric prefix always prompts for a URL.
+ (eww-goto-url): New function. Assumes the previous role of `eww',
+ now accepting an optional `buffer' argument
+ (eww-read-string): New function. Wrapper for `read-string'
+ used by `eww' and `eww-goto-url'.
+ (eww-setup-buffer): Accept `buffer' argument.
+ (eww-mode-map): Replace existing bindings for M-n and M-p with
+ a binding of M-n to `clone-buffer'.
+
2015-02-19 Dima Kogan <dima@secretsauce.net>
* autorevert.el (auto-revert-buffers-counter)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b7ee065..37df68e 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -239,17 +239,41 @@ This list can be customized via `eww-suggest-uris'."
(push uri uris)))))
(nreverse uris)))
+(defun eww-read-string ()
+ (let* ((uris (eww-suggested-uris))
+ (prompt (concat "Enter URL or keywords"
+ (if uris (format " (default %s)" (car uris)))
+ ": ")))
+ (read-string prompt nil nil uris)))
+
;;;###autoload
-(defun eww (url)
+(defun eww (&optional url buffer)
+ "Enter eww, the Emacs Web Wowser.
+Optional argument URL specifies the target to navigate;
+the default is `eww-search-prefix'.
+
+In interactive use, a non-numeric prefix argument directs
+this command to read URL from the minibuffer.
+
+A numeric prefix argument of N selects an eww buffer named \"*eww*<N>\"."
+ (interactive
+ (let ((name (if (numberp current-prefix-arg)
+ (format "*eww*<%s>" current-prefix-arg)
+ "*eww*")))
+ (list (if (or (not (get-buffer name))
+ (and current-prefix-arg (not (numberp current-prefix-arg))))
+ (eww-read-string))
+ name)))
+ (if (and (get-buffer buffer) (or (not current-prefix-arg) (numberp current-prefix-arg)))
+ (pop-to-buffer-same-window (or buffer "*eww*"))
+ (eww-goto-url url (or buffer "*eww*"))))
+
+(defun eww-goto-url (url &optional buffer)
"Fetch URL and render the page.
If the input doesn't look like an URL or a domain name, the
word(s) will be searched for via `eww-search-prefix'."
(interactive
- (let* ((uris (eww-suggested-uris))
- (prompt (concat "Enter URL or keywords"
- (if uris (format " (default %s)" (car uris)) "")
- ": ")))
- (list (read-string prompt nil nil uris))))
+ (list (eww-read-string)))
(setq url (string-trim url))
(cond ((string-match-p "\\`file:/" url))
;; Don't mangle file: URLs at all.
@@ -278,7 +302,7 @@ word(s) will be searched for via `eww-search-prefix'."
(when (or (plist-get eww-data :url)
(plist-get eww-data :dom))
(eww-save-history))
- (eww-setup-buffer)
+ (eww-setup-buffer buffer)
(plist-put eww-data :url url)
(plist-put eww-data :title "")
(eww-update-header-line-format)
@@ -531,8 +555,8 @@ See the `eww-search-prefix' variable for the search engine used."
(mailcap-view-mime "application/pdf")))
(goto-char (point-min)))
-(defun eww-setup-buffer ()
- (switch-to-buffer (get-buffer-create "*eww*"))
+(defun eww-setup-buffer (buffer)
+ (switch-to-buffer (get-buffer-create (or buffer "*eww*")))
(let ((inhibit-read-only t))
(remove-overlays)
(erase-buffer))
@@ -624,7 +648,7 @@ the like."
(let ((map (make-sparse-keymap)))
(set-keymap-parent map special-mode-map)
(define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead!
- (define-key map "G" 'eww)
+ (define-key map "G" 'eww-goto-url)
(define-key map [?\t] 'shr-next-link)
(define-key map [?\M-\t] 'shr-previous-link)
(define-key map [backtab] 'shr-previous-link)
@@ -648,8 +672,7 @@ the like."
(define-key map "b" 'eww-add-bookmark)
(define-key map "B" 'eww-list-bookmarks)
- (define-key map [(meta n)] 'eww-next-bookmark)
- (define-key map [(meta p)] 'eww-previous-bookmark)
+ (define-key map [(meta n)] 'clone-buffer)
(easy-menu-define nil map ""
'("Eww"
--
2.3.0
next prev parent reply other threads:[~2015-02-19 22:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 15:03 bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like Mark Oteiza
2015-02-19 15:05 ` Mark Oteiza
2015-02-19 15:32 ` Eli Zaretskii
2015-02-19 15:52 ` Mark Oteiza
2015-02-19 15:35 ` Ivan Shmakov
2015-02-19 15:51 ` Mark Oteiza
2015-02-19 17:32 ` bug#19902: 25.0.50; " Ivan Shmakov
2015-02-19 18:33 ` Stefan Monnier
2015-02-19 19:03 ` bug#19902: 25.0.50; [PATCH] " Juri Linkov
2015-02-19 22:55 ` Mark Oteiza [this message]
2015-02-20 23:34 ` bug#19902: 25.0.50; [PATCH v2] " Mark Oteiza
2015-02-21 10:37 ` bug#19902: 25.0.50; " Ivan Shmakov
2015-03-04 18:52 ` bug#19902: 25.0.50; [PATCH v3] " Mark Oteiza
2015-03-05 12:52 ` Lars Magne Ingebrigtsen
2015-03-05 15:05 ` Mark Oteiza
2015-03-05 22:21 ` Lars Magne Ingebrigtsen
2015-03-05 23:25 ` Mark Oteiza
2015-03-06 0:16 ` Lars Magne Ingebrigtsen
2015-12-25 6:38 ` Lars Ingebrigtsen
2015-12-25 16:34 ` Mark Oteiza
2015-12-25 16:37 ` Lars Ingebrigtsen
2015-12-25 17:59 ` Mark Oteiza
2015-12-25 18:00 ` Mark Oteiza
2015-02-23 19:28 ` bug#19902: 25.0.50; [PATCH v2] " Juri Linkov
2015-03-04 19:01 ` Mark Oteiza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878uftfr46.fsf_-_@udel.edu \
--to=mvoteiza@udel.edu \
--cc=19902@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).