From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] New package: marginalia Date: Fri, 11 Jun 2021 20:13:23 +0300 Organization: LINKOV.NET Message-ID: <87o8ccwh9s.fsf@mail.linkov.net> References: <5146817f-4b3f-8a7e-edce-f34a9a10f805@daniel-mendler.de> <871r9qk9el.fsf@mail.linkov.net> <92c218f7-1168-a7f4-3861-04f64a37eec9@daniel-mendler.de> <874kehcnl6.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="703"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Omar =?iso-8859-1?Q?Antol=EDn?= Camarena , Stefan Monnier , "emacs-devel@gnu.org" To: Daniel Mendler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 11 19:15:12 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrkkS-000AUv-Md for ged-emacs-devel@m.gmane-mx.org; Fri, 11 Jun 2021 19:15:12 +0200 Original-Received: from localhost ([::1]:33898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrkkR-0001bg-KG for ged-emacs-devel@m.gmane-mx.org; Fri, 11 Jun 2021 13:15:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrkjE-0008KC-A4 for emacs-devel@gnu.org; Fri, 11 Jun 2021 13:13:56 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:52863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrkjB-00088J-LJ for emacs-devel@gnu.org; Fri, 11 Jun 2021 13:13:56 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 8DE4220008; Fri, 11 Jun 2021 17:13:47 +0000 (UTC) In-Reply-To: (Daniel Mendler's message of "Tue, 1 Jun 2021 23:07:39 +0200") Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270707 Archived-At: --=-=-= Content-Type: text/plain > 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=help--symbol-class.patch 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) --=-=-=--