SFbay007
SFbay007

Reputation: 2027

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.

Upvotes: 0

Views: 67

Answers (1)

Thomas
Thomas

Reputation: 17422

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

Upvotes: 1

Related Questions