When loading auto-complete
via auto-complete-config
with use-package
, then :config
is not executed and local keymap is not set. (See example below)
Why that and how to solve this?
Example: save following into a file foo.el
and run with emacs -Q -l foo.el
.
(message "DEBUG: my-shortconfig start")
;; init package and use-package
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(require 'package)
(package-initialize)
(require 'use-package)
;; auto-complete-config:
(use-package auto-complete-config
:commands (global-auto-complete-mode auto-complete auto-complete-mode)
:bind (("M-<tab>" . my--auto-complete)
(:map ac-mode-map
("M-<tab>" . auto-complete)))
:init (progn
(message "DEBUG: auto-complete-config init")
(defun my--auto-complete ()
(interactive)
(message "DEBUG: my--auto-complete inside")
(unless (boundp 'auto-complete-mode)
(global-set-key (kbd "M-<tab>") nil)
(global-auto-complete-mode 1))
(auto-complete))
(setq ac-auto-start nil
ac-quick-help-delay 0.5))
:config (progn
(message "DEBUG: auto-complete-config config")))
(message "DEBUG: my-shortconfig done")
The expected Messages, after pressing M-tab
in *scratch*
buffer, are:
DEBUG: my-shortconfig start
DEBUG: auto-complete-config init
DEBUG: my-shortconfig done
DEBUG: my--auto-complete inside
DEBUG: auto-complete-config config
But I only get:
DEBUG: my-shortconfig start
DEBUG: auto-complete-config init
DEBUG: my-shortconfig done
DEBUG: my--auto-complete inside
Also M-tab
is not bound in ac-mode-map
Note:
I found some questions to similar problems, but they do not help.
auto-complete-config
provides auto-complete-config
and :config
stuff should be executed after (require 'auto-complete-config)