Search code examples
htmlemacsnxhtml

How can I make emacs load nXhtml only when php/html files are open and prevent it from loading at startup


So in order to optimize emacs startup time I prefer to encapsualte all mods within a hook or an eval-after-load. So I figured out python, cpp and latex but am stuck with nXhtml. I tried the following:

(eval-after-load "HTML-mode"
'(progn
(load-file "~/.emacs.d/plugins/nxhtml/autostart.el")
))

Which doesn't work at all.

The code :

(add-hook 'html-mode-hook (lambda()
(progn
  (load-file "~/.emacs.d/plugins/nxhtml/autostart.el")
)))

loads some parts of nXhtml but the nXhtml mode is not on (only SGML and AC) so scopes aren't colored differently in my php sources or autocomplete/ bracket completion doesn't work.

The only way it works properly is if I let it load on startup.

Looking at the trace , when nxhtml is loaded during startup it says :

"majmodpri-apply-priorities running ... (done)"

However when the load is encapsulated by a n html-mode-hook or the eval-after-load the trace says:

"majmodpri-apply-priorities running ... MU:majmodpri-check changing majmodpri-apply-priorities: buffer=index.php, html-mode,nil => sgml-mode,nil majmodpri-apply-priorities running ... (done)"

Any ideas?


Solution

  • I think nXhtml's autostart file (which is all that you would be loading) is designed to be fairly minimal, so it might be the case that you can't reduce it too much more without constraining some of its abilities?

    How long is it actually taking? It looks like there should be a "Nxml/Nxhtml Autostart.el loaded in %.1f seconds" message logged.