unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61535: 29.0.60; choose-completion erases in-region buffer
@ 2023-02-15 18:32 Juri Linkov
  2023-02-15 19:35 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2023-02-15 18:32 UTC (permalink / raw)
  To: 61535

0. emacs-29 -Q
1. type: (with-c C-M-i
2. type: M-down ... M-RET
3. check that the whole buffer was deleted before a selected
   completion candidate was inserted to the buffer:
   C-h v buffer-undo-list RET

Here is a possible fix for emacs-29:

diff --git a/lisp/simple.el b/lisp/simple.el
index c58acfe3adc..1924567cc3f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9882,7 +9882,8 @@ choose-completion
       (with-current-buffer buffer
         (choose-completion-string
          choice buffer
-         (or (and completion-use-base-affixes base-affixes)
+         (or (and (not completion-in-region-mode)
+                  completion-use-base-affixes base-affixes)
              base-position
              ;; If all else fails, just guess.
              (list (choose-completion-guess-base-position choice)))





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-15 18:32 bug#61535: 29.0.60; choose-completion erases in-region buffer Juri Linkov
@ 2023-02-15 19:35 ` Eli Zaretskii
  2023-02-16 17:51   ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-02-15 19:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 61535

> From: Juri Linkov <juri@linkov.net>
> Date: Wed, 15 Feb 2023 20:32:18 +0200
> 
> 0. emacs-29 -Q
> 1. type: (with-c C-M-i
> 2. type: M-down ... M-RET
> 3. check that the whole buffer was deleted before a selected
>    completion candidate was inserted to the buffer:
>    C-h v buffer-undo-list RET

Which buffer was deleted? *scratch*?  It isn't here.

And what does "C-h v buffer-undo-list RET" mean?

Bottom line: I don't understand what is the bug here and/or how to
reproduce it.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-15 19:35 ` Eli Zaretskii
@ 2023-02-16 17:51   ` Juri Linkov
  2023-02-16 20:09     ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2023-02-16 17:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61535

>> 1. type: (with-c C-M-i
>> 2. type: M-down ... M-RET
>> 3. check that the whole buffer was deleted before a selected
>>    completion candidate was inserted to the buffer:
>>    C-h v buffer-undo-list RET
>
> Which buffer was deleted? *scratch*?  It isn't here.
>
> And what does "C-h v buffer-undo-list RET" mean?
>
> Bottom line: I don't understand what is the bug here and/or how to
> reproduce it.

The contents of the *scratch* buffer is erased and replaced
with the same text.  This fact can be confirmed by looking
at the value of 'buffer-undo-list' that contains the text
of the whole buffer as a string.  Especially this is noticeable
when using in-region completion in a large buffer.

With the patch, only the completed string is inserted.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-16 17:51   ` Juri Linkov
@ 2023-02-16 20:09     ` Eli Zaretskii
  2023-02-17  7:50       ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-02-16 20:09 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 61535

> From: Juri Linkov <juri@linkov.net>
> Cc: 61535@debbugs.gnu.org
> Date: Thu, 16 Feb 2023 19:51:05 +0200
> 
> >> 1. type: (with-c C-M-i
> >> 2. type: M-down ... M-RET
> >> 3. check that the whole buffer was deleted before a selected
> >>    completion candidate was inserted to the buffer:
> >>    C-h v buffer-undo-list RET
> >
> > Which buffer was deleted? *scratch*?  It isn't here.
> >
> > And what does "C-h v buffer-undo-list RET" mean?
> >
> > Bottom line: I don't understand what is the bug here and/or how to
> > reproduce it.
> 
> The contents of the *scratch* buffer is erased and replaced
> with the same text.  This fact can be confirmed by looking
> at the value of 'buffer-undo-list' that contains the text
> of the whole buffer as a string.  Especially this is noticeable
> when using in-region completion in a large buffer.
> 
> With the patch, only the completed string is inserted.

Thanks for the explanation.  Then please install this on master, since
AFAIU this is a very old problem, and it's just an aesthetic one.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-16 20:09     ` Eli Zaretskii
@ 2023-02-17  7:50       ` Juri Linkov
  2023-02-17  8:37         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2023-02-17  7:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61535

>> >> 1. type: (with-c C-M-i
>> >> 2. type: M-down ... M-RET
>> >> 3. check that the whole buffer was deleted before a selected
>> >>    completion candidate was inserted to the buffer:
>> >>    C-h v buffer-undo-list RET
>> >
>> > Which buffer was deleted? *scratch*?  It isn't here.
>> >
>> > And what does "C-h v buffer-undo-list RET" mean?
>> >
>> > Bottom line: I don't understand what is the bug here and/or how to
>> > reproduce it.
>>
>> The contents of the *scratch* buffer is erased and replaced
>> with the same text.  This fact can be confirmed by looking
>> at the value of 'buffer-undo-list' that contains the text
>> of the whole buffer as a string.  Especially this is noticeable
>> when using in-region completion in a large buffer.
>>
>> With the patch, only the completed string is inserted.
>
> Thanks for the explanation.  Then please install this on master, since
> AFAIU this is a very old problem, and it's just an aesthetic one.

Actually, this is not an old problem.  It's in a new feature added in 29.1.
And this patch fixes the new feature.  This is different from a similar
problem fixed now in bug#61479 that is really an old problem.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-17  7:50       ` Juri Linkov
@ 2023-02-17  8:37         ` Eli Zaretskii
  2023-02-18 18:43           ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-02-17  8:37 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 61535

> From: Juri Linkov <juri@linkov.net>
> Cc: 61535@debbugs.gnu.org
> Date: Fri, 17 Feb 2023 09:50:40 +0200
> 
> >> >> 1. type: (with-c C-M-i
> >> >> 2. type: M-down ... M-RET
> >> >> 3. check that the whole buffer was deleted before a selected
> >> >>    completion candidate was inserted to the buffer:
> >> >>    C-h v buffer-undo-list RET
> >> >
> >> > Which buffer was deleted? *scratch*?  It isn't here.
> >> >
> >> > And what does "C-h v buffer-undo-list RET" mean?
> >> >
> >> > Bottom line: I don't understand what is the bug here and/or how to
> >> > reproduce it.
> >>
> >> The contents of the *scratch* buffer is erased and replaced
> >> with the same text.  This fact can be confirmed by looking
> >> at the value of 'buffer-undo-list' that contains the text
> >> of the whole buffer as a string.  Especially this is noticeable
> >> when using in-region completion in a large buffer.
> >>
> >> With the patch, only the completed string is inserted.
> >
> > Thanks for the explanation.  Then please install this on master, since
> > AFAIU this is a very old problem, and it's just an aesthetic one.
> 
> Actually, this is not an old problem.  It's in a new feature added in 29.1.

Hmmm... I don't think I see that.  Both completion-in-region-mode and
the condition at that place haven't changed in a while.  The addition
of completion-use-base-affixes part is new, but since it's via 'and',
it cannot have changed what the code before did, only cause it to do
that in fewer cases.  What am I missing?

> And this patch fixes the new feature.  This is different from a similar
> problem fixed now in bug#61479 that is really an old problem.

This is all undecipherable for me, sorry.  What is that "new feature",
and how is it fixed here?  And how is bug#61479 relevant?





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-17  8:37         ` Eli Zaretskii
@ 2023-02-18 18:43           ` Juri Linkov
  2023-02-18 19:30             ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2023-02-18 18:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61535

>> >> >> 1. type: (with-c C-M-i
>> >> >> 2. type: M-down ... M-RET
>>
>> Actually, this is not an old problem.  It's in a new feature added in 29.1.
>
> Hmmm... I don't think I see that.  Both completion-in-region-mode and
> the condition at that place haven't changed in a while.  The addition
> of completion-use-base-affixes part is new, but since it's via 'and',
> it cannot have changed what the code before did, only cause it to do
> that in fewer cases.  What am I missing?

'M-RET' above is new.  It's bound to the new function
'minibuffer-choose-completion' that let-binds
'completion-use-base-affixes' to t that works
only in the minibuffer, not in 'completion-in-region-mode'.

>> And this patch fixes the new feature.  This is different from a similar
>> problem fixed now in bug#61479 that is really an old problem.
>
> This is all undecipherable for me, sorry.  What is that "new feature",
> and how is it fixed here?

New feature is 'M-RET', 'minibuffer-choose-completion',
'completion-use-base-affixes'.  What is fixed here
is their interaction.

> And how is bug#61479 relevant?

It's an example of a bug fixed in an old feature.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-18 18:43           ` Juri Linkov
@ 2023-02-18 19:30             ` Eli Zaretskii
  2023-02-19 17:31               ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-02-18 19:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 61535

> From: Juri Linkov <juri@linkov.net>
> Cc: 61535@debbugs.gnu.org
> Date: Sat, 18 Feb 2023 20:43:21 +0200
> 
> >> >> >> 1. type: (with-c C-M-i
> >> >> >> 2. type: M-down ... M-RET
> >>
> >> Actually, this is not an old problem.  It's in a new feature added in 29.1.
> >
> > Hmmm... I don't think I see that.  Both completion-in-region-mode and
> > the condition at that place haven't changed in a while.  The addition
> > of completion-use-base-affixes part is new, but since it's via 'and',
> > it cannot have changed what the code before did, only cause it to do
> > that in fewer cases.  What am I missing?
> 
> 'M-RET' above is new.  It's bound to the new function
> 'minibuffer-choose-completion' that let-binds
> 'completion-use-base-affixes' to t that works
> only in the minibuffer, not in 'completion-in-region-mode'.
> 
> >> And this patch fixes the new feature.  This is different from a similar
> >> problem fixed now in bug#61479 that is really an old problem.
> >
> > This is all undecipherable for me, sorry.  What is that "new feature",
> > and how is it fixed here?
> 
> New feature is 'M-RET', 'minibuffer-choose-completion',
> 'completion-use-base-affixes'.  What is fixed here
> is their interaction.

Sorry, I'm still confused.  The patch you want to install is

diff --git a/lisp/simple.el b/lisp/simple.el
index c58acfe3adc..1924567cc3f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9882,7 +9882,8 @@ choose-completion
       (with-current-buffer buffer
         (choose-completion-string
          choice buffer
-         (or (and completion-use-base-affixes base-affixes)
+         (or (and (not completion-in-region-mode)
+                  completion-use-base-affixes base-affixes)
              base-position
              ;; If all else fails, just guess.
              (list (choose-completion-guess-base-position choice)))

But by default, completion-in-region-mode is t and
completion-use-base-affixes is nil.  So this code is never executed in
the recipe you posted, right?

Moreover, if I look at buffer-undo-list, I don't think I see there
that the entire buffer text of *scratch* was deleted and recreated.

So what am I missing, and what is the problem you are trying to fix?





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-18 19:30             ` Eli Zaretskii
@ 2023-02-19 17:31               ` Juri Linkov
  2023-02-19 18:35                 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2023-02-19 17:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61535

>> >> >> >> 1. type: (with-c C-M-i
>> >> >> >> 2. type: M-down ... M-RET
>>
>> 'M-RET' above is new.  It's bound to the new function
>> 'minibuffer-choose-completion' that let-binds
>> 'completion-use-base-affixes' to t that works
>> only in the minibuffer, not in 'completion-in-region-mode'.
>
> Sorry, I'm still confused.  The patch you want to install is
>
> diff --git a/lisp/simple.el b/lisp/simple.el
> index c58acfe3adc..1924567cc3f 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -9882,7 +9882,8 @@ choose-completion
>        (with-current-buffer buffer
>          (choose-completion-string
>           choice buffer
> -         (or (and completion-use-base-affixes base-affixes)
> +         (or (and (not completion-in-region-mode)
> +                  completion-use-base-affixes base-affixes)
>               base-position
>               ;; If all else fails, just guess.
>               (list (choose-completion-guess-base-position choice)))
>
> But by default, completion-in-region-mode is t and
> completion-use-base-affixes is nil.  So this code is never executed in
> the recipe you posted, right?

M-RET is bound to minibuffer-choose-completion in completion-in-region-mode-map.
minibuffer-choose-completion let-binds completion-use-base-affixes to t
before calling choose-completion.  Therefore completion-use-base-affixes
should be ignored in choose-completion for completion-in-region-mode.

> Moreover, if I look at buffer-undo-list, I don't think I see there
> that the entire buffer text of *scratch* was deleted and recreated.
>
> So what am I missing, and what is the problem you are trying to fix?

Here is the output of 'C-h v buffer-undo-list' after typing M-RET
in the *scratch* buffer:

  buffer-undo-list is a variable defined in ‘C source code’.

  Its value is shown below.

  Value:
  (nil
   (1 . 166)
   (#(";; This buffer is for text that is not saved, and for Lisp evaluation.
  ;; To create a file, visit it with C-x C-f and enter text in its buffer.

  (with-c" 0 3
  ...





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-19 17:31               ` Juri Linkov
@ 2023-02-19 18:35                 ` Eli Zaretskii
  2023-02-19 19:32                   ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-02-19 18:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 61535

> From: Juri Linkov <juri@linkov.net>
> Cc: 61535@debbugs.gnu.org
> Date: Sun, 19 Feb 2023 19:31:27 +0200
> 
> > But by default, completion-in-region-mode is t and
> > completion-use-base-affixes is nil.  So this code is never executed in
> > the recipe you posted, right?
> 
> M-RET is bound to minibuffer-choose-completion in completion-in-region-mode-map.
> minibuffer-choose-completion let-binds completion-use-base-affixes to t
> before calling choose-completion.  Therefore completion-use-base-affixes
> should be ignored in choose-completion for completion-in-region-mode.

OK, thanks for the explanations.  I wonder if some of the above should
be in comments to the code, though.

Please install the patch on emacs-29.





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

* bug#61535: 29.0.60; choose-completion erases in-region buffer
  2023-02-19 18:35                 ` Eli Zaretskii
@ 2023-02-19 19:32                   ` Juri Linkov
  0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2023-02-19 19:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61535-done

>> M-RET is bound to minibuffer-choose-completion in completion-in-region-mode-map.
>> minibuffer-choose-completion let-binds completion-use-base-affixes to t
>> before calling choose-completion.  Therefore completion-use-base-affixes
>> should be ignored in choose-completion for completion-in-region-mode.
>
> OK, thanks for the explanations.  I wonder if some of the above should
> be in comments to the code, though.

Added to comments.

> Please install the patch on emacs-29.

Done.





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

end of thread, other threads:[~2023-02-19 19:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 18:32 bug#61535: 29.0.60; choose-completion erases in-region buffer Juri Linkov
2023-02-15 19:35 ` Eli Zaretskii
2023-02-16 17:51   ` Juri Linkov
2023-02-16 20:09     ` Eli Zaretskii
2023-02-17  7:50       ` Juri Linkov
2023-02-17  8:37         ` Eli Zaretskii
2023-02-18 18:43           ` Juri Linkov
2023-02-18 19:30             ` Eli Zaretskii
2023-02-19 17:31               ` Juri Linkov
2023-02-19 18:35                 ` Eli Zaretskii
2023-02-19 19:32                   ` Juri Linkov

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