unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bug in minibuffer-complete-and-exit, fix included
@ 2005-12-27  8:38 Ryan Barrett
  2005-12-27 16:36 ` Stefan Monnier
  2005-12-27 18:27 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Ryan Barrett @ 2005-12-27  8:38 UTC (permalink / raw)


hi all. i recently noticed a bug in minibuffer-complete-and-exit. if
completion-ignore-case is t, and the minibuffer contains a valid completion in
the wrong case, its case isn't fixed. it should be.

sorry, that was a mouthful. :P here's an example. if foo is a possible
completion, and you enter FoO in the minibuffer, minibuffer-complete-and-exit
returns FoO. it should return foo instead.

this spreads to other code that uses the minibuffer. for example, read-buffer
has an optional arg require-match. if t, an existing buffer name must be
entered. the list of existing buffer names is used as completions. if
completion-ignore-case is t, and you enter an existing buffer name *in the
wrong case*, it's not completed to the right case. (same with read-file-name
and mustmatch.)

here's a test case. run emacs -q, then evaluate these forms:

   (setq completion-ignore-case t)
   (read-buffer "buffer name: " nil t)

enter *scrATCH* at the prompt. it returns *scrATCH*, but it should return
*scratch*.

the patch below, against CVS, fixes this. if i understand the process right,
it's small enough that you can include it without papers. hopefully it's also
small enough to consider for the emacs 22 release.


*** minibuf.c       21 Dec 2005 17:33:40 -0000      1.297
--- minibuf.c       27 Dec 2005 07:39:07 -0000
***************
*** 2139,2145 ****
           if (STRINGP (compl)
               /* If it weren't for this piece of paranoia, I'd replace
                  the whole thing with a call to do_completion. */
!             && EQ (Flength (val), Flength (compl)))
             {
               del_range (XINT (Fminibuffer_prompt_end ()), ZV);
               Finsert (1, &compl);
--- 2139,2145 ----
           if (STRINGP (compl)
               /* If it weren't for this piece of paranoia, I'd replace
                  the whole thing with a call to do_completion. */
!             && EQ (XFASTINT (Flength (val)), XFASTINT (Flength (compl))))
             {
               del_range (XINT (Fminibuffer_prompt_end ()), ZV);
               Finsert (1, &compl);

-Ryan

--
http://snarfed.org/

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-27  8:38 bug in minibuffer-complete-and-exit, fix included Ryan Barrett
@ 2005-12-27 16:36 ` Stefan Monnier
  2005-12-28 20:19   ` Ryan Barrett
  2005-12-27 18:27 ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2005-12-27 16:36 UTC (permalink / raw)
  Cc: bug-gnu-emacs, emacs-devel

> *** minibuf.c       21 Dec 2005 17:33:40 -0000      1.297
> --- minibuf.c       27 Dec 2005 07:39:07 -0000
> ***************
> *** 2139,2145 ****
>            if (STRINGP (compl)
>                /* If it weren't for this piece of paranoia, I'd replace
>                   the whole thing with a call to do_completion. */
> !             && EQ (Flength (val), Flength (compl)))
>              {
>                del_range (XINT (Fminibuffer_prompt_end ()), ZV);
>                Finsert (1, &compl);
> --- 2139,2145 ----
>            if (STRINGP (compl)
>                /* If it weren't for this piece of paranoia, I'd replace
>                   the whole thing with a call to do_completion. */
> !             && EQ (XFASTINT (Flength (val)), XFASTINT (Flength (compl))))
>              {
>                del_range (XINT (Fminibuffer_prompt_end ()), ZV);
>                Finsert (1, &compl);

This patch doesn't make any sense: EQ takes two args of type Lisp_Object
(which is also the type returned by Flength), whereas XFASTINT takes
a Lisp_Object and returns an int.

Now, if you say it fixes your problem in your test case, I believe you, but
it's probably just happenstance.  ho I must say I can't figure out how that
could happen here ;-)


        Stefan

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-27  8:38 bug in minibuffer-complete-and-exit, fix included Ryan Barrett
  2005-12-27 16:36 ` Stefan Monnier
@ 2005-12-27 18:27 ` Stefan Monnier
  2005-12-27 18:51   ` Kevin Rodgers
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2005-12-27 18:27 UTC (permalink / raw)
  Cc: bug-gnu-emacs, emacs-devel

> here's a test case. run emacs -q, then evaluate these forms:

>    (setq completion-ignore-case t)
>    (read-buffer "buffer name: " nil t)

> enter *scrATCH* at the prompt. it returns *scrATCH*, but it should return
> *scratch*.

