unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bugs in newly added completion capabilities.
@ 2005-06-28  2:27 Luc Teirlinck
  2005-06-28 18:47 ` Richard M. Stallman
  0 siblings, 1 reply; 26+ messages in thread
From: Luc Teirlinck @ 2005-06-28  2:27 UTC (permalink / raw)


The following change:

2005-02-22  Kim F. Storm  <storm@cua.dk>

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2005-07-02 12:32 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-28  2:27 Bugs in newly added completion capabilities Luc Teirlinck
2005-06-28 18:47 ` Richard M. Stallman
2005-06-29  3:50   ` Luc Teirlinck
2005-06-29 20:43     ` Richard M. Stallman
2005-06-30  2:29       ` Luc Teirlinck
2005-06-30  7:48         ` Kim F. Storm
2005-06-30  7:50         ` Miles Bader
2005-06-30 12:51           ` Kim F. Storm
2005-06-30 17:19           ` Luc Teirlinck
2005-06-30 17:42           ` Stefan Monnier
2005-06-30 18:28             ` Luc Teirlinck
2005-06-30 19:42               ` Stefan Monnier
2005-07-01  8:14               ` Kim F. Storm
2005-07-01 14:59                 ` Stefan Monnier
2005-07-02 12:32                   ` Richard M. Stallman
2005-06-30 18:32             ` Luc Teirlinck
2005-06-30 19:43               ` Stefan Monnier
2005-07-01  4:03             ` Richard M. Stallman
2005-07-01  4:36               ` Miles Bader
2005-07-01  7:33                 ` David Kastrup
2005-07-01  7:55                   ` Miles Bader
2005-07-01  8:34                 ` Kim F. Storm
2005-07-01 22:45                   ` Richard M. Stallman
2005-07-01  8:30               ` Kim F. Storm
2005-06-30 21:29         ` Richard M. Stallman
2005-06-29  3:56   ` Luc Teirlinck

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).