鉴于Lisp中代码和数据的"所有列表"同源方法,我很难理解如何在Emacs Lisp中操作alist.特别是,如何将alist转换为普通的双元素列表列表,反之亦然?几乎看起来alist是他们自己的一种特殊类型,它不能像常规列表那样被操纵.
具体示例:我正在尝试在我的.emacs文件中绑定一个键,以使用编程生成的名称创建一个特定大小的帧,如下所示:
(make-frame '((name . "Blarg") (width . 80) (height . 24)))
Run Code Online (Sandbox Code Playgroud)
只要"Blarg"是一个常量字符串,这样就可以正常工作,但是由于alist开头的引用,我不能将任何求值的代码放在一个字符串中代替"Blarg".我想要做的是通过cons宽度和高度的符号和整数,然后add-list是前面的名称来建立一个列表,并将整个事物传递给make-frame.但是如何将结果数据结构转换为alist呢?
关于如何make-frame做我想做的事情的具体答案当然会受到赞赏,但正如我的标题所示,我希望能更详细地解释如何操纵alist并将它们转换为常规列表.
该功能的“ Emacs帮助”页面显示shell-command-on-region(省略空格):
(shell-command-on-region START END COMMAND &optional OUTPUT-BUFFER
REPLACE ERROR-BUFFER DISPLAY-ERROR-BUFFER)
...
The noninteractive arguments are START, END, COMMAND,
OUTPUT-BUFFER, REPLACE, ERROR-BUFFER, and DISPLAY-ERROR-BUFFER.
...
If the optional fourth argument OUTPUT-BUFFER is non-nil,
that says to put the output in some other buffer.
If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
If OUTPUT-BUFFER is not a buffer and not nil,
insert output in the current buffer.
In either case, the output is inserted after …Run Code Online (Sandbox Code Playgroud)