unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 45361@debbugs.gnu.org, 45361-done@debbugs.gnu.org
Subject: bug#45361: 28.0.50; tabulated-list-mode: should be sorting by specified sort function
Date: Tue, 22 Dec 2020 12:43:55 +0300	[thread overview]
Message-ID: <X+G/28v4RXcoKJwx@protected.rcdrun.com> (raw)
In-Reply-To: <87v9cu9og8.fsf@gmx.net>

* Stephen Berman <stephen.berman@gmx.net> [2020-12-22 12:32]:
> On Tue, 22 Dec 2020 08:13:50 +0100 Jean Louis <bugs@gnu.support> wrote:
> 
> > PROBLEM:
> >
> > The variable `tabulated-list-format' provides for programmer
> > option to sort columns and I would like to sort number as
> > strings "12" as numbers, not as strings. I do not know how to
> > properly provide the sorting function to `tabulated-list-format' so
> > that it works when actually sorting.
> [...]
> > Then I would like to use the function `string-collate-lessp' as that
> > seem to understand how numbers should be compared.
> >
> > For example this is giving me correct result:
> >
> > (sort '("121" "117" "1") 'string-collate-lessp) => ("1" "117" "121")
> 
> But:
> 
> (sort '("21" "117" "1") 'string-collate-lessp) => ("1" "117" "21")
> 
> So string-collate-lessp doesn't do what it seems you want.

Oh, I missed to see that. That is the problem.

> Actually, tabulated-list-print does call my-sort via
> tabulated-list--get-sorter.  Anyway, buffer-menu.el has the function
> `tabulated-list-entry-size->', which with a small adjustment does what
> you seem to want.  Try this:
> 
> (defun my-tabulated-list-entry-size-> (entry1 entry2)
>   (> (string-to-number (aref (cadr entry1) 0))
>      (string-to-number (aref (cadr entry2) 0))))

That is what I missed to see, thank you for references and your
help. Now it works well. 

Jean

P.S. Closing it as it is not a bug.








      reply	other threads:[~2020-12-22  9:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22  7:13 bug#45361: 28.0.50; tabulated-list-mode: should be sorting by specified sort function Jean Louis
2020-12-22  9:31 ` Stephen Berman
2020-12-22  9:43   ` Jean Louis [this message]

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=X+G/28v4RXcoKJwx@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=45361-done@debbugs.gnu.org \
    --cc=45361@debbugs.gnu.org \
    --cc=stephen.berman@gmx.net \
    /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).