My .emacs file (emacs 23.4.1) contains python and latex related code. For both there is eval-after-load (code that I want to be executed just once when emacs initiates) and hooks. A relevant part of it is:
(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.3")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
(defun my-eval-after-load-python()
(setq initial-frame-alist '((top . 48) (left . 45) (width . 142) (height . 57)))
(split-window-horizontally (floor (* 0.49 (window-width)))))
(eval-after-load "python-mode" '(my-eval-after-load-python))
All hooks work fine, but my-eval-after-load-python doesn't, which causes the frame to be split into two windows everytime emacs initiates for every extension (for example: emacs file.py, emacs file.tex, emacs file). I tried to change it to:
(eval-after-load "python-mode"
'(progn
(setq initial-frame-alist '((top . 48) (left . 45) (width . 142) (height . 57)))
(split-window-horizontally (floor (* 0.49 (window-width))))
, but it still doesn't work. There's probably a beginner mistake going on here, but I'm unable to find it. How would I split the window just the first time a python script is opened (emacs file.py) and not every time I open a new buffer file2.py?
It sounds like something is causing (load "python-mode")
to happen "everytime emacs initiates for every extension" (I'm not sure what you actually mean by that).
Your code is also strange in that you are forcibly loading python-mode with require
, and then subsequently evaluating eval-after-load
for that same library, even though you know that it's definitely already loaded. This will still work, but it's odd. One tends to use eval-after-load
to avoid loading something up front (letting autoloading deal with it on demand, but still having the custom code running at that time).
Edit: Oh, do you just mean that when you start Emacs it evaluates your eval-after-load
code? That's because you've told it to -- you loaded python mode, and then told Emacs that if/when python mode is loaded, split the screen in two.