o4-mini-2025-04-16· OpenAI
LMArena Human Preference 140K
In Emacs, how do I bind the <tab> key to the function "complete-symbol" in certain modes…
- User
In Emacs, how do I bind the key to the function "complete-symbol" in certain modes such as lisp-mode?
- Assistant
Here’s a quick recipe to make TAB run
complete-symbolonly in your Lisp buffers:;; 1. Use a mode‐hook to bind TAB locally: (defun my-lisp-completion-setup () (local-set-key (kbd "TAB") #'complete-symbol)) (add-hook 'emacs-lisp-mode-hook #'my-lisp-completion-setup) (add-hook 'lisp-mode-hook #'my-lisp-completion-setup) (add-hook 'inferior-lisp-mode-hook #'my-lisp-completion-setup)Or, if you prefer to tweak the keymap directly after it’s loaded:
(with-eval-after-load 'lisp-mode (define-key lisp-mode-map (kbd "TAB") #'complete-symbol)) (with-eval-after-load 'emacs-lisp (define-key emacs-lisp-mode-map (kbd "TAB") #'complete-symbol))Explanation:
local-set-keyin a hook only affects the current buffer’s keymap.with-eval-after-loadensures that the mode’s keymap exists before you redefine it.
Now when you hit TAB in any of those Lisp modes, Emacs will try
complete-symbolinstead of the usual indent or yasnippet trigger. 🚀
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.