unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
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: Fri, 11 Jun 2021 20:13:23 +0300	[thread overview]
Message-ID: <87o8ccwh9s.fsf@mail.linkov.net> (raw)
In-Reply-To: <f83eff0b-998a-9fbd-182e-e776660f0a32@daniel-mendler.de> (Daniel Mendler's message of "Tue, 1 Jun 2021 23:07:39 +0200")

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

> What about adding the extended `symbol-class` function from Marginalia
> directly to help-fns.el? Note that the Marginalia function returns
> multiple characters "fv" if a symbol denotes both a function and a variable.
>
> Do you want to keep the `symbol-class` to be a single character under
> all circumstances?

I have tried to use marginalia--symbol-class for help--symbol-class,
and noticed a few problems:

1. It's hard to visually scan the column with types
   when the primary char (f, c, v, u) is not the first in the row.
   In the following patch I moved the primary char to the beginning.

2. Also it would help to see the letter of the primary char
   if secondary chars are not letters.  So I replaced "o" (obsolete)
   with a strikethrough symbol "-".

3. Are Unicode characters allowed?  Then could we add to the primary char
   e.g. COMBINING LONG STROKE OVERLAY (U+0336) to designate obsolete.

4. The remaining secondary letter is "l" for local, but I can't find
   a non-letter character to replace it.

5. Isn't using formatting such as "%-6s" not suitable in the backend?
   At least, I moved it out of help--symbol-class.  Ideally,
   the frontend should adjust column sizes to fit them to the longest value.

6. The format "%-6s " with 7 placeholders that is too wide for most symbols
   when a tiny fraction of symbols has 4 chars max, so reduced it to 4:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: help--symbol-class.patch --]
[-- Type: text/x-diff, Size: 2313 bytes --]

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 133763add1..804ab43063 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -130,23 +130,25 @@ help--symbol-class
   "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
-        ))
+  (concat
+   (when (fboundp s)
+     (concat
+      (cond
+       ((commandp s) "c")
+       ((eq (car-safe (symbol-function s)) 'macro) "m")
+       (t "f"))
+      (and (let ((flist (indirect-function s)))
+             (advice--p (if (eq 'macro (car-safe flist)) (cdr flist) flist)))
+           "!")
+      (and (get s 'byte-obsolete-info) "-")))
+   (when (boundp s)
+     (concat
+      (if (custom-variable-p s) "u" "v")
+      (and (local-variable-if-set-p s) "l")
+      (and (ignore-errors (not (equal (symbol-value s) (default-value s)))) "*")
+      (and (get s 'byte-obsolete-variable) "-")))
+   (and (facep s) "a")
+   (and (fboundp 'cl-find-class) (cl-find-class s) "t")))
 
 (defun help--symbol-completion-table-affixation (completions)
   (mapcar (lambda (c)
@@ -154,7 +156,7 @@ help--symbol-completion-table-affixation
                    (doc (condition-case nil (documentation s) (error nil)))
                    (doc (and doc (substring doc 0 (string-match "\n" doc)))))
               (list c (propertize
-                       (concat (help--symbol-class s) " ") ; prefix separator
+                       (format "%-4s " (help--symbol-class s))
                        'face 'completions-annotations)
                     (if doc (propertize (format " -- %s" doc)
                                         'face 'completions-annotations)

  parent reply	other threads:[~2021-06-11 17:13 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
2021-06-01 21:07         ` Daniel Mendler
2021-06-02 22:13           ` Juri Linkov
2021-06-11 17:13           ` Juri Linkov [this message]
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=87o8ccwh9s.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).