* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2015-08-17 17:25 bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Keith David Bershatsky
@ 2016-05-04 7:40 ` Marcin Borkowski
2016-05-04 18:14 ` Keith David Bershatsky
` (3 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Marcin Borkowski @ 2016-05-04 7:40 UTC (permalink / raw)
To: Keith David Bershatsky; +Cc: 21284
On 2015-08-17, at 10:25, Keith David Bershatsky <esq@lawlist.com> wrote:
> The function `completion-file-name-table' uses `(setq all (nreverse comp))' instead of `(setq all comp)'.
>
> This has the effect of reversing what was accomplished when `pcomplete-compare-entry-function' is set to `'string-lessp'.
>
> In a nutshell, the completions are in reverse alphabetical order as a result of `(setq all (nreverse comp))'.
>
> This was tested in an eshell buffer by typing at a prompt: rm [space tab]; and, with `lawlist-eshell-cmpl-compare-entry-function` set to `'string-lessp'.
Hi,
I tried to reproduce it on GNU Emacs 25.1.50.9 (commit fafdfcb) and
failed. However, I'm not sure whether I understood your report
correctly. My Emacs doesn't seem to have
`lawlist-eshell-cmpl-compare-entry-function', only
`eshell-cmpl-compare-entry-function'. Did you mean that variable?
I tried to set it to `'string-lessp', but nothing seemed to change after
"rm [space] [tab]" in Eshell.
> Thanks,
>
> Keith
Best,
--
Marcin
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2015-08-17 17:25 bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Keith David Bershatsky
2016-05-04 7:40 ` Marcin Borkowski
@ 2016-05-04 18:14 ` Keith David Bershatsky
2022-02-13 8:52 ` bug#21284: eshell does not sort completion candidates Lars Ingebrigtsen
2016-06-06 2:50 ` bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Noam Postavsky
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Keith David Bershatsky @ 2016-05-04 18:14 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: 21284
Thank you, Marcin, for taking a look at 21284.
I apologize for mislabeling the variable. It turns out that the same erroneous behavior is observable with Emacs -Q. The `*Completions*` are in reverse alphabetical order.
Step 1: Launch the graphical version of Emacs -Q.
Step 2: M-x eshell
Step 3: cd to a directory containing files and folders with a variety of different names beginning with letters a to z.
Step 4: type rm
Step 5: hit the space bar
Step 6: hit the tab key
Step 7: The *Completions* are in reverse alphabetical order.
Thanks,
Keith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> Hi,
>
> I tried to reproduce it on GNU Emacs 25.1.50.9 (commit fafdfcb) and
> failed. However, I'm not sure whether I understood your report
> correctly. My Emacs doesn't seem to have
> `lawlist-eshell-cmpl-compare-entry-function', only
> `eshell-cmpl-compare-entry-function'. Did you mean that variable?
> I tried to set it to `'string-lessp', but nothing seemed to change after
> "rm [space] [tab]" in Eshell.
>
> > Thanks,
> >
> > Keith
>
> Best,
>
> --
> Marcin
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: eshell does not sort completion candidates
2016-05-04 18:14 ` Keith David Bershatsky
@ 2022-02-13 8:52 ` Lars Ingebrigtsen
2022-03-14 10:33 ` Lars Ingebrigtsen
0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-13 8:52 UTC (permalink / raw)
To: Keith David Bershatsky; +Cc: Marcin Borkowski, 21284
Keith David Bershatsky <esq@lawlist.com> writes:
> Step 1: Launch the graphical version of Emacs -Q.
>
> Step 2: M-x eshell
>
> Step 3: cd to a directory containing files and folders with a variety
> of different names beginning with letters a to z.
>
> Step 4: type rm
>
> Step 5: hit the space bar
>
> Step 6: hit the tab key
>
> Step 7: The *Completions* are in reverse alphabetical order.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
I tried to reproduce this in Emacs 29, but was unable to. Are you still
seeing this problem in recent Emacs versions?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2015-08-17 17:25 bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Keith David Bershatsky
2016-05-04 7:40 ` Marcin Borkowski
2016-05-04 18:14 ` Keith David Bershatsky
@ 2016-06-06 2:50 ` Noam Postavsky
2016-06-06 14:43 ` Eli Zaretskii
2016-06-06 16:19 ` Keith David Bershatsky
2016-06-06 20:00 ` Keith David Bershatsky
4 siblings, 1 reply; 13+ messages in thread
From: Noam Postavsky @ 2016-06-06 2:50 UTC (permalink / raw)
To: 21284; +Cc: Keith David Bershatsky, Marcin Borkowski
tag 21284 unreproducible
quit
I'm getting completions in what looks like a random order, here are
the first few lines for completions in the emacs src directory:
Possible completions are:
undo.o ChangeLog.12 eval.o insdel.o
xfaces.o sysdep.o category.o marker.o
search.c ChangeLog.10 fontset.o dynlib.h
kqueue.c deps/ lastfile.o dired.o
insdel.c w32fns.c textprop.o xselect.c
inotify.c doprnt.c cmds.c xdisp.c
data.o fontset.c xsettings.h character.o
keymap.c xsettings.o emacsgtkfixed.h systime.h
syntax.h bytecode.o character.h deps.mk
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2016-06-06 2:50 ` bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Noam Postavsky
@ 2016-06-06 14:43 ` Eli Zaretskii
2016-06-06 23:12 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2016-06-06 14:43 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 21284, esq, mbork
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sun, 5 Jun 2016 22:50:10 -0400
> Cc: Keith David Bershatsky <esq@lawlist.com>, Marcin Borkowski <mbork@mbork.pl>
> I'm getting completions in what looks like a random order, here are
> the first few lines for completions in the emacs src directory:
I suspect that there's a hidden factor here: the order in which the
'readdir' libc function returns the directory entries. On GNU/Linux,
the order is arbitrary (AFAIK, it's the order of the entries in the
directory file). On MS-Windows, the order is alphabetic, so reversing
will produce the reverse alphabetic order. I don't know what happens
on OS X.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2016-06-06 14:43 ` Eli Zaretskii
@ 2016-06-06 23:12 ` Noam Postavsky
0 siblings, 0 replies; 13+ messages in thread
From: Noam Postavsky @ 2016-06-06 23:12 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21284, Keith David Bershatsky, Marcin Borkowski
tag 21284 - unreproducible
severity 21284 minor
quit
On Mon, Jun 6, 2016 at 10:43 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> I suspect that there's a hidden factor here: the order in which the
> 'readdir' libc function returns the directory entries. On GNU/Linux,
> the order is arbitrary (AFAIK, it's the order of the entries in the
> directory file). On MS-Windows, the order is alphabetic, so reversing
> will produce the reverse alphabetic order. I don't know what happens
> on OS X.
Oh yeah, I see reversed order on Windows.
On Mon, Jun 6, 2016 at 12:19 PM, Keith David Bershatsky <esq@lawlist.com> wrote:
> I am on OS X and the default sort order is alphabetic, which gets reversed by `completion-file-name-table` because it uses `nreverse'.
Actually, the result from `file-name-all-completions` is already
reversed. `completion-file-name-table` then reverses it twice: once in
the loop (dolist (tem all) (... (push tem comp))), and the `nreverse`
call to undo it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2015-08-17 17:25 bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Keith David Bershatsky
` (2 preceding siblings ...)
2016-06-06 2:50 ` bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Noam Postavsky
@ 2016-06-06 16:19 ` Keith David Bershatsky
2016-06-06 18:50 ` Eli Zaretskii
2016-06-06 20:00 ` Keith David Bershatsky
4 siblings, 1 reply; 13+ messages in thread
From: Keith David Bershatsky @ 2016-06-06 16:19 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21284, Marcin Borkowski, Noam Postavsky
I am on OS X and the default sort order is alphabetic, which gets reversed by `completion-file-name-table` because it uses `nreverse'.
Keith
At Mon, 06 Jun 2016 17:43:04 +0300,
Eli Zaretskii wrote:
>
> . . .
>
> I suspect that there's a hidden factor here: the order in which the
> 'readdir' libc function returns the directory entries. On GNU/Linux,
> the order is arbitrary (AFAIK, it's the order of the entries in the
> directory file). On MS-Windows, the order is alphabetic, so reversing
> will produce the reverse alphabetic order. I don't know what happens
> on OS X.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2016-06-06 16:19 ` Keith David Bershatsky
@ 2016-06-06 18:50 ` Eli Zaretskii
2016-06-08 2:43 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2016-06-06 18:50 UTC (permalink / raw)
To: Keith David Bershatsky; +Cc: 21284, mbork, npostavs
> Date: Mon, 06 Jun 2016 09:19:07 -0700
> From: Keith David Bershatsky <esq@lawlist.com>
> Cc: 21284@debbugs.gnu.org,Noam Postavsky <npostavs@users.sourceforge.net>,Marcin Borkowski <mbork@mbork.pl>
>
> I am on OS X and the default sort order is alphabetic, which gets reversed by `completion-file-name-table` because it uses `nreverse'.
Then what exactly is the problem here? Emacs doesn't know in what
order the files are returned, it considers the order random.
Reversing a randomly ordered list produces another randomly ordered
list. Applications that need to present the list in some specific
order need to do that explicitly. For example, "C-x C-f TAB TAB" does
display the files in alphabetic order for me, not in reverse
alphabetic order.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2016-06-06 18:50 ` Eli Zaretskii
@ 2016-06-08 2:43 ` Noam Postavsky
0 siblings, 0 replies; 13+ messages in thread
From: Noam Postavsky @ 2016-06-08 2:43 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21284, Keith David Bershatsky, Marcin Borkowski
retitle 21284 eshell does not sort completion candidates
quit
On Mon, Jun 6, 2016 at 2:50 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> Then what exactly is the problem here? Emacs doesn't know in what
> order the files are returned, it considers the order random.
> Reversing a randomly ordered list produces another randomly ordered
> list. Applications that need to present the list in some specific
> order need to do that explicitly. For example, "C-x C-f TAB TAB" does
> display the files in alphabetic order for me, not in reverse
> alphabetic order.
So the problem is that eshell's completion doesn't sort its candidates.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2015-08-17 17:25 bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'? Keith David Bershatsky
` (3 preceding siblings ...)
2016-06-06 16:19 ` Keith David Bershatsky
@ 2016-06-06 20:00 ` Keith David Bershatsky
2016-06-07 2:36 ` Eli Zaretskii
4 siblings, 1 reply; 13+ messages in thread
From: Keith David Bershatsky @ 2016-06-06 20:00 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21284, Marcin Borkowski, Noam Postavsky
If there is/are valid reason(s) to reverse the order, then perhaps consider mentioning one or more of those reasons in a comment within `completion-file-name-table' along with a mention of bug 21284.
If there is no valid reason whatsoever to reverse the order, then perhaps consider removing `nreverse` from `completion-file-name-table`.
If the issue is "de minimus", then the bug report can be closed without further ado.
Keith
At Mon, 06 Jun 2016 21:50:05 +0300,
Eli Zaretskii wrote:
>
> . . .
>
> Then what exactly is the problem here? Emacs doesn't know in what
> order the files are returned, it considers the order random.
> Reversing a randomly ordered list produces another randomly ordered
> list. Applications that need to present the list in some specific
> order need to do that explicitly. For example, "C-x C-f TAB TAB" does
> display the files in alphabetic order for me, not in reverse
> alphabetic order.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#21284: 25.0.50; `completion-file-name-table' should/not use `nreverse'?
2016-06-06 20:00 ` Keith David Bershatsky
@ 2016-06-07 2:36 ` Eli Zaretskii
0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2016-06-07 2:36 UTC (permalink / raw)
To: Keith David Bershatsky; +Cc: 21284, mbork, npostavs
> Date: Mon, 06 Jun 2016 13:00:40 -0700
> From: Keith David Bershatsky <esq@lawlist.com>
> Cc: 21284@debbugs.gnu.org,Marcin Borkowski <mbork@mbork.pl>,Noam Postavsky <npostavs@users.sourceforge.net>
>
> If there is/are valid reason(s) to reverse the order, then perhaps consider mentioning one or more of those reasons in a comment within `completion-file-name-table' along with a mention of bug 21284.
>
> If there is no valid reason whatsoever to reverse the order, then perhaps consider removing `nreverse` from `completion-file-name-table`.
>
> If the issue is "de minimus", then the bug report can be closed without further ado.
I believe the reason is the usual one: we create the list by pushing
each new element onto it, so the result comes in reverse order of the
files. The call to nreverse then restores the original order. IOW,
this is an implementation detail.
^ permalink raw reply [flat|nested] 13+ messages in thread