0

我正在尝试为我自己的编译插件创建一个动态菜单,但我碰壁了。这是我目前拥有的代码:

(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”的子菜单并用条目填充它。但是没有创建条目。任何帮助,将不胜感激。

4

2 回答 2

1

我建议你做类似的事情

(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))))))))))
于 2013-09-03T00:19:19.210 回答
0

我怀疑您可能正在寻找类似的东西,但是如果不查看更多代码就很难知道。您应该能够自己调试它,使用macroexpand等,直到您获得一组正确的参数传递给easy-menu-define.

Wrt Stefan 的代码,正如您所提到的,这添加了缺少的mapcar第二个 arg,并且它删除了之前的反引号(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))))
于 2013-10-26T16:38:10.767 回答