emacs-devel
[Top][All Lists]
Advanced

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

Re: Package initialization


From: Stephen J. Turnbull
Subject: Re: Package initialization
Date: Sun, 19 Jul 2015 09:13:17 +0900

Helmut Eller writes:

 > Now with the package stuff the (require 'slime-autoloads) line is
 > unnecessary.  But additionally somebody claimed that it's idiomatic to
 > call slime-setup automatically in slime-autoloads.

FWIW, in XEmacs's package system calls to package initialization
functions in autoloads has always been considered anti-social behavior
(and it's one of the few things we care about enough to override a
maintainer's preference).  In fact, we don't even allow those
functions to be called when a library is loaded.  All too frequently
packages contain useful utility functions in libraries that other
packages require, even though the user doesn't want the require'd
library's primary functionality.

What is considered good style in an XEmacs package:

1.  The package has an idempotent initialization function, typically
    implemented by wrapping the whole function in `(if (not
    <package>-initialized-p) ...)'.
2.  The autoloads include exactly those commands that users are
    expected to invoke in the uninitialized state.  (Users who know
    what they are doing can of course explicitly require or load
    package files and call any function.)
3.  All autoloaded commands should call the package initialization
    function as their first action.
4.  The autoloads may defvar global variables in the package's
    namespace.  However defcustoms (which are automatically
    initialized by the XEmacs package system) are preferred for
    variables the user might customize, even if that is unusual.

XEmacs packages aren't supposed to manipulate load-path etc, but
that's because XEmacs packages are supposed to have a standard layout,
and those standard locations are added to load-path etc by the package
system at startup.  I personally like that system, analogous to FHS
and/or LSB conformance in GNU/Linux systems, but many package
maintainers were distressed by it because they had existing layouts
which were incompatible with XEmacs's preferred layout.  So as Artur
says, it may be desirable to modify search paths and the like in
autoloads, though I prefer to delegate that to the lazily-called
initialization functions.

 > I quite like to see the explicit call to slime-setup in my .emacs, but
 > others might not.

I think the rules 1-4 above would satisfy both you and those others.



reply via email to

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