* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
@ 2015-02-19 15:03 Mark Oteiza
2015-02-19 15:05 ` Mark Oteiza
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-02-19 15:03 UTC (permalink / raw)
To: 19902
---
eww already has some info-like behaviour, and I think this is a good
thing. An example is isearch in eww.
It's weird how M-x eww will always just reset the whole eww session
instead of going back to a buried eww buffer. Also, now that eww has a
nice way to select instances with S, there should be an easy way to
duplicate eww buffers. The way info does this is with clone-buffer, and
it makes sense for eww to do the same.
With these changes, one can keep eww sessions around without clobbering
them every time M-x eww is invoked. Now, one can have multiple eww's,
and to get to one of them, either:
M-x eww RET S
M-N eww RET
where M-N is the numeric prefix N. Aside from eww's `S' command for
switching sessions, this is very much like how one uses info, and usage
feels much smoother and familiar for an Emacs interface.
P.S. This (or some other patches I have sitting on the ML) puts my
contributions over 15 lines. Paperwork is currently a WIP.
lisp/ChangeLog | 6 ++++++
lisp/net/eww.el | 25 ++++++++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 933e5bb..f12889a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-19 Mark Oteiza <mvoteiza@udel.edu>
+
+ * net/eww.el (eww): Behave more like `info' entry point
+ (eww-fetch): Replaces prior eww function.
+ (eww-mode-map): More Info-like `M-n' for `clone-buffer'
+
2015-02-19 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/smie.el (smie-prec2->grammar): Fix corner case problem.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b7ee065..ad322ed 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -239,8 +239,7 @@ This list can be customized via `eww-suggest-uris'."
(push uri uris)))))
(nreverse uris)))
-;;;###autoload
-(defun eww (url)
+(defun eww-fetch (url)
"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'."
@@ -288,6 +287,23 @@ word(s) will be searched for via `eww-search-prefix'."
(url-retrieve url 'eww-render
(list url nil (current-buffer))))
+;;;###autoload
+(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 numeric prefix argument of N selects an eww
+buffer named \"*eww*<N>\"."
+ (interactive
+ (let ((buf (get-buffer (if (numberp current-prefix-arg)
+ (format "*eww*<%s>" current-prefix-arg)
+ "*eww*"))))
+ (list (unless buf (read-string "Enter URL or keywords: "))
+ buf)))
+ (if buffer (pop-to-buffer-same-window buffer)
+ (eww-fetch url)))
+
;;;###autoload (defalias 'browse-web 'eww)
;;;###autoload
@@ -624,7 +640,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-fetch)
(define-key map [?\t] 'shr-next-link)
(define-key map [?\M-\t] 'shr-previous-link)
(define-key map [backtab] 'shr-previous-link)
@@ -648,8 +664,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
^ permalink raw reply related [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
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
` (2 subsequent siblings)
3 siblings, 0 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-02-19 15:05 UTC (permalink / raw)
To: 19902
On 19/02/15 at 10:03am, Mark Oteiza wrote:
> M-N eww RET
M-N M-x eww RET
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
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 19:03 ` bug#19902: 25.0.50; [PATCH] " Juri Linkov
3 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2015-02-19 15:32 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
> From: Mark Oteiza <mvoteiza@udel.edu>
> Date: Thu, 19 Feb 2015 10:03:50 -0500
>
> With these changes, one can keep eww sessions around without clobbering
> them every time M-x eww is invoked. Now, one can have multiple eww's,
> and to get to one of them, either:
>
> M-x eww RET S
> M-N eww RET
>
> where M-N is the numeric prefix N. Aside from eww's `S' command for
> switching sessions, this is very much like how one uses info, and usage
> feels much smoother and familiar for an Emacs interface.
Thanks.
> +2015-02-19 Mark Oteiza <mvoteiza@udel.edu>
> +
> + * net/eww.el (eww): Behave more like `info' entry point
> + (eww-fetch): Replaces prior eww function.
> + (eww-mode-map): More Info-like `M-n' for `clone-buffer'
Please describe the changes themselves (i.e. the new behavior), not
what the behavior is similar to. The ChangeLog entries are supposed
to be self-contained in their descriptions.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
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:35 ` Ivan Shmakov
2015-02-19 15:51 ` Mark Oteiza
2015-02-19 19:03 ` bug#19902: 25.0.50; [PATCH] " Juri Linkov
3 siblings, 1 reply; 25+ messages in thread
From: Ivan Shmakov @ 2015-02-19 15:35 UTC (permalink / raw)
To: 19902
>>>>> Mark Oteiza <mvoteiza@udel.edu> writes:
[…]
> * net/eww.el (eww): Behave more like `info' entry point
> (eww-fetch): Replaces prior eww function.
> (eww-mode-map): More Info-like `M-n' for `clone-buffer'
Looks good to me, although I tend to prefer non-numeric suffixes
(like <w:en>, <w:eo>, <w:ru> for the Wikipedias, <gbts> for the
GNU debbugs, etc. FWIW, it makes it pretty easy to complete.)
[…]
> + (interactive
> + (let ((buf (get-buffer (if (numberp current-prefix-arg)
> + (format "*eww*<%s>" current-prefix-arg)
> + "*eww*"))))
> + (list (unless buf (read-string "Enter URL or keywords: "))
> + buf)))
… Except for this part, which essentially reintroduces #19106;
see [1]. I presume that for this reason, the new ‘eww’ command
should call ‘eww-suggested-uris’ just like the old one does.
[1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19106#msg8
[…]
--
FSF associate member #7257 http://boycottsystemd.org/ … 3013 B6A0 230E 334A
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
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
0 siblings, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-02-19 15:51 UTC (permalink / raw)
To: 19902
Ivan Shmakov <ivan@siamics.net> writes:
>>>>>> Mark Oteiza <mvoteiza@udel.edu> writes:
> > + (interactive
> > + (let ((buf (get-buffer (if (numberp current-prefix-arg)
> > + (format "*eww*<%s>" current-prefix-arg)
> > + "*eww*"))))
> > + (list (unless buf (read-string "Enter URL or keywords: "))
> > + buf)))
>
> … Except for this part, which essentially reintroduces #19106;
> see [1]. I presume that for this reason, the new ‘eww’ command
> should call ‘eww-suggested-uris’ just like the old one does.
>
> [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19106#msg8
Hm, good catch. I'm not sure how this should fit in. Perhaps
`eww-suggested-uris' should be the behaviour behind the non-numeric
prefix (C-u)?
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
2015-02-19 15:32 ` Eli Zaretskii
@ 2015-02-19 15:52 ` Mark Oteiza
0 siblings, 0 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-02-19 15:52 UTC (permalink / raw)
To: 19902
Eli Zaretskii <eliz@gnu.org> writes:
>> +2015-02-19 Mark Oteiza <mvoteiza@udel.edu>
>> +
>> + * net/eww.el (eww): Behave more like `info' entry point
>> + (eww-fetch): Replaces prior eww function.
>> + (eww-mode-map): More Info-like `M-n' for `clone-buffer'
>
> Please describe the changes themselves (i.e. the new behavior), not
> what the behavior is similar to. The ChangeLog entries are supposed
> to be self-contained in their descriptions.
Thanks, I'll attend to that
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; Make eww entry point more info-like
2015-02-19 15:51 ` Mark Oteiza
@ 2015-02-19 17:32 ` Ivan Shmakov
2015-02-19 18:33 ` Stefan Monnier
0 siblings, 1 reply; 25+ messages in thread
From: Ivan Shmakov @ 2015-02-19 17:32 UTC (permalink / raw)
To: 19902
>>>>> Mark Oteiza <mvoteiza@udel.edu> writes:
>>>>> Ivan Shmakov <ivan@siamics.net> writes:
>>>>> Mark Oteiza <mvoteiza@udel.edu> writes:
>>> (eww-mode-map): More Info-like `M-n' for `clone-buffer'
On a second thought, it may still be worth preserving the
(M-n, M-p) pair for some kind of navigation (whether bookmark or
something else; FWIW, I don’t use EWW bookmarks personally.)
It may even make sense to bind clone-buffer to a different key
sequence in Info-mode-map (in addition to the current binding.)
>>> + (interactive
>>> + (let ((buf (get-buffer (if (numberp current-prefix-arg)
>>> + (format "*eww*<%s>" current-prefix-arg)
>>> + "*eww*"))))
>>> + (list (unless buf (read-string "Enter URL or keywords: "))
>>> + buf)))
>> … Except for this part, which essentially reintroduces #19106; see
>> [1]. I presume that for this reason, the new ‘eww’ command should
>> call ‘eww-suggested-uris’ just like the old one does.
>> [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19106#msg8
> Hm, good catch. I'm not sure how this should fit in. Perhaps
> `eww-suggested-uris' should be the behaviour behind the non-numeric
> prefix (C-u)?
The list of defaults returned by ‘eww-suggested-uris’ is only
meaningful for the ‘read-string’ code path, which implies that
either no prefix argument is given, /or/ the prefix given does
not refer to an existing *eww* buffer.
--
FSF associate member #7257 http://boycottsystemd.org/ … 3013 B6A0 230E 334A
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; Make eww entry point more info-like
2015-02-19 17:32 ` bug#19902: 25.0.50; " Ivan Shmakov
@ 2015-02-19 18:33 ` Stefan Monnier
0 siblings, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2015-02-19 18:33 UTC (permalink / raw)
To: 19902
> On a second thought, it may still be worth preserving the
> (M-n, M-p) pair for some kind of navigation (whether bookmark or
> something else; FWIW, I don’t use EWW bookmarks personally.)
> It may even make sense to bind clone-buffer to a different key
> sequence in Info-mode-map (in addition to the current binding.)
Indeed, the M-n/M-p pair can be useful for other things.
I chose M-n in Info-mode because that's what came up first in my mind
("n" is for "new"), but we could use something else just as well.
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
2015-02-19 15:03 bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like Mark Oteiza
` (2 preceding siblings ...)
2015-02-19 15:35 ` Ivan Shmakov
@ 2015-02-19 19:03 ` Juri Linkov
2015-02-19 22:55 ` bug#19902: 25.0.50; [PATCH v2] " Mark Oteiza
3 siblings, 1 reply; 25+ messages in thread
From: Juri Linkov @ 2015-02-19 19:03 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
> -(defun eww (url)
> +(defun eww-fetch (url)
> "Fetch URL and render the page.
The corresponding Info command is named `Info-goto-node',
so a better name would be `eww-goto-url' because
it not only fetches URL, but also renders the page.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like
2015-02-19 19:03 ` bug#19902: 25.0.50; [PATCH] " Juri Linkov
@ 2015-02-19 22:55 ` Mark Oteiza
2015-02-20 23:34 ` Mark Oteiza
2015-02-23 19:28 ` bug#19902: 25.0.50; [PATCH v2] " Juri Linkov
0 siblings, 2 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-02-19 22:55 UTC (permalink / raw)
To: 19902
---
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
^ permalink raw reply related [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like
2015-02-19 22:55 ` bug#19902: 25.0.50; [PATCH v2] " Mark Oteiza
@ 2015-02-20 23:34 ` Mark Oteiza
2015-02-21 10:37 ` bug#19902: 25.0.50; " Ivan Shmakov
2015-02-23 19:28 ` bug#19902: 25.0.50; [PATCH v2] " Juri Linkov
1 sibling, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-02-20 23:34 UTC (permalink / raw)
To: 19902
On 19/02/15 at 05:55pm, Mark Oteiza wrote:
> + (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*"))))
`buffer' has to be non-nil, so the first predicate should instead be
(and buffer (get-buffer buffer)
(or (not current-prefix-arg (numberp current-prefix-arg))))
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; Make eww entry point more info-like
2015-02-20 23:34 ` Mark Oteiza
@ 2015-02-21 10:37 ` Ivan Shmakov
2015-03-04 18:52 ` bug#19902: 25.0.50; [PATCH v3] " Mark Oteiza
0 siblings, 1 reply; 25+ messages in thread
From: Ivan Shmakov @ 2015-02-21 10:37 UTC (permalink / raw)
To: 19902
>>>>> Mark Oteiza <mvoteiza@udel.edu> writes:
>>>>> On 19/02/15 at 05:55pm, Mark Oteiza wrote:
>> + (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*"))))
> `buffer' has to be non-nil, so the first predicate should instead be
> (and buffer (get-buffer buffer)
> (or (not current-prefix-arg (numberp current-prefix-arg))))
… And thus (or buffer …) is the same as simply ‘buffer’ in the
“true” branch.
(if (and buffer (get-buffer buffer)
(or (not current-prefix-arg) (numberp current-prefix-arg)))
(pop-to-buffer-same-window buffer)
(eww-goto-url url (or buffer "*eww*")))
--
FSF associate member #7257 np. Vivo duras sed vi molas — Martin & La Talpoj
e
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like
2015-02-19 22:55 ` bug#19902: 25.0.50; [PATCH v2] " Mark Oteiza
2015-02-20 23:34 ` Mark Oteiza
@ 2015-02-23 19:28 ` Juri Linkov
2015-03-04 19:01 ` Mark Oteiza
1 sibling, 1 reply; 25+ messages in thread
From: Juri Linkov @ 2015-02-23 19:28 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
> 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.
Both info and eww could share a better keybinding. What comes to mind is
`C-x 4 c' globally bound to clone-indirect-buffer-other-window.
Could it be used in eww?
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-02-21 10:37 ` bug#19902: 25.0.50; " Ivan Shmakov
@ 2015-03-04 18:52 ` Mark Oteiza
2015-03-05 12:52 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-03-04 18:52 UTC (permalink / raw)
To: 19902
---
Ivan Shmakov <ivan@siamics.net> writes:
> … And thus (or buffer …) is the same as simply ‘buffer’ in the
> “true” branch.
>
> (if (and buffer (get-buffer buffer)
> (or (not current-prefix-arg) (numberp current-prefix-arg)))
> (pop-to-buffer-same-window buffer)
> (eww-goto-url url (or buffer "*eww*")))
Thanks, change made
lisp/ChangeLog | 13 +++++++++++++
lisp/net/eww.el | 48 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cdd4bf8..9fe4d50 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
+2015-03-04 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-03-04 Filipp Gunbin <fgunbin@fastmail.fm>
* autorevert.el (auto-revert-notify-add-watch):
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 577cd41..4b696f7 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -239,17 +239,42 @@ 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 buffer (get-buffer buffer)
+ (or (not current-prefix-arg) (numberp current-prefix-arg)))
+ (pop-to-buffer-same-window buffer)
+ (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 +303,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 +556,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 +649,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 +673,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.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v2] Make eww entry point more info-like
2015-02-23 19:28 ` bug#19902: 25.0.50; [PATCH v2] " Juri Linkov
@ 2015-03-04 19:01 ` Mark Oteiza
0 siblings, 0 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-03-04 19:01 UTC (permalink / raw)
To: 19902
Juri Linkov <juri@linkov.net> writes:
>> 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.
>
> Both info and eww could share a better keybinding. What comes to mind is
> `C-x 4 c' globally bound to clone-indirect-buffer-other-window.
> Could it be used in eww?
Shadowing a global binding seems weird. Also, it does not do the same
thing as clone-buffer and is disabled in Info.
Because of the incumbence, the mnemonic nature, and the brevity of M-n,
I'm hard pressed to think of a better binding.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
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
0 siblings, 1 reply; 25+ messages in thread
From: Lars Magne Ingebrigtsen @ 2015-03-05 12:52 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
Mark Oteiza <mvoteiza@udel.edu> writes:
> +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>\"."
This all seems too complicated.
`M-x eww RET' should allow people to just paste in URLs or whatever.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-03-05 12:52 ` Lars Magne Ingebrigtsen
@ 2015-03-05 15:05 ` Mark Oteiza
2015-03-05 22:21 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-03-05 15:05 UTC (permalink / raw)
To: 19902
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
>> +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>\"."
>
> This all seems too complicated.
>
> `M-x eww RET' should allow people to just paste in URLs or whatever.
Which it does, unless *eww* already exists, in which case it switches to
the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
one can just do C-u M-x eww RET.
It works like info, and info works nicely. It gives people the choice
either to enter a URL, switch to any existing eww session, or create a
new one.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-03-05 15:05 ` Mark Oteiza
@ 2015-03-05 22:21 ` Lars Magne Ingebrigtsen
2015-03-05 23:25 ` Mark Oteiza
0 siblings, 1 reply; 25+ messages in thread
From: Lars Magne Ingebrigtsen @ 2015-03-05 22:21 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
Mark Oteiza <mvoteiza@udel.edu> writes:
> Which it does, unless *eww* already exists, in which case it switches to
> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
> one can just do C-u M-x eww RET.
I think that's way too confusing.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-03-05 22:21 ` Lars Magne Ingebrigtsen
@ 2015-03-05 23:25 ` Mark Oteiza
2015-03-06 0:16 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-03-05 23:25 UTC (permalink / raw)
To: 19902
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
>> Which it does, unless *eww* already exists, in which case it switches to
>> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
>> one can just do C-u M-x eww RET.
>
> I think that's way too confusing.
Thanks for the constructive feedback.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-03-05 23:25 ` Mark Oteiza
@ 2015-03-06 0:16 ` Lars Magne Ingebrigtsen
2015-12-25 6:38 ` Lars Ingebrigtsen
0 siblings, 1 reply; 25+ messages in thread
From: Lars Magne Ingebrigtsen @ 2015-03-06 0:16 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
Mark Oteiza <mvoteiza@udel.edu> writes:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Mark Oteiza <mvoteiza@udel.edu> writes:
>>
>>> Which it does, unless *eww* already exists, in which case it switches to
>>> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
>>> one can just do C-u M-x eww RET.
>>
>> I think that's way too confusing.
>
> Thanks for the constructive feedback.
Your patch changes what happens when the user types `M-x eww' depending
on whether an unseen buffer exists or not. This makes the command
inconsistent, and therefore confusing.
You're welcome.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
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 18:00 ` Mark Oteiza
0 siblings, 2 replies; 25+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-25 6:38 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
>> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>>
>>> Mark Oteiza <mvoteiza@udel.edu> writes:
>>>
>>>> Which it does, unless *eww* already exists, in which case it switches to
>>>> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
>>>> one can just do C-u M-x eww RET.
>>>
>>> I think that's way too confusing.
>>
>> Thanks for the constructive feedback.
>
> Your patch changes what happens when the user types `M-x eww' depending
> on whether an unseen buffer exists or not. This makes the command
> inconsistent, and therefore confusing.
>
> You're welcome.
I'm still of the opinion that this feature is too confusing, so I'm
closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-12-25 6:38 ` Lars Ingebrigtsen
@ 2015-12-25 16:34 ` Mark Oteiza
2015-12-25 16:37 ` Lars Ingebrigtsen
2015-12-25 18:00 ` Mark Oteiza
1 sibling, 1 reply; 25+ messages in thread
From: Mark Oteiza @ 2015-12-25 16:34 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 19902
On 25/12/15 at 07:38am, Lars Ingebrigtsen wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
> > Mark Oteiza <mvoteiza@udel.edu> writes:
> >
> >> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> >>
> >>> Mark Oteiza <mvoteiza@udel.edu> writes:
> >>>
> >>>> Which it does, unless *eww* already exists, in which case it switches to
> >>>> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
> >>>> one can just do C-u M-x eww RET.
> >>>
> >>> I think that's way too confusing.
> >>
> >> Thanks for the constructive feedback.
> >
> > Your patch changes what happens when the user types `M-x eww' depending
> > on whether an unseen buffer exists or not. This makes the command
> > inconsistent, and therefore confusing.
> >
> > You're welcome.
>
> I'm still of the opinion that this feature is too confusing, so I'm
> closing this bug report.
I had the idea of hiding this behind a defcustom to the effect of
`eww-always-prompt` (which would be t so the default behavior is
unchanged) but I still am at a loss to how you think this is confusing.
It's almost exactly how M-x info works.
If there was some simplification to which you would be amenable, I think
the bare minimum from this patch would be just switching to *eww* if it
exists already.
IIRC doing M-x eww RET some-url RET destroys the history of an existing
*eww* buffer, which is another annoying problem that the current M-x eww
"workflow" exacerbates. But I already mentioned that when I first
submitted the patch.
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-12-25 16:34 ` Mark Oteiza
@ 2015-12-25 16:37 ` Lars Ingebrigtsen
2015-12-25 17:59 ` Mark Oteiza
0 siblings, 1 reply; 25+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-25 16:37 UTC (permalink / raw)
To: Mark Oteiza; +Cc: 19902
Mark Oteiza <mvoteiza@udel.edu> writes:
> IIRC doing M-x eww RET some-url RET destroys the history of an existing
> *eww* buffer, which is another annoying problem that the current M-x eww
> "workflow" exacerbates.
That bug has been fixed now.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-12-25 16:37 ` Lars Ingebrigtsen
@ 2015-12-25 17:59 ` Mark Oteiza
0 siblings, 0 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-12-25 17:59 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 19902
On 25/12/15 at 05:37pm, Lars Ingebrigtsen wrote:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
> > IIRC doing M-x eww RET some-url RET destroys the history of an existing
> > *eww* buffer, which is another annoying problem that the current M-x eww
> > "workflow" exacerbates.
>
> That bug has been fixed now.
Thanks (for all those fixes, for that matter).
^ permalink raw reply [flat|nested] 25+ messages in thread
* bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
2015-12-25 6:38 ` Lars Ingebrigtsen
2015-12-25 16:34 ` Mark Oteiza
@ 2015-12-25 18:00 ` Mark Oteiza
1 sibling, 0 replies; 25+ messages in thread
From: Mark Oteiza @ 2015-12-25 18:00 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 19902
On 25/12/15 at 07:38am, Lars Ingebrigtsen wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
> > Mark Oteiza <mvoteiza@udel.edu> writes:
> >
> >> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> >>
> >>> Mark Oteiza <mvoteiza@udel.edu> writes:
> >>>
> >>>> Which it does, unless *eww* already exists, in which case it switches to
> >>>> the buffer. Then one can kit a key 'G' and paste a URL. Alternatively,
> >>>> one can just do C-u M-x eww RET.
> >>>
> >>> I think that's way too confusing.
> >>
> >> Thanks for the constructive feedback.
> >
> > Your patch changes what happens when the user types `M-x eww' depending
> > on whether an unseen buffer exists or not. This makes the command
> > inconsistent, and therefore confusing.
> >
> > You're welcome.
>
> I'm still of the opinion that this feature is too confusing, so I'm
> closing this bug report.
OK, I'll continue on e-d then.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2015-12-25 18:00 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` bug#19902: 25.0.50; [PATCH v2] " Mark Oteiza
2015-02-20 23:34 ` 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
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).