all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Order of eshell/pcomplete completions when cycling
Date: Fri, 10 Apr 2015 14:19:27 +0200	[thread overview]
Message-ID: <87bniwmb00.fsf@gnu.org> (raw)
In-Reply-To: <83oamwtej9.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 10 Apr 2015 14:21:14 +0300")

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



  reply	other threads:[~2015-04-10 12:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 15:20 Order of eshell/pcomplete completions when cycling Tassilo Horn
2015-04-09 16:10 ` Eli Zaretskii
2015-04-10 11:08   ` Tassilo Horn
2015-04-10 11:21     ` Eli Zaretskii
2015-04-10 12:19       ` Tassilo Horn [this message]
2015-04-10 12:36         ` Stefan Monnier
2015-04-10 13:53           ` Tassilo Horn
2015-04-10 17:34             ` Stefan Monnier

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bniwmb00.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.