aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emacs-lisp/autoload.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2000-06-11 05:00:35 +0000
committerStefan Monnier <[email protected]>2000-06-11 05:00:35 +0000
commite8139c11fb471e2c1ae0be2a2f59b4e045f0ed63 (patch)
treedbc4be5c837f6ea2550b38ba5808569da55120fd /lisp/emacs-lisp/autoload.el
parent1328a6dfa20b62cba2f7275e572c9cff700fe2b2 (diff)
(make-autoload): Use `cond'.
Handle easy-mmode-define-global-mode. For complex macros like define-minor-mode that can generate several autoload entries, try to autoload entries in the macroexpanded code.
Diffstat (limited to 'lisp/emacs-lisp/autoload.el')
-rw-r--r--lisp/emacs-lisp/autoload.el89
1 files changed, 56 insertions, 33 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 3d1833c2fb..3928ee1a74 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -62,39 +62,60 @@ that text will be copied verbatim to `generated-autoload-file'.")
(defun make-autoload (form file)
"Turn FORM into an autoload or defvar for source file FILE.
-Returns nil if FORM is not a function or variable or macro definition."
- (let ((car (car-safe form)))
- (if (memq car '(defun define-skeleton defmacro define-derived-mode
- define-generic-mode easy-mmode-define-minor-mode
- define-minor-mode defun*))
- (let* ((macrop (eq car 'defmacro))
- (name (nth 1 form))
- (body (nthcdr (get car 'doc-string-elt) form))
- (doc (if (stringp (car body)) (pop body))))
- ;; `define-generic-mode' quotes the name, so take care of that
- (list 'autoload (if (listp name) name (list 'quote name)) file doc
- (or (and (memq car '(define-skeleton define-derived-mode
- define-generic-mode
- easy-mmode-define-minor-mode
- define-minor-mode)) t)
- (eq (car-safe (car body)) 'interactive))
- (if macrop (list 'quote 'macro) nil)))
- ;; Convert defcustom to a simpler (and less space-consuming) defvar,
- ;; but add some extra stuff if it uses :require.
- (if (eq car 'defcustom)
- (let ((varname (car-safe (cdr-safe form)))
- (init (car-safe (cdr-safe (cdr-safe form))))
- (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
- (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))))
- (if (not (plist-get rest :require))
- `(defvar ,varname ,init ,doc)
- `(progn
- (defvar ,varname ,init ,doc)
- (custom-add-to-group ,(plist-get rest :group)
- ',varname 'custom-variable)
- (custom-add-load ',varname
- ,(plist-get rest :require)))))
- nil))))
+Returns nil if FORM is not a special autoload form (i.e. a function definition
+or macro definition or a defcustom)."
+ (let ((car (car-safe form)) expand)
+ (cond
+ ;; For complex cases, try again on the macro-expansion.
+ ((and (memq car '(easy-mmode-define-global-mode
+ easy-mmode-define-minor-mode define-minor-mode))
+ (setq expand (let ((load-file-name file)) (macroexpand form)))
+ (eq (car expand) 'progn)
+ (memq :autoload-end expand))
+ (let ((end (memq :autoload-end expand)))
+ ;; Cut-off anything after the :autoload-end marker.
+ (setcdr end nil)
+ (cons 'progn
+ (mapcar (lambda (form) (make-autoload form file))
+ (cdr expand)))))
+
+ ;; For special function-like operators, use the `autoload' function.
+ ((memq car '(defun define-skeleton defmacro define-derived-mode
+ define-generic-mode easy-mmode-define-minor-mode
+ easy-mmode-define-global-mode
+ define-minor-mode defun*))
+ (let* ((macrop (eq car 'defmacro))
+ (name (nth 1 form))
+ (body (nthcdr (get car 'doc-string-elt) form))
+ (doc (if (stringp (car body)) (pop body))))
+ ;; `define-generic-mode' quotes the name, so take care of that
+ (list 'autoload (if (listp name) name (list 'quote name)) file doc
+ (or (and (memq car '(define-skeleton define-derived-mode
+ define-generic-mode
+ easy-mmode-define-global-mode
+ easy-mmode-define-minor-mode
+ define-minor-mode)) t)
+ (eq (car-safe (car body)) 'interactive))
+ (if macrop (list 'quote 'macro) nil))))
+
+ ;; Convert defcustom to a simpler (and less space-consuming) defvar,
+ ;; but add some extra stuff if it uses :require.
+ ((eq car 'defcustom)
+ (let ((varname (car-safe (cdr-safe form)))
+ (init (car-safe (cdr-safe (cdr-safe form))))
+ (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
+ (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))))
+ (if (not (plist-get rest :require))
+ `(defvar ,varname ,init ,doc)
+ `(progn
+ (defvar ,varname ,init ,doc)
+ (custom-add-to-group ,(plist-get rest :group)
+ ',varname 'custom-variable)
+ (custom-add-load ',varname
+ ,(plist-get rest :require))))))
+
+ ;; nil here indicates that this is not a special autoload form.
+ (t nil))))
;;; Forms which have doc-strings which should be printed specially.
;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
@@ -127,6 +148,8 @@ Returns nil if FORM is not a function or variable or macro definition."
(put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
(put 'define-minor-mode 'doc-string-elt 2)
(put 'define-generic-mode 'doc-string-elt 7)
+;; defin-global-mode has no explicit docstring.
+(put 'easy-mmode-define-global-mode 'doc-string-elt 1000)
(defun autoload-trim-file-name (file)