From: Basil L. Contovounesios Date: Tue, 30 Apr 2024 06:31:58 +0000 (+0200) Subject: Assume match before calling help-xref-button X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3779b9dff3609fef7047c7f236cdd84f89dd2e0d;p=emacs.git Assume match before calling help-xref-button help-xref-button fails if not preceded by a valid match, so a preceding unconditional search should not be allowed to fail silently. * lisp/emacs-lisp/ert.el (ert-describe-test): * lisp/help-fns.el (help-fns--compiler-macro) (help-fns-function-description-header, describe-variable) (help-fns--customize-variable, describe-face) (help-fns--face-attributes, describe-keymap): Let unconditional re-search-backward before help-xref-button fail early, as that would indicate a logic bug, and the backtrace would more accurately point to the actual source of the mistake. (cherry picked from commit 65fa47e3fa15c5553974a6d99080f21b4117245b) --- diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 0f66cca2ca4..2a28dd6f3d2 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -2815,8 +2815,7 @@ To be used in the ERT results buffer." (insert (format-message " defined in `%s'" (file-name-nondirectory file-name))) (save-excursion - (re-search-backward (substitute-command-keys "`\\([^`']+\\)'") - nil t) + (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) (help-xref-button 1 'help-function-def test-name file-name))) (insert ".") (fill-region-as-paragraph (point-min) (point)) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index bb0b58b25ef..e043bc8750d 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -701,16 +701,14 @@ the C sources, too." (progn (insert (format-message " `%s'" handler)) (save-excursion - (re-search-backward (substitute-command-keys "`\\([^`']+\\)'") - nil t) + (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) (help-xref-button 1 'help-function handler))) ;; FIXME: Obsolete since 24.4. (let ((lib (get function 'compiler-macro-file))) (when (stringp lib) (insert (format-message " in `%s'" lib)) (save-excursion - (re-search-backward (substitute-command-keys "`\\([^`']+\\)'") - nil t) + (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) (help-xref-button 1 'help-function-cmacro function lib))))))) (unless (bolp) (insert ". See " @@ -1175,8 +1173,7 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)." (setq help-mode--current-data (list :symbol function :file file-name)) (save-excursion - (re-search-backward (substitute-command-keys "`\\([^`']+\\)'") - nil t) + (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) (help-xref-button 1 'help-function-def function file-name)))) (princ ".")))) @@ -1375,8 +1372,7 @@ it is displayed along with the global value." :file file-name)) (save-excursion (re-search-backward (substitute-command-keys - "`\\([^`']+\\)'") - nil t) + "`\\([^`']+\\)'")) (help-xref-button 1 'help-variable-def variable file-name))) (if valvoid @@ -1615,8 +1611,7 @@ This cancels value editing without updating the value." (princ (concat " You can " customize-label (or text " this variable."))) (with-current-buffer standard-output (save-excursion - (re-search-backward - (concat "\\(" customize-label "\\)") nil t) + (re-search-backward (concat "\\(" customize-label "\\)")) (help-xref-button 1 'help-customize-variable variable))) (terpri)))) @@ -1846,8 +1841,7 @@ If FRAME is omitted or nil, use the selected frame." "\n\n")) (with-current-buffer standard-output (save-excursion - (re-search-backward - (concat "\\(" customize-label "\\)") nil t) + (re-search-backward (concat "\\(" customize-label "\\)")) (help-xref-button 1 'help-customize-face f))) (setq file-name (find-lisp-object-file-name f 'defface)) (if (not file-name) @@ -1860,7 +1854,7 @@ If FRAME is omitted or nil, use the selected frame." ;; Make a hyperlink to the library. (save-excursion (re-search-backward - (substitute-command-keys "`\\([^`']+\\)'") nil t) + (substitute-command-keys "`\\([^`']+\\)'")) (help-xref-button 1 'help-face-def f file-name)) (princ ".") (terpri) @@ -1907,7 +1901,7 @@ If FRAME is omitted or nil, use the selected frame." (not (eq attr 'unspecified))) ;; Make a hyperlink to the parent face. (save-excursion - (re-search-backward ": \\([^:]+\\)" nil t) + (re-search-backward ": \\([^:]+\\)") (help-xref-button 1 'help-face attr))) (insert "\n"))) (terpri))) @@ -2158,9 +2152,7 @@ keymap value." "C source code" (help-fns-short-filename file-name)))) (save-excursion - (re-search-backward (substitute-command-keys - "`\\([^`']+\\)'") - nil t) + (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")) (setq help-mode--current-data (list :symbol keymap :file file-name)) (help-xref-button 1 'help-variable-def