I've been using Elfeed for some time, and I like it very much. However, there is one small thing I'd like to adjust. When leaving the search window (with elfeed-search-quit-window
bound to q
in the mode map), Elfeed leaves a trail of open buffers: *elfeed-search*
, *elfeed-log*
and myfeeds.org
(I use elfeed-org
).
I like the behavior of org-agenda-exit
which checks if any files visited by the agenda have been modified, if so offers to save them, and otherwise kills them. As it turns out, this is performed by the function org-release-buffers
in org.el
, so I tried to adapt it for my purposes.
As I don't have a list of buffers, as Org Agenda does, I tried to use rmh-elfeed-org-files
which is rather a list of files, so I employ file-name-nondirectory
to get the corresponding buffer name.
My unsuccessful attempt is the following:
(defun my/elfeed-search-quit-and-kill-buffers ()
"Save the database, then kill elfeed buffers, asking the user
for confirmation when needed."
(interactive)
(elfeed-db-save)
(let (buf)
(dolist (file rmh-elfeed-org-files)
(setq buf (file-name-nondirectory file))
(when (and (buffer-modified-p buf)
file
(y-or-n-p (format "Save file %s? " file)))
(with-current-buffer buf (save-buffer)))
(kill-buffer buf)))
(kill-buffer "*elfeed-log*")
(kill-buffer (current-buffer)))
As this is intended to be bound to the elfeed-search-mode-map
the last (kill-buffer (current-buffer))
kills *elfeed-search*
.
But this fails with a Wrong type argument: bufferp, "myfeeds.org"
error.
What am I doing wrong?
get-buffer
. E.g.,(get-buffer "myfeeds.org")
will return the object buffer. Some functions have the ability to use either form; however, your error message is telling you that a string buffer name is not what is sought. I don't use elfeed, but if I had to guess, I would guess ...(setq buf (get-buffer (file-name-nondirectory file)))
assuming that(file-name-nondirectory file)
will give you the string name for the buffer.(setq buf (get-file-buffer file))
. Still, thank you for your comment. And an answer of yours in these lines would be welcome and accepted.