* bad interaction between set-buffer-multibyte and narrowing
@ 2003-05-30 17:27 Dave Love
2003-06-01 23:40 ` Kenichi Handa
0 siblings, 1 reply; 2+ messages in thread
From: Dave Love @ 2003-05-30 17:27 UTC (permalink / raw)
This is cut down from a real example in a Gnus bug report. Note how
the buffer-string is truncated.
Making the buffer unibyte leaves point-max unchanged and it gets
reduced when the buffer is made multibyte again. You can see this by
just making a narrowed buffer unibyte which contains Japanese. The
effect is present in both the released and development code.
(with-temp-buffer
(insert "From: ニシキノネット FC事業部
Content-Type: text/plain; charset=ISO-2022-JP\n\n")
(narrow-to-region (point-min) (1- (point-max)))
(set-buffer-multibyte nil)
(set-buffer-multibyte t)
(buffer-string))
=> "From: ニシキノネット FC事業部
Content-Type: text/plain"
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: bad interaction between set-buffer-multibyte and narrowing
2003-05-30 17:27 bad interaction between set-buffer-multibyte and narrowing Dave Love
@ 2003-06-01 23:40 ` Kenichi Handa
0 siblings, 0 replies; 2+ messages in thread
From: Kenichi Handa @ 2003-06-01 23:40 UTC (permalink / raw)
Cc: bug-gnu-emacs
In article <rzqsmqw5oqg.fsf@albion.dl.ac.uk>, Dave Love <d.love@dl.ac.uk> writes:
> This is cut down from a real example in a Gnus bug report.
> Note how the buffer-string is truncated.
> Making the buffer unibyte leaves point-max unchanged and
> it gets reduced when the buffer is made multibyte again.
> You can see this by just making a narrowed buffer unibyte
> which contains Japanese. The effect is present in both
> the released and development code.
> (with-temp-buffer (insert "From: ニシキノネット FC事業部
> Content-Type: text/plain; charset=ISO-2022-JP\n\n")
> (narrow-to-region (point-min) (1- (point-max)))
> (set-buffer-multibyte nil) (set-buffer-multibyte t)
> (buffer-string)) => "From: ニシキノネット FC事業部
> Content-Type: text/plain"
Thank you for the report. I've just installed the attached
fix in HEAD and RC.
---
Ken'ichi HANDA
handa@m17n.org
2003-05-31 Kenichi Handa <handa@m17n.org>
* buffer.c (Fset_buffer_multibyte): Correctly recover a narrowed
region when a buffer is changed to unibyte.
Index: buffer.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.c,v
retrieving revision 1.423
retrieving revision 1.424
diff -u -c -r1.423 -r1.424
cvs server: conflicting specifications of output style
*** buffer.c 29 May 2003 18:36:07 -0000 1.423
--- buffer.c 1 Jun 2003 23:27:34 -0000 1.424
***************
*** 2049,2055 ****
Lisp_Object tail, markers;
struct buffer *other;
int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
! int begv = BEGV, zv = ZV;
int narrowed = (BEG != begv || Z != zv);
int modified_p = !NILP (Fbuffer_modified_p (Qnil));
--- 2049,2055 ----
Lisp_Object tail, markers;
struct buffer *other;
int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
! int begv, zv;
int narrowed = (BEG != begv || Z != zv);
int modified_p = !NILP (Fbuffer_modified_p (Qnil));
***************
*** 2067,2072 ****
--- 2067,2077 ----
/* If the cached position is for this buffer, clear it out. */
clear_charpos_cache (current_buffer);
+
+ if (NILP (flag))
+ begv = BEGV_BYTE, zv = ZV_BYTE;
+ else
+ begv = BEGV, zv = ZV;
if (narrowed)
Fwiden ();
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-06-01 23:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-30 17:27 bad interaction between set-buffer-multibyte and narrowing Dave Love
2003-06-01 23:40 ` Kenichi Handa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.