From: Juri Linkov <juri@linkov.net>
To: Daniel Mendler <mail@daniel-mendler.de>
Cc: "Omar Antolín Camarena" <omar@matem.unam.mx>,
"Stefan Monnier" <monnier@iro.umontreal.ca>,
"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [ELPA] New package: marginalia
Date: Tue, 01 Jun 2021 23:54:45 +0300 [thread overview]
Message-ID: <874kehcnl6.fsf@mail.linkov.net> (raw)
In-Reply-To: <92c218f7-1168-a7f4-3861-04f64a37eec9@daniel-mendler.de> (Daniel Mendler's message of "Sat, 29 May 2021 10:06:03 +0200")
[-- Attachment #1: Type: text/plain, Size: 730 bytes --]
>>> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: help--symbol-class.patch --]
[-- Type: text/x-diff, Size: 2597 bytes --]
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)
[-- Attachment #3: Type: text/plain, Size: 115 bytes --]
Then you could use it, and prepend/append more characters
such as: o for obsolete, ! for advised, * for modified.
next prev parent reply other threads:[~2021-06-01 20:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 6:35 [ELPA] New package: marginalia Daniel Mendler
2021-05-28 13:47 ` Stefan Monnier
2021-05-28 13:59 ` Daniel Mendler
2021-05-28 14:08 ` Eli Zaretskii
2021-05-28 18:40 ` Juri Linkov
2021-05-29 8:06 ` Daniel Mendler
2021-06-01 20:54 ` Juri Linkov [this message]
2021-06-01 21:07 ` Daniel Mendler
2021-06-02 22:13 ` Juri Linkov
2021-06-11 17:13 ` Juri Linkov
2021-06-17 20:22 ` Juri Linkov
2021-06-02 14:46 ` Jens C. Jensen
2021-06-02 15:07 ` Daniel Mendler
2021-06-03 6:17 ` Jens C. Jensen
2021-06-02 15:10 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874kehcnl6.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=emacs-devel@gnu.org \
--cc=mail@daniel-mendler.de \
--cc=monnier@iro.umontreal.ca \
--cc=omar@matem.unam.mx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).