emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why js2-mode in Emacs 23.2?


From: Carsten Dominik
Subject: Re: Why js2-mode in Emacs 23.2?
Date: Mon, 10 Aug 2009 12:41:58 +0200


On Aug 10, 2009, at 10:44 AM, Leo wrote:

On 2009-08-10 01:49 +0100, Daniel Colascione wrote:
[...]
eval-after-load should not be used in emacs packages.

Why not?

On 2009-08-10 08:06 +0100, Carsten Dominik wrote:
[...]
eval-after-load should not be used in emacs packages.

Why not?

- Carsten

I seem to recall RMS said that sometime ago. It is also documented  in
the elisp manual:

,----[ (info "(elisp)Hooks for Loading") ]
| In general, well-designed Lisp programs should not use this feature.
| The clean and modular ways to interact with a Lisp library are (1)
| examine and set the library's variables (those which are meant for
| outside use), and (2) call the library's functions. If you wish to do | (1), you can do it immediately--there is no need to wait for when the
| library is loaded.  To do (2), you must load the library (preferably
| with `require').
|
|    But it is OK to use `eval-after-load' in your personal
| customizations if you don't feel they must meet the design standards
| for programs meant for wider use.
`----


I see.  Still, I can imagine good use cases for it.  For example,
if your package needs to do some tweaking to correctly interact with
some library, but if that library is only used by very few people.
In this case you'd want to avoid loading the library just to apply your tweaks. I'd say this is a good case for using eval-after-load in a normal Emacs library.

Here is an example from Org-mode:

(eval-after-load "imenu"
  '(progn
     (add-hook 'imenu-after-jump-hook
               (lambda ()
                 (if (eq major-mode 'org-mode)
                     (org-show-context 'org-goto))))))

When imenu jumps into a location in a file that is hidden by outline folding,
then the context of point needs to be revealed.  However, loading imenu
just to do this setup is useless for user who do use imenu at all.


- Carsten





reply via email to

[Prev in Thread] Current Thread [Next in Thread]