我正在寻找一种模拟迷你缓冲输入的方法.因此,some-func会从迷你缓冲区获取一些输入并对其执行某些操作.问题是,我有打电话给一些-FUNC从其他一些功能调用,FUNC,我需要交互做,所以我不能只是传递一个参数.
(defun some-func (arg)
(interactive "*sEnter something: ")
;; Do something with arg
)
(defun calling-func ()
(call-interactively 'some-func)
;; Type to minibuffer
)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢!
探索为什么需要以交互方式调用其他函数可能会很有趣...但这不是您所要求的.
这是一个以交互方式"调用"函数并向迷你缓冲区发送文本的示例.您只需使用Emacs键盘宏:
(defun my-call-find-file (something)
"An example of how to have emacs 'interact' with the minibuffer
use a kbd macro"
(interactive "sEnter something:")
(let ((base-vector [?\M-x ?f ?i ?n ?d ?- ?f ?i ?l ?e return]))
;; create new macro of the form
;; M-x find-file RET <userinput> RET
(execute-kbd-macro (vconcat base-vector
(string-to-vector something)
(vector 'return)))))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
865 次 |
| 最近记录: |