read-minibuffer函数输入字符串,带“标点符号”

时间:2016-04-17 13:48:44

标签: emacs

我按如下方式编写emacs lisp代码:

#!/usr/bin/emacs --script
(setq input (read-minibuffer "please input your name:") )
(message "%s" input)

然后我使用此代码来测试标准输入:

./test.el
please input your name:hello
hello

第一次测试没问题。但是当我将字符串hello,world放入标准输入时,会出现错误:

please input your name:hello,world
Trailing garbage following expression

然后我将字符串"hello,world"添加到标准输入中,它传递了:

please input your name:"hello,world"
hello,world

然后我想知道,我该怎么做才能获得没有"的输入字符串 标点。我只想输入hello,world,而不是"hello,world"。 感谢

1 个答案:

答案 0 :(得分:2)

函数read-minibuffer期望用户输入Lisp对象。如果您输入hello,则会返回一个符号,如果您输入"hello,world",则会返回一个字符串。

您可能希望使用函数read-from-minibuffer。它返回用户输入的字符串,而不试图以任何方式解释它。