Warm tip: This article is reproduced from stackoverflow.com, please click
list emacs org-mode emacs-helm

Put all opened org mode files in a list to be used eventually with helm lists

发布于 2020-03-29 12:45:43

I am trying to put all (opened) org files in a list so I could add them to helm-projectile-switch-to-file lists.

I was able to get to this code:

  (->> (buffer-list)
       (--select (with-current-buffer it
                   (derived-mode-p 'org-mode)))
       (mapc #'kill-buffer))

but this kills the buffers instead of putting them in an aggregated list.

Questioner
SFbay007
Viewed
74
Thomas 2020-01-31 16:08

If you don't want to kill the buffers, I suggest not applying kill-buffer to each element. Other than that, you pretty much got everything done already. Here's a version that does not require any external libraries:

(seq-filter '(lambda (buffer)                                                                                                                                                            
               (with-current-buffer buffer
                 (derived-mode-p 'org-mode)))
            (buffer-list))