comparison lisp/autoload.el @ 4352:d2f4dd8611d9

Factor out lists of operators specially treated by 'make-autoload'. General idea approved by Mike Sperber, and tested in 21.4 by building JDE.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 22 Dec 2007 15:57:21 -0800
parents 6ad202d453cb
children bfb8a26de3cb
comparison
equal deleted inserted replaced
4351:bc3b9f61018e 4352:d2f4dd8611d9
224 224
225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
226 ;; Parsing the source file text. 226 ;; Parsing the source file text.
227 ;; Autoloads in C source differ from those in Lisp source. 227 ;; Autoloads in C source differ from those in Lisp source.
228 228
229 ;; #### Eventually operators like defclass and defmethod (defined in an
230 ;; external package, EIEIO) may be factored out. Don't add operators here
231 ;; without discussing whether and how to do that on the developers' channel.
232 (defvar autoload-make-autoload-operators
233 '(defun define-skeleton defmacro define-derived-mode define-generic-mode
234 easy-mmode-define-minor-mode easy-mmode-define-global-mode
235 define-minor-mode defun* defmacro* defclass defmethod)
236 "`defun'-like operators that use `autoload' to load the library.")
237
238 (defvar autoload-make-autoload-complex-operators
239 '(easy-mmode-define-minor-mode easy-mmode-define-global-mode
240 define-minor-mode)
241 "`defun'-like operators to macroexpand before using `autoload'.")
242
229 (defun make-autoload (form file) 243 (defun make-autoload (form file)
230 "Turn FORM into an autoload or defvar for source file FILE. 244 "Turn FORM into an autoload or defvar for source file FILE.
231 Returns nil if FORM is not a special autoload form (i.e. a function definition 245 Returns nil if FORM is not a special autoload form (i.e. a function definition
232 or macro definition or a defcustom)." 246 or macro definition or a defcustom)."
233 (let ((car (car-safe form)) expand) 247 (let ((car (car-safe form)) expand)
234 (cond 248 (cond
235 ;; For complex cases, try again on the macro-expansion. 249 ;; For complex cases, try again on the macro-expansion.
236 ((and (memq car '(easy-mmode-define-global-mode 250 ((and (memq car autoload-make-autoload-complex-operators)
237 easy-mmode-define-minor-mode define-minor-mode))
238 (setq expand (let ((load-file-name file)) (macroexpand form))) 251 (setq expand (let ((load-file-name file)) (macroexpand form)))
239 (eq (car expand) 'progn) 252 (eq (car expand) 'progn)
240 (memq :autoload-end expand)) 253 (memq :autoload-end expand))
241 (let ((end (memq :autoload-end expand))) 254 (let ((end (memq :autoload-end expand)))
242 ;; Cut-off anything after the :autoload-end marker. 255 ;; Cut-off anything after the :autoload-end marker.
244 (cons 'progn 257 (cons 'progn
245 (mapcar (lambda (form) (make-autoload form file)) 258 (mapcar (lambda (form) (make-autoload form file))
246 (cdr expand))))) 259 (cdr expand)))))
247 260
248 ;; For special function-like operators, use the `autoload' function. 261 ;; For special function-like operators, use the `autoload' function.
249 ((memq car '(defun define-skeleton defmacro define-derived-mode 262 ((memq car autoload-make-autoload-operators)
250 define-generic-mode easy-mmode-define-minor-mode
251 easy-mmode-define-global-mode
252 define-minor-mode defun* defmacro*
253 defclass defmethod)) ; from the EIEIO package
254 (let* ((macrop (memq car '(defmacro defmacro*))) 263 (let* ((macrop (memq car '(defmacro defmacro*)))
255 (name (nth 1 form)) 264 (name (nth 1 form))
256 (body (nthcdr (get car 'doc-string-elt) form)) 265 (body (nthcdr (get car 'doc-string-elt) form))
257 (doc (if (stringp (car body)) (pop body)))) 266 (doc (if (stringp (car body)) (pop body))))
258 ;; `define-generic-mode' quotes the name, so take care of that 267 ;; `define-generic-mode' quotes the name, so take care of that