abo-abo / swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
https://oremacs.com/swiper/
2.29k stars 338 forks source link

How to add actions mode-locally? #1598

Open et2010 opened 6 years ago

et2010 commented 6 years ago

For example, I use these command to add org links into an org buffer. But they are of no use when in other modes. How could I add actions only visible when current buffer is an orgmode buffer?

(ivy-add-actions
   'counsel-find-file
   '(("k" et/counsel-insert-org-link "insert org link")
     ("I" et/counsel-org-download "insert image")))
basil-conto commented 6 years ago

AFAIK, actions are currently designed to be "global", so there is no "built-in" way to predicate them on the current major-mode. Nevertheless, there are various hacks you could try until such conditionality is added: