What is the simplest way to have Counsel versions of write-file (C-x C-w) and insert-file (C-x i)?

I would like these replacements to work similarly to counsel-find-file (typically bound to C-x C-f). I don't want to add actions (M-o ...) to counsel-find-file but to have a dedicated functions, as in default Emacs.

  • 2
    What would Counsel versions of these functions do that Ivy doesn't already provide?
    – Basil
    Feb 9 '20 at 0:55
  • @Basil: my mistake. I thought there should be functions equivalent to counsel-find-file for write-file and insert-file, as Counsel was not changing the behavior of these. But I now created an init.el file that just loads Ivy and Counsel and write-file and insert-file are working as expected (i.e., with Counsel-like behavior). So, it seems my question is how to make Helm not take over write-file and insert-file (I cannot just remove Helm, as I need some it's other functions). Feb 10 '20 at 18:18
  • 2
    OK. So, the solution was simply to add (add-to-list 'helm-completing-read-handlers-alist '(write-file . nil)) (add-to-list 'helm-completing-read-handlers-alist '(insert-file . nil)) after (helm-mode) in my configuration. Feb 10 '20 at 18:30
  • For future reference, Ivy is the package/mode that makes completion Ivy-like (i.e. in the minibuffer, with colours, etc.), and Counsel is the library of handy commands that integrate with Ivy better than built-in Emacs commands do. In other words, Ivy is an alternative to Helm, and Counsel builds on Ivy.
    – Basil
    Feb 11 '20 at 15:05

Your Answer

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

Browse other questions tagged or ask your own question.