1

这就是我一直在使用的:

  (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 代码?

4

2 回答 2

1

If I understand your question correctly, if you use Lisp code to build a list of arguments to interactive, your code needs to handle all the arguments, and you will not have access to the convenience prompting facilities of interactive. So your first example would turn into

(interactive
  (list
    (read-file-name "Image file: " (if (file-exists-p "_static")
                                       "_static"
                                      default-directory) )
    (read-string "Caption: ") ))
于 2012-09-05T10:50:24.237 回答
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 代码集成。

于 2012-09-05T08:26:18.417 回答