aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-08-09 16:36:41 +0200
committerLars Ingebrigtsen2022-08-09 16:36:41 +0200
commitee201bc77b37181bbb4378f360ee8dc94c231676 (patch)
treeb6a24614fbdd015d6721e913d25f231bd21ec581
parentaccb1d1132ad467304a909aa2e01993e0b5ff0f9 (diff)
downloademacs-ee201bc77b37181bbb4378f360ee8dc94c231676.tar.gz
emacs-ee201bc77b37181bbb4378f360ee8dc94c231676.zip
Make the loaddefs.el file slightly shorter
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--shorten-autoload): New function. (loaddefs-generate--make-autoload): Use it to drop optional nil values from the `autoloads' forms. This makes the loaddefs.el file about 12K shorter.
-rw-r--r--lisp/emacs-lisp/loaddefs-gen.el46
1 files changed, 28 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 8aa17be765e..3b329357ad9 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -127,6 +127,15 @@ scanning for autoloads and will be in the `load-path'."
127 (substring name 0 (match-beginning 0)) 127 (substring name 0 (match-beginning 0))
128 name))) 128 name)))
129 129
130(defun loaddefs-generate--shorten-autoload (form)
131 "Remove optional nil elements from an `autoload' form."
132 (take (max (- (length form)
133 (seq-position (reverse form) nil
134 (lambda (e1 e2)
135 (not (eq e1 e2)))))
136 3)
137 form))
138
130(defun loaddefs-generate--make-autoload (form file &optional expansion) 139(defun loaddefs-generate--make-autoload (form file &optional expansion)
131 "Turn FORM into an autoload or defvar for source file FILE. 140 "Turn FORM into an autoload or defvar for source file FILE.
132Returns nil if FORM is not a special autoload form (i.e. a function definition 141Returns nil if FORM is not a special autoload form (i.e. a function definition
@@ -165,8 +174,8 @@ expression, in which case we want to handle forms differently."
165 ;; Add the usage form at the end where describe-function-1 174 ;; Add the usage form at the end where describe-function-1
166 ;; can recover it. 175 ;; can recover it.
167 (when (consp args) (setq doc (help-add-fundoc-usage doc args))) 176 (when (consp args) (setq doc (help-add-fundoc-usage doc args)))
168 ;; (message "autoload of %S" (nth 1 form)) 177 (loaddefs-generate--shorten-autoload
169 `(autoload ,(nth 1 form) ,file ,doc ,interactive ,type))) 178 `(autoload ,(nth 1 form) ,file ,doc ,interactive ,type))))
170 179
171 ((and expansion (memq car '(progn prog1))) 180 ((and expansion (memq car '(progn prog1)))
172 (let ((end (memq :autoload-end form))) 181 (let ((end (memq :autoload-end form)))
@@ -220,22 +229,23 @@ expression, in which case we want to handle forms differently."
220 ;; can recover it. 229 ;; can recover it.
221 (when (listp args) (setq doc (help-add-fundoc-usage doc args))) 230 (when (listp args) (setq doc (help-add-fundoc-usage doc args)))
222 ;; `define-generic-mode' quotes the name, so take care of that 231 ;; `define-generic-mode' quotes the name, so take care of that
223 `(autoload ,(if (listp name) name (list 'quote name)) 232 (loaddefs-generate--shorten-autoload
224 ,file ,doc 233 `(autoload ,(if (listp name) name (list 'quote name))
225 ,(or (and (memq car '(define-skeleton define-derived-mode 234 ,file ,doc
226 define-generic-mode 235 ,(or (and (memq car '(define-skeleton define-derived-mode
227 easy-mmode-define-global-mode 236 define-generic-mode
228 define-global-minor-mode 237 easy-mmode-define-global-mode
229 define-globalized-minor-mode 238 define-global-minor-mode
230 easy-mmode-define-minor-mode 239 define-globalized-minor-mode
231 define-minor-mode)) 240 easy-mmode-define-minor-mode
232 t) 241 define-minor-mode))
233 (and (eq (car-safe (car body)) 'interactive) 242 t)
234 ;; List of modes or just t. 243 (and (eq (car-safe (car body)) 'interactive)
235 (or (if (nthcdr 1 (car body)) 244 ;; List of modes or just t.
236 (list 'quote (nthcdr 1 (car body))) 245 (or (if (nthcdr 1 (car body))
237 t)))) 246 (list 'quote (nthcdr 1 (car body)))
238 ,(if macrop ''macro nil)))) 247 t))))
248 ,(if macrop ''macro nil)))))
239 249
240 ;; For defclass forms, use `eieio-defclass-autoload'. 250 ;; For defclass forms, use `eieio-defclass-autoload'.
241 ((eq car 'defclass) 251 ((eq car 'defclass)