emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: completing-read case problem


From: Markus Rost
Subject: Re: completing-read case problem
Date: Sun, 14 Nov 2004 02:03:16 -0500

> It is unreasonable to use a case-sensitive predicate with
> completion-ignore-case non-nil.

But it can be inconvenient if one has to avoid using a case-sensitive
predicate.

The original problem which led to the bug-report was the following:
Call

M-x customize-group Mouse [return] 

[Note the upper case in "Mouse"]

You get a buffer "*Customize Group: Mouse*" showing no members of the
(non-empty) group 'mouse -- which is not what is intended.  This
problem appears because of completing-read with non-nil
completion-ignore-case in customize-group.  completing-read returns
"Mouse", which is not the symbol-name of group 'mouse.  I guess the
problem should be fixed somehow.

Next kill that buffer and repeat the first procedure:

C-x k [kill-buffer]
M-x customize-group Mouse [return]

Now you get a buffer "*Customize Group: Mouse*" with correct contents.
The reason is that meanwhile "Mouse" has been put into obarray by some
Custom code, which somehow makes completing-read return "mouse".
completing-read should have returned "mouse" already on the first try.

Perhaps there is a good fix by changing customize-group, but I rather
thought that better completing-read should behave differently as it
does now.  As I understand, the output of completing-read should be
always a member of its argument TABLE narrowed to a subset by argument
PREDICATE.  The determination of the subset should not depend on
completion-ignore-case.  Now if completion-ignore-case is non-nil,
then some member of that subset which equals (up to case) the input
should be returned.  And, one could add, preferably the exact
case-sensitive match, if it exists in the subset, should be returned.

One may experiment with the following form:

(let ((completion-ignore-case t))
  (completing-read "Give me ABC: "
                   (list "abc")
                   (lambda (string)
                     (string= string "abc"))
                   t
                   ))

With input "ABC" it returns "ABC", which I think is incorrect -- at
least it may lead to surprises in programs which assume that the
output of completing-read is always an exact member of TABLE,
restricted by PREDICATE.

The form

(let ((completion-ignore-case t))
  (completing-read "Give me ABC: "
                   (list "ABC" "abc")
                   (lambda (string)
                     (string= string "abc"))
                   t
                   ))

however correctly returns "abc" on input "ABC".  Unlike

(let ((completion-ignore-case t))
  (completing-read "Give me ABC: "
                   (list "abc" "ABC")
                   (lambda (string)
                     (string= string "abc"))
                   t
                   ))

which returns "ABC" on input "ABC".




reply via email to

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