aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2026-01-11 18:26:53 -0500
committerStefan Monnier2026-01-11 18:26:53 -0500
commit9dcf0bc428f76004d2e33019de640a9d4920f4f2 (patch)
tree81d07244a989460de0069f4547e139b8581b6b02 /lisp
parent762902c2c62de1853472c2c1a1a724ea67be45c4 (diff)
downloademacs-9dcf0bc428f76004d2e33019de640a9d4920f4f2.tar.gz
emacs-9dcf0bc428f76004d2e33019de640a9d4920f4f2.zip
Fix recent test suite regression (bug#80177)
* lisp/emacs-lisp/cl-generic.el (cl--generic-make-function): Preserve advertised-calling-convention info. * test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-quote-optimization): Require `byte-opt` to fix the test when the compiler is not loaded yet. * lisp/progmodes/elisp-mode.el: Fix some >80column problems. (elisp--xref-format-extra) (elisp--xref-format): Make them constant, now that we don't have the purespace. Also, use %S since some of the elements don't necessarily have names and even if they do, we'd want to escape any funny characters in them to avoid ambiguities. (elisp--xref-find-definitions): Fix uses of `elisp--xref-format-extra` accordingly. Improve heuristic to distinguish proper `cl-defgeneric` from implicit ones. (elisp-eldoc-docstring-length-limit) (elisp-eldoc-funcall-with-docstring-length): Remove redundant `:group`. * lisp/cedet/mode-local.el (xref-mode-local-overload): Pass the override symbol rather than its name through `elisp--xref-format-extra`. * test/lisp/progmodes/elisp-mode-tests.el (find-defs-constructor): Adjust test to new text.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/cedet/mode-local.el30
-rw-r--r--lisp/emacs-lisp/cl-generic.el21
-rw-r--r--lisp/progmodes/elisp-mode.el68
3 files changed, 69 insertions, 50 deletions
diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el
index 73f60f1972a..808840f895d 100644
--- a/lisp/cedet/mode-local.el
+++ b/lisp/cedet/mode-local.el
@@ -723,19 +723,23 @@ SYMBOL is a function that can be overridden."
723 override (symbol-function override))))) 723 override (symbol-function override)))))
724 724
725 (when (and override override-file) 725 (when (and override override-file)
726 (let ((meta-name (cons override major-mode)) 726 (let* ((meta-name (cons override major-mode))
727 ;; For the declaration: 727 ;; For the declaration:
728 ;; 728 ;;
729 ;;(define-mode-local-override xref-elisp-foo c-mode 729 ;;(define-mode-local-override xref-elisp-foo c-mode
730 ;; 730 ;;
731 ;; The override symbol name is 731 ;; The override symbol name is
732 ;; "xref-elisp-foo-c-mode". The summary should match 732 ;; "xref-elisp-foo-c-mode". The summary should match
733 ;; the declaration, so strip the mode from the 733 ;; the declaration, so strip the mode from the
734 ;; symbol name. 734 ;; symbol name.
735 (summary (format elisp--xref-format-extra 735 (overridesymbol
736 'define-mode-local-override 736 (intern
737 (substring (symbol-name override) 0 (- (1+ (length (symbol-name major-mode))))) 737 (substring (symbol-name override)
738 major-mode))) 738 0 (- (1+ (length (symbol-name major-mode)))))))
739 (summary (format elisp--xref-format-extra
740 'define-mode-local-override
741 overridesymbol
742 major-mode)))
739 743
740 (unless (xref-mode-local--override-present override xrefs) 744 (unless (xref-mode-local--override-present override xrefs)
741 (push (elisp--xref-make-xref 745 (push (elisp--xref-make-xref
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index d501a421ea2..320bc4c3d8e 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -324,6 +324,9 @@ DEFAULT-BODY, if present, is used as the body of a default method.
324 ,@warnings 324 ,@warnings
325 (defalias ',name 325 (defalias ',name
326 (cl-generic-define ',name ',args ',(nreverse options)) 326 (cl-generic-define ',name ',args ',(nreverse options))
327 ;; FIXME: This docstring argument is used as circumstantial
328 ;; evidence that this generic function was defined via
329 ;; `cl-defgeneric' rather than only `cl-defmethod's.
327 ,(if (consp doc) ;An expression rather than a constant. 330 ,(if (consp doc) ;An expression rather than a constant.
328 `(help-add-fundoc-usage ,doc ',args) 331 `(help-add-fundoc-usage ,doc ',args)
329 (help-add-fundoc-usage doc args))) 332 (help-add-fundoc-usage doc args)))
@@ -844,12 +847,18 @@ You might need to add: %S"
844 ;; at which point we replace the dummy with the real one. 847 ;; at which point we replace the dummy with the real one.
845 (with-memoization (cl--generic-lazy-function generic) 848 (with-memoization (cl--generic-lazy-function generic)
846 (lambda (&rest args) 849 (lambda (&rest args)
847 (let ((real 850 (let* ((real
848 (cl--generic-make-next-function generic 851 (cl--generic-make-next-function generic
849 (cl--generic-dispatches generic) 852 (cl--generic-dispatches generic)
850 (cl--generic-method-table generic)))) 853 (cl--generic-method-table generic)))
851 (let ((current-load-list nil)) 854 (sym (cl--generic-name generic))
852 (defalias (cl--generic-name generic) real)) 855 (old-adv-cc (get-advertised-calling-convention
856 (symbol-function sym))))
857 (when (listp old-adv-cc)
858 (set-advertised-calling-convention real old-adv-cc nil))
859 (when (symbol-function sym)
860 (let ((current-load-list nil))
861 (defalias sym real)))
853 (apply real args))))) 862 (apply real args)))))
854 863
855(defun cl--generic-make-next-function (generic dispatches methods) 864(defun cl--generic-make-next-function (generic dispatches methods)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 13106ee6885..c4fb6946aeb 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1249,17 +1249,13 @@ functions are annotated with \"<f>\" via the
1249 1249
1250(defun elisp--xref-backend () 'elisp) 1250(defun elisp--xref-backend () 'elisp)
1251 1251
1252;; WORKAROUND: This is nominally a constant, but the text properties 1252(defconst elisp--xref-format
1253;; are not preserved thru dump if use defconst. See bug#21237. 1253 #("(%S %S)"
1254(defvar elisp--xref-format
1255 #("(%s %s)"
1256 1 3 (face font-lock-keyword-face) 1254 1 3 (face font-lock-keyword-face)
1257 4 6 (face font-lock-function-name-face))) 1255 4 6 (face font-lock-function-name-face)))
1258 1256
1259;; WORKAROUND: This is nominally a constant, but the text properties 1257(defconst elisp--xref-format-extra
1260;; are not preserved thru dump if use defconst. See bug#21237. 1258 #("(%S %S %S)"
1261(defvar elisp--xref-format-extra
1262 #("(%s %s %s)"
1263 1 3 (face font-lock-keyword-face) 1259 1 3 (face font-lock-keyword-face)
1264 4 6 (face font-lock-function-name-face))) 1260 4 6 (face font-lock-function-name-face)))
1265 1261
@@ -1539,22 +1535,28 @@ namespace but with lower confidence."
1539 ;; defined in C; the doc strings from the C source have 1535 ;; defined in C; the doc strings from the C source have
1540 ;; not been loaded yet. Second call will return "src/*.c" 1536 ;; not been loaded yet. Second call will return "src/*.c"
1541 ;; in file; handled by t case below. 1537 ;; in file; handled by t case below.
1542 (push (elisp--xref-make-xref nil symbol (help-C-file-name (symbol-function symbol) 'subr)) xrefs)) 1538 (push (elisp--xref-make-xref
1539 nil symbol (help-C-file-name (symbol-function symbol)
1540 'subr))
1541 xrefs))
1543 1542
1544 ((and (setq doc (documentation symbol t)) 1543 ((and (setq doc (documentation symbol t))
1545 ;; This doc string is defined in cl-macs.el cl-defstruct 1544 ;; This doc string is defined in cl-macs.el cl-defstruct
1546 (string-match "Constructor for objects of type `\\(.*\\)'" doc)) 1545 ;; FIXME: This is hideously brittle!
1546 (string-match "Constructor for objects of type `\\(.*\\)'"
1547 doc))
1547 ;; `symbol' is a name for the default constructor created by 1548 ;; `symbol' is a name for the default constructor created by
1548 ;; cl-defstruct, so return the location of the cl-defstruct. 1549 ;; cl-defstruct, so return the location of the cl-defstruct.
1549 (let* ((type-name (match-string 1 doc)) 1550 (let* ((type-name (match-string 1 doc))
1550 (type-symbol (intern type-name)) 1551 (type-symbol (intern type-name))
1551 (file (find-lisp-object-file-name type-symbol 'define-type)) 1552 (file (find-lisp-object-file-name
1553 type-symbol 'define-type))
1552 (summary (format elisp--xref-format-extra 1554 (summary (format elisp--xref-format-extra
1553 'cl-defstruct 1555 'cl-defstruct type-symbol
1554 (concat "(" type-name) 1556 `(:constructor ,symbol))))
1555 (concat "(:constructor " (symbol-name symbol) "))")))) 1557 (push (elisp--xref-make-xref 'define-type type-symbol
1556 (push (elisp--xref-make-xref 'define-type type-symbol file summary) xrefs) 1558 file summary)
1557 )) 1559 xrefs)))
1558 1560
1559 ((setq generic (cl--generic symbol)) 1561 ((setq generic (cl--generic symbol))
1560 ;; FIXME: move this to elisp-xref-find-def-functions, in cl-generic.el 1562 ;; FIXME: move this to elisp-xref-find-def-functions, in cl-generic.el
@@ -1585,22 +1587,28 @@ namespace but with lower confidence."
1585 ;; Default method has all t in specializers. 1587 ;; Default method has all t in specializers.
1586 (setq non-default (or non-default (not (equal t item))))) 1588 (setq non-default (or non-default (not (equal t item)))))
1587 1589
1588 (when (and file 1590 ;; Assuming only co-located default has null doc string
1589 (or non-default 1591 (when (and file (or non-default (nth 2 info)))
1590 (nth 2 info))) ;; assuming only co-located default has null doc string
1591 (if specializers 1592 (if specializers
1592 (let ((summary (format elisp--xref-format-extra 'cl-defmethod symbol (nth 1 info)))) 1593 (let ((summary (format elisp--xref-format-extra
1593 (push (elisp--xref-make-xref 'cl-defmethod met-name file summary) xrefs)) 1594 'cl-defmethod symbol
1594 1595 (nth 1 info))))
1595 (let ((summary (format elisp--xref-format-extra 'cl-defmethod symbol "()"))) 1596 (push (elisp--xref-make-xref 'cl-defmethod met-name
1596 (push (elisp--xref-make-xref 'cl-defmethod met-name file summary) xrefs)))) 1597 file summary)
1598 xrefs))
1599
1600 (let ((summary (format elisp--xref-format-extra
1601 'cl-defmethod symbol ())))
1602 (push (elisp--xref-make-xref 'cl-defmethod met-name
1603 file summary)
1604 xrefs))))
1597 )) 1605 ))
1598 1606
1599 (if (and (setq doc (documentation symbol t)) 1607 ;; FIXME: We rely on the fact that `cl-defgeneric' sets
1600 ;; This doc string is created somewhere in 1608 ;; a `function-documentation' property (via the third arg of
1601 ;; cl--generic-make-function for an implicit 1609 ;; `defalias'), whereas implicit declaration of a generic via
1602 ;; defgeneric. 1610 ;; `cl-defmethod' doesn't.
1603 (string-match "\n\n(fn ARG &rest ARGS)" doc)) 1611 (if (null (get symbol 'function-documentation))
1604 ;; This symbol is an implicitly defined defgeneric, so 1612 ;; This symbol is an implicitly defined defgeneric, so
1605 ;; don't return it. 1613 ;; don't return it.
1606 nil 1614 nil
@@ -2238,7 +2246,6 @@ Intended for `eldoc-documentation-functions' (which see)."
2238(defcustom elisp-eldoc-docstring-length-limit 1000 2246(defcustom elisp-eldoc-docstring-length-limit 1000
2239 "Maximum length of doc strings displayed by elisp ElDoc functions." 2247 "Maximum length of doc strings displayed by elisp ElDoc functions."
2240 :type 'natnum 2248 :type 'natnum
2241 :group 'elisp
2242 :version "31.1") 2249 :version "31.1")
2243 2250
2244(defcustom elisp-eldoc-funcall-with-docstring-length 'short 2251(defcustom elisp-eldoc-funcall-with-docstring-length 'short
@@ -2248,7 +2255,6 @@ Otherwise if set to `full', display full doc string."
2248 :type '(choice 2255 :type '(choice
2249 (const :tag "Short" short) 2256 (const :tag "Short" short)
2250 (const :tag "Full" full)) 2257 (const :tag "Full" full))
2251 :group 'elisp
2252 :version "31.1") 2258 :version "31.1")
2253 2259
2254(defun elisp-eldoc-funcall-with-docstring (callback &rest _ignored) 2260(defun elisp-eldoc-funcall-with-docstring (callback &rest _ignored)