all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: "Stephen J. Turnbull" <stephen@xemacs.org>,
	Artur Malabarba <bruce.connor.am@gmail.com>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: Package initialization
Date: Sun, 19 Jul 2015 12:27:54 +0200	[thread overview]
Message-ID: <87615gtpat.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <m2h9p01mp0.fsf@gmail.com> (Helmut Eller's message of "Sun, 19 Jul 2015 12:11:39 +0200")

Helmut Eller <eller.helmut@gmail.com> 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



  reply	other threads:[~2015-07-19 10:27 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-18 15:56 Package initialization Helmut Eller
2015-07-18 17:16 ` Artur Malabarba
2015-07-18 19:00   ` Helmut Eller
2015-07-18 19:20     ` Artur Malabarba
2015-07-18 22:56       ` Helmut Eller
2015-07-18 23:07         ` Artur Malabarba
2015-07-18 23:29           ` Helmut Eller
2015-07-18 23:48             ` Artur Malabarba
2015-07-19  0:13             ` Stephen J. Turnbull
2015-07-19  7:23               ` Helmut Eller
2015-07-19  8:10                 ` Artur Malabarba
2015-07-19  9:58                   ` Helmut Eller
2015-07-19 10:07                     ` David Kastrup
2015-07-19 10:11                       ` Helmut Eller
2015-07-19 10:27                         ` David Kastrup [this message]
2015-07-19 10:33                           ` Helmut Eller
2015-07-19 10:38                             ` David Kastrup
2015-07-19 10:41                               ` Helmut Eller
2015-07-19 10:51                                 ` David Kastrup
2015-07-19 10:11                     ` Artur Malabarba
2015-07-19 10:14                       ` Helmut Eller
2015-07-19 10:35                         ` bruce.connor.am
2015-07-19 10:48                           ` Helmut Eller
2015-07-19 11:35                             ` Artur Malabarba
2015-07-19 10:54                           ` David Kastrup
2015-07-19 11:34                             ` Artur Malabarba
2015-07-19 12:09                               ` David Kastrup
2015-07-19 12:33                                 ` Artur Malabarba
2015-07-19 16:54                       ` Eli Zaretskii
2015-07-19 15:52                 ` Stephen J. Turnbull
2015-07-19 16:37                   ` Helmut Eller
2015-07-20  1:30                     ` Stephen J. Turnbull
2015-07-20 17:01                       ` Helmut Eller
2015-07-20 17:25                         ` Chad Brown
2015-07-20 18:12                           ` Helmut Eller
2015-07-20 19:09                             ` Artur Malabarba
2015-07-20 20:54                         ` Dmitry Gutov
2015-07-21  5:59                         ` Stephen J. Turnbull
2015-07-21  6:40                           ` Helmut Eller
2015-07-25  4:42                             ` Alexis
2015-07-19 16:51                 ` Eli Zaretskii
2015-07-20  0:11             ` Stefan Monnier
2015-07-20 16:33               ` Helmut Eller
2015-07-20 22:25                 ` Stefan Monnier
2015-07-21  5:53                   ` Stephen J. Turnbull
2015-07-21  6:45                     ` David Kastrup
2015-07-21  6:05                   ` Helmut Eller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87615gtpat.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=bruce.connor.am@gmail.com \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=stephen@xemacs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.