My emacs daemon for ocaml (I more than one emacs daemon) start in a tuareg scratch buffer, I am aware of initial-major-mode
but this hasn't work, the scratch is started before (setq
initial-major-mode 'tuareg-mode)` is evaluated...
Since I keep the initial-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 scratches 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 magnificient initial-scratch-message
...
Of course I have tried to (setq initial-major-mode 'tuareg-mode)
which normally does modify the scratch major mode, 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.