配置*scratch* buffer

相信大家对*scratch* buffer应该都挺熟悉了,毕竟每次启动Emacs,都会显示这个buffer. 若设置inhibit-startup-screen为t,则它会是你打开Emacs后看到的第一个buffer(除非你修改了initial- buffer-choice,这样的话,它所指的buffer会成为地一个显示的buffer)

scratch buffer可以很方便的用来临时记录一些便贴,或做一些Emacs Lisp的实验, 然而很多人可能并不常写Emacs Lisp,这样的话,*scratch* buffer对他们的价值就不是那么高了.

很少人知道的是,我们可以配置*scratch* buffer的major-mode(默认为lisp-interaction-mode).

如果你是个Ruby开发人员,可以通过下面代码来让*scratch* buffer默认使用ruby-mode

(setq initial-major-mode 'ruby-mode)

当然,你也可以更改*scratch* buffer的初始内容,默认情况下初始内容为:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.;; If you want to create a file, visit that file with C-x C-f,              ;; then enter the text in that file's own buffer.

而若你设置了*scratch* buffer默认为ruby-mode,则可以将初始内容修改为:

(setq initial-scratch-message "\                                     # This buffer is for notes you don't want to save, and for Ruby code.# If you want to create a file, visit that file with C-x C-f,        # then enter the text in that file's own buffer.")

当然,你也可以直接将initial-scratch-message设置为nil,则初始内容为空.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章