• Build up of many eww buffers

    From Matto Fransen@mattof@sdf.org to gnu.emacs.help on Thu Apr 20 22:17:37 2023
    From Newsgroup: gnu.emacs.help

    Hi,

    To keep up with my RSS feeds, I use Gnus together with the
    brilliant service of gwene.org.

    I use eww as my standard browser.

    Links from the gwene messages are opened in eww. When I am
    done with such a page, I use 'q' in eww to quit the webpage
    and revert to the message-list.

    After such a session I end up with a lot of eww buffers,
    labeled *eww*<2>, *eww*<3>, and so on.

    - Is there a way to prevent the build-up of those buffers?
    - Is there a way to quickly close all of the eww-buffers?
    - Should I change my workflow?

    Best regards,

    Matto
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to gnu.emacs.help on Fri Apr 21 10:33:04 2023
    From Newsgroup: gnu.emacs.help

    * Matto Fransen <mattof@sdf.org>
    | After such a session I end up with a lot of eww buffers,
    | labeled *eww*<2>, *eww*<3>, and so on.

    | - Is there a way to prevent the build-up of those buffers?
    | - Is there a way to quickly close all of the eww-buffers?

    Here is what I use to get rid of unchanged buffers.
    It should be easily adapted to kill only *eww* buffers:

    ;; Kill any unchanged buffers
    (defconst kill-unchanged-buffers-dont-kill
    (list (regexp-quote "*scratch*")
    (regexp-quote "*info*")
    (regexp-quote "*Async Shell Command*")
    )
    "List of buffer names regexps which should NOT be killed by `kill-unchanged-buffers'.
    The regexps are anchored against beginning of buffer name.")

    ;; modified from a suggestion by Ralph Finch
    (defun kill-unchanged-buffers ()
    "Kill all unchanged buffers."
    (interactive)
    (let ((list (buffer-list)) (count 0))
    (while list
    (let* ((buffer (car list))
    (name (buffer-name buffer)))
    (and (not (string-equal name ""))
    (not (delq nil (mapcar (lambda (elt) (string-match (concat "\\`" elt) name))
    kill-unchanged-buffers-dont-kill)))
    (/= (aref name 0) ? )
    (if (buffer-modified-p buffer)
    nil (kill-buffer buffer) (setq count (1+ count)))))
    (setq list (cdr list)))
    (message "Killed %d %s." count (if (/= count 1) "buffers" "buffer"))))

    I have bound it on C-x C-k.

    (global-set-key "\C-x\C-k" 'kill-unchanged-buffers)


    HTH
    R'
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Manuel Giraud@manuel@ledu-giraud.fr to gnu.emacs.help on Fri Apr 21 13:26:08 2023
    From Newsgroup: gnu.emacs.help

    Matto Fransen <mattof@sdf.org> writes:

    [...]

    Hi Matto,

    - Is there a way to prevent the build-up of those buffers?

    You'd have to look for how eww is called here because by default "M-x
    eww" is re-using *eww*

    - Is there a way to quickly close all of the eww-buffers?

    There is "M-x eww-list-buffers" where you could "C-k" those buffers.

    - Should I change my workflow?

    rCa or modify Emacs: nobody has definitive answer to this question yet ;-)
    --
    Manuel Giraud
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Matto Fransen@matto@tradesystem.nl to gnu.emacs.help on Tue Apr 25 14:46:26 2023
    From Newsgroup: gnu.emacs.help

    Hi Ralf,

    sorry, was a few days off-line

    On 21 April 2023 10:33 Ralf Fassel, wrote:
    * Matto Fransen <mattof@sdf.org>
    | After such a session I end up with a lot of eww buffers,
    | labeled *eww*<2>, *eww*<3>, and so on.

    | - Is there a way to prevent the build-up of those buffers?
    | - Is there a way to quickly close all of the eww-buffers?

    Here is what I use to get rid of unchanged buffers.
    It should be easily adapted to kill only *eww* buffers:

    ;; Kill any unchanged buffers
    (defconst kill-unchanged-buffers-dont-kill
    [ ... ]

    This looks to be will be very helpful !
    I will try it and let you know :)

    Thanks a lot,

    Matto
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Matto Fransen@matto@tradesystem.nl to gnu.emacs.help on Tue Apr 25 14:52:52 2023
    From Newsgroup: gnu.emacs.help

    Hi Manuel,

    sorry, was a few days offline

    On 21 April 2023 13:26 Manuel Giraud, wrote:

    - Is there a way to prevent the build-up of those buffers?

    You'd have to look for how eww is called here because by default "M-x
    eww" is re-using *eww*

    this is a part from the code:

    (pop-to-buffer (generate-new-buffer "*eww*"))
    (eww-mode)
    (eww url-to-open)

    - Is there a way to quickly close all of the eww-buffers?

    There is "M-x eww-list-buffers" where you could "C-k" those buffers.

    Cool :)
    Will try this out!

    - Should I change my workflow?

    rCa or modify Emacs: nobody has definitive answer to this question yet ;-)

    He he :)

    Thanks a lot,

    Matto
    --- Synchronet 3.21d-Linux NewsLink 1.2