I can't reproduce it here.  If I start `emacs -Q' and then copy your two
lines of code into *scratch* then hit C-x C-e after the first and C-x C-e
after the second and enter *scrATCH* read-buffer returns "*scratch*".


        Stefan

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-27 18:27 ` Stefan Monnier
@ 2005-12-27 18:51   ` Kevin Rodgers
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2005-12-27 18:51 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Stefan Monnier wrote:
>>here's a test case. run emacs -q, then evaluate these forms:
> 
> 
>>   (setq completion-ignore-case t)
>>   (read-buffer "buffer name: " nil t)
> 
> 
>>enter *scrATCH* at the prompt. it returns *scrATCH*, but it should return
>>*scratch*.
> 
> 
> I can't reproduce it here.  If I start `emacs -Q' and then copy your two
> lines of code into *scratch* then hit C-x C-e after the first and C-x C-e
> after the second and enter *scrATCH* read-buffer returns "*scratch*".

I know Ryan posted a patch against CVS, but FWIW in Emacs 21.4
read-buffer returns "*scrATCH*".

-- 
Kevin

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-27 16:36 ` Stefan Monnier
@ 2005-12-28 20:19   ` Ryan Barrett
  2005-12-29  3:13     ` Stefan Monnier
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ryan Barrett @ 2005-12-28 20:19 UTC (permalink / raw)
  Cc: bug-gnu-emacs, emacs-devel

On Tue, 27 Dec 2005, Stefan Monnier wrote:

>> !             && EQ (XFASTINT (Flength (val)), XFASTINT (Flength (compl))))
...
> This patch doesn't make any sense: EQ takes two args of type Lisp_Object
> (which is also the type returned by Flength), whereas XFASTINT takes
> a Lisp_Object and returns an int.

understood, and apologies. it was my first foray into the C source. :P

EQ is defined in lisp.h to be ==:

    #define EQ(x, y) ((x) == (y))
or
    #define EQ(x, y) ((x).i == (y).i)

i spent some quality time with gdb, and noticed that even when val and compl
were the same length, the Lisp_Objects returned by Flength for them weren't
equal. specifically, EQ (Flength (val)), Flength (compl)) evaluated to false.

i'm not sure why that was. however, when i coerced the returned Lisp_Objects
to ints with XFASTINT, they were equal.

i don't know why CVS didn't reproduce the bug for you. i'll look into it. if i
was mistaken, and it is fixed, i'll drop it. if it's still a bug, though, i
could change the patch to use == instead of EQ. would that be more palatable?

!             && XFASTINT (Flength (val)) == XFASTINT (Flength (compl)))

-Ryan

--
http://snarfed.org/

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-28 20:19   ` Ryan Barrett
@ 2005-12-29  3:13     ` Stefan Monnier
  2005-12-29 17:10     ` Richard M. Stallman
  2005-12-31  1:49     ` Ryan Barrett
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2005-12-29  3:13 UTC (permalink / raw)
  Cc: bug-gnu-emacs, emacs-devel

> i spent some quality time with gdb, and noticed that even when val and
> compl were the same length, the Lisp_Objects returned by Flength for them
> weren't equal.

That would be a bug.  But I'm tempted to suspect the bug's in GDB more than
in Emacs because Flength is used extensively so such a bug seems
rather unlikely.


        Stefan

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-28 20:19   ` Ryan Barrett
  2005-12-29  3:13     ` Stefan Monnier
@ 2005-12-29 17:10     ` Richard M. Stallman
  2005-12-31  1:49     ` Ryan Barrett
  2 siblings, 0 replies; 8+ messages in thread
From: Richard M. Stallman @ 2005-12-29 17:10 UTC (permalink / raw)
  Cc: bug-gnu-emacs, monnier, emacs-devel

    i spent some quality time with gdb, and noticed that even when val and compl
    were the same length, the Lisp_Objects returned by Flength for them weren't
    equal. specifically, EQ (Flength (val)), Flength (compl)) evaluated to false.

Could you display both values in hex?  With all the facts,
we will see the answer to the mystery.

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

* Re: bug in minibuffer-complete-and-exit, fix included
  2005-12-28 20:19   ` Ryan Barrett
  2005-12-29  3:13     ` Stefan Monnier
  2005-12-29 17:10     ` Richard M. Stallman
@ 2005-12-31  1:49     ` Ryan Barrett
  2 siblings, 0 replies; 8+ messages in thread
From: Ryan Barrett @ 2005-12-31  1:49 UTC (permalink / raw)


On Wed, 28 Dec 2005, Ryan Barrett wrote:

> i don't know why CVS didn't reproduce the bug for you. i'll look into it. if
> i was mistaken, and it is fixed, i'll drop it.

i don't know what i was doing before, but i can't reproduce it with CVS any
more either, only with 21. shame on me. :P

consider it dropped, and sorry for the false alarm. i'm glad that it's fixed!

-Ryan

--
http://snarfed.org/

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

end of thread, other threads:[~2005-12-31  1:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-27  8:38 bug in minibuffer-complete-and-exit, fix included Ryan Barrett
2005-12-27 16:36 ` Stefan Monnier
2005-12-28 20:19   ` Ryan Barrett
2005-12-29  3:13     ` Stefan Monnier
2005-12-29 17:10     ` Richard M. Stallman
2005-12-31  1:49     ` Ryan Barrett
2005-12-27 18:27 ` Stefan Monnier
2005-12-27 18:51   ` Kevin Rodgers

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).