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.
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))
Thank you Thomas. I tried applying this to helm-projectile list: (add-to-list helm-source-projectile-buffers-list '(lambda (buffer) (with-current-buffer buffer (derived-mode-p 'org-mode))) (buffer-list)) but that gave errors. I don't know how to correctly add the list of open org-files to the helm-projectile-switch-to-buffer list.
It looks like you forgot the
(seq-filter
part at the beginning. But also,add-to-list
is only for adding a single element. Try(setq helm-source-projectile-buffers-list (append helm-source-projectile-buffers-list (seq-filter...)))
instead.I still don't see org-files that are open listed along other project files when calling helm-projectile-switch-to-buffer.
Sorry, can't help you with that - the above code gets you the list of buffers you're after, but I have no experience with helm-projectile.