So after a few months of frustration today i discovered the issue that's been bothering me for a long time..the REALLY slow emacs startup (sometimes 5 minutes or more).

The cause is the org mode init file i use. what i currently have in my setup is

A. this init.el:

(require 'package)
;since we are using use-package-don't autoload anythings
(setq package-enable-at-startup nil)

(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;; org maybe suspect of hanging melpa, if you have hangs disable this first
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
;; Initialize installed package

;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
    (package-install 'use-package))

(org-babel-load-file (expand-file-name "~/.emacs.d/settings.org"))

B. My config stored in settings.org which alot of lisp code (like 17,000 lines..yeah i like to tinker :))

Using this method i discovered that every time i make a small change to setting.org and restart emacs the setting.org gets tangled to settings.el and emacs takes nearly 6!!! minutes to start (Init time was 396.10s (395.33s in init.el) , yeah thats painful as you can imagine.

BUT what i discovered today is that if i just stick my config chunks from setting.org (ie the tangled setting.el file) into init.el, emacs starts super fast each time, even when i change the init.el file!

can anyone help me with this, i really would appreciate you guys help with this as its driving me mad :)

  • Wow 17000 lines of code. Just curious what do you have in there? about the org init file, I did see someone say the same thing #emacs in freenode. I don't remember the exact details, but he experienced a slowdown as well, but not to your degree Commented Dec 10, 2016 at 12:39
  • thx. well not all 17000 lines are code, its added documentation etc. i can post the org file if you want :)
    – zeltak
    Commented Dec 10, 2016 at 12:45
  • Ok some more exploring made me realize that also using M-x org-babel-load-file on the setting.org file and tangling it takes a LONG time (like 6-7 minutes) so its not a problem of the init its the actual tangling of the file. 6-7 minutes cant be normal right?
    – zeltak
    Commented Dec 10, 2016 at 12:54
  • Do post the org init file :) I'd love to see what you got there. Hmm does the same thing happen when you run emacsclient?? Commented Dec 10, 2016 at 13:09
  • 1
    @ChakravarthyRaghunandan, here you go paste.xinu.at/wsTw
    – zeltak
    Commented Dec 10, 2016 at 15:18

2 Answers 2


Not necessarily a solution, but at least an explanation.

I’ve seen this myself, although not to the extent of your tangling time. The startup time appears related to the number of separate begin_src blocks that you’ve got – in the case of a literate programming init.el file you’re likely to have a lot of separate blocks as you intersperse elisp fragments with explanatory text and headings, which leads to the worst case startup time.

I’ve not investigated this myself, but it’s described in more detail here: http://www.holgerschurig.de/en/emacs-init-tangle/

(EDIT: zeltak has pointed out an updated approach here: http://www.holgerschurig.de/en/emacs-efficiently-untangling-elisp/)

That post doesn’t have a solution for “fixing” Org-mode’s tangling time, but it does present an alternative tangling function that avoids this problem. That function isn’t as general as Org-babel, but for this use case it’s quite likely sufficient.

I won’t reproduce that function here since it’s not my work, but the above link describes that in more detail. Note that I’ve not used this myself because my tangling time isn’t bad enough to force me down that path and I don’t modify my init.org much any more.

  • wow, thats an amazing find. @Stuart Hickinbottom ,thx so much!. there is actually an updated post for anyone whos interested: holgerschurig.de/en/emacs-efficiently-untangling-elisp. I wonder if there is a downside to using a non standard org function..that is with a new org version where thet might change things etc
    – zeltak
    Commented Dec 10, 2016 at 15:58
  • @zeltak -- it's probably unlikely that the syntax for elisp babel blocks will change significantly. Since all this is doing is extracting to a .el file that is then loaded normally, I don't see much of a drawback. If something ever does change then switching back to org-babel-load-file remains an option. Commented Dec 10, 2016 at 17:35
  • 1
    the provided links are not working! unfortunately, I cannot find it to fix the links.
    – M.Rez
    Commented Dec 12, 2019 at 18:59
  • Bah, internet link-rot. This version is slightly different, but maybe newer. I've not tried it myself but it looks very similar to the original. Look at the "my-tangle-config-org" function. github.com/novoid/dot-emacs/blob/master/init.el Commented Dec 18, 2019 at 15:00

Another route is to tangle, and compile, upon saving the file. I do this and then the init.el loads that compiled file. Fast to load, but slower to save.

My ~/.emacs.d/init/init-org.org contains the usual Org structured file with headings and #+BEGIN_SRC emacs-lisp as described elsewhere.

I define this hook to detect that this file is being saved and tangle and byte-compile after save:

(defun my/tangle-dotfiles ()
   "If the current file is this file, the code blocks are tangled"
   (when (equal (buffer-file-name) (expand-file-name "~/.emacs.d/init/init-org.org"))
     (org-babel-tangle nil "~/.emacs.d/init/init-org.el")
     (byte-compile-file "~/.emacs.d/init/init-org.el")))

(add-hook 'after-save-hook #'my/tangle-dotfiles)

The ~/.emacs.d/init/init.el contains:


(load-file "~/.emacs.d/init/init-org.elc")


followed by whatever else Emacs wants to put in there.

  • thx. can you share your code @jtgd that does that?
    – zeltak
    Commented Dec 14, 2016 at 12:35
  • Sure. Edited into above.
    – jtgd
    Commented Dec 15, 2016 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.