listemacsorg-modeemacs-helm

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


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.


Solution

  • 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))