all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: Bugs in newly added completion capabilities.
Date: Mon, 27 Jun 2005 21:27:47 -0500 (CDT)	[thread overview]
Message-ID: <200506280227.j5S2Rln23310@raven.dms.auburn.edu> (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)
============================================================

             reply	other threads:[~2005-06-28  2:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28  2:27 Luc Teirlinck [this message]
2005-06-28 18:47 ` Bugs in newly added completion capabilities 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200506280227.j5S2Rln23310@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.