]> git.eshelyaron.com Git - emacs.git/commitdiff
Assume match before calling help-xref-button
authorBasil L. Contovounesios <basil@contovou.net>
Tue, 30 Apr 2024 06:31:58 +0000 (08:31 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:30:39 +0000 (18:30 +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.

(cherry picked from commit 65fa47e3fa15c5553974a6d99080f21b4117245b)

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

index 0f66cca2ca46acb170352f77f2575185ee918817..2a28dd6f3d2a51c5040e7879d454599c1c973bf7 100644 (file)
@@ -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))
index bb0b58b25efbb1412a804cd031039269ca0cb5c1..e043bc8750d170b89c8ccbd367c8dbaa8d705b44 100644 (file)
@@ -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