From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" 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: Sun, 5 Oct 2008 15:53:50 -0700 Message-ID: <013601c9273d$3c20a330$0200a8c0@us.oracle.com> References: <00b801c92674$b294d550$0200a8c0@us.oracle.com> <00be01c92677$7951fdb0$0200a8c0@us.oracle.com> Reply-To: Drew Adams , 1085@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1223248242 30519 80.91.229.12 (5 Oct 2008 23:10:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 Oct 2008 23:10:42 +0000 (UTC) To: <1085@emacsbugs.donarmstrong.com>, Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 06 01:11:40 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 1KmclH-0005cV-Lh for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Oct 2008 01:11:40 +0200 Original-Received: from localhost ([127.0.0.1]:50331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KmckC-0004SF-UR for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Oct 2008 19:10:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kmcjh-0004KS-Hy for bug-gnu-emacs@gnu.org; Sun, 05 Oct 2008 19:10:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kmcjg-0004Jx-Uz for bug-gnu-emacs@gnu.org; Sun, 05 Oct 2008 19:10:01 -0400 Original-Received: from [199.232.76.173] (port=48403 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kmcjg-0004Jt-HI for bug-gnu-emacs@gnu.org; Sun, 05 Oct 2008 19:10:00 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45582) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kmcjf-0007D5-IT for bug-gnu-emacs@gnu.org; Sun, 05 Oct 2008 19:10:00 -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 m95N9vH1011114; Sun, 5 Oct 2008 16:09:57 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m95N04ck008147; Sun, 5 Oct 2008 16:00:04 -0700 X-Loop: don@donarmstrong.com Resent-From: "Drew Adams" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sun, 05 Oct 2008 23:00:04 +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.12232472326785 (code B ref 1085); Sun, 05 Oct 2008 23:00:04 +0000 Original-Received: (at 1085) by emacsbugs.donarmstrong.com; 5 Oct 2008 22:53:52 +0000 Original-Received: from agminet01.oracle.com (agminet01.oracle.com [141.146.126.228]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m95MrmF9006777 for <1085@emacsbugs.donarmstrong.com>; Sun, 5 Oct 2008 15:53:49 -0700 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id m95MrfbJ000409; Sun, 5 Oct 2008 17:53:41 -0500 Original-Received: from acsmt701.oracle.com (acsmt701.oracle.com [141.146.40.71]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m95Mrd1F018049; Sun, 5 Oct 2008 16:53:40 -0600 Original-Received: from dradamslap1 (/24.23.165.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 05 Oct 2008 22:53:39 +0000 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <00be01c92677$7951fdb0$0200a8c0@us.oracle.com> Thread-Index: AckmdLI3jEaez6OqTMujV9yEDqzNRAAAj08wAC3xPDA= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sun, 05 Oct 2008 19:10:01 -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:21143 gmane.emacs.pretest.bugs:23153 Archived-At: > From: Drew Adams Sent: Saturday, October 04, 2008 4:18 PM > > From: Drew Adams Sent: Saturday, October 04, 2008 3:58 PM > > > > emacs -Q > > C-h i > > > > 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)".] > > > > M-: (all-completions "(el" 'Info-read-node-name-1) > > > > It returns ("elisp"), meaning that the only valid > completion of "(el" > > is "elisp". But "elisp" does not have the common prefix "(elisp)" as > > determined by `try-completion', and "elisp" does not even have the > > input "(el" as a prefix. This is inconsistent. `all-completions' > > should return ("(elisp)") in this case. > > > > Lisp code needs to be able to depend on the fact that 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). > > > > 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. > > > > One should be able to use `all-completions' to construct a cons > > completion table that is equivalent to the original TABLE argument, > > regardless of how TABLE is defined (e.g. function, obarray). That > > is, when used with the same inputs it should have the same effect, > > in particular for `try-completion', `all-completions', and > > `test-completion'. > > > > I don't know if this is a bug for Info-read-node-name-1 (or -2) or a > > bug for one of the `minibuffer.el' functions that it uses. The code > > is a bit hard to follow. > > > > > > In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600) > > of 2008-10-03 on LENNART-69DE564 > > Windowing system distributor `Microsoft Corp.', version 5.1.2600 > > configured using `configure --with-gcc (3.4) --no-opt > > --cflags -Ic:/g/include > > -fno-crossjumping' > > FWIW, Emacs 22 also has the same problem, albeit differently: > > (try-completion "(el" 'Info-read-node-name-1) -> "(elisp" > (all-completions "(el" 'Info-read-node-name-1) -> ("elisp") > > So the problem is likely not with the `minibuffer.el' code. > > In GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) > of 2008-09-06 on SOFT-MJASON > Windowing system distributor `Microsoft Corp.', version 5.1.2600 > configured using `configure --with-gcc (3.4)' I'm not sure this is a complete fix, but this code makes some progress at least. It seems to DTRT, but I haven't tested it extensively. What I tried to do was make it DTRT for `code' = t (in the first `cond' clause - I did not adjust the second). (defun Info-read-node-name-1 (string predicate code) (cond ;; First complete embedded file names. ((string-match "\\`(\\([^)]*\\)\\().*\\)?\\'" string) ; <=== 1 (let* ((node (match-string 2 string)) (ctwc (completion-table-with-context "(" (apply-partially 'completion-table-with-terminator (or node ")") ; <=== 2 (apply-partially 'Info-read-node-name-2 Info-directory-list (mapcar 'car Info-suffix-list))) (match-string 1 string) ; <=== 3 predicate code))) (cond ((eq code nil) ctwc) ((eq code t) (mapcar (lambda (file) ; <=== 4 (concat "(" file (or node ")"))) ctwc)) (t t)))) ;; If a file name was given, then any node is fair game. ((string-match "\\`(" string) (cond ((eq code nil) string) ((eq code t) nil) (t t))) ;; Otherwise use Info-read-node-completion-table. (t (complete-with-action code Info-read-node-completion-table string predicate)))) 1. I changed the regexp so it matches also a possible closing paren and node name. 2. I included the node name, if any, as the terminator in the call to `completion-table-with-terminator'. 3. I changed (substring string 1) to (match-string 1 string), to pick up just the file name, without closing paren. 4. I added the `mapcar' for a t `code', to wrap each of the file names in (): ("elisp") -> ("(elisp)"). Previously, the code just returned nil (meaning no candidates) for `code' = t. I did not try to look at or test the second clause of the first `cond': (string-match "\\`(" string). I have no idea if it is correct - it's not even clear to me what this clause is for. But it too returns nil (no candidates) for a `code' value of t, so it seems suspect. It would be great if someone else would please take a look and finish the job. I think the code above is at least an improvement and doesn't introduce any problems, but it should be checked, of course. HTH.