make better integration with helm-mini
Hello. I would like to add some groups from helm-bufler-source to helm-mini-default-sources. For example I would like to have a group with projectile's buffers in helm-mini. With helm-bufler-source there are many duplicate buffers. I still don't know the best way to do this, maybe it would be nice to have their own source for each group. There are many sources here in helm-mini, such as helm-source-recentf helm-source-bookmarks helm-source-locate. So I would like to stay with that, but use bufler as additional sources. Thank you!
Do you mean something like this?
(defun helm-bufler-path-source (path)
"Return Helm source for Bufler group at PATH.
PATH is a Bufler path, e.g. like the value of the frame parameter
`bufler-workspace-path' after calling `bufler-workspace-focus-buffer'."
(let ((source-name (concat "Bufler: " (bufler-format-path path))))
(helm-make-source source-name 'helm-source-sync
:header-name source-name
:candidates (lambda ()
(let* ((bufler-vc-state nil)
(group-path (unless current-prefix-arg
;; FIXME: This initial-nil-skipping logic probably belongs elsewhere.
(if (car path) path (cdr path)))))
(bufler-buffer-alist-at group-path)))
:action (cons (cons "Switch to buffer with Bufler" 'helm-bufler-switch-buffer)
helm-type-buffer-actions))))
(helm :sources (list (helm-bufler-path-source '("Projectile"))))
Can't reproduce, because if I try to eval
(helm :sources (list (helm-bufler-path-source '("Projectile"))))
I get this error:
(void-variable path)
It requires lexical binding.
I tried replacing let* with lexical-let, now there are no candidates in helm. The same thing when I moved the code to helm-bufler.el
I tried replacing
let*withlexical-let
That's not how lexical binding works in Emacs.
Place this code in an Elisp buffer, save it to a file, revert the buffer, and evaluate it:
;; -*- lexical-binding: t; -*-
(defun helm-bufler-path-source (path)
"Return Helm source for Bufler group at PATH.
PATH is a Bufler path, e.g. like the value of the frame parameter
`bufler-workspace-path' after calling `bufler-workspace-focus-buffer'."
(let ((source-name (concat "Bufler: " (bufler-format-path path))))
(helm-make-source source-name 'helm-source-sync
:header-name source-name
:candidates (lambda ()
(let* ((bufler-vc-state nil)
(group-path (unless current-prefix-arg
;; FIXME: This initial-nil-skipping logic probably belongs elsewhere.
(if (car path) path (cdr path)))))
(bufler-buffer-alist-at group-path)))
:action (cons (cons "Switch to buffer with Bufler" 'helm-bufler-switch-buffer)
helm-type-buffer-actions))))
(helm :sources (list (helm-bufler-path-source '("Projectile"))))
The same thing: executed without errors, but there are not any candidates in helm.
It works for me, e.g. to see buffers in the *Special* group:
(helm :sources (list (helm-bufler-path-source '("*Special*"))))
It works for me with *Special* too, but not with Projectile.
This is my init.el:
(use-package projectile
:straight t
:config
(projectile-mode 1)
(setq projectile-completion-system 'helm))
(use-package helm
:straight t
:config
(helm-mode 1))
(use-package bufler
:straight t)
(use-package helm-bufler
:straight t)
(defun helm-bufler-path-source (path)
"Return Helm source for Bufler group at PATH.
PATH is a Bufler path, e.g. like the value of the frame parameter
`bufler-workspace-path' after calling `bufler-workspace-focus-buffer'."
(let ((source-name (concat "Bufler: " (bufler-format-path path))))
(helm-make-source source-name 'helm-source-sync
:header-name source-name
:candidates (lambda ()
(let* ((bufler-vc-state nil)
(group-path (unless current-prefix-arg
;; FIXME: This initial-nil-skipping logic probably belongs elsewhere.
(if (car path) path (cdr path)))))
(bufler-buffer-alist-at group-path)))
:action (cons (cons "Switch to buffer with Bufler" 'helm-bufler-switch-buffer)
helm-type-buffer-actions))))
(helm :sources '(helm-bufler-source))
(helm :sources (list (helm-bufler-path-source '("Projectile:"))))
(helm :sources (list (helm-bufler-path-source '("*Special*"))))
I can see some Projectile candidates with (helm :sources '(helm-bufler-source)), but there are not any candidates with (helm :sources (list (helm-bufler-path-source '("Projectile:"))))
The code (helm-bufler-path-source '("Projectile:")) requires that there be a group named Projectile: in your configured groups.
I have this config for bulfer-group:
(setq bufler-groups
(bufler-defgroups
(group
;; Subgroup collecting these "special special" buffers
;; separately for convenience.
(name-match "**Special**"
(rx bos "*" (or "Messages" "Warnings" "scratch" "Backtrace") "*")))
;; All buffers under "~/.emacs.d" (or wherever it is).
(group
;; Subgroup collecting buffers in a projectile project.
(auto-projectile)))
With M-x bufler at least I can see a few groups named Projectile: *project-name1* Projectile: *project-name2* and etc. in my case.
I would like to add all this groups to helm-mini-default-sources.