reddit / emacs

counsel-projectile and embark integration

IntelligentTea281 · 2022-03-05 15:56
I use projectile and counsel-projectile regularly. Recently I was trying to use embark with counsel-projectile-find-file. Somehow embark is unable to determine the type of the selection. Is anyone using this combination successfully? Below function from embark library gets executed when I press embark-act after selecting a file (defun embark--ivy-selected () "Target the currently selected item in Ivy. Return the category metadatum as the type of the target." ;; my favorite way of detecting Ivy (when (memq 'ivy--queue-exhibit post-command-hook) (cons (completion-metadata-get (embark--metadata) 'category) (ivy--expand-file-name (if (and (> ivy--length 0) (stringp (ivy-state-current ivy-last))) (ivy-state-current ivy-last) ivy-text))))) I debugged an found that the following expression is returning nil (completion-metadata-get (embark--metadata) 'category) Not sure what am I missing.
oantolin · 2022-03-06 00:01
Lots of function that prompt the user for data do not specify a category. It's not just counsel functions that don't specify completion categories: tons of built-in Emacs function don't specify it either! There is a library called [Marginalia](https://github.com/minad/marginalia/) that can provide the missing metadata. If you install Marginalia you can configure it to make `counsel-project-find-file` report the `file` category as follows: (add-to-list 'marginalia-command-categories '(counsel-projectile-find-file . file)) (Don't forget to turn on `marginalia-mode`.) Also, in case you don't know: Ivy also has it's own implementation of actions (though only for the minibuffer), and I would guess that `counsel-projectile-find-file` has all the usual file actions already associated to it.
IntelligentTea281 · 2022-03-06 01:10
u/oantolin Awesome! Thank you!