From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Order of eshell/pcomplete completions when cycling Date: Fri, 10 Apr 2015 14:19:27 +0200 Message-ID: <87bniwmb00.fsf@gnu.org> References: <871tjt49bj.fsf@gnu.org> <83y4m1e0z8.fsf@gnu.org> <87k2xkmeb2.fsf@gnu.org> <83oamwtej9.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1428668417 13602 80.91.229.3 (10 Apr 2015 12:20:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Apr 2015 12:20:17 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 10 14:20:08 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YgXuW-0005FK-8p for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 14:19:48 +0200 Original-Received: from localhost ([::1]:39014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgXuV-0003BX-HX for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 08:19:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgXuI-0003BJ-1f for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 08:19:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgXuF-0003p1-AF for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 08:19:34 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:51005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgXuE-0003nG-V2 for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 08:19:31 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8AF0020137 for ; Fri, 10 Apr 2015 08:19:26 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Fri, 10 Apr 2015 08:19:30 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=sh1cLSqry72Tj6R KAsgiXyOvccA=; b=mZjT3/MI3rnKe/tFWdXJfj/tY+a8mvh+DiRJqM4qJBFshz/ IGFm92wCazeMkB52Vb7PoG2D+3VRQwaHuS9MxA5yhtVadlvv4oE98c3L9v4m6HdN uZFdy8RZTawXdH884Sj1B0m/WJPEY+w4L+CO0/N9cu08wXJ6sYZzI5cdrp74= X-Sasl-enc: tuqzN8PphA4CUbnCeufw9jUeh2nCu0GD3WYPnmcQ88nQ 1428668370 Original-Received: from thinkpad-t440p (unknown [2.163.240.161]) by mail.messagingengine.com (Postfix) with ESMTPA id A6774C00011; Fri, 10 Apr 2015 08:19:29 -0400 (EDT) Mail-Followup-To: Eli Zaretskii , help-gnu-emacs@gnu.org In-Reply-To: <83oamwtej9.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 10 Apr 2015 14:21:14 +0300") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.28 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103629 Archived-At: Eli Zaretskii writes: >> > I think you want string-collate-lessp, not string-lessp. AFAIK, >> > that's what the shells use. >>=20 >> 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") ] | =E2=80=98cycle-sort-function=E2=80=99 | The value should be a function for sorting completions, when | =E2=80=98completion-cycle-threshold=E2=80=99 is non-=E2=80=98nil=E2= =80=99 and the user is cycling | through completion alternatives. *Note (emacs)Completion | Options::. Its argument list and return value are the same as for | =E2=80=98display-sort-function=E2=80=99. `---- 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