From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Package initialization Date: Sun, 19 Jul 2015 12:27:54 +0200 Message-ID: <87615gtpat.fsf@fencepost.gnu.org> References: <87twt1dmxu.fsf@uwakimon.sk.tsukuba.ac.jp> <87a8ustq9i.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1437301688 17395 80.91.229.3 (19 Jul 2015 10:28:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jul 2015 10:28:08 +0000 (UTC) Cc: "Stephen J. Turnbull" , Artur Malabarba , emacs-devel To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 19 12:28:07 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZGlpG-0007iB-8A for ged-emacs-devel@m.gmane.org; Sun, 19 Jul 2015 12:28:06 +0200 Original-Received: from localhost ([::1]:50966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGlpF-00058z-IF for ged-emacs-devel@m.gmane.org; Sun, 19 Jul 2015 06:28:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGlpC-00058j-8u for emacs-devel@gnu.org; Sun, 19 Jul 2015 06:28:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZGlpB-000744-5e for emacs-devel@gnu.org; Sun, 19 Jul 2015 06:28:02 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZGlp6-00070A-4R; Sun, 19 Jul 2015 06:27:56 -0400 Original-Received: from localhost ([127.0.0.1]:34497 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1ZGlp5-0004tQ-9a; Sun, 19 Jul 2015 06:27:55 -0400 Original-Received: by lola (Postfix, from userid 1000) id A27FEE0E09; Sun, 19 Jul 2015 12:27:54 +0200 (CEST) In-Reply-To: (Helmut Eller's message of "Sun, 19 Jul 2015 12:11:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187978 Archived-At: Helmut Eller 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 =E2=80=98.el=E2=80=99 or =E2=80=98.elc=E2=80=99, 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 =E2=80=98load-suffixes= =E2=80=99 specifies the exact required suffixes.) The argument DOCSTRING is the documentation string for the function. Specifying the documentation string in the call to =E2=80=98autoload=E2=80=99 makes it possible to look at the documentat= ion without loading the function=E2=80=99s real definition. Normally, this should= be identical to the documentation string in the function definition itself. If it isn=E2=80=99t, the function definition=E2=80=99s docume= ntation string takes effect when it is loaded. If INTERACTIVE is non-=E2=80=98nil=E2=80=99, that says FUNCTION can be= called interactively. This lets completion in =E2=80=98M-x=E2=80=99 work wit= hout loading FUNCTION=E2=80=99s real definition. The complete interactive specific= ation is not given here; it=E2=80=99s not needed unless the user actually ca= lls FUNCTION, and when that happens, it=E2=80=99s time to load the real definition. You can autoload macros and keymaps as well as ordinary functions. Specify TYPE as =E2=80=98macro=E2=80=99 if FUNCTION is really a macro.= Specify TYPE as =E2=80=98keymap=E2=80=99 if FUNCTION is really a keymap. Vari= ous 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=E2=80=99s 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 =E2=80=98define-key=E2=80=99; 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 =E2=80=98loaddefs.el=E2=80=99. That is not desirable. You can put the des= ired =E2=80=98autoload=E2=80=99 call into =E2=80=98loaddefs.el=E2=80=99 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? --=20 David Kastrup