我想重命名一個綁定Emacs中當前緩衝區的文件。重命名當前緩衝區和Emacs中的相關文件
我發現下面的elisp從這篇文章: How do I rename an open file in Emacs?
;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file name new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
它工作正常,但如果可能的話我想設置當前文件名作爲默認值。 我會如何寫這個?
看看http://stackoverflow.com/a/384612/41861 –