本文介绍了不能绑定输入到Emacs中的newline-and-indent!很烦人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在Emacs中无法绑定到 newline-and-indent 中的输入!非常烦人。 我已经尝试通过将模式更改为红宝石,仍然没有任何内容的以下内容: 如何使Emacs自动缩进我的C代码? 我知道问题是键,因为如果我绑定到别的东西,工作正常。 我试过 [enter] ,(kbdenter), read-kbd-macroenter),(kbdRET) 跟进1。 这是我从 我不知道该怎么做,或者如何弄清楚它是一个全局的或本地绑定, 。尝试重新映射 也无效。解决方案使用(describe-key)来查看当它不做你想要的时候键被绑定到什么。 (kbdfoo)语法对于 foo describe-key指定为可能您根本没有在适当的键盘映射中定义该键。 请注意,主要和次要模式键盘映射优先于全局键盘映射,所以如果覆盖全局绑定,您不一定会感到惊讶。 编辑: 我自己,我有一个钩子功能,用于我使用的所有编程模式的常见行为,它包括您重新映射的类型。相关部分如下所示: (defun my-coding-config()(本地设置键(kbdRET)(key-binding(kbdMj)))(local-set-key(kbd< S-return>)'newline)) (mapc (lambda(language-mode-hook)(add-hook language-mode-hook'my-coding-config))'(cperl-mode -hook css-mode-hook emacs-lisp-mode-hook ;; etc ... )) / pre> 请参阅Daimrod的回答,说明为什么我将重新绑定到当前绑定的 key, since if I bind to something else, works fine.I tried [enter], (kbd "enter"), (read-kbd-macro "enter"), (kbd "RET")Follow-up 1.This is what I get from I dont know what to make of it or how to figure out if it's a globalor local binding that gets in the way. trying to remap also doesnt work. 解决方案 As a previous comment says, use (describe-key) to see what the key is bound to at the point when it's not doing what you want. The (kbd "foo") syntax will be correct for whichever foo describe-key refers to it as.Chances are that you are simply not defining that key in the appropriate keymap.Note that major and minor mode keymaps take precedence over the global keymap, so you shouldn't necessarily be surprised if a global binding is overridden.edit:Myself, I have a hook function for common behaviours for all the programming modes I use, and it includes the sort of remapping you're after. The relevant part looks like this:(defun my-coding-config () (local-set-key (kbd "RET") (key-binding (kbd "M-j"))) (local-set-key (kbd "<S-return>") 'newline) )(mapc (lambda (language-mode-hook) (add-hook language-mode-hook 'my-coding-config)) '(cperl-mode-hook css-mode-hook emacs-lisp-mode-hook ;; etc... ))See Daimrod's answer for the explanation of why I'm re-binding to the current binding of -- although I'm using comment-indent-new-line (or similar) instead of newline-and-indent (or similar), which does what I want in both comments and non-comments.In Emacs 24, programming modes seem to derive from prog-mode, so you could probably (un-tested) reduce that list to prog-mode-hook plus any exceptions for third-party modes which don't yet do that. 这篇关于不能绑定输入到Emacs中的newline-and-indent!很烦人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 02:17