1

我尝试编写一个函数来抽象helm-imenu要使用的变体:

(defun my/helm-menu ()
  "For Org mode buffers, show Org headlines.
For programming mode buffers, show functions, variables, etc."
  (interactive)
  (cond ((derived-mode-p 'org-mode)
           (helm-org-in-buffer-headings))
        (t
           (helm-semantic-or-imenu))))

但是,当在非 Org 模式缓冲区中使用它时,它会失败,说它需要一个参数。

确实,helm-semantic-or-imenu需要arg.

我应该如何通过?

为什么要使用 a M-x helm-semantic-or-imenu: 论点在哪里?

4

1 回答 1

0

按照 Drew 的建议,应该这样做:

(defun my/helm-menu (arg)
  "For Org mode buffers, show Org headlines.
For programming mode buffers, show functions, variables, etc."
  (interactive "P")
  (cond ((derived-mode-p 'org-mode)
           (helm-org-in-buffer-headings))
        (t
            (helm-semantic-or-imenu arg))))

至少,它有效!

于 2016-06-25T09:06:38.993 回答