My emacs daemon for ocaml (I use more than one emacs daemon) starts in a tuareg scratch buffer. I am aware of initial-major-mode
but this hasn't worked: 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.
But now, when I kill the scratch, new scratch 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 magnificent initial-scratch-message
.
I have tried to (setq initial-major-mode 'tuareg-mode)
, which normally modifies 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.
tuareg-mode
is loaded before you setinitial-major-mode
. I originally followed the instructions here to do what you want to do, emacsredux.com/blog/2014/07/25/… but it sounds like you have already tried these steps(setq initial-major-mode 'tuareg-mode)
i've added(require 'tuareg)
and it works ! Thank you elethan !