Windows 上的 Gnu Emacs 24.4 预测试。我想即时修改 nxml-mode 的菜单栏菜单,附加已知 XML 文件的林结构(由 xi:include 形成的任何被编辑的 XML 文件)。除了菜单修补外,工作正常。这实际上也适用于单个文件,但一旦它成为一个层次结构(嵌套键盘映射),访问菜单就会给我带来邪恶的“哇,间接键盘映射输入”错误,此时是时候退出 Emacs 因为事情变得严重了(Alt-Tab 停止工作时令人不安)。有趣的是,我曾看到有人提交了一份错误报告,要求提供更易于理解的错误文本,但遭到拒绝。
我把打补丁前后的菜单结构都转储了,看不出打补丁的版本有什么问题。转储读起来很乏味,但我认为它的补丁代码比它更乏味,这可能只会引起恐怖的喘息而不会引出解决方案。这是菜单栏相关部分的之前状态:
((Show\ Outline\ Only menu-item "Show Outline Only" nxml-hide-all-text-content)
(Show\ Everything menu-item "Show Everything" nxml-show-all)
(nil menu-item "---")
(Validation menu-item "Validation" rng-validate-mode :button (:toggle . rng-validate-mode))
(nil-4 menu-item "---")
(Set\ Schema menu-item "Set Schema" (keymap "Set Schema" (Automatically menu-item "Automatically" rng-auto-set-schema) (For\ Document\ Type menu-item "For Document Type" nil :filter #[257 "ÂÁ!À\"" ["For Document Type" (lambda (menu) (mapcar (lambda (type-id) (vector type-id (list (quote rng-set-document-type) type-id))) (rng-possible-type-ids))) easy-menu-filter-return] 4 " (fn MENU)"]) (Any\ Well-Formed\ XML menu-item "Any Well-Formed XML" rng-set-vacuous-schema) (File\.\.\. menu-item "File..." rng-set-schema-file)))
(Show\ Schema\ Location menu-item "Show Schema Location" rng-what-schema)
(Save\ Schema\ Location menu-item "Save Schema Location" rng-save-schema-location :help "Save the location of the schema currently being used for this buffer")
(nil-8 menu-item "---")
(First\ Error menu-item "First Error" rng-first-error :enable rng-validate-mode)
(Next\ Error menu-item "Next Error" rng-next-error :enable rng-validate-mode)
(nil-11 menu-item "---")
(Customize\ nXML menu-item "Customize nXML" menu-function-7 :key-sequence nil))
这是将我的菜单内容附加到末尾后的状态:
((Show\ Outline\ Only menu-item "Show Outline Only" nxml-hide-all-text-content)
(Show\ Everything menu-item "Show Everything" nxml-show-all)
(nil menu-item "---")
(Validation menu-item "Validation" rng-validate-mode :button (:toggle . rng-validate-mode))
(nil-4 menu-item "---")
(Set\ Schema menu-item "Set Schema" (keymap "Set Schema" (Automatically menu-item "Automatically" rng-auto-set-schema) (For\ Document\ Type menu-item "For Document Type" nil :filter #[257 "ÂÁ!À\"" ["For Document Type" (lambda (menu) (mapcar (lambda (type-id) (vector type-id (list (quote rng-set-document-type) type-id))) (rng-possible-type-ids))) easy-menu-filter-return] 4 " (fn MENU)"]) (Any\ Well-Formed\ XML menu-item "Any Well-Formed XML" rng-set-vacuous-schema) (File\.\.\. menu-item "File..." rng-set-schema-file)))
(Show\ Schema\ Location menu-item "Show Schema Location" rng-what-schema)
(Save\ Schema\ Location menu-item "Save Schema Location" rng-save-schema-location :help "Save the location of the schema currently being used for this buffer")
(nil-8 menu-item "---")
(First\ Error menu-item "First Error" rng-first-error :enable rng-validate-mode)
(Next\ Error menu-item "Next Error" rng-next-error :enable rng-validate-mode)
(nil-11 menu-item "---")
(Customize\ nXML menu-item "Customize nXML" menu-function-7 :key-sequence nil)
(ppop-event-0 "intro.xml" (keymap "intro.xml" (ppop-event-4 menu-item "introswan.xml" nil) (ppop-event-3 menu-item "introgame.xml" nil) (ppop-event-2 menu-item "introclark.xml" nil) (ppop-event-1 menu-item "introroots.xml" nil))))
为清楚起见,将此 sexp 添加到列表中,就在最后一个列表元素 (Customize\nXML ...
:
(ppop-event-0
"intro.xml"
(keymap "intro.xml"
(ppop-event-4 menu-item "introswan.xml" nil)
(ppop-event-3 menu-item "introgame.xml" nil)
(ppop-event-2 menu-item "introclark.xml" nil)
(ppop-event-1 menu-item "introroots.xml" nil)))
目的是现有下拉列表的末尾有一个新条目,文本为“intro.xml”,它应该生成另一个菜单,其中包含条目“introswan.xml”、“introclark.xml”、“introroots” .xml”和“introgame.xml”。为简洁起见,我已将所有添加项目的回调函数设置为 nil;放入真正的函数并不能避免错误。
我的子层次结构似乎与同一下拉列表中的另一个子层次结构相同(请参阅键盘映射“设置模式”),这当然有效。我看不出有什么问题,也看不出该结构如何被解释为间接键盘映射。对于不需要嵌套键映射的单个文件,它似乎工作正常。我已经没有什么可以尝试的了……
发出消息的相关来源是 C 语言,可见于:http://bzr.savannah.gnu.org/lh/emacs/emacs-24/annotate/head:/src/keymap.c#L789
最佳答案
我认为问题在于您的 ppop-event-0
绑定(bind)在其 "intro.xml"
之前缺少一个 menu-item
符号> “名字”。最终结果是你的绑定(bind)最终看起来像一些旧格式,AFAIK 不再在任何地方使用(但很难弄清楚,因此如果/当我们真的遇到这样的事情时,我会在那里添加一个讨厌的错误,所以以确保我们听到用户的意见)。
我认为这个错误消息已经伴随我们很长时间了,我们可以肯定地说不再使用这种间接绑定(bind)并且我们可以放弃对它的支持(因此相应的错误,最终结果可能对你帮助不大)。
关于emacs - 修补菜单,出现 "Wow, indirect keymap entry"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24512092/