* bug#65914: Exclude current buffer from eww-switch-to-buffer
@ 2023-09-13 10:45 James Thomas
2023-09-15 12:05 ` Stefan Kangas
0 siblings, 1 reply; 4+ messages in thread
From: James Thomas @ 2023-09-13 10:45 UTC (permalink / raw)
To: 65914
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."
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#65914: Exclude current buffer from eww-switch-to-buffer
2023-09-13 10:45 bug#65914: Exclude current buffer from eww-switch-to-buffer James Thomas
@ 2023-09-15 12:05 ` Stefan Kangas
2023-09-16 0:31 ` James Thomas
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2023-09-15 12:05 UTC (permalink / raw)
To: James Thomas; +Cc: 65914
James Thomas <jimjoe@gmx.net> writes:
> Tags: patch, notabug
[BTW, we typically don't use the "notabug" for patches.]
> 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.
Thanks, I would like to install this patch.
Could you please send the patch as an attachment instead? We prefer
that patches are created with a command like `git format-patch -1'.
Please also include:
- The bug number of this bug in the commit message, like so: Bug#65914
- A ChangeLog entry, as described in the CONTRIBUTE file.
That would make it easier for us to review and install this patch.
Thanks in advance.
> * 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."
>
> --
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#65914: Exclude current buffer from eww-switch-to-buffer
2023-09-15 12:05 ` Stefan Kangas
@ 2023-09-16 0:31 ` James Thomas
2023-10-01 16:53 ` Stefan Kangas
0 siblings, 1 reply; 4+ messages in thread
From: James Thomas @ 2023-09-16 0:31 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 65914
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
Stefan Kangas wrote:
> Thanks, I would like to install this patch.
>
> Could you please send the patch as an attachment instead? We prefer
> that patches are created with a command like `git format-patch -1'.
>
> Please also include:
>
> - The bug number of this bug in the commit message, like so: Bug#65914
>
> - A ChangeLog entry, as described in the CONTRIBUTE file.
>
> That would make it easier for us to review and install this patch.
> Thanks in advance.
PFA:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Exclude current buffer from eww-switch-to-buffer --]
[-- Type: text/x-patch, Size: 1808 bytes --]
From 229b3e5be1df7c753410e840d6ea9c36f822fefd Mon Sep 17 00:00:00 2001
From: James Thomas <jimjoe@gmx.net>
Date: Sat, 16 Sep 2023 05:50:58 +0530
Subject: [PATCH] Exclude current buffer from eww-switch-to-buffer
Exclude the current buffer from the completion list of
eww-switch-to-buffer; to avoid an extra cycling keystroke
(Bug#65914).
* lisp/net/eww.el (eww-switch-to-buffer):
---
lisp/net/eww.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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."
--
2.34.1
[-- Attachment #3: Type: text/plain, Size: 4 bytes --]
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#65914: Exclude current buffer from eww-switch-to-buffer
2023-09-16 0:31 ` James Thomas
@ 2023-10-01 16:53 ` Stefan Kangas
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2023-10-01 16:53 UTC (permalink / raw)
To: James Thomas; +Cc: 65914-done
Version: 30.1
James Thomas <jimjoe@gmx.net> writes:
> Stefan Kangas wrote:
>
>> Thanks, I would like to install this patch.
>>
>> Could you please send the patch as an attachment instead? We prefer
>> that patches are created with a command like `git format-patch -1'.
>>
>> Please also include:
>>
>> - The bug number of this bug in the commit message, like so: Bug#65914
>>
>> - A ChangeLog entry, as described in the CONTRIBUTE file.
>>
>> That would make it easier for us to review and install this patch.
>> Thanks in advance.
>
> PFA:
Installed on master [1: 5d9dbf17cf6].
Thanks again for the patch!
[1: 5d9dbf17cf6]: 2023-10-01 18:51:18 +0200
Exclude current buffer from eww-switch-to-buffer
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5d9dbf17cf6123ad24d8f9193818ac64606e3a45
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-01 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-13 10:45 bug#65914: Exclude current buffer from eww-switch-to-buffer James Thomas
2023-09-15 12:05 ` Stefan Kangas
2023-09-16 0:31 ` James Thomas
2023-10-01 16:53 ` Stefan Kangas
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).