[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Package initialization
From: |
David Kastrup |
Subject: |
Re: Package initialization |
Date: |
Sun, 19 Jul 2015 12:27:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Helmut Eller <address@hidden> writes:
> On Sun, Jul 19 2015, David Kastrup wrote:
>
>>> How without adding something to .emacs?
>>
>> You can autoload on a prefix keymap as well I think. So if some
>> bindings are to be present globally, you can do that without preloading
>> the package itself.
>
> Show me the code and where to put it.
Hmmm?
(info "(elisp) autoload")
-- Function: autoload function filename &optional docstring interactive
type
This function defines the function (or macro) named FUNCTION so as
to load automatically from FILENAME. The string FILENAME specifies
the file to load to get the real definition of FUNCTION.
If FILENAME does not contain either a directory name, or the suffix
‘.el’ or ‘.elc’, this function insists on adding one of these
suffixes, and it will not load from a file whose name is just
FILENAME with no added suffix. (The variable ‘load-suffixes’
specifies the exact required suffixes.)
The argument DOCSTRING is the documentation string for the
function. Specifying the documentation string in the call to
‘autoload’ makes it possible to look at the documentation without
loading the function’s real definition. Normally, this should be
identical to the documentation string in the function definition
itself. If it isn’t, the function definition’s documentation
string takes effect when it is loaded.
If INTERACTIVE is non-‘nil’, that says FUNCTION can be called
interactively. This lets completion in ‘M-x’ work without loading
FUNCTION’s real definition. The complete interactive specification
is not given here; it’s not needed unless the user actually calls
FUNCTION, and when that happens, it’s time to load the real
definition.
You can autoload macros and keymaps as well as ordinary functions.
Specify TYPE as ‘macro’ if FUNCTION is really a macro. Specify
TYPE as ‘keymap’ if FUNCTION is really a keymap. Various parts of
Emacs need to know this information without loading the real
definition.
An autoloaded keymap loads automatically during key lookup when a
prefix key’s binding is the symbol FUNCTION. Autoloading does not
occur for other kinds of access to the keymap. In particular, it
does not happen when a Lisp program gets the keymap from the value
of a variable and calls ‘define-key’; not even if the variable name
is the same symbol FUNCTION.
[...]
If you write a function definition with an unusual macro that is not
one of the known and recognized function definition methods, use of an
ordinary magic autoload comment would copy the whole definition into
‘loaddefs.el’. That is not desirable. You can put the desired
‘autoload’ call into ‘loaddefs.el’ instead by writing this:
;;;###autoload (autoload 'foo "myfile")
(mydefunmacro foo
...)
So basically:
;;;autoload (autoload 'foo-prefix-map "myfile" "Prefix for foo" t 'keymap)
(define-prefix-command 'foo-prefix-map ...
;;;autoload (global-set-key (kbd "C-x c 5") 'foo-prefix-map)
Is there any problem with that?
--
David Kastrup
- Re: Package initialization, (continued)
- Re: Package initialization, Helmut Eller, 2015/07/18
- Re: Package initialization, Artur Malabarba, 2015/07/18
- Re: Package initialization, Helmut Eller, 2015/07/18
- Re: Package initialization, Artur Malabarba, 2015/07/18
- Re: Package initialization, Stephen J. Turnbull, 2015/07/18
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, Artur Malabarba, 2015/07/19
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, David Kastrup, 2015/07/19
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization,
David Kastrup <=
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, David Kastrup, 2015/07/19
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, David Kastrup, 2015/07/19
- Re: Package initialization, Artur Malabarba, 2015/07/19
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, bruce.connor.am, 2015/07/19
- Re: Package initialization, Helmut Eller, 2015/07/19
- Re: Package initialization, Artur Malabarba, 2015/07/19
- Re: Package initialization, David Kastrup, 2015/07/19