1

I really like helm-projectile-switch-to-buffer as it shows buffers for the specific project I am working in (i have multiple projects open at the same time). But I also rely on org files for notes and debug information.

How is it possible to create a function that performs the exact same functionality of helm-projectile-switch-to-buffer but add to the possible buffers to switch to the opened org files as well?

1

One way is to define a class that inherits from the helm-source-buffers class. You can use the candidate-transformer slot to remove non-Org buffers from the list. Then add the new source to the list of sources in your custom command.

(defclass helm-source-org-buffers (helm-source-buffers)
  ((candidate-transformer :initform (lambda (buffers)
                                      (cl-loop for b in buffers
                                               when (eq (with-current-buffer b
                                                          major-mode)
                                                        'org-mode)
                                               collect b)))))

(defvar helm-source-org-buffers-list nil)

(defun your-helm-projectile-switch-to-buffer ()
  (interactive)
  (unless helm-source-org-buffers-list
    (setq helm-source-org-buffers-list
          (helm-make-source "Org Buffers" 'helm-source-org-buffers)))
  (helm :sources '(helm-source-projectile-buffers-list
                   helm-source-org-buffers-list)))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.