unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark Oteiza <mvoteiza@udel.edu>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 22244@debbugs.gnu.org
Subject: bug#22244: [PATCH] New command eww-switch-to-buffer
Date: Thu, 4 Feb 2016 01:31:43 -0500	[thread overview]
Message-ID: <20160204063143.GA13606@holos> (raw)
In-Reply-To: <87powdnrp4.fsf@gnus.org>

* doc/misc/eww.texi: Document eww-switch-to-buffer and its keybinding
* etc/NEWS: Mention new command
* lisp/net/eww.el (eww-mode-map): Bind eww-switch-to-buffer to "s"
(eww-mode-map): Add menu item
(eww-switch-to-buffer): New command
---
On 04/02/16 at 01:18pm, Lars Ingebrigtsen wrote:
> Mark Oteiza <mvoteiza@udel.edu> writes:
> 
> > I don't, but I was thinking more like "S but in the minibuffer". Where the
> > buffer names in erc are meaningful, in eww they are not so much (at
> > least in my case where I'm usually using clone-buffer to make more eww
> > buffers). So the completion candidates might be the buffer urls, titles, or
> > instead just showing annotations like so:
> 
> That sounds pretty cool...  Alternatively we could give the eww buffers
> better names (based on URLs or titles).  That may be a handful, though.
> 
> Could you send a patch for this new command against the trunk (including
> documentation)?

Hopefully covered everything. "s" seemed a sensible bind.

 doc/misc/eww.texi |  6 +++++-
 etc/NEWS          |  5 +++++
 lisp/net/eww.el   | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index 0e9bedb..afb1caf 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -164,12 +164,16 @@ You can view stored bookmarks with @kbd{B}
 (@code{eww-list-bookmarks}).  This will open the bookmark buffer
 @file{*eww bookmarks*}.
 
+@findex eww-switch-to-buffer
 @findex eww-list-buffers
+@kindex s
 @kindex S
 @cindex Multiple Buffers
   To get summary of currently opened EWW buffers, press @kbd{S}
 (@code{eww-list-buffers}).  The @file{*eww buffers*} buffer allows you
-to quickly kill, flip through and switch to specific EWW buffer.
+to quickly kill, flip through and switch to specific EWW buffer.  To
+switch EWW buffers through a minibuffer prompt, press @kbd{s}
+(@code{eww-switch-to-buffer}).
 
 @findex eww-browse-with-external-browser
 @vindex shr-external-browser
diff --git a/etc/NEWS b/etc/NEWS
index 3150432..faf49b0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -52,6 +52,11 @@ in these situations.
 \f
 * Changes in Specialized Modes and Packages in Emacs 25.2
 
+** eww
+
++++
+*** A new `s' command for switching to another eww buffer via the minibuffer.
+
 +++
 ** The commands that add ChangeLog entries now prefer a VCS root directory
 for the ChangeLog file, if none already exists.  Customize
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index cb23127..5a50877 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -689,6 +689,7 @@ the like."
     (define-key map "R" 'eww-readable)
     (define-key map "H" 'eww-list-histories)
     (define-key map "E" 'eww-set-character-encoding)
+    (define-key map "s" 'eww-switch-to-buffer)
     (define-key map "S" 'eww-list-buffers)
     (define-key map "F" 'eww-toggle-fonts)
     (define-key map [(meta C)] 'eww-toggle-colors)
@@ -712,6 +713,7 @@ the like."
 	["View page source" eww-view-source]
 	["Copy page URL" eww-copy-page-url t]
 	["List histories" eww-list-histories t]
+	["Switch to buffer" eww-switch-to-buffer t]
 	["List buffers" eww-list-buffers t]
 	["Add bookmark" eww-add-bookmark t]
 	["List bookmarks" eww-list-bookmarks t]
@@ -1498,6 +1500,24 @@ If CHARSET is nil then use UTF-8."
       (eww-reload nil 'utf-8)
     (eww-reload nil charset)))
 
+(defun eww-switch-to-buffer ()
+  "Prompt for an EWW buffer to display in the selected window."
+  (interactive)
+  (let ((completion-extra-properties
+         '(:annotation-function (lambda (buf)
+                                  (with-current-buffer buf
+                                    (format " %s" (eww-current-url)))))))
+    (switch-to-buffer
+     (read-buffer "Switch to EWW buffer: "
+                  (cl-loop for buf in (nreverse (buffer-list))
+                           if (with-current-buffer buf (derived-mode-p 'eww-mode))
+                           return buf)
+                  t
+                  (lambda (bufn)
+                    (with-current-buffer
+                        (if (consp bufn) (cdr bufn) (get-buffer bufn))
+                      (derived-mode-p 'eww-mode)))))))
+
 (defun eww-toggle-fonts ()
   "Toggle whether to use monospaced or font-enabled layouts."
   (interactive)
-- 
2.7.0






  reply	other threads:[~2016-02-04  6:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-26 16:54 bug#22244: 25.0.50; Make eww use display-buffer to display eww buffer Michael Heerdegen
2015-12-26 17:02 ` Lars Ingebrigtsen
2015-12-26 17:29   ` Michael Heerdegen
2015-12-26 17:45     ` Lars Ingebrigtsen
2015-12-26 18:09       ` Michael Heerdegen
2015-12-26 18:19         ` Lars Ingebrigtsen
2015-12-26 23:19           ` Michael Heerdegen
2015-12-26 23:28             ` Lars Ingebrigtsen
2016-01-09  6:01               ` Michael Heerdegen
2016-02-02  4:55                 ` Lars Ingebrigtsen
2016-02-02 15:24                   ` Mark Oteiza
2016-02-03  1:59                     ` Lars Ingebrigtsen
2016-02-03  2:57                       ` Mark Oteiza
2016-02-04  2:18                         ` Lars Ingebrigtsen
2016-02-04  6:31                           ` Mark Oteiza [this message]
2016-02-04  7:02                             ` bug#22244: [PATCH] New command eww-switch-to-buffer Lars Ingebrigtsen
2016-02-04 13:10                               ` Michael Heerdegen
2016-02-04 17:49                                 ` Mark Oteiza
2016-02-04 19:09                                   ` Michael Heerdegen
2016-02-04 16:46                             ` Eli Zaretskii
2016-02-04 17:48                               ` Mark Oteiza
2016-02-02  4:58                 ` bug#22244: 25.0.50; Make eww use display-buffer to display eww buffer Lars Ingebrigtsen
2016-02-02 14:19                   ` Michael Heerdegen
2016-02-03  2:35                     ` Lars Ingebrigtsen

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=20160204063143.GA13606@holos \
    --to=mvoteiza@udel.edu \
    --cc=22244@debbugs.gnu.org \
    --cc=larsi@gnus.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).