]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow inhibiting linkification in *Help* buffers
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 7 May 2022 10:46:55 +0000 (12:46 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 7 May 2022 10:46:55 +0000 (12:46 +0200)
* 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
etc/NEWS
lisp/help-mode.el
test/lisp/help-mode-tests.el

index d53bfad8e9e774406f5761d7af0835eec15bebdd..f029a1c97ccaf700300558c103e2fe3906213473 100644 (file)
@@ -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
index b595eae7e10f6decaec82507ebd1d8857e58b86b..a2f7f038524cebe2894799d58e2abe827181c7ca 100644 (file)
--- 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
index a0a587cd8105ed64ef8ff5d8d695a1f2d7c47679..4a65f40507b2d7c9a84bf7eb4efc0aedfbb44108 100644 (file)
@@ -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
index c0c1cf8b5306b159a677bcd60506e40d7b503d0b..b5bdf6b8d49b43185f9f3a081585c5785fb510a3 100644 (file)
@@ -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))))))