unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text
       [not found] ` <E1a8Cgi-00039X-Ic@vcs.savannah.gnu.org>
@ 2015-12-13 20:25   ` Stefan Monnier
  2015-12-13 20:46     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-12-13 20:25 UTC (permalink / raw)
  To: emacs-devel; +Cc: Eli Zaretskii

> -	Fset_buffer_multibyte (Qnil);
> +	if (inserted > 0)
> +	  bset_enable_multibyte_characters (current_buffer, Qnil);
> +	else
> +	  Fset_buffer_multibyte (Qnil);

Hmm... IIUC if (inserted > 0) we need bset_enable_multibyte_characters
because Fset_buffer_multibyte would try to convert the chars we
just inserted.

And IIUC we recently switched to Fset_buffer_multibyte in order to
handle the case where the buffer was not empty when we started (in
which case we need to convert the content that was present before we
started insertion).

So, IIUC if the buffer was not empty to start with *and* (inserted > 0),
then we have a problem because neither function is right.

Or did I miss something?


        Stefan



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

* Re: [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text
  2015-12-13 20:25   ` [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text Stefan Monnier
@ 2015-12-13 20:46     ` Eli Zaretskii
  2015-12-14  4:25       ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2015-12-13 20:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Sun, 13 Dec 2015 15:25:33 -0500
> 
> > -	Fset_buffer_multibyte (Qnil);
> > +	if (inserted > 0)
> > +	  bset_enable_multibyte_characters (current_buffer, Qnil);
> > +	else
> > +	  Fset_buffer_multibyte (Qnil);
> 
> Hmm... IIUC if (inserted > 0) we need bset_enable_multibyte_characters
> because Fset_buffer_multibyte would try to convert the chars we
> just inserted.
> 
> And IIUC we recently switched to Fset_buffer_multibyte in order to
> handle the case where the buffer was not empty when we started (in
> which case we need to convert the content that was present before we
> started insertion).
> 
> So, IIUC if the buffer was not empty to start with *and* (inserted > 0),
> then we have a problem because neither function is right.
> 
> Or did I miss something?

If inserted is positive, there's code after that which takes care of
adjusting the buffer's gap etc.  So it's only needed when nothing was
inserted.




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

* Re: [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text
  2015-12-13 20:46     ` Eli Zaretskii
@ 2015-12-14  4:25       ` Stefan Monnier
  2015-12-14 15:52         ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-12-14  4:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> > -	Fset_buffer_multibyte (Qnil);
>> > +	if (inserted > 0)
>> > +	  bset_enable_multibyte_characters (current_buffer, Qnil);
>> > +	else
>> > +	  Fset_buffer_multibyte (Qnil);
>> 
>> Hmm... IIUC if (inserted > 0) we need bset_enable_multibyte_characters
>> because Fset_buffer_multibyte would try to convert the chars we
>> just inserted.
>> 
>> And IIUC we recently switched to Fset_buffer_multibyte in order to
>> handle the case where the buffer was not empty when we started (in
>> which case we need to convert the content that was present before we
>> started insertion).
>> 
>> So, IIUC if the buffer was not empty to start with *and* (inserted > 0),
>> then we have a problem because neither function is right.
>> 
>> Or did I miss something?

> If inserted is positive, there's code after that which takes care of
> adjusting the buffer's gap etc.  So it's only needed when nothing was
> inserted.

But if (inserted > 0) and the buffer was not empty beforehand, how can
the subsequent code know (after we've called
bset_enable_multibyte_characters) that it has to decode the earlier
buffer's content (since bset_enable_multibyte_characters has thrown away
the information that the earlier buffer's content was multibyte)?


        Stefan



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

* Re: [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text
  2015-12-14  4:25       ` Stefan Monnier
@ 2015-12-14 15:52         ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2015-12-14 15:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: emacs-devel@gnu.org
> Date: Sun, 13 Dec 2015 23:25:28 -0500
> 
> > If inserted is positive, there's code after that which takes care of
> > adjusting the buffer's gap etc.  So it's only needed when nothing was
> > inserted.
> 
> But if (inserted > 0) and the buffer was not empty beforehand, how can
> the subsequent code know (after we've called
> bset_enable_multibyte_characters) that it has to decode the earlier
> buffer's content (since bset_enable_multibyte_characters has thrown away
> the information that the earlier buffer's content was multibyte)?

adjust_after_insert (which is the code I alluded to above) doesn't do
any such decoding, it never did.  IOW, I just returned the situation
in this particular case to what it was before.  The unconditional call
to Fset_buffer_multibyte erroneously caused the gap and ZV adjustments
to be done twice when inserted is positive; this commit fixed that.

Feel free to make more changes there, I don't claim I understand this
code better than you do.  (I asked for comments, but no one
responded.)  Just make sure the two test cases, viz.:

  http://lists.gnu.org/archive/html/bug-gnu-emacs/2015-12/msg00171.html
  http://lists.gnu.org/archive/html/bug-gnu-emacs/2015-12/msg00442.html

both still work correctly.

Thanks.



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

end of thread, other threads:[~2015-12-14 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20151213195208.12085.93274@vcs.savannah.gnu.org>
     [not found] ` <E1a8Cgi-00039X-Ic@vcs.savannah.gnu.org>
2015-12-13 20:25   ` [Emacs-diffs] emacs-25 25e461c 1/2: Fix visiting files with raw-text Stefan Monnier
2015-12-13 20:46     ` Eli Zaretskii
2015-12-14  4:25       ` Stefan Monnier
2015-12-14 15:52         ` Eli Zaretskii

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