1

Currently, to use a certain plugin (nxhtml), I place the following statements in my .emacs,

(load "<plugin-location>/autostart.el")

Therefore everytime I open emacs, this is loaded, regardless of whether I am editing a file that the plug-in is applicable to (e.g. .htm). This loading is undesirable as it takes several seconds, how might I alter my settings so that this plug-in is loaded only when I am editing .htm or .css files?

countunique
  • 4,068
  • 6
  • 26
  • 35
  • possible duplicate of [How can I make Emacs start-up faster?](http://stackoverflow.com/questions/778716/how-can-i-make-emacs-start-up-faster) – Trey Jackson Dec 20 '11 at 21:13
  • autostart.el doesn't do a huge amount of work -- it sets up autoload declarations in order to defer the real work until needed. Does it really take several seconds? Have you byte-compiled it? – phils Dec 20 '11 at 21:16
  • @phils With and without the load statement makes about a 5-second difference at start-up. I'm not sure what byte-compiled means or how you would go about doing it. – countunique Dec 20 '11 at 21:25
  • By definition, interpreted languages do not get "compiled" in the way that a language like C does; however, many interpreted languages support "byte-compilation" meaning that the source code is compressed into a form which, while still interpreted, can be interpreted *faster* than the original source. Emacs lisp files `*.el` can be byte-compiled into equivalent `*.elc` files which Emacs will use in preference. There are standard commands for byte-compiling, however in this instance nXhtml provides its own: `M-x nxhtmlmaint-start-byte-compilation` – phils Dec 20 '11 at 22:18
  • As documented here, btw: http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html – phils Dec 20 '11 at 22:19
  • This fixed the problem, start-up time is barely noticeable now. Thanks – countunique Dec 21 '11 at 18:29
  • Great; I'll make it a proper answer in that case. – phils Dec 21 '11 at 22:58

2 Answers2

0

Not sure what you mean about plugins. For format specific code, I use hooks:

(add-hook 'sgml-mode-hook
      '(lambda () (setq sgml-indent-data t)
         (turn-on-auto-fill))
      )

Can you try loading the plugins in hooks?

choroba
  • 231,213
  • 25
  • 204
  • 289
0

nXhtml's autostart.el doesn't do a huge amount of work (it sets up autoload declarations in order to defer the real work until needed), however it can still be slow if you have not yet byte-compiled the library.

nXhtml provides its own command for handling the necessary byte-compilation (which is documented at http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html), so you can just type:

M-x nxhtmlmaint-start-byte-compilation RET

phils
  • 71,335
  • 11
  • 153
  • 198