Heitor Chang
Heitor Chang

Reputation: 6057

Prevent arrow keys from opening autocomplete menu

I am using cx4a.org's Auto Complete mode with GNU Emacs 24.3.1, and following options:

(setq ac-ignore-case nil)
(define-key ac-completing-map "\r" nil)
(setq ac-auto-start 2)

When I type a prefix at the end of a line, and wish to move down a line (pressing the Down arrow key), instead of moving the cursor, the auto-completion menu pops up. For example (in Python)

def passing():
    print("passing")

def passed():
    print("passed")

# insert new function here

def willpass():
    print("will pass")

When I insert a dummy function (that just passes) at the comment location, after typing pass, I press the Down arrow key (wanting to move down a line), but instead, the menu pops up with options "pass, passed, passing".

How do I prevent this menu from popping up in this usage example? I tried re-mapping <up> and <down> in both ac-mode-map and ac-menu-map to nil, with no effect.

Note: Pressing C-n instead of Down does not open the menu, but it feels unnatural. And rebinding Down to (next-line) did nothing.

Also, I could sidestep this issue by setting ac-delay to 1 and setting the trigger-key to Tab, but this set of options has other drawbacks that led me to revert back to the first set of options.

Upvotes: 4

Views: 352

Answers (1)

abo-abo
abo-abo

Reputation: 20342

Use this:

(define-key ac-completing-map [down] nil)
(define-key ac-completing-map [up] nil)

And actually most people prefer C-n to down. Did you swap Ctrl and Caps?

Upvotes: 5

Related Questions