我目前对 *scratch* buffer 的操作需求,不包含编写 elisp 代码片段等,只是想把其当做 Sublime Text 一般的空页面做临时记录使用。
故需要对 *scratch buffer 配置为 text-mode 以减少各种自动化修正操作:
(setq initial-major-mode 'text-mode); for the initial ‘*scratch*’ buffer.
创建空 buffer
我封装了下 xahlee 的方法:
(defunxah-new-empty-buffer()"Create a new empty buffer. New buffer will be named “untitled” or “untitled<2>”, “untitled<3>”, etc. It returns the buffer (for elisp programing). URL `http://xahlee.info/emacs/emacs/emacs_new_empty_buffer.html' Version 2017-11-01"(let(($buf (generate-new-buffer "untitled")))(switch-to-buffer $buf)(funcall initial-major-mode)(setq buffer-offer-save t)
$buf))(defunscratch()"Call xah-new-empty-buffer by scratch."(interactive)(xah-new-empty-buffer))