3

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?

octi
  • 1,470
  • 1
  • 17
  • 28

4 Answers4

2

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.

phils
  • 71,335
  • 11
  • 153
  • 198
  • it takes 1.7 seconds to load everything. While this won't be terrible i'm wondering if there is a possibility to load nXhtml when I need it for web development only, as I use Emacs for editing just about everything – octi May 02 '12 at 17:35
  • Have you byte-compiled it? (IIRC nXhtml provides a menu item to do that, so that you don't need to worry about what needs compiling and what doesn't.) – phils May 02 '12 at 21:57
  • Nxml/Nxhtml Autostart.el loaded in 0.1 seconds. Byte compiling did it. I can live very well with 0.1 seconds rather 1.7 :) – octi May 03 '12 at 19:40
  • This does not answer the question at all ; And local performance statistics are irrelevant. – yPhil Jul 16 '12 at 11:17
  • 1
    Well thank you for your down-vote, Philippe CM. I feel suitably ashamed that I was able to resolve the problem to octi's satisfaction, and I look forward to your own more-useful answer. – phils Jul 16 '12 at 12:11
0

Infact html-mode is defined in sgml-mode.el file.

So you eval-after-load should be as follows

(eval-after-load "sgml-mode" (lambda ()
;;;  code to load your nxhtml
                               ))
kindahero
  • 5,817
  • 3
  • 25
  • 32
  • for some reason when I use that it gives me a "recursive load error". It might be that nxhtml triggers a sgml-mode hook – octi Apr 27 '12 at 19:34
0

I also use nxhtml-mode to edit the erb documents when I programming ROR app. Take a look at my configuration, this may help you.

(autoload 'eruby-nxhtml-mumamo-mode "autostart.el" "Edit erb document." t)
(add-to-list 'auto-mode-alist '("\\.erb" . eruby-nxhtml-mumamo-mode))
hbin
  • 2,657
  • 1
  • 23
  • 23
0

I just combined the OP code and it works for me:

(add-hook 'html-mode-hook (lambda()
(progn
  (load-file "~/.emacs.d/vendor/~nxhtml/nxhtml/main/autostart.el")
))) 
RThomas
  • 10,702
  • 2
  • 48
  • 61
fdelacruz
  • 13
  • 4