5
我试图从Elisp Cookbook一些代码的内容无名缓冲区,我最初因子评分,此代码:elisp的创建文件
(defun process-file (file)
"Read the contents of a file into a temp buffer and then do
something there."
(when (file-readable-p file)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(while (not (eobp))
;; do something here with buffer content
(forward-line)))))
将创建一个新的(未命名/未保存的)缓冲器我Emacs窗口上,有该文件的内容(也许在前台打开它)。但是,这不会发生。你能指导我走向这个吗?
编辑:我尝试了一下,并得到了这一点:
(defun myTest (file)
(interactive "f")
; check if file is readable
(when (file-readable-p file)
; create a new "untitled" buffer
(let ((myBuf (get-buffer-create "untitled")))
; make it the current displayed buffer
(switch-to-buffer myBuf)
(insert "Hello"))))
这是为了做到这一点?
由于这是一个名为“无标题”的缓冲区,因此我只能在会话中使用其中的一个。有什么我可以用来超过一个,而不诉诸随机数字?