1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

loaddefs-gen: Weed out some elements from the shortcut path

The predefined macros marked as `autoload-macro expand` can't
get to the shortcul path, so simplify it accordingly.
Mark a few more macros from the shortcut path as `autoload-macro expand`
but don't remove them yet from the shortcut path (need to update
`ldefs-boot.el`).

* lisp/progmodes/compile.el (define-compilation-mode):
* lisp/emacs-lisp/generic.el (define-generic-mode):
* lisp/emacs-lisp/derived.el (define-derived-mode):
* lisp/cedet/mode-local.el (define-overloadable-function):
* lisp/skeleton.el (define-skeleton): Mark as `autoload-macro expand`
so as to make the "shortcut" path in `loaddefs-gen.el` redundant.

* lisp/emacs-lisp/loaddefs-gen.el (loaddefs--defining-macros):
Remove the easy-mmode.el macros since they are already marked as
`autoload-macro expand` and they are always defined, so we never check
them against that list.
(loaddefs-generate--make-autoload): Remove handling of the
`easy-mmode.el` macros as well as `defun` and `defmacro` from the
shortcut path since we can never get there with them anyway.
This commit is contained in:
Stefan Monnier 2025-11-21 09:02:24 -05:00
parent dbd2cd2516
commit 74087e252f
6 changed files with 73 additions and 71 deletions

View file

