From: James Thomas <jimjoe@gmx.net>
To: 65914@debbugs.gnu.org
Subject: bug#65914: Exclude current buffer from eww-switch-to-buffer
Date: Wed, 13 Sep 2023 16:15:03 +0530 [thread overview]
Message-ID: <87y1ha1he8.fsf@gmx.net> (raw)
Tags: patch, notabug
This patch excludes the current buffer from the completion list of the
above command. The main motivation is avoiding one cycling keystroke in
icomplete.
For eg. a use-case of cycling visits between the last 3 visited eww
buffers:
Currently (to visit each buffer in succession), after pressing s, one
would have to cycle thrice in icomplete before pressing C-j. With this
patch, it would only need to be done twice (a mnemonic to remember the
number of times to cycle could be 'the last 2 *other* buffers' rather
than 'the last 3 buffers' it is currently).
Moreover, if you remember that the target eww buffer was the last n-th
buffer you opened, you may now simply cycle n times. Eg. n is 1 for the
previous buffer.
* lisp/net/eww.el (eww-switch-to-buffer):
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 4ddda216afc..e43ef2bfe8b 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -2062,7 +2062,8 @@ eww-switch-to-buffer
(let ((completion-extra-properties
'(:annotation-function (lambda (buf)
(with-current-buffer buf
- (format " %s" (eww-current-url)))))))
+ (format " %s" (eww-current-url))))))
+ (curbuf (current-buffer)))
(pop-to-buffer-same-window
(read-buffer "Switch to EWW buffer: "
(cl-loop for buf in (nreverse (buffer-list))
@@ -2070,9 +2071,10 @@ eww-switch-to-buffer
return buf)
t
(lambda (bufn)
- (with-current-buffer
- (if (consp bufn) (cdr bufn) (get-buffer bufn))
- (derived-mode-p 'eww-mode)))))))
+ (setq bufn (if (consp bufn) (cdr bufn) (get-buffer bufn)))
+ (and (with-current-buffer bufn
+ (derived-mode-p 'eww-mode))
+ (not (eq bufn curbuf))))))))
(defun eww-toggle-fonts ()
"Toggle whether to use monospaced or font-enabled layouts."
--
next reply other threads:[~2023-09-13 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 10:45 James Thomas [this message]
2023-09-15 12:05 ` bug#65914: Exclude current buffer from eww-switch-to-buffer Stefan Kangas
2023-09-16 0:31 ` James Thomas
2023-10-01 16:53 ` Stefan Kangas
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=87y1ha1he8.fsf@gmx.net \
--to=jimjoe@gmx.net \
--cc=65914@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 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).