GNU bug report logs - #63896
[PATCH] Support annotating and sorting the project list during completion

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Sun, 4 Jun 2023 21:21:02 UTC

Severity: wishlist

Tags: patch

Full log


View this message in rfc822 format

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63896 <at> debbugs.gnu.org
Subject: bug#63896: [PATCH] Support annotating and sorting the project list during completion
Date: Tue, 13 Jun 2023 17:19:52 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Date: Sun, 04 Jun 2023 17:20:19 -0400
>> 
>> This patch adds an annotation-function and display-sort-function to the
>> completion-table used for project-prompt-project-dir and
>> project-prompt-project-name, as well as a user customization variable to
>> customize the behavior of the annotation and sorting functions.
>
> Thanks.  A few minor comments.

Thanks, fixed.

>> +          (cons (+ (* 100 compilation-num-errors-found)
>> +                   (* 10 compilation-num-warnings-found)
>
> Why "encode" these numbers in a single value? why not use a cons or a
> vector?

I'd be happy to use a cons or a vector, or even a more complicated
structure, but I didn't see an easy way to do comparison of
complicated structures, for the sorting of projects based on their
annotation.  For example, if I have values of the form
(num . (num num num))

there's no way to know what sorting predicate to use for such values - I
need to be able to know which value should sort sort first, when I have
a pair of them.

I could make project-annotations a list of tuples of functions, the
first being the annotation-generating function, the second being the
annotation-comparison function.  Then I wouldn't need to encode the
numbers into a single value.  Does that seem like a reasonable design?
I thought that was a bit overly complex.

>> +                (format-mode-line mode-line-process nil nil buf)))
>
> Do you really need to call format-mode-line?  My advice is to stay
> away of that function: it could have unpleasant side effects.

Annoyingly if I want to include the exit code of the compilation in the
annotation, the only place it's found is as a string in
mode-line-process.  I could extract that string from mode-line-process
and use it, but I thought it would be a bad idea to depend on the exact
structure of what compile.el puts in mode-line-process.  So I just
format-mode-line'd it.

Would it be OK to make compile.el store the exit code as a number in a
variable and then use that?  Then I wouldn't need to touch
mode-line-process at all.




This bug report was last modified 73 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.