我想编写一个函数,如果已经存在一个给定缓冲区名称,它将采取行动.例如:
(if (buffer-exists "my-buffer-name") ; do something )
elisp是否有一个函数来检查是否存在类似于我的"缓冲存在"函数的缓冲区的存在?
谢谢
从文档:
(get-buffer name) Return the buffer named name (a string). If there is no live buffer named name, return nil. name may also be a buffer; if so, the value is that buffer. (get-buffer-create name) Return the buffer named name, or create such a buffer and return it. A new buffer is created if there is no live buffer named name. If name starts with a space, the new buffer does not keep undo information. If name is a buffer instead of a string, then it is the value returned. The value is never nil.
这就是我做的:
(when (get-buffer "*scratch*") (kill-buffer "*scratch*"))
这将检查缓冲区划痕.如果有这样的事情,就杀掉它.如果没有,什么都不做.