From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#1085: 23.0.60; all-completions, try-completion inconsistent: Info-read-node-name-1 Date: Tue, 07 Oct 2008 10:52:44 -0400 Message-ID: References: <00b801c92674$b294d550$0200a8c0@us.oracle.com> <014a01c9276c$1f45f740$0200a8c0@us.oracle.com> <000f01c927d3$2963f850$c2b22382@us.oracle.com> <001901c92837$16b82910$0200a8c0@us.oracle.com> Reply-To: Stefan Monnier , 1085@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1223394670 7187 80.91.229.12 (7 Oct 2008 15:51:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Oct 2008 15:51:10 +0000 (UTC) Cc: 1085@emacsbugs.donarmstrong.com, emacs-pretest-bug@gnu.org To: "Drew Adams" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 07 17:52:03 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KnEj8-0003Yf-N4 for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 17:43:59 +0200 Original-Received: from localhost ([127.0.0.1]:43704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnEi4-0002Un-AK for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 11:42:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KnEhl-0002If-FI for bug-gnu-emacs@gnu.org; Tue, 07 Oct 2008 11:42:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KnEhi-0002Gs-6v for bug-gnu-emacs@gnu.org; Tue, 07 Oct 2008 11:42:33 -0400 Original-Received: from [199.232.76.173] (port=41374 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnEhi-0002Gh-0b for bug-gnu-emacs@gnu.org; Tue, 07 Oct 2008 11:42:30 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:36804) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KnECN-0008Ca-Qf for bug-gnu-emacs@gnu.org; Tue, 07 Oct 2008 11:10:11 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m97F9vsX026631; Tue, 7 Oct 2008 08:09:58 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m97F06qu023705; Tue, 7 Oct 2008 08:00:06 -0700 X-Loop: don@donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 07 Oct 2008 15:00:06 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1085 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1085-submit@emacsbugs.donarmstrong.com id=B1085.122339117322289 (code B ref 1085); Tue, 07 Oct 2008 15:00:06 +0000 Original-Received: (at 1085) by emacsbugs.donarmstrong.com; 7 Oct 2008 14:52:53 +0000 Original-Received: from chene.dit.umontreal.ca (chene.dit.umontreal.ca [132.204.246.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m97Eqk8o022283 for <1085@emacsbugs.donarmstrong.com>; Tue, 7 Oct 2008 07:52:47 -0700 Original-Received: from alfajor.home (vpn-132-204-232-40.acd.umontreal.ca [132.204.232.40]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id m97EqjGo021881; Tue, 7 Oct 2008 10:52:45 -0400 Original-Received: by alfajor.home (Postfix, from userid 20848) id AF4C91C54B; Tue, 7 Oct 2008 10:52:44 -0400 (EDT) In-Reply-To: <001901c92837$16b82910$0200a8c0@us.oracle.com> (Drew Adams's message of "Mon, 6 Oct 2008 21:42:21 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3119=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Tue, 07 Oct 2008 11:42:32 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:21211 gmane.emacs.pretest.bugs:23171 Archived-At: > 1. User's input should be a prefix of what it is completed to in the > minibuffer, which should be the same as the common prefix of all its > completions, the result of `try-completion': Let's keep "completion in the minibuffer" for another thread and let's focus on try0completion, all-completions, and test-competion. >> M-: (try-completion "(el" 'Info-read-node-name-1) >> >> It returns "(elisp)", meaning that this is the common prefix of all >> completions of "(el". [This is reasonable, and it satisfies the >> requirement that "(el" is a prefix of "(elisp)".] I believe this is indeed a valid invariant. At least I can't remember any case where this needed to be broken. > 2. `all-completions' elements correspond to `test-completion': >> And each of the completions returned by `all-completions' must >> also satisfy `test-completion'. In particular, >> (test-completion STRG (all-completions strg TABLE)) must always >> return t, for all STRG and TABLE. In this case, for STRG = "(el" and >> TABLE = `Info-read-node-name-1', it returns nil. This is not a valid invariant. E.g. let's say you want a completion table for "png files". You'll probably want the completion to happen "one directory at a time", like all other file completions in Emacs, so all-completions will have to be able to return directories, even though these are not png files and will hence be rejected by test-completion. > 3. `all-completions' elements correspond to `try-completion': >> the valid completions returned by `all-completions' have the >> common prefix that is returned by `try-completion' (which >> must in turn have the input as its prefix [see #1]). As discussed, this would imply that the code that builds *Completions* figure out which part of the prefix to drop. So this is the feature about which I said: I have banged my head against this problem for a long time, while working on the minibuffer.el code (and its predecessors), so I don't expect to change my mind any time soon. The only thing you'd accomplish with your proposal is "change", but it would just shift the problems from one place to another without any actual benefit. So of the 3 invariants you request, the first already holds, the second cannot always hold, and the third will not always hold because it would introduce problems elsewhere. > P.S. Could you explain a little about boundaries and what you meant > about using that feature. This is not clear to me. minibuffer.el says: ;; - The `action' can be (additionally to nil, t, and lambda) of the form ;; (boundaries . SUFFIX) in which case it should return ;; (boundaries START . END). See `completion-boundaries'. ;; Any other return value should be ignored (so we ignore values returned ;; from completion tables that don't know about this new `action' form). So, (funcall TABLE STRING PRED '(boundary . "")) should return (boundaries START END) where END should be (length STRING) or nil, and START will be the length of the prefix of STRING which is missing from the all-completions output (e.g. for file completion, START should be more or less equivalent to (length (file-name-directory STRING))). Note that some completion tables may not know about this new `boundaries' argument, and will hence return something different from (boundaries START END), so any code using this new feature should treat any other return value as equivalent to (boundaries 0 (length STRING)). As for your invariant 3, you should be able to recover it if you use something like: (defun drew-all-completions (string table pred) (if (not (functionp table)) (all-completions string table pred) (let* ((bs (funcall table string pred '(boundaries . ""))) (prefix (and (eq 'boundaries (car-safe bs)) (integerp (car-safe (cdr bs))) (substring string 0 (cadr bs))))) (mapcar (lambda (s) (concat prefix s)) (all-completions string table pred))))) I'm pretty sure this code won't work as-is, but hopefully, you get the idea. Stefan