簡體   English   中英

如何在Emacs抽象函數中傳遞arg

[英]How to pass arg in Emacs abstract function

我嘗試編寫一個函數來抽象使用哪個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

我該怎么辦?

為什么使用Mx helm-semantic-or-imenu :參數在哪里?

按照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))))

至少,它有效!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM