From: Mark Oteiza <mvoteiza@udel.edu>
To: 19902@debbugs.gnu.org
Subject: bug#19902: 25.0.50; [PATCH v3] Make eww entry point more info-like
Date: Wed, 04 Mar 2015 13:52:25 -0500 [thread overview]
Message-ID: <87r3t4k32u.fsf_-_@udel.edu> (raw)
In-Reply-To: <878ufr4kkq.fsf_-_@violet.siamics.net> (Ivan Shmakov's message of "Sat, 21 Feb 2015 10:37:09 +0000")
---
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
next prev parent reply other threads:[~2015-03-04 18:52 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 ` 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 ` Mark Oteiza [this message]
2015-03-05 12:52 ` bug#19902: 25.0.50; [PATCH v3] " 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3t4k32u.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.