@ -548,12 +548,15 @@ OVERARGS is a list of arguments passed to the override and
`NAME-default' function, in place of those deduced from ARGS." `NAME-default' function, in place of those deduced from ARGS."
(declare (doc-string 3) (declare (doc-string 3)
(indent defun) (indent defun)
(debug (&define name lambda-list stringp def-body))) (debug (&define name lambda-list stringp def-body))
`(eval-and-compile (autoload-macro expand))
`(progn
(defun ,name ,args (defun ,name ,args
,docstring ,docstring
,@(mode-local--overload-body name args body)) ,@(mode-local--overload-body name args body))
(put ',name 'mode-local-overload t))) :autoload-end
(eval-and-compile
(put ',name 'mode-local-overload t))))
(put :override-with-args 'lisp-indent-function 1) (put :override-with-args 'lisp-indent-function 1)
(define-obsolete-function-alias 'define-overload (define-obsolete-function-alias 'define-overload

View file

@ -174,7 +174,8 @@ See Info node `(elisp)Derived Modes' for more details.
(declare (debug (&define name symbolp sexp [&optional stringp] (declare (debug (&define name symbolp sexp [&optional stringp]
[&rest keywordp sexp] def-body)) [&rest keywordp sexp] def-body))
(doc-string 4) (doc-string 4)
(indent defun)) (indent defun)
(autoload-macro expand))
(when (and docstring (not (stringp docstring))) (when (and docstring (not (stringp docstring)))
;; Some trickiness, since what appears to be the docstring may really be ;; Some trickiness, since what appears to be the docstring may really be
@ -208,6 +209,8 @@ See Info node `(elisp)Derived Modes' for more details.
parent child docstring syntax abbrev)) parent child docstring syntax abbrev))
`(progn `(progn
(progn
:autoload-end
(defvar ,hook nil) (defvar ,hook nil)
(unless (get ',hook 'variable-documentation) (unless (get ',hook 'variable-documentation)
(put ',hook 'variable-documentation (put ',hook 'variable-documentation
@ -243,7 +246,7 @@ No problems result if this variable is not bound.
(if (fboundp 'derived-mode-set-parent) ;; Emacs≥30.1 (if (fboundp 'derived-mode-set-parent) ;; Emacs≥30.1
(derived-mode-set-parent ',child ',parent) (derived-mode-set-parent ',child ',parent)
(put ',child 'derived-mode-parent ',parent)) (put ',child 'derived-mode-parent ',parent))
,(if group `(put ',child 'custom-mode-group ,group)) ,(if group `(put ',child 'custom-mode-group ,group)))
(defun ,child () (defun ,child ()
,docstring ,docstring

View file

@ -152,23 +152,27 @@ See the file generic-x.el for some examples of `define-generic-mode'."
(declare (debug (sexp def-form def-form def-form form def-form (declare (debug (sexp def-form def-form def-form form def-form
[&optional stringp] &rest [keywordp form])) [&optional stringp] &rest [keywordp form]))
(indent 1) (indent 1)
(doc-string 7)) (doc-string 7)
(autoload-macro expand))
;; Backward compatibility. ;; Backward compatibility.
(when (eq (car-safe mode) 'quote) (when (eq (car-safe mode) 'quote)
(setq mode (eval mode))) (setq mode (eval mode t)))
(let* ((name (symbol-name mode)) (let* ((name (symbol-name mode))
(pretty-name (capitalize (replace-regexp-in-string (pretty-name (capitalize (replace-regexp-in-string
"-mode\\'" "" name)))) "-mode\\'" "" name))))
`(progn `(progn
(progn
:autoload-end
;; Add a new entry. ;; Add a new entry.
(add-to-list 'generic-mode-list ,name) (add-to-list 'generic-mode-list ,name)
;; Add it to auto-mode-alist ;; Add it to auto-mode-alist
(dolist (re ,auto-mode-list) (dolist (re ,auto-mode-list)
(add-to-list 'auto-mode-alist (cons re ',mode))) (add-to-list 'auto-mode-alist (cons re ',mode))))
(defun ,mode () (defun ,mode ()
,(or docstring ,(or docstring
@ -205,7 +209,7 @@ See the file generic-x.el for some examples of `define-generic-mode'."
(setq font-lock-defaults '(generic-font-lock-keywords)) (setq font-lock-defaults '(generic-font-lock-keywords))
;; Call a list of functions ;; Call a list of functions
(mapc 'funcall function-list) (mapc #'funcall function-list)
(run-mode-hooks mode-hook))) (run-mode-hooks mode-hook)))

View file

@ -155,14 +155,10 @@ scanning for autoloads and will be in the `load-path'."
;; employing :autoload-end to omit unneeded forms). ;; employing :autoload-end to omit unneeded forms).
(defconst loaddefs--defining-macros (defconst loaddefs--defining-macros
'( define-skeleton define-derived-mode define-compilation-mode '( define-skeleton define-derived-mode define-compilation-mode
define-generic-mode define-globalized-minor-mode define-minor-mode define-generic-mode
cl-defun defun* cl-defmacro defmacro* define-overloadable-function cl-defun defun* cl-defmacro defmacro* define-overloadable-function
transient-define-prefix transient-define-suffix transient-define-infix transient-define-prefix transient-define-suffix transient-define-infix
transient-define-argument transient-define-group transient-define-argument transient-define-group))
;; Obsolete; keep until the alias is removed.
easy-mmode-define-global-mode
easy-mmode-define-minor-mode
define-global-minor-mode))
(defvar loaddefs--load-error-files nil) (defvar loaddefs--load-error-files nil)
(defun loaddefs-generate--make-autoload (form file &optional expansion) (defun loaddefs-generate--make-autoload (form file &optional expansion)
@ -254,8 +250,7 @@ expand)' among their `declare' forms."
(let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*)))
(name (nth 1 form)) (name (nth 1 form))
(args (pcase car (args (pcase car
((or 'defun 'defmacro ((or 'defun* 'defmacro* 'cl-defun 'cl-defmacro
'defun* 'defmacro* 'cl-defun 'cl-defmacro
'define-overloadable-function 'define-overloadable-function
'transient-define-prefix 'transient-define-suffix 'transient-define-prefix 'transient-define-suffix
'transient-define-infix 'transient-define-argument 'transient-define-infix 'transient-define-argument
@ -277,17 +272,11 @@ expand)' among their `declare' forms."
,file ,doc ,file ,doc
,(or (and (memq car '( define-skeleton define-derived-mode ,(or (and (memq car '( define-skeleton define-derived-mode
define-generic-mode define-generic-mode
define-globalized-minor-mode
define-minor-mode
transient-define-prefix transient-define-prefix
transient-define-suffix transient-define-suffix
transient-define-infix transient-define-infix
transient-define-argument transient-define-argument
transient-define-group transient-define-group))
;; Obsolete; keep until the alias is removed.
easy-mmode-define-global-mode
easy-mmode-define-minor-mode
define-global-minor-mode))
t) t)
(and (eq (car-safe (car body)) 'interactive) (and (eq (car-safe (car body)) 'interactive)
;; List of modes or just t. ;; List of modes or just t.

View file

@ -2443,7 +2443,8 @@ The parent is always `compilation-mode' and the customizable `compilation-...'
variables are also set from the name of the mode you have chosen, variables are also set from the name of the mode you have chosen,
by replacing the first word, e.g., `compilation-scroll-output' from by replacing the first word, e.g., `compilation-scroll-output' from
`grep-scroll-output' if that variable exists." `grep-scroll-output' if that variable exists."
(declare (indent defun)) (declare (indent defun)
(autoload-macro expand))
(let ((mode-name (replace-regexp-in-string "-mode\\'" "" (symbol-name mode)))) (let ((mode-name (replace-regexp-in-string "-mode\\'" "" (symbol-name mode))))
`(define-derived-mode ,mode compilation-mode ,name `(define-derived-mode ,mode compilation-mode ,name
,doc ,doc

View file

@ -116,13 +116,11 @@ are integer buffer positions in the reverse order of the insertion order.")
DOCUMENTATION is that of the command. DOCUMENTATION is that of the command.
SKELETON is as defined under `skeleton-insert'." SKELETON is as defined under `skeleton-insert'."
(declare (doc-string 2) (debug (&define name stringp skeleton-edebug-spec)) (declare (doc-string 2) (debug (&define name stringp skeleton-edebug-spec))
(indent defun)) (indent defun)
(autoload-macro expand))
(if skeleton-debug (if skeleton-debug
(set command skeleton)) (set command skeleton))
`(progn `(progn
;; Tell self-insert-command that this function, if called by an
;; abbrev, should cause the self-insert to be skipped.
(put ',command 'no-self-insert t)
(defun ,command (&optional str arg) (defun ,command (&optional str arg)
,(concat documentation ,(concat documentation
(if (string-match "\n\\'" documentation) (if (string-match "\n\\'" documentation)
@ -139,7 +137,11 @@ A prefix argument of zero says to wrap around zero words---that is, nothing.
This is a way of overriding the use of a highlighted region.") This is a way of overriding the use of a highlighted region.")
(interactive "*P\nP") (interactive "*P\nP")
(atomic-change-group (atomic-change-group
(skeleton-proxy-new ',skeleton str arg))))) (skeleton-proxy-new ',skeleton str arg)))
:autoload-end
;; Tell self-insert-command that this function, if called by an
;; abbrev, should cause the self-insert to be skipped.
(put ',command 'no-self-insert t)))
;;;###autoload ;;;###autoload
(defun skeleton-proxy-new (skeleton &optional str arg) (defun skeleton-proxy-new (skeleton &optional str arg)
@ -257,7 +259,7 @@ available:
(while (and l1 (> skeleton-regions 0)) (while (and l1 (> skeleton-regions 0))
(push (copy-marker (pop l1) t) l2) (push (copy-marker (pop l1) t) l2)
(setq skeleton-regions (1- skeleton-regions))) (setq skeleton-regions (1- skeleton-regions)))
(sort l2 '<)))) (sort l2 #'<))))
(goto-char (car skeleton-regions)) (goto-char (car skeleton-regions))
(setq skeleton-regions (cdr skeleton-regions))) (setq skeleton-regions (cdr skeleton-regions)))
(let ((beg (point)) (let ((beg (point))
@ -327,7 +329,7 @@ automatically, and you are prompted to fill in the variable parts.")))
(symbol-value 'input)))))) (symbol-value 'input))))))
((functionp prompt) ((functionp prompt)
(funcall prompt)) (funcall prompt))
(t (eval prompt)))) (t (eval prompt t))))
(or eolp (or eolp
(delete-char 1)))) (delete-char 1))))
(if (and recursive (if (and recursive
@ -436,7 +438,7 @@ automatically, and you are prompted to fill in the variable parts.")))
((eq element '@) ((eq element '@)
(push (point) skeleton-positions)) (push (point) skeleton-positions))
((eq 'quote (car-safe element)) ((eq 'quote (car-safe element))
(eval (nth 1 element))) (eval (nth 1 element) t))
((and (consp element) ((and (consp element)
(or (stringp (car element)) (listp (car element)))) (or (stringp (car element)) (listp (car element))))
;; Don't forget: `symbolp' is also true for nil. ;; Don't forget: `symbolp' is also true for nil.
@ -449,7 +451,7 @@ automatically, and you are prompted to fill in the variable parts.")))
(skeleton-internal-list element (car literal)) (skeleton-internal-list element (car literal))
(setq literal (cdr literal))))) (setq literal (cdr literal)))))
((null element)) ((null element))
(t (skeleton-internal-1 (eval element) t recursive)))) (t (skeleton-internal-1 (eval element t) t recursive))))
;; Maybe belongs into simple.el or elsewhere ;; Maybe belongs into simple.el or elsewhere
;; ;;;###autoload ;; ;;;###autoload