]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix argument highlighting in 'describe-function' output
authorEshel Yaron <me@eshelyaron.com>
Thu, 23 May 2024 19:59:38 +0000 (21:59 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 23 May 2024 19:59:38 +0000 (21:59 +0200)
lisp/help-fns.el

index e043bc8750d170b89c8ccbd367c8dbaa8d705b44..051362fcd78f0c3f290d350c5f80306d594a53be 100644 (file)
@@ -405,14 +405,17 @@ if the variable `help-downcase-arguments' is non-nil."
   (propertize (if help-downcase-arguments (downcase arg) arg)
              'face 'help-argument-name))
 
-(defun help-do-arg-highlight (doc args)
+(defun help-do-arg-highlight (doc args &optional usage-p)
   (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
     (modify-syntax-entry ?\- "w")
     (dolist (arg args)
       (setq doc (replace-regexp-in-string
                  ;; This is heuristic, but covers all common cases
                  ;; except ARG1-ARG2
-                 (concat "([^ ]+ .*"             ; skip function name
+                 (concat (when usage-p
+                           ;; Skip function name in usage string
+                           ;; (Bug#65580).
+                           "([^ ]+ .*")
                          "\\<"                   ; beginning of word
                          "\\(?:[a-z-]*-\\)?"     ; for xxx-ARG
                          "\\("
@@ -447,7 +450,7 @@ if the variable `help-downcase-arguments' is non-nil."
               (search-backward "(")
               (goto-char (scan-sexps (point) 1)))))
         ;; Highlight arguments in the USAGE string
-        (setq usage (help-do-arg-highlight (buffer-string) args))
+        (setq usage (help-do-arg-highlight (buffer-string) args t))
         ;; Highlight arguments in the DOC string
         (setq doc (and doc (help-do-arg-highlight doc args))))))
   ;; Return value is like the one from help-split-fundoc, but highlighted