[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] New package: marginalia
From: |
Juri Linkov |
Subject: |
Re: [ELPA] New package: marginalia |
Date: |
Tue, 01 Jun 2021 23:54:45 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>>> BTW, I hope we can merge some of that code directly into Emacs itself.
>>
>> For example, marginalia--symbol-class adds new symbol characters to
>> the replacement of `help--symbol-completion-table-affixation',
>> but it would be better to add new characters directly to
>> `help--symbol-completion-table-affixation'...
>
> Yes, I would be glad if you merge back the `marginalia--symbol-class` to
> the Emacs help system! The `marginalia--symbol-class` has been inspired
> by your `help--symbol-completion-table-affixation`, but I wanted to go a
> little step further in Marginalia. Maybe it makes sense to add
> `help--symbol-class` such that the function can be reused potentially at
> other places?
Maybe something like
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 5a805a2302..133763add1 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -126,29 +126,35 @@ help-enable-completion-autoload
:group 'help
:version "26.3")
+(defun help--symbol-class (s)
+ "Return symbol class characters for symbol S."
+ (when (stringp s)
+ (setq s (intern-soft s)))
+ (cond ((commandp s)
+ "c") ; command
+ ((eq (car-safe (symbol-function s)) 'macro)
+ "m") ; macro
+ ((fboundp s)
+ "f") ; function
+ ((custom-variable-p s)
+ "u") ; user option
+ ((boundp s)
+ "v") ; variable
+ ((facep s)
+ "a") ; fAce
+ ((and (fboundp 'cl-find-class)
+ (cl-find-class s))
+ "t") ; CL type
+ (" ") ; something else
+ ))
+
(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-match "\n" doc)))))
(list c (propertize
- (concat (cond ((commandp s)
- "c") ; command
- ((eq (car-safe (symbol-function s))
'macro)
- "m") ; macro
- ((fboundp s)
- "f") ; function
- ((custom-variable-p s)
- "u") ; user option
- ((boundp s)
- "v") ; variable
- ((facep s)
- "a") ; fAce
- ((and (fboundp 'cl-find-class)
- (cl-find-class s))
- "t") ; CL type
- (" ")) ; something else
- " ") ; prefix separator
+ (concat (help--symbol-class s) " ") ; prefix separator
'face 'completions-annotations)
(if doc (propertize (format " -- %s" doc)
'face 'completions-annotations)
Then you could use it, and prepend/append more characters
such as: o for obsolete, ! for advised, * for modified.
- Re: [ELPA] New package: marginalia,
Juri Linkov <=