unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Howard Melman <hmelman@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 38614@debbugs.gnu.org
Subject: bug#38614: 26.3;  Info completions in reverse order
Date: Sun, 15 Dec 2019 14:39:16 -0500	[thread overview]
Message-ID: <C7458367-94AB-4D09-BFCE-DCE1660C1299@gmail.com> (raw)
In-Reply-To: <83mubt60an.fsf@gnu.org>

(Sorry if this is a resend, I don't think I included debbugs in my original reply)

> On Dec 15, 2019, at 11:06 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Howard Melman <hmelman@gmail.com>
>> Date: Sat, 14 Dec 2019 12:18:54 -0500
>> 
>> When using ivy mode, Info-index shows me the list of
>> completions in reverse alphabetical order. Info-menu does too.
>> Both Info-index and Info-menu use completing-read with
>> Info-complete-menu-item as the collections argument. It
>> seems to generate the list in reverse order.
>> 
>> Sorry this isn't a formatted patch, but a one line fix solves it for me.
>> 
>> If after this line in Info-complete-menu-item:
>> 		    (setq completions (delete-dups completions))
>> I add this line:
>> 		    (setq completions (nreverse completions))
>> the index and menus are shown in alphabetical order.
> 
> Sorry, I don't understand: when I type "i SUBJECT" and press TAB in
> Info, I get completions in alphabetical order, so how come with ivy
> you get the reverse order?

I tried that in Emacs 26.3 with -Q and and I see an alphabetical list. I'm not sure what mechanism that's using and I don't particularly know icomplete or ido, though I tried enabling each and saw the same alphabetical list. 

Note that's not quite the same thing as I was describing. Ivy has two sort mechanisms. Ivy displays a list of possible completions (from the collections argument of completing-read) BEFORE you enter any text (SUBJECT in your case). There's no need to hit TAB to see the completions. Then after you enter text it displays completions that are sorted via a different mechanism (because the various matching mechanisms and what you type might indicate a different sort order from the original completions list such as: shorter matches first, prefix matches first, or just alphabetical). AFAIK, Ivy usually doesn't do a sort of the initial list because often it's in a useful order other than alphabetical.

It's clearer in the Info-menu case, where my desired order is the order of the menu items in the info buffer. Using emacs -Q, Info-menu and TAB shows me an alphabetical list. That tells me that whatever mechanism it's using is sorting the list alphabetically and not using the original order of the collection list. 

Ivy shows me the menu items in reverse buffer order because the original collection list presented to ivy (via completing-read) is in reverse order as found in the buffer. Info-complete-menu-item is clearly pushing onto a list and then not nreversing it as is the common idiom. 

I got a bit lost following the elisp docs for Programmed Completion but didn't see any guidelines about the order of the collections intially returned (Info-complete-menu-item doesn't seem to be setting a display-sort-function which I think is the mechanism but I got lost).

Info uses the same function to build the collection list for both Info-menu and Info-index. In the Info-index case the order from the buffer is alphabetical, so Info-complete-menu-item is returning a collection list in reverse alphabetical order. 

Info-complete-menu-item is saving the cost of an nreverse. It would be useful if it returned the items in the order as found in the buffer, because that order isn't always easily recreated after sorting. In the Info-menu case, that's a logical order of the menu items. In the Info-index case, that happens to be alphabetical without the need for an additional sort.

buffer-list returns the buffers in most recently displayed order because it's useful. I think Info-complete-menu-item should return it's items in a logical order too (and not the reverse of one) even if some popular completion mechanisms hide this by always sorting the list alphabetically before display. 

Ivy seems to show other initial completions in a useful order, to me it seems only it's display of Info commands is wrong, because of this missing idomatic nreverse.

Howard




  reply	other threads:[~2019-12-15 19:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-14 17:18 bug#38614: 26.3; Info completions in reverse order Howard Melman
2019-12-15 16:06 ` Eli Zaretskii
2019-12-15 19:39   ` Howard Melman [this message]
2020-01-03 19:27     ` Howard Melman
2020-08-25 23:09     ` Stefan Kangas
2020-08-25 23:38       ` Howard Melman
2020-08-26 23:20         ` Stefan Kangas
2020-08-26 23:39           ` Howard Melman
2020-08-27  0:04             ` Stefan Kangas
2020-08-27  0:05               ` Howard Melman
2020-08-27  0:45                 ` Stefan Kangas

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=C7458367-94AB-4D09-BFCE-DCE1660C1299@gmail.com \
    --to=hmelman@gmail.com \
    --cc=38614@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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).