Exiting from Emacs is very slow... How to troubleshoot?
I run Emacs on Windows 7 and whenever I close it, it usually takes at least 5 seconds for the window to actually close. It doesn't seem to matter what sort of buffers I have open or what modes I am in. Meanwhile the status bar at the bottom normally says:
(No files need saving)
Is there any way I can get an idea of what it taking so long, like a log file or debug message?
Here are the custom variables from my init file in case anyone can recognize something that would cause such a delay.
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-PDF-mode t)
'(TeX-engine (quote xetex))
'(ac-ignores (quote ("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")))
'(ac-modes (quote (emacs-lisp-mode lisp-interaction-mode c-mode cc-mode c++-mode java-mode clojure-mode scala-mode scheme-mode ocaml-mode tuareg-mode perl-mode cperl-mode python-mode ruby-mode ecmascript-mode javascript-mode js-mode js2-mode php-mode css-mode makefile-mode sh-mode fortran-mode f90-mode ada-mode xml-mode sgml-mode org-mode)))
'(ac-user-dictionary (quote ("")))
'(ansi-color-names-vector ["#3f3f3f" "#cc9393" "#7f9f7f" "#f0dfaf" "#8cd0d3" "#dc8cc3" "#93e0e3" "#dcdccc"])
'(custom-enabled-themes (quote (deeper-blue)))
'(custom-safe-themes (quote ("bf7ed640479049f1d74319ed004a9821072c1d9331bc1147e01d22748c18ebdf" default)))
'(default-major-mode (quote text-mode) t)
'(fci-rule-color "#383838")
'(fill-column 70)
'(global-auto-complete-mode t)
'(global-visual-line-mode t)
'(inhibit-startup-screen t)
'(make-backup-files nil)
'(org-agenda-files (quote ("e:/org-mode/diary.org" "e:/org-mode/gtd.org")))
'(org-agenda-show-inherited-tags t)
'(org-agenda-sorting-strategy (quote ((agenda habit-down time-up priority-down category-keep) (todo todo-state-up priority-down category-keep) (tags priority-down category-keep) (search category-keep))))
'(org-capture-templates (quote (("d" "Diary" entry (file+datetree "E:\\org-mode\\diary.org") "* %? %i %a %^g %U") ("t" "Task" entry (file+headline "E:\\org-mode\\gtd.org" "Tasks") "* TODO %? %i %a %^g %U") ("r" "Reference to find" entry (file+headline "e:\\org-mode\\ToFind.org" "Incoming") ""))))
'(org-mode-hook (quote (#[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook org-show-block-all append local] 5] #[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes org-mode-reftex-setup)) t)
'(org-modules (quote (org-bbdb org-bibtex org-docview org-gnus org-info org-jsinfo org-habit org-mew org-mhe org-rmail org-vm org-wl org-w3m)))
'(org-refile-targets (quote ((org-agenda-files :tag . "") (nil :maxlevel . 3))))
'(org-startup-indented t)
'(org-support-shift-select t)
'(org-todo-keywords (quote ((sequence "NEXT(n)" "TODO(t)" "WAITING(w)" "|" "SOMEDAY(s)" "MAYBE(m)" "CANCELLED(c)" "DONE(d)"))))
'(package-archives (quote (("MELPA" . "http://melpa.milkbox.net/packages/") ("gnu" . "http://elpa.gnu.org/packages/"))))
'(save-place t nil (saveplace))
'(text-mode-hook (quote (text-mode-hook-identify))))
Solution 1:
I ran into this problem on Linux with Emacs 24.3.1
Eventually I noticed that I had a .emacs-places file that was 12MB. I deleted the file and now Emacs exits immediately. I suspect Emacs was trying to do some update to the file on shutdown but the file had gotten long enough that Emacs was getting stuck parsing and updating the file.
It looks like .emacs-places is used by saveplace which stores you position in a file so that when you reopen the file the cursor is positioned at the same point you were in when you closed the file. Maybe after a while this file fills up and gets time consuming to update? I'm going to keep an eye on it and disable saveplace if that seems to be the problem.
Solution 2:
Unfortunately, there doesn't seem to be an easy way to get a useful log of what is happening as Emacs shuts down.
In the end, I resolved this problem by building a new .emacs
file from scratch. I am re-adding things as I need them, and so far have had no problems.