[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like
From: |
Mark Oteiza |
Subject: |
bug#19902: 25.0.50; [PATCH] Make eww entry point more info-like |
Date: |
Thu, 19 Feb 2015 10:03:50 -0500 |
---
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