My emacs daemon for ocaml (I use more than one emacs daemon) startstarts in a tuareg scratch buffer, I. I am aware of initial-major-mode
but this hasn't work,worked: the scratch is started before (setq
initial-major-mode 'tuareg-mode)` is evaluated...
Since I keep the initial-buffer-choiceinitial-buffer-choice
to scratch, I just run (tuareg-mode)
and my scratch mode is modified as I want. Cool.
But now, when I kill the scratch, new scratchesscratch buffers are not in tuareg mode, so I added a little hack found on stackexchange :
(defun prepare-scratch-for-kill ()
(save-excursion
(set-buffer (get-buffer-create "*scratch*"))
(tuareg-mode)
(add-hook 'kill-buffer-query-functions 'kill-scratch-buffer t)))
(defun kill-scratch-buffer ()
(let (kill-buffer-query-functions)
(kill-buffer (current-buffer)))
;; no way, *scratch* shall live
(prepare-scratch-for-kill)
;; Since we "killed" it, don't let caller try too
nil)
(prepare-scratch-for-kill)
It works, but now I don't see my magnificientmagnificent initial-scratch-message
...
Of course II have tried to (setq initial-major-mode 'tuareg-mode)
, which normally does modifymodifies the scratch major mode,. But it doesn't, even if I start a new scratch.
I would like to do it the proper way, emacs embeded way, but what I have tried doesn't work.