复杂的互动表达

时间:2012-09-05 08:14:45

标签: emacs elisp

这就是我一直在使用的:

  (interactive "sEnterh the name of the figure (e.g. markov-chain.png): 
sCaption: ")

这就是我想要使用的东西:

  (interactive (list (read-file-name "Image file: " (if (file-exists-p "_static")
                                                        "_static"
                                                      default-directory
                                                      )))
"sCaption: ")

如何做到这一点?

用文字表示 - 可以将交互式类型混合在一个字符串中:

  (interactive "r
sEnter char to use: 
sNumbering style used (d for digit, l for letter, r for Roman digits): 
sShould I dobule line breaks? (RET for yes) ")

但是如何组合交互式,在我的例子中是“s”和elisp代码?

2 个答案:

答案 0 :(得分:1)

如果我正确理解你的问题,如果你使用Lisp代码来构建interactive的参数列表,你的代码需要处理所有的参数,你将无法访问{的便利提示功能。 {1}}。所以你的第一个例子将变成

interactive

答案 1 :(得分:0)

哦,我没有互动类型解决了它:

(defun rst-bk-numfigs ()
  (interactive) 
  (let (Fig Caption)
    (setq Fig (file-name-nondirectory 
               (car (list (read-file-name "Image file: "
                                     (if (file-exists-p "_static") ;; actually I need dir-p
                                         "_static"
                                       default-directory
                                       ))))))
    (setq Caption (read-from-minibuffer "Caption: "))))

可能无法将交互式类型与elisp代码集成。