Assume match before calling help-xref-button
authorBasil L. Contovounesios <basil@contovou.net>
Tue, 30 Apr 2024 06:31:58 +0000 (08:31 +0200)
committerBasil L. Contovounesios <basil@contovou.net>
Wed, 1 May 2024 10:38:51 +0000 (12:38 +0200)
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.

lisp/emacs-lisp/ert.el
lisp/help-fns.el

index 8ab57d2b23859ba31386d671a004c2d3d15ea9fa..6a665c8181de315c4739cf2dc3af278c5c1238c7 100644 (file)
@@ -2816,8 +2816,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))
index cfe27077055215c49fec9707dae6532dac9c82d5..9bf2f61aee63272a91e9dd3b4128989cc0820633 100644 (file)
@@ -658,16 +658,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 "
@@ -1132,8 +1130,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 "."))))
 
@@ -1332,8 +1329,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
@@ -1572,8 +1568,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))))
 
@@ -1803,8 +1798,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)
@@ -1817,7 +1811,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)
@@ -1864,7 +1858,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)))
@@ -2115,9 +2109,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