-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 form)) '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))))
-
-;;; Forms which have doc-strings which should be printed specially.
-;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
-;;; the doc-string in FORM.
-;;;
-;;; There used to be the following note here:
-;;; ;;; Note: defconst and defvar should NOT be marked in this way.
-;;; ;;; We don't want to produce defconsts and defvars that
-;;; ;;; make-docfile can grok, because then it would grok them twice,
-;;; ;;; once in foo.el (where they are given with ;;;###autoload) and
-;;; ;;; once in loaddefs.el.
-;;;
-;;; Counter-note: Yes, they should be marked in this way.
-;;; make-docfile only processes those files that are loaded into the
-;;; dumped Emacs, and those files should never have anything
-;;; autoloaded here. The above-feared problem only occurs with files
-;;; which have autoloaded entries *and* are processed by make-docfile;
-;;; there should be no such files.
-
-(put 'autoload 'doc-string-elt 3)
-(put 'defun 'doc-string-elt 3)
-(put 'defun* 'doc-string-elt 3)
-(put 'defvar 'doc-string-elt 3)
-(put 'defcustom 'doc-string-elt 3)
-(put 'defconst 'doc-string-elt 3)
-(put 'defmacro 'doc-string-elt 3)
-(put 'defsubst 'doc-string-elt 3)
-(put 'define-skeleton 'doc-string-elt 2)
-(put 'define-derived-mode 'doc-string-elt 4)
-(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)
+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-compilation-mode
+ define-generic-mode easy-mmode-define-minor-mode
+ easy-mmode-define-global-mode
+ define-minor-mode defun* defmacro*))
+ (let* ((macrop (memq car '(defmacro defmacro*)))
+ (name (nth 1 form))
+ (args (case car
+ ((defun defmacro defun* defmacro*) (nth 2 form))
+ ((define-skeleton) '(&optional str arg))
+ ((define-generic-mode define-derived-mode
+ define-compilation-mode) nil)
+ (t)))
+ (body (nthcdr (get car 'doc-string-elt) form))
+ (doc (if (stringp (car body)) (pop body))))
+ (when (listp args)
+ ;; Add the usage form at the end where describe-function-1
+ ;; can recover it.
+ (setq doc (help-add-fundoc-usage doc args)))
+ ;; `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 less space-consuming data.
+ ((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)))))
+ )
+ `(progn
+ (defvar ,varname ,init ,doc)
+ (custom-autoload ',varname ,file))))
+
+ ;; 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
+;; the doc-string in FORM.
+;; Those properties are now set in lisp-mode.el.