GNU bug report logs - #65914
Exclude current buffer from eww-switch-to-buffer

Previous Next

Package: emacs;

Reported by: James Thomas <jimjoe <at> gmx.net>

Date: Wed, 13 Sep 2023 10:46:01 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: James Thomas <jimjoe <at> gmx.net>
Subject: bug#65914: closed (Re: bug#65914: Exclude current buffer from
 eww-switch-to-buffer)
Date: Sun, 01 Oct 2023 16:55:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#65914: Exclude current buffer from eww-switch-to-buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 65914 <at> debbugs.gnu.org.

-- 
65914: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65914
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Kangas <stefankangas <at> gmail.com>
To: James Thomas <jimjoe <at> gmx.net>
Cc: 65914-done <at> debbugs.gnu.org
Subject: Re: bug#65914: Exclude current buffer from eww-switch-to-buffer
Date: Sun, 1 Oct 2023 09:53:39 -0700
Version: 30.1

James Thomas <jimjoe <at> 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

[Message part 3 (message/rfc822, inline)]
From: James Thomas <jimjoe <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Exclude current buffer from eww-switch-to-buffer
Date: Wed, 13 Sep 2023 16:15:03 +0530
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."

--



This bug report was last modified 1 year and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.