如何知道何时使用括号

时间:2013-01-13 23:13:27

标签: emacs elisp

我正在阅读An Introduction to Programming in Emacs Lisp,我看到以下内容:

此代码有效:

(message "The name of this buffer is: %s." (buffer-name))

虽然这个失败了:

(message "The name of this buffer is: %s." buffer-name)

但是,此代码有效:

(message "The value of fill-column is %d." fill-column)

虽然这个失败了:

(message "The value of fill-column is %d." (fill-column))

我的问题是为什么? buffer-namefill-column之间有什么区别?我怎么知道何时使用括号?

1 个答案:

答案 0 :(得分:5)

简单地说 - buffer-name是一个函数(返回一个字符串),fill-column是一个变量(计算结果为整数)。

所有Lisp方言中的函数调用都应该用括号括起来。

要查看有关Emacs中的功能的详细信息,请按 C-h f函数名称RET 。 要在Emacs中查看有关变量的详细信息,请按 C-h v变量名称RET