From e77910b59c8a319dd5f34911da7622d95571e33b Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 15 Jan 2025 09:47:03 +0100 Subject: [PATCH] Consolidate symbols ERT uses with find-function --- lisp/emacs-lisp/ert.el | 16 +++++----------- lisp/emacs-lisp/find-func.el | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 1f87059237a..bbefa7c788c 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -245,12 +245,6 @@ in batch mode, an error is signaled. :file-name ,(or (macroexp-file-name) buffer-file-name))) ',name)))) -(defvar ert--find-test-regexp - (concat "^\\s-*(ert-deftest" - find-function-space-re - "%s\\(\\s-\\|$\\)") - "The regexp the `find-function' mechanisms use for finding test definitions.") - (define-error 'ert-test-failed "Test failed") (define-error 'ert-test-skipped "Test skipped") @@ -1887,7 +1881,7 @@ default (if any)." (defun ert-find-test-other-window (test-name) "Find, in another window, the definition of TEST-NAME." (interactive (list (ert-read-test-name-at-point "Find test definition"))) - (find-function-do-it test-name 'ert--test 'switch-to-buffer-other-window)) + (find-function-do-it test-name 'ert-deftest 'switch-to-buffer-other-window)) (defun ert-delete-test (test-name) "Make the test TEST-NAME unbound. @@ -2467,7 +2461,9 @@ To be used in the ERT results buffer." (defun ert--test-name-button-action (button) "Find the definition of the test BUTTON belongs to, in another window." - (let ((name (button-get button 'ert-test-name))) + ;; Support both `insert-test-name-button' and `help-xref-button'. + (let ((name (or (button-get button 'ert-test-name) + (car (button-get button 'help-args))))) (ert-find-test-other-window name))) (defun ert--ewoc-position (ewoc node) @@ -2813,7 +2809,7 @@ To be used in the ERT results buffer." (file-name-nondirectory file-name))) (save-excursion (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) - (help-xref-button 1 'help-function-def test-name file-name))) + (help-xref-button 1 'ert--test-name-button test-name file-name))) (insert ".") (fill-region-as-paragraph (point-min) (point)) (insert "\n\n") @@ -2846,7 +2842,6 @@ To be used in the ERT results buffer." `("ERT test" ,#'ert-test-boundp ,(lambda (s _b _f) (ert-describe-test s)))) -(add-to-list 'find-function-regexp-alist '(ert--test . ert--find-test-regexp)) (add-to-list 'minor-mode-alist '(ert--current-run-stats (:eval (ert--tests-running-mode-line-indicator)))) @@ -2854,7 +2849,6 @@ To be used in the ERT results buffer." (defun ert--unload-function () "Unload function to undo the side-effects of loading ert.el." - (ert--remove-from-list 'find-function-regexp-alist 'ert-deftest :key #'car) (ert--remove-from-list 'minor-mode-alist 'ert--current-run-stats :key #'car) (ert--remove-from-list 'emacs-lisp-mode-hook 'ert--activate-font-lock-keywords) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 0a5938ff62a..45209dc53c0 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -110,7 +110,7 @@ should insert the feature name." :version "25.1") (defcustom find-ert-deftest-regexp - "(ert-deftest +'%s" + (concat "^\\s-*(ert-deftest" find-function-space-re "%s\\(\\s-\\|$\\)") "The regexp used to search for an `ert-deftest' definition. Note it must contain a `%s' at the place where `format' should insert the feature name." -- 2.39.5