![](/img/trans.png)
[英]How to pass &rest arguments to another function in emacs lisp?
[英]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.