emacs - 重新映射 Emacs 命令

标签 emacs elisp key-bindings remap

我想在 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/

相关文章:

emacs - 如何知道emacs服务器是否正在运行

Python.el 错误处理了我在文档字符串上的 M-q 缩进

emacs - Flymake 提示 X 不可用,即使配置为不使用 X

emacs - 如何在 emacs 中添加工具栏按钮?

涉及正斜杠的 Emacs 键绑定(bind)

java - 在 Java 中创建热键

Emacs - 无法映射 C-[

emacs - 在基于 Solaris 的远程服务器上找不到退出状态 "test -e ... "

java - Swing JTable - 在 Shift 键上使用键绑定(bind)而不是 KeyListener