我想在 matlab-mode
中将 forward-sexp
重新映射到 matlab-forward-sexp
。
目前我这样做:
(define-key matlab-mode-map [remap forward-sexp] 'matlab-forward-sexp-safe)
但是当我在 matlab 模式下输入 M-xforward-sexp
时,我仍然得到旧的行为。为什么?是否只有当我通过键盘快捷键调用 forward-sexp
时才有效?
当我输入C-h fforward-sexp
时,一切似乎都正常:
forward-sexp is an interactive compiled Lisp function in `lisp.el'.
It is remapped to `matlab-forward-sexp-safe', which is bound to C-M-f,
<C-M-right>, ESC <C-right>.
(forward-sexp &optional ARG)
For more information check the manuals.
Move forward across one balanced expression (sexp).
With ARG, do it that many times. Negative arg -N means
move backward across N balanced expressions.
This command assumes point is not in a string or comment.
This function is advised.
After-advice `ctx-flash'.
[back]
最佳答案
是的,[remap]
语法是明确用于键绑定(bind)的。当绑定(bind)调用旧函数时,重新映射会导致它调用新函数。然而,这并没有改变这两个函数的定义——它们仍然可以被直接调用。
有关详细信息,请参阅M-: (info "(elisp) 重新映射命令")
RET
Emacs 24 最近的一项更改澄清了此帮助文本,因此现在的内容如下:
forward-sexp is an interactive compiled Lisp function in `lisp.el'.
Its keys are remapped to `matlab-forward-sexp-safe'. Without this remapping, it would be bound to C-M-f, <C-M-right>, ESC <C-right>. .
关于emacs - 重新映射 Emacs 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9761667/