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"))))
這是爲了做到這一點?
由於這是一個名爲「無標題」的緩衝區,因此我只能在會話中使用其中的一個。有什麼我可以用來超過一個,而不訴諸隨機數字?