When company-mode completion is activated, the key bindings in company-active-map should take effect (or when searching through candidates, company-search-map should take effect).
Actual behavior
The key bindings of insert state (evil-mode) are used.
Steps to reproduce the problem
While evil-mode is enabled, trigger the company-mode completion inside cider-repl buffer, then try to press the keys defined inside the company-active-map, it will trigger the insert state key bindings of evil-mode.
Leiningen 2.9.4 on Java 14.0.2 OpenJDK 64-Bit Server VM
Emacs version
GNU Emacs 28.0.50
Operating system
Linux arch 5.7.12-arch1-1
More detail
Currently, every time function nrepl-bdecode executed, it will change the major-mode of " nrepl-decoding" buffer to fundamental-mode, which causes the key bindings of company-mode to be overridden. Remove the call to fundamental-mode inside nrepl-bdecode, the issue seems solved.
Reason
Every time company-mode completion is activated, it will call company-ensure-emulation-alist to ensure its company-emulation-alist is the first item of emulation-mode-map-alists, thus ensure its keymaps have higher priority (at least higher than evil-mode-map-alist, which contains the keymaps of evil-mode). This works most of the time.
The problem is whenever after-change-major-mode-hook executed, evil-mode will elevate the priority of its keymaps by
putting the evil-mode-map-alist in the front of emulation-mode-map-alists. Since nrepl-bdecode change the major-mode of " nrepl-decoding" buffer to fundamental-mode while company-mode completion is activated, after-change-major-mode-hook executed, evil-mode elevate its keymaps, thus override the key bindings of company-mode.
Normally, during the time company-mode completion is activated, there won't have buffers change their major-mode, thus won't cause the above issue.
I don't know what's the appropriate way to handle this issue, maybe avoid change major-mode to fundamental-mode inside nrepl-bdecode?
" nrepl-decoding" buffer is created by get-buffer-create and the major mode for a newly created buffer is set to Fundamental mode. It's there any particular reason to call fundamental-mode manually inside nrepl-bdecode? (maybe some packages will change its major-mode?)
Related issues: #2832, hlissner/doom-emacs#1335
Expected behavior
When company-mode completion is activated, the key bindings in
company-active-map
should take effect (or when searching through candidates,company-search-map
should take effect).Actual behavior
The key bindings of insert state (evil-mode) are used.
Steps to reproduce the problem
While evil-mode is enabled, trigger the company-mode completion inside cider-repl buffer, then try to press the keys defined inside the
company-active-map
, it will trigger the insert state key bindings of evil-mode.Environment & Version information
CIDER version information
Lein/Boot version
Leiningen 2.9.4 on Java 14.0.2 OpenJDK 64-Bit Server VM
Emacs version
GNU Emacs 28.0.50
Operating system
Linux arch 5.7.12-arch1-1
More detail
Currently, every time function
nrepl-bdecode
executed, it will change the major-mode of " nrepl-decoding" buffer to fundamental-mode, which causes the key bindings of company-mode to be overridden. Remove the call tofundamental-mode
insidenrepl-bdecode
, the issue seems solved.Reason
Every time company-mode completion is activated, it will call
company-ensure-emulation-alist
to ensure itscompany-emulation-alist
is the first item ofemulation-mode-map-alists
, thus ensure its keymaps have higher priority (at least higher thanevil-mode-map-alist
, which contains the keymaps of evil-mode). This works most of the time.The problem is whenever
after-change-major-mode-hook
executed, evil-mode will elevate the priority of its keymaps by putting theevil-mode-map-alist
in the front ofemulation-mode-map-alists
. Sincenrepl-bdecode
change the major-mode of " nrepl-decoding" buffer to fundamental-mode while company-mode completion is activated,after-change-major-mode-hook
executed, evil-mode elevate its keymaps, thus override the key bindings of company-mode.Normally, during the time company-mode completion is activated, there won't have buffers change their major-mode, thus won't cause the above issue.
I don't know what's the appropriate way to handle this issue, maybe avoid change major-mode to fundamental-mode inside
nrepl-bdecode
?" nrepl-decoding" buffer is created by
get-buffer-create
and the major mode for a newly created buffer is set to Fundamental mode. It's there any particular reason to callfundamental-mode
manually insidenrepl-bdecode
? (maybe some packages will change its major-mode?)