[Top][All Lists]

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

Re: Package initialization

From: Artur Malabarba
Subject: Re: Package initialization
Date: Sat, 18 Jul 2015 18:16:05 +0100

> The manual says this about NAME-autoload.el files:
>    They are typically used to autoload the principal user commands defined
>    in the package, but they can also perform other tasks, such as adding
>    an element to ‘auto-mode-alist’
> Which seems to suggest that one should write some
> ;;;###autoload (progn ...)
> somewhere that does the initialization.  Is this the way it should be
> done?

Yes, that line can be added to any of the package's “.el” files.

Any code that you write there will be run when your package is
activated (not loaded). This means the code is run when Emacs starts,
(either during or after loading the init file, depending on what's in
the actual init file).

Note, however, that the package itself will not be loaded at this
time. And neither should this code load your package (or be slow in
some other way). Adding an entry to auto-mode-alist is fine.

> And what is supposed to happen if two packages make conflicting changes
> to auto-mode-alist?

If you add your entry with add-to-list, nothing unexpected will
happen. If two different packages add entries regarding the same
extension, then both entries will get added. When the user visits a
file, the entry on top (the most recently added) will be the one used,
but I suppose that's what they get for installing two major-modes for
the same file type.

reply via email to

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