emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bugs in newly added completion capabilities.


From: Luc Teirlinck
Subject: Bugs in newly added completion capabilities.
Date: Mon, 27 Jun 2005 21:27:47 -0500 (CDT)

The following change:

2005-02-22  Kim F. Storm  <address@hidden>

            * 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)
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]