emacs - Elisp:在交互式命令中询问是或否

标签 emacs lisp elisp

我是 Emacs 的新手,正在尝试编写一些 Emacs Lisp 函数。

我想编写一个带有两个参数并且可以处理交互的函数。但是,其中一个参数是 bool 值 — 如果我可以使用 (y-or-no-p) 就完美了,但是 (interactive) 不能似乎有一个字符代码。

有什么想法吗?

更新:我使用的是 GNU Emacs 23。

此外,这是我的函数到目前为止的样子:

(defun foo (str bool)
  (interactive "sSome text: \nsDo the thing?")
  (some-func str)
  (if bool (some-other-func str)))

最佳答案

啊,找到了。

(defun foo (str bool)
  (interactive
    (list (read-string "Some text: ")
          (y-or-n-p "Do the thing? ")))
  (some-func str)
  (if bool (some-other-func str)))

关于emacs - Elisp:在交互式命令中询问是或否,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4497073/

相关文章:

functional-programming - Racket 中的引用变量

emacs - adoc模式是什么意思?

emacs - 使用 ox-publish 导出,无法将变量分配给关键字

lisp - Elisp中定义的pow-mod函数在哪里

emacs - 如何为 dired 启用 hl-line-mode?

javascript - 如何编写与 GNU Emacs 一起使用的 Node.js REPL?

emacs - 在 emacs 中使用 gnus 从 microsoft exchange(2010) 访问邮件

Emacs、Zen-Coding 模式和 Putty

eclipse - 编写 Eclipse 脚本以在 emacs 中打开文件

file - Lisp if 语句 - emacs 初始化文件 ".emacs"