相信大家對*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,則初始內容爲空.