From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Bugs in newly added completion capabilities. Date: Mon, 27 Jun 2005 21:27:47 -0500 (CDT) Message-ID: <200506280227.j5S2Rln23310@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1119925799 7367 80.91.229.2 (28 Jun 2005 02:29:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 28 Jun 2005 02:29:59 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 28 04:29:51 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dn5r3-00018k-BE for ged-emacs-devel@m.gmane.org; Tue, 28 Jun 2005 04:29:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dn5yo-00015D-A0 for ged-emacs-devel@m.gmane.org; Mon, 27 Jun 2005 22:37:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dn5t0-0007Rh-Oj for emacs-devel@gnu.org; Mon, 27 Jun 2005 22:31:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dn5sp-0007LQ-4P for emacs-devel@gnu.org; Mon, 27 Jun 2005 22:31:37 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dn5sm-0007IN-AJ for emacs-devel@gnu.org; Mon, 27 Jun 2005 22:31:28 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Dn5vF-0002K5-SA for emacs-devel@gnu.org; Mon, 27 Jun 2005 22:34:02 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j5S2TWCK019004 for ; Mon, 27 Jun 2005 21:29:32 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j5S2Rln23310; Mon, 27 Jun 2005 21:27:47 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:39712 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:39712 The following change: 2005-02-22 Kim F. Storm * minibuf.c (Ftry_completion, Fall_completions): Allow both string and symbol keys in alists and hash tables. has some remaining bugs and inconsistencies. First of all, it does not work perfectly for try-completion and all-completions as the ielm run below shows. This problem actually prevents minibuffer completion from working in the patch I sent for Custom themes (so the problem occurs in natural, practical situations): ELISP> (try-completion "b" '(aa bb)) *** Eval error *** Invalid function: (aa bb) ELISP> (try-completion "b" '("aa" bb)) "bb" ELISP> The problem is that try-completion and friends try to handle both lists of symbols and anonymous lambda expressions. They check whether a list is an anonymous lambda expression by checking whether its car is a symbol other than nil. Why not just simply check whether the car is lambda? The patch below implements this for try-completion, all-completions and test-completion (which has the same problem). After that, a user would still have to make sure that his list of symbols does not start with lambda, which we could point out in the docs. That may not be pretty, but should not yield too much inconvenience in practice. This leaves the inconsistency that try-completion and all-completions now can handle symbols in alists, lists and hash-tables, but not test-completion. Even after applying my patch, one gets: ELISP> (test-completion "bb" '(aa bb)) nil ELISP> I do not know what the best fix for that is. Would we be willing to go as far as to make assoc-string treat symbols as strings in exactly the same way, which would automatically take care of test-completion? Here is my patch, which I can install if desired: ===File ~/minibuf.c-diff==================================== *** minibuf.c 25 Mar 2005 14:53:52 -0600 1.280 --- minibuf.c 27 Jun 2005 15:51:51 -0500 *************** *** 1217,1224 **** int type = HASH_TABLE_P (alist) ? 3 : VECTORP (alist) ? 2 : NILP (alist) || (CONSP (alist) ! && (!SYMBOLP (XCAR (alist)) ! || NILP (XCAR (alist)))); int index = 0, obsize = 0; int matchcount = 0; int bindcount = -1; --- 1217,1223 ---- int type = HASH_TABLE_P (alist) ? 3 : VECTORP (alist) ? 2 : NILP (alist) || (CONSP (alist) ! && !EQ (XCAR (alist), Qlambda)); int index = 0, obsize = 0; int matchcount = 0; int bindcount = -1; *************** *** 1480,1487 **** int type = HASH_TABLE_P (alist) ? 3 : VECTORP (alist) ? 2 : NILP (alist) || (CONSP (alist) ! && (!SYMBOLP (XCAR (alist)) ! || NILP (XCAR (alist)))); int index = 0, obsize = 0; int bindcount = -1; Lisp_Object bucket, tem, zero; --- 1479,1485 ---- int type = HASH_TABLE_P (alist) ? 3 : VECTORP (alist) ? 2 : NILP (alist) || (CONSP (alist) ! && !EQ (XCAR (alist), Qlambda)); int index = 0, obsize = 0; int bindcount = -1; Lisp_Object bucket, tem, zero; *************** *** 1754,1761 **** CHECK_STRING (string); ! if ((CONSP (alist) && (!SYMBOLP (XCAR (alist)) || NILP (XCAR (alist)))) ! || NILP (alist)) { tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil); if NILP (tem) --- 1752,1758 ---- CHECK_STRING (string); ! if ((CONSP (alist) && !EQ (XCAR (alist), Qlambda)) || NILP (alist)) { tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil); if NILP (tem) ============================================================