Enable autocomplete in Emacs minibuffer

I am trying to turn auto-complete into a minibuffer:

(add-hook 'minibuffer-setup-hook 'auto-complete-mode) 

I get auto-complete , working in the first instance of the minibuffer, but no longer working. This is the full minibuffer-setup-hook after loading:

 (auto-complete-mode turn-on-visual-line-mode ido-minibuffer-setup rfn-eshadow-setup-minibuffer minibuffer-history-isearch-setup minibuffer-history-initialize) 

How to constantly press auto-complete ?

+4
source share
3 answers

Zev turned to my attention auto-complete-mode-maybe , and these are the necessary changes (file auto-complete.el , all changes have comments):

 ;; Add this variable (defcustom ac-in-minibuffer t "Non-nil means expand in minibuffer." :type 'boolean :group 'auto-complete) ... (defun ac-handle-post-command () (condition-case var (when (and ac-triggered (not (ido-active)) ;; Disable auto pop-up in ido mode (or ac-auto-start ac-completing) (not isearch-mode)) (setq ac-last-point (point)) (ac-start :requires (unless ac-completing ac-auto-start)) (ac-inline-update)) (error (ac-error var)))) ... (defun auto-complete-mode-maybe () "What buffer `auto-complete-mode' prefers." (if (or (and (minibufferp (current-buffer)) ac-in-minibuffer) ;; Changed (memq major-mode ac-modes)) (auto-complete-mode 1))) 

And .emacs :

 (add-hook 'minibuffer-setup-hook 'auto-complete-mode) 

Of course, there are binding conflicts, but they can be resolved.

0
source

You rarely ever want to add a function character to a hook variable if that function acts as a switch (which will be the case for most minor modes).

minibuffer-setup-hook starts "immediately after entering the minibuffer", which means that when you turn on the minibuffer for the first time, you turn on the automatic completion mode; disable it a second time; letting him a third time; etc...

Usually you either look to see if there is a given type of function turn-on-autocomplete-mode , or specify your own:

 (defun my-turn-on-autocomplete-mode () (autocomplete-mode 1)) ;; an argument of 1 will enable most modes (add-hook 'minibuffer-setup-hook 'my-turn-on-auto-complete-mode) 

I cannot verify this because you are not related to the autocomplete used.

+7
source

The creator of "auto-complete-mode" explicitly excludes the minibuffer for use with autocompletion. Definition for minor mode:

 (define-global-minor-mode global-auto-complete-mode auto-complete-mode auto-complete-mode-maybe :group 'auto-complete) 

therefore, the function "enable on mode" is "auto-full-mode-possible" - the definition of this function:

 (defun auto-complete-mode-maybe () "What buffer `auto-complete-mode' prefers." (if (and (not (minibufferp (current-buffer))) (memq major-mode ac-modes)) (auto-complete-mode 1))) 

This function explicitly checks in the if statement if the current buffer is a minibuffer and does not enable auto-complete mode, if any.

If you want to use auto-full mode in the minibuffer, you probably should contact the supporting device and ask him why he excluded the minibuffer and what programming changes he considers necessary to enable the mode in the minibuffer.

+4
source

All Articles