]> git.eshelyaron.com Git - emacs.git/commitdiff
; Refine dictionary definition display in *Help* buffers
authorEshel Yaron <me@eshelyaron.com>
Sun, 25 Feb 2024 11:25:58 +0000 (12:25 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 25 Feb 2024 11:25:58 +0000 (12:25 +0100)
* lisp/net/dictionary.el (dictionary-display-definition-in-help-buffer):
Add one-line description and normalize whitespace in references.

lisp/net/dictionary.el

index 1981b757017d0cd5dc230ae5a8498ff6a33bc5f1..f207894ae143aaf784d728a60ce75c4df368838f 100644 (file)
@@ -1569,7 +1569,13 @@ Further arguments are currently ignored."
                      (called-interactively-p 'interactive))
     (with-help-window (help-buffer)
       (with-current-buffer (help-buffer)
-        (insert definition)
+        (insert "Definition of {" word "} in "
+                (cond
+                 ((string= dictionary "*") "all dictionaries")
+                 ((string= dictionary "!") "first matching dictionary")
+                 (t (format "dictionary %s" dictionary)))
+                ":\n\n"
+                definition)
         ;; Buttonize references to other definitions.  These appear as
         ;; words enclosed with curly braces.
         (goto-char (point-min))
@@ -1578,7 +1584,9 @@ Further arguments are currently ignored."
                                       "}")
                                   nil t)
           (help-xref-button 1 'help-word
-                            (match-string 1)
+                            ;; Normalize spaces in references.
+                            (replace-regexp-in-string
+                             (rx (+ (or space "\n"))) " " (match-string 1))
                             dictionary))))))
 
 (defvar dictionary-color-support (display-color-p)