Nameless
Nameless copied to clipboard
Opening org.el is slow
Opening org.el
is very slow for me.
I did some profiling, and it seems nameless
is responsible.
(progn
(profiler-start 'cpu)
(dotimes (_ 5)
(find-file "~/emacs/lisp/org/org.el"))
(profiler-report)
(profiler-stop))
Here are the relevants parts of the profile tree:
- find-file 14269 89%
- find-file-noselect 14253 89%
- find-file-noselect-1 14236 89%
- after-find-file 14224 89%
- normal-mode 14207 89%
- set-auto-mode 14183 89%
- set-auto-mode-0 14183 89%
- emacs-lisp-mode 14183 89%
- run-mode-hooks 14178 89%
- apply 7101 44%
- run-hooks 7101 44%
- nameless-mode 7101 44%
- nameless--after-hack-local-variables 7101 44%
- apply 4124 25%
- nameless--add-keywords 4124 25%
- nameless--ensure 4124 25%
+ font-lock-fontify-region 4124 25%
- nameless--remove-keywords 2977 18%
- nameless--ensure 2977 18%
+ font-lock-fontify-region 2977 18%
- hack-local-variables 7006 44%
- hack-local-variables-apply 7006 44%
- run-hooks 7006 44%
- nameless--after-hack-local-variables 7006 44%
- apply 4102 25%
- nameless--add-keywords 4102 25%
- nameless--ensure 4102 25%
+ font-lock-fontify-region 4102 25%
- nameless--remove-keywords 2904 18%
- nameless--ensure 2904 18%
+ font-lock-fontify-region 2904 18%
It looks like nameless--after-hack-local-variables
is getting called
twice, and so ultimately font-lock-fontify-region
(which is the
expensive part) is getting called twice too.
Is it actually necessary for that to get called twice? I don't understand how hooks or local variables work.
GNU Emacs 26.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-06-25
emacs-lisp-mode-hook => (nameless-mode)
Nameless uses font-locking to do its thing. Looks like the problem is that org.el is a very big file and it takes a while to font-lock completely.
I think the solution here would be for nameless to font-lock more lazily (I believe font-lock already supports that, so we're probably just using it wrong).