From: Eshel Yaron Date: Thu, 28 Mar 2024 18:46:43 +0000 (+0100) Subject: Improve 'help--symbol-completion-table-affixation' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d5609b4bcfb59d922f04ba7bc769ebe9a404f16b;p=emacs.git Improve 'help--symbol-completion-table-affixation' --- diff --git a/lisp/help-fns.el b/lisp/help-fns.el index faa0ab20746..12910b1961d 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -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."