При выполнении M-x describe-mode в файле .el я заметил, что режим Emacs- Lisp действительно выполняет завершение кода. Однако lisp-complete-symbol
привязан к M-TAB. В Windows эта привязка ключа выполняется Windows для переключения активного окна. Большинство IDE используют C-SPC, но также и в Emacs. Что является хорошим, достаточно общим ключом для завершения кода?
Связывание ключей завершения кода в Emacs
Ответ 1
Если вам нравится завершение всех видов, я рекомендую M-/ и привязать это к hippie-expand.
(global-set-key (kbd "M-/") 'hippie-expand)
Он выполняет множество завершений, которые контролируются переменной hippie-expand-try-functions-list
. В файлах .el вы можете установить это, чтобы сначала выполнить 'try-complete-lisp-symbol
, чтобы получить поведение, о котором вы просите выше, а также все другие расширения, предлагаемые hippie-expand.
Это сделало бы это для вас:
(add-hook 'emacs-lisp-mode-hook 'move-lisp-completion-to-front)
(defun move-lisp-completion-to-front ()
"Adjust hippie-expand-try-functions-list to have lisp completion at the front."
(make-local-variable 'hippie-expand-try-functions-list)
(setq hippie-expand-try-functions-list
(cons 'try-complete-lisp-symbol
(delq 'try-complete-lisp-symbol hippie-expand-try-functions-list)))
(setq hippie-expand-try-functions-list
(cons 'try-complete-lisp-symbol-partially
(delq 'try-complete-lisp-symbol-partially hippie-expand-try-functions-list))))
Ответ 2
Как отметил Трей джексон, hippie-expand
- это путь, но наряду с привязкой его к M-/, мне также нравится, когда клавиша TAB выполняет всю мою работу по завершению за меня. Итак, у меня есть это из Emacs-Wiki в моем файле .emacs:
;;function to implement a smarter TAB (EmacsWiki)
(defun smart-tab ()
"This smart tab is minibuffer compliant: it acts as usual in
the minibuffer. Else, if mark is active, indents region. Else if
point is at the end of a symbol, expands it. Else indents the
current line."
(interactive)
(if (minibufferp)
(unless (minibuffer-complete)
(hippie-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\_>")
(hippie-expand nil)
(indent-for-tab-command)))))
(global-set-key (kbd "TAB") 'smart-tab)
Вы можете настроить параметры хиппи следующим образом:
;;settings for hippie-expand
(setq hippie-expand-try-functions-list
'(try-complete-lisp-symbol
try-complete-lisp-symbol-partially
try-expand-dabbrev
try-expand-dabbrev-from-kill
try-expand-dabbrev-all-buffers
try-expand-line
try-complete-file-name-partially
try-complete-file-name))
Ответ 3
C-M-i; не требуется настройка.
Ответ 4
Я использую:
(define-key function-key-map [(control tab)] [?\M-\t])
Ответ 5
Я использую M-.
и M-/
для двух режимов завершения - hippie-expand и стандартный emacs.
Ответ 6
Поместите это в свой .emacs
, чтобы Windows предоставила Emacs использование M-TAB
:
(when (fboundp 'w32-register-hot-key) (w32-register-hot-key [M-tab]))