我正试图为自己的编译插件创建一个动态菜单,但遇到了麻烦。这是我目前拥有的代码:
(defun mme-tools-create-menu ()
(easy-menu-define mme-tools-menu erlang-mode-map "MME-Tools-Menu"
'("MME-Tools"
("Current Subsystem"
["Run gmake" mme-tools-build]
["Build beams" mme-tools-build-beam]
["Run Posttest" mme-tools-build-posttest]
["Run Move" mme-tools-build-move])
("Build Subsystem")))
(dolist (path mmepaths)
(if (string-match "code" path)
(let* ((ss (file-name-base path))
(uss (upcase ss)))
(easy-menu-add-item mme-tools-menu '("Build Subsystem")
[uss (mme-tools-build-path-subsystem " -j10 beam" (getenv ss))])))))
我希望代码做的是制作一个名为"Build Subsystem"的子菜单,并用条目填充它。但没有创建任何条目。如有任何帮助,我们将不胜感激。
我建议你做一些类似的事情
(easy-menu-define mme-tools-menu erlang-mode-map "MME-Tools-Menu"
`("MME-Tools"
("Current Subsystem"
["Run gmake" mme-tools-build]
["Build beams" mme-tools-build-beam]
["Run Posttest" mme-tools-build-posttest]
["Run Move" mme-tools-build-move])
("Build Subsystem"
,@(mapcar (lambda (path)
(when (string-match "code" path)
(let* ((ss (file-name-base path))
(uss (upcase ss)))
(vector uss `(mme-tools-build-path-subsystem " -j10 beam" (getenv ',ss))))))))))
我怀疑您可能正在寻找这样的东西,但如果没有看到更多的代码,很难知道。您应该能够使用macroexpand
等自行调试,直到获得一组合适的参数传递给easy-menu-define
。
在Stefan的代码中,正如您所提到的,这添加了缺少的mapcar
第二个参数,并删除了(mme-tools-build-path-subsystem...)
之前的后引号(只是猜测)。
(easy-menu-define
mme-tools-menu
erlang-mode-map "MME-Tools-Menu"
`("MME-Tools"
("Current Subsystem"
["Run gmake" mme-tools-build]
["Build beams" mme-tools-build-beam]
["Run Posttest" mme-tools-build-posttest]
["Run Move" mme-tools-build-move])
("Build Subsystem"
,@(mapcar (lambda (path)
(when (string-match "code" path)
(let* ((ss (file-name-base path))
(uss (upcase ss)))
(vector uss
(mme-tools-build-path-subsystem
" -j10 beam" (getenv ',ss))))))
mmepaths))))