在 coffee-mode
RET
绑定(bind)到 coffee-newline-and-indent
效果很好。
我也用 evil-mode
有 Vim 仿真。 evil-mode
使用标准 newline-and-indent
所以缩进对于一些vim命令是不正确的,比如o
或 O
.
重新绑定(bind)newline-and-indent
的最佳方法是什么?至coffee-newline-and-indent
?
我仍然是 ELisp 的新手,并尝试了下面的行,但它不起作用。
(add-hook 'coffee-mode-hook
(lambda ()
(setq newline-and-indent '(funcall coffee-newline-and-indent))))
最佳答案
这是我的尝试。它应该工作,但我真的不喜欢它。
(add-hook
'coffee-mode-hook
(lambda ()
(defalias
'newline-and-indent
(lambda()
(interactive)
(if (eq major-mode 'coffee-mode)
(coffee-newline-and-indent)
(delete-horizontal-space t)
(newline)
(indent-according-to-mode))))))
我希望我可以使用比复制源代码更优雅的东西
的
newline-and-indent
, 但是 make-variable-buffer-local
不适用于这种情况,我无法获得
symbol-function
的深拷贝任何一个。我很高兴看到更好的方法。
关于emacs - 如何在 Emacs 中将一个函数重新映射到另一个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18313914/