[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
From: |
Mark Oteiza |
Subject: |
bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like |
Date: |
Wed, 04 Mar 2015 13:52:25 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
---
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
- bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like,
Mark Oteiza <=