GNU bug report logs -
#26313
25.1; completion: display-sort-function=identity shows reverse
Previous Next
Reported by: Kyle Meyer <kyle <at> kyleam.com>
Date: Thu, 30 Mar 2017 18:36:01 UTC
Severity: minor
Tags: fixed
Merged with 24676
Found in version 25.1
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26313 in the body.
You can then email your comments to 26313 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26313
; Package
emacs
.
(Thu, 30 Mar 2017 18:36:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kyle Meyer <kyle <at> kyleam.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 30 Mar 2017 18:36:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I'm trying to make the *Completions* help buffer display the collection
in the original order passed to completing-read. I found a question
about this on Emacs StackExchange [*1*], and Stefan's advice was to
specify display-sort-function for the completion table.
(defun my-presorted-completion-table (completions)
(lambda (string pred action)
(if (eq action 'metadata)
`(metadata (display-sort-function . ,#'identity))
(complete-with-action action completions string pred))))
(completing-read "test: " (my-presorted-completion-table
'("d" "e" "a" "r")))
Hitting tab to bring up the help buffer shows that this does override
the default alphabetical sorting, but it displays the list in reverse,
with "r" as the first item [*2*].
Replacing "identity" with "nreverse" shows the list in the expected
order. It seems that the collection needs to be reversed to get the
original order because completion-pcm--all-completions returns the items
in reverse, constructing the list with "(dolist _ (push ...))".
However, using nreverse for the display-sort-function messes up the
order displayed for partial completions because
completion-pcm--all-completions returns the result of all-completions
rather than following the "dolist" path described above. For example,
(completing-read "test: " (my-presorted-completion-table
'("db" "dd" "da" "e" "a" "r")))
with "d<TAB>" now shows "da dd db" instead of "db dd da".
Should completion-pcm--all-completions reverse the list before returning
it? With identity as the display-sort-function, this change appears to
give the correct order for both cases above (empty input and partial
input).
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 355d2ee6af..2e2c55db5e 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2994,7 +2994,7 @@ completion-pcm--all-completions
(let ((poss ()))
(dolist (c compl)
(when (string-match-p regex c) (push c poss)))
- poss)))))
+ (nreverse poss))))))
(defun completion-pcm--hilit-commonality (pattern completions)
(when completions
--8<---------------cut here---------------end--------------->8---
[*1*] http://emacs.stackexchange.com/questions/8115/make-completing-read-respect-sorting-order-of-a-collection/8177#8177
[*2*] Evaluated in a buffer visited with "emacs -Q", Emacs 25.1.1
--
Kyle
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26313
; Package
emacs
.
(Thu, 30 Mar 2017 19:04:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 26313 <at> debbugs.gnu.org (full text, mbox):
forcemerge 24676 26313
quit
On Thu, Mar 30, 2017 at 2:34 PM, Kyle Meyer <kyle <at> kyleam.com> wrote:
>
> Should completion-pcm--all-completions reverse the list before returning
> it?
Yeah, it was suggested and approved in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24676#11, but never
installed.
Also related, completion-pcm--filename-try-filter has the same
problem: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25995#8
Forcibly Merged 24676 26313.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Thu, 30 Mar 2017 19:04:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26313
; Package
emacs
.
(Thu, 30 Mar 2017 19:22:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 26313 <at> debbugs.gnu.org (full text, mbox):
Noam Postavsky <npostavs <at> users.sourceforge.net> writes:
> On Thu, Mar 30, 2017 at 2:34 PM, Kyle Meyer <kyle <at> kyleam.com> wrote:
>>
>> Should completion-pcm--all-completions reverse the list before returning
>> it?
>
> Yeah, it was suggested and approved in
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24676#11, but never
> installed.
Thanks. Sorry for missing that report.
--
Kyle
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 21 Jun 2017 02:50:03 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
24676 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 21 Jun 2017 02:50:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 19 Jul 2017 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 335 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.