Emacs auto-complete: don't trigger on RET in inline suggestion

前端 未结 1 508
轻奢々
轻奢々 2021-02-09 04:14

I am very happy with auto-complete but one thing bugs me:

I\'m setup to show the inline suggestion immediately but the menu with 0.9 s delay. I type the first few lette

1条回答
  •  死守一世寂寞
    2021-02-09 05:06

    By adding the following lines after other settings for the auto-complete mode, you can enable completion by RET only when completion menu is displayed:

    (define-key ac-completing-map "\C-m" nil)
    (setq ac-use-menu-map t)
    (define-key ac-menu-map "\C-m" 'ac-complete)
    

    ac-completing-map is a keymap where RET is by default bound to ac-complete, and ac-menu-map is a keymap for completion on completion menu. The ac-menu-map keymap is enabled when the ac-use-menu-map variable is t.

    FYI, completion can be stopped by pressing C-g at any time. So you will also be able to hit C-g and RET to enter a newline with the bindings of RET intact. Also, you can use C-j rather than RET when you want to enter a newline. C-j does not bind to ac-complete by default.

    0 讨论(0)
提交回复
热议问题