[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ea58276462: Allow inhibiting linkification in *Help* buffers
From: |
Lars Ingebrigtsen |
Subject: |
master ea58276462: Allow inhibiting linkification in *Help* buffers |
Date: |
Sat, 7 May 2022 06:47:48 -0400 (EDT) |
branch: master
commit ea58276462d93f24c75473c69154ef7a4a47b63c
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Allow inhibiting linkification in *Help* buffers
* doc/lispref/help.texi (Keys in Documentation): Document it.
lisp/help-mode.el (help-make-xrefs): Implement a new \+ syntax to
inhibit buttonification.
---
doc/lispref/help.texi | 4 ++++
etc/NEWS | 9 +++++++++
lisp/help-mode.el | 42 ++++++++++++++++++++++--------------------
test/lisp/help-mode-tests.el | 2 +-
4 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index d53bfad8e9..f029a1c97c 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -362,6 +362,10 @@ depending on the value of @code{text-quoting-style}.
quotes the following character and is discarded; thus, @samp{\=`} puts
@samp{`} into the output, @samp{\=\[} puts @samp{\[} into the output,
and @samp{\=\=} puts @samp{\=} into the output.
+
+@item \+
+This indicates that the symbol directly following should not be marked
+as link in the @file{*Help*} buffer.
@end table
@strong{Please note:} Each @samp{\} must be doubled when written in a
diff --git a/etc/NEWS b/etc/NEWS
index b595eae7e1..a2f7f03852 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -461,6 +461,15 @@ This allows you to enter emoji using short strings, eg
:face_palm: or
** Help
++++
+*** New doc string syntax to indicate that symbols shouldn't be links.
+When displaying doc strings in *Help* buffers, strings that are
+"`like-this'" are made into links (if they point to a bound
+function/variable). This can lead to false positives when talking
+about values that are symbols that happen to have the same names as
+functions/variables. To inhibit this buttonification, the new
+"\\+`like-this'" syntax can be used.
+
+++
*** New user option 'help-window-keep-selected'.
If non-nil, commands to show the info manual and the source will reuse
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index a0a587cd81..4a65f40507 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -452,6 +452,7 @@ Commands:
"\\(symbol\\|program\\|property\\)\\|" ; Don't link
"\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
"[ \t\n]+\\)?"
+ "\\(\\\\\\+\\)?"
"['`‘]\\(\\(?:\\sw\\|\\s_\\)+\\|`\\)['’]"))
"Regexp matching doc string references to symbols.
@@ -628,27 +629,28 @@ that."
;; Quoted symbols
(save-excursion
(while (re-search-forward help-xref-symbol-regexp nil t)
- (let* ((data (match-string 8))
- (sym (intern-soft data)))
- (if sym
- (cond
- ((match-string 3) ; `variable' &c
- (and (or (boundp sym) ; `variable' doesn't ensure
+ (when-let ((sym (intern-soft (match-string 9))))
+ (if (match-string 8)
+ (delete-region (match-beginning 8)
+ (match-end 8))
+ (cond
+ ((match-string 3) ; `variable' &c
+ (and (or (boundp sym) ; `variable' doesn't ensure
; it's actually bound
- (get sym 'variable-documentation))
- (help-xref-button 8 'help-variable sym)))
- ((match-string 4) ; `function' &c
- (and (fboundp sym) ; similarly
- (help-xref-button 8 'help-function sym)))
- ((match-string 5) ; `face'
- (and (facep sym)
- (help-xref-button 8 'help-face sym)))
- ((match-string 6)) ; nothing for `symbol'
- ((match-string 7)
- (help-xref-button 8 'help-function-def sym))
- ((cl-some (lambda (x) (funcall (nth 1 x) sym))
- describe-symbol-backends)
- (help-xref-button 8 'help-symbol sym)))))))
+ (get sym 'variable-documentation))
+ (help-xref-button 9 'help-variable sym)))
+ ((match-string 4) ; `function' &c
+ (and (fboundp sym) ; similarly
+ (help-xref-button 9 'help-function sym)))
+ ((match-string 5) ; `face'
+ (and (facep sym)
+ (help-xref-button 9 'help-face sym)))
+ ((match-string 6)) ; nothing for `symbol'
+ ((match-string 7)
+ (help-xref-button 9 'help-function-def sym))
+ ((cl-some (lambda (x) (funcall (nth 1 x) sym))
+ describe-symbol-backends)
+ (help-xref-button 9 'help-symbol sym)))))))
;; An obvious case of a key substitution:
(save-excursion
(while (re-search-forward
diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el
index c0c1cf8b53..b5bdf6b8d4 100644
--- a/test/lisp/help-mode-tests.el
+++ b/test/lisp/help-mode-tests.el
@@ -81,7 +81,7 @@ Lisp concepts such as car, cdr, cons cell and list.")
(insert (format fmt fn))
(goto-char (point-min))
(re-search-forward help-xref-symbol-regexp)
- (help-xref-button 8 'help-function)
+ (help-xref-button 9 'help-function)
(should-not (button-at (1- beg)))
(should-not (button-at (+ beg (length (symbol-name fn)))))
(should (eq (button-type (button-at beg)) 'help-function))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ea58276462: Allow inhibiting linkification in *Help* buffers,
Lars Ingebrigtsen <=