Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: execute function only after restarting, not after evaluating a buffer

Tags:

emacs

startup

I like to start my work in Emacs with two open windows. For that, I have a function (split-window-horizontally) in my .emacs file.

It works with no problems, splitting window into two side-by-side windows after each evaluation of .emacs buffer. Of course, it also splits window every time I re-evaluate .emacs file to test some new setting. How can I tell emacs not to split the window after each evaluation of .emacs buffer, but rather only after restarting emacs?

I'm looking for something like:

(eval-only-after-restart
    (split-window-horizontally))

Is there any such function? Or another way how to do it?

like image 414
Katarina Avatar asked Nov 01 '13 12:11

Katarina


2 Answers

Like this:

(unless (boundp 'done-split-window-horizontally)
  (split-window-horizontally)
  (setq done-split-window-horizontally t))
like image 74
abo-abo Avatar answered Sep 22 '22 15:09

abo-abo


Another way:

(add-hook 'emacs-startup-hook #'split-window-horizontally)
like image 26
tungd Avatar answered Sep 22 '22 15:09

tungd