[Top][All Lists]

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

Bug in completing-read

From: Luc Teirlinck
Subject: Bug in completing-read
Date: Wed, 17 Dec 2003 21:25:28 -0600 (CST)

If one evaluates:

(read-from-minibuffer "Input: " '("123456789" . 3))

point appears on the "3" in the minibuffer.

But if one evaluates:

(completing-read "Input: " '("123456789") nil nil '("123456789" . 3))

point appears on the "4" in the minibuffer.

This is inconsistent and it also contradicts the documentation string
of `completing-read'.  In other words, the behavior of
`completing-read' is an obvious bug.  It is trivial to fix, in fact I
"inadvertently" fixed it in my own private Emacs.  

In another thread ("read-from-minibuffer and friends"), I proposed a
patch that will move the handling of string-integer conses of the type
used above from Fread_from_minibuffer into read_minibuf.  (Not yet
installed because of the Savannah situation.)  After proposing that
patch I made some small further changes.  (I got rid of variables that
were no longer used, but which I inadvertently forgot to remove.)  But
then I noticed nearly identical code in Fcompleting_read.  I removed
this now redundant code.  But while diffing I noticed that a "-1" was
missing in a formula in the removed code.  At first sight, wonderful.
Code gone, bug gone, end of story.  Now the problem.

People using such arguments to `completing-read' apparently found it
easier to just get around the bug by putting the "-1" in their own
code, rather than reporting it or fixing it in minibuf.c.

So now we are left with the following choice:

1.  Document this inconsistency in the documentation string of
    `completing-read', as well as in the Elisp manual, and say that it
    exists for historical compatibility.  (I could do that, if that is
    what we decide to do.)

2.  Fix the bug and also fix existing code that relies on the bug.  (I
    could trivially fix the bug, if that is what we decide to do.  As
    mentioned above, I have already fixed it in my personal Emacs.
    Finding _all_ code relying on the bug seems very non-trivial,
    however, because `completing-read' is used so often.)


M-x load-library RET ffap

M-: (ffap-read-file-or-url "Input: " "myfile") RET


Input: ~/emacscvsdir/emacs/lisp/myfile

with point on the `m' of myfile, as probably intended.  Fixing the bug
in `completing-read' would put it on the last `/'.

So do we fix this bug or make the inconsistency an "official, but
deprecated, feature" by documenting it?



reply via email to

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