bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: bad interaction between set-buffer-multibyte and narrowing


From: Kenichi Handa
Subject: Re: bad interaction between set-buffer-multibyte and narrowing
Date: Mon, 2 Jun 2003 08:40:15 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, Dave Love <address@hidden> 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
address@hidden

2003-05-31  Kenichi Handa  <address@hidden>

        * 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 ();




reply via email to

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