mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-05 03:39:38 +00:00
add autoload keyword
:autoload is similar to :command but this generate autoload statement as *no-interactive* function.
This commit is contained in:
parent
ffa5f0397a
commit
dbfb3484cd
1 changed files with 26 additions and 1 deletions
|
@ -94,6 +94,7 @@
|
||||||
;; Any other keyword that also declares commands to be autoloaded (such as
|
;; Any other keyword that also declares commands to be autoloaded (such as
|
||||||
;; :bind) must appear before this keyword.
|
;; :bind) must appear before this keyword.
|
||||||
:commands
|
:commands
|
||||||
|
:autoload
|
||||||
:init
|
:init
|
||||||
:defer
|
:defer
|
||||||
:demand
|
:demand
|
||||||
|
@ -118,7 +119,8 @@ declaration is incorrect."
|
||||||
(defcustom use-package-deferring-keywords
|
(defcustom use-package-deferring-keywords
|
||||||
'(:bind-keymap
|
'(:bind-keymap
|
||||||
:bind-keymap*
|
:bind-keymap*
|
||||||
:commands)
|
:commands
|
||||||
|
:autoload)
|
||||||
"Unless `:demand' is used, keywords in this list imply deferred loading.
|
"Unless `:demand' is used, keywords in this list imply deferred loading.
|
||||||
The reason keywords like `:hook' are not in this list is that
|
The reason keywords like `:hook' are not in this list is that
|
||||||
they only imply deferred loading if they reference actual
|
they only imply deferred loading if they reference actual
|
||||||
|
@ -1309,6 +1311,28 @@ meaning:
|
||||||
(delete-dups arg)))
|
(delete-dups arg)))
|
||||||
(use-package-process-keywords name rest state)))
|
(use-package-process-keywords name rest state)))
|
||||||
|
|
||||||
|
;;;; :autoload
|
||||||
|
|
||||||
|
(defalias 'use-package-normalize/:autoload 'use-package-normalize/:commands)
|
||||||
|
|
||||||
|
(defun use-package-handler/:autoload (name _keyword arg rest state)
|
||||||
|
(use-package-concat
|
||||||
|
;; Since we deferring load, establish any necessary autoloads, and also
|
||||||
|
;; keep the byte-compiler happy.
|
||||||
|
(let ((name-string (use-package-as-string name)))
|
||||||
|
(cl-mapcan
|
||||||
|
#'(lambda (command)
|
||||||
|
(when (symbolp command)
|
||||||
|
(append
|
||||||
|
(unless (plist-get state :demand)
|
||||||
|
`((unless (fboundp ',command)
|
||||||
|
(autoload #',command ,name-string))))
|
||||||
|
(when (bound-and-true-p byte-compile-current-file)
|
||||||
|
`((eval-when-compile
|
||||||
|
(declare-function ,command ,name-string)))))))
|
||||||
|
(delete-dups arg)))
|
||||||
|
(use-package-process-keywords name rest state)))
|
||||||
|
|
||||||
;;;; :defer
|
;;;; :defer
|
||||||
|
|
||||||
(defalias 'use-package-normalize/:defer 'use-package-normalize-predicate)
|
(defalias 'use-package-normalize/:defer 'use-package-normalize-predicate)
|
||||||
|
@ -1570,6 +1594,7 @@ this file. Usage:
|
||||||
package. This is useful if the package is being lazily
|
package. This is useful if the package is being lazily
|
||||||
loaded, and you wish to conditionally call functions in your
|
loaded, and you wish to conditionally call functions in your
|
||||||
`:init' block that are defined in the package.
|
`:init' block that are defined in the package.
|
||||||
|
:autoload Similar to :commands, but it for no-interactive one.
|
||||||
:hook Specify hook(s) to attach this package to.
|
:hook Specify hook(s) to attach this package to.
|
||||||
|
|
||||||
:bind Bind keys, and define autoloads for the bound commands.
|
:bind Bind keys, and define autoloads for the bound commands.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue