I have been experimenting with various completion frameworks in Emacs. I am currently using consult together with icomplete. I like the way things are working for me but I would like to disable icomplete for find-file. I prefer the traditional Emacs find-file.

I have tried this, which did not work:

(define-key icomplete-minibuffer-map [remap find-file] nil)
(define-key icomplete-minibuffer-map [remap write-file] nil)

I based this on the following which did work when I was experimenting using ivy.

(define-key ivy-minibuffer-map [remap counsel-find-file] nil)
(define-key ivy-minibuffer-map [remap counsel-describe-variable] nil)
(define-key ivy-minibuffer-map [remap counsel-describe-function] nil)

Below are my configurations for icomplete:

(require 'icomplete)
(icomplete-mode 1)
(setq icomplete-hide-common-prefix nil)
(setq icomplete-in-buffer t)
(bind-key "<tab>" 'icomplete-force-complete minibuffer-local-map)
(bind-key "<return>" 'icomplete-force-complete-and-exit minibuffer-local-map) ; exit with completion
(bind-key "C-j" 'exit-minibuffer minibuffer-local-map) ; force input unconditionally
(bind-key "C-n" 'icomplete-forward-completions minibuffer-local-map)
(bind-key "<down>" 'icomplete-forward-completions minibuffer-local-map)
(bind-key "C-p" 'icomplete-backward-completions minibuffer-local-map)
(bind-key "<up>" 'icomplete-backward-completions minibuffer-local-map)
(bind-key "<C-backspace>" 'icomplete-fido-backward-updir minibuffer-local-map)

I would appreciate some help to configure this.

  • 1
    Advise those commands, so they turn off icomplete-mode only for their duration. See the Elisp manual, node Advising Functions and its subnodes. Or just define your own commands, which use those commands but which turn-off icomplete-mode for the duration, and bind those commands to the keys used for the original commands.
    – Drew
    Feb 12 '21 at 19:13
  • I have cobbled something together, but now there is no history in the minibuffer when I click the <up> and <down> arrows. ;use regular find file key (defun my-find-file() (interactive) (icomplete-mode -1) (call-interactively 'find-file) (icomplete-mode 1)) (global-set-key (kbd "C-x C-f") 'my-find-file) Feb 13 '21 at 13:12

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.