[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Order of eshell/pcomplete completions when cycling
From: |
Tassilo Horn |
Subject: |
Re: Order of eshell/pcomplete completions when cycling |
Date: |
Fri, 10 Apr 2015 14:19:27 +0200 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
>> > I think you want string-collate-lessp, not string-lessp. AFAIK,
>> > that's what the shells use.
>>
>> Yes, you are right. Unfortunately, it seems the function used for
>> `eshell-cmpl-compare-entry-function' (which is the default value for
>> `pcomplete-compare-entry-function' in eshell buffers) has no effect on
>> the order in which completions are cycled when hitting TAB repeatedly.
>
> Well, then maybe they should, at least as an option?
Yes, of course they should. :-)
I have no deep understanding of the emacs completion stuff. But in
pcomplete.el there is
--8<---------------cut here---------------start------------->8---
(defun pcomplete--entries (&optional regexp predicate)
"Like `pcomplete-entries' but without env-var handling."
(let* ((ign-pred
[...snip...]
(lambda (s p a)
(if (and (eq a 'metadata) pcomplete-compare-entry-function)
`(metadata (cycle-sort-function
. ,(lambda (comps)
(sort comps pcomplete-compare-entry-function)))
,@(cdr (completion-file-name-table s p a)))
(let ((completion-ignored-extensions nil)
(completion-ignore-case pcomplete-ignore-case))
(completion-table-with-predicate
#'comint-completion-file-name-table pred 'strict s p a))))))
--8<---------------cut here---------------end--------------->8---
where the lambda returns a cycle-sort-function using
`pcomplete-compare-entry-function' if asked for completion metadata.
The docs say
,----[ (info "(elisp)Programmed Completion") ]
| ‘cycle-sort-function’
| The value should be a function for sorting completions, when
| ‘completion-cycle-threshold’ is non-‘nil’ and the user is cycling
| through completion alternatives. *Note (emacs)Completion
| Options::. Its argument list and return value are the same as for
| ‘display-sort-function’.
`----
so that seems to be what I am looking for and eshell/pcomplete
initialize it correctly.
The returned lambda is only called via
(complete-with-action action table newstring pred))
where table is that lambda.
I've verified that the lambda is never called with the a(ction) argument
bound to 'metadata, so the cycle-sort-function which would sort using
`pcomplete-compare-entry-function' is never asked for.
Grepping the sources, the only user of cycle-sort-function is
`completion-all-sorted-completions' which is never called by eshell or
pcomplete. So the `pcomplete-compare-entry-function' will never every
be called.
I suspect that there has been a time where that used to work, and in the
meantime the completion stuff has changed and forgotten that some
completion users want sorted completions also without calling
`completion-all-sorted-completions'.
Bye,
Tassilo