1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Basil L. Contovounesios 2024-04-30 08:31:58 +02:00
parent 54dbd8b4fa
commit 65fa47e3fa
2 changed files with 10 additions and 19 deletions

View 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