]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve 'help--symbol-completion-table-affixation'
authorEshel Yaron <me@eshelyaron.com>
Thu, 28 Mar 2024 18:46:43 +0000 (19:46 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 28 Mar 2024 18:46:43 +0000 (19:46 +0100)
lisp/help-fns.el

index faa0ab207465404eb8ea2b65e6a4bbbe5890f925..12910b1961d276cfc3de2dea3b2274e4be6f243a 100644 (file)
@@ -188,17 +188,24 @@ type specifier when available."
    (and (fboundp 'cl-find-class) (cl-find-class s) "t")))
 
 (defun help--symbol-completion-table-affixation (completions)
-  (mapcar (lambda (c)
-            (let* ((s (intern c))
-                   (doc (condition-case nil (documentation s) (error nil)))
-                   (doc (and doc (substring doc 0 (string-search "\n" doc)))))
-              (list c (propertize
-                       (format "%-4s" (help--symbol-class s))
-                       'face 'completions-annotations)
-                    (if doc (propertize (format " -- %s" doc)
-                                        'face 'completions-annotations)
-                      ""))))
-          completions))
+  (let ((max (+ (seq-max (mapcar #'string-width completions)) 5)))
+    (mapcar (lambda (c)
+              (let* ((s (intern c))
+                     (doc (or (condition-case nil (documentation s) (error nil))
+                              (and (boundp s) (not (keywordp s))
+                                   (documentation-property s 'variable-documentation))
+                              (and (facep s) (documentation-property s 'face-documentation))
+                              (when-let ((class (cl-find-class s)))
+                                (cl--class-docstring class))))
+                     (doc (and doc (substring doc 0 (string-search "\n" doc)))))
+                (list c (propertize
+                         (format "%-4s" (help--symbol-class s))
+                         'face 'completions-annotations)
+                      (if doc (concat
+                               (make-string (- max (string-width c)) ?\s)
+                               (propertize doc 'face 'completions-annotations))
+                        ""))))
+            completions)))
 
 (defun help--symbol-narrow-by-property ()
   "Restrict symbol completions list to symbols with a given property."