From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: bug of auto saving Date: Tue, 10 Jun 2003 16:03:17 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200306100703.QAA10770@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1055228595 24924 80.91.224.249 (10 Jun 2003 07:03:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 10 Jun 2003 07:03:15 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jun 10 09:03:13 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19PdA1-0006Ts-00 for ; Tue, 10 Jun 2003 09:03:13 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19PdUP-00006H-00 for ; Tue, 10 Jun 2003 09:24:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19PdAZ-0006QS-1M for emacs-devel@quimby.gnus.org; Tue, 10 Jun 2003 03:03:47 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19PdAC-0006HF-5x for emacs-devel@gnu.org; Tue, 10 Jun 2003 03:03:24 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19PdAA-0006C0-BY for emacs-devel@gnu.org; Tue, 10 Jun 2003 03:03:23 -0400 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19PdA9-0005xC-A1 for emacs-devel@gnu.org; Tue, 10 Jun 2003 03:03:21 -0400 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h5A73Hu12922 for ; Tue, 10 Jun 2003 16:03:17 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) by fs.m17n.org (8.11.6/3.7W-20010823150639) with ESMTP id h5A73H900475 for ; Tue, 10 Jun 2003 16:03:17 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id QAA10770; Tue, 10 Jun 2003 16:03:17 +0900 (JST) Original-To: emacs-devel@gnu.org 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) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:14986 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:14986 It seems that my recent change as to auto saving revealed an old bug. Currently Fwrite_region has this code. /* Special kludge to simplify auto-saving. */ if (NILP (start)) { XSETFASTINT (start, BEG); XSETFASTINT (end, Z); } And we later calls annotations and per-write-conversion as this: res = call2 (XCAR (p), start, end); or res = call2 (pre_write_conversion, start, end); But, it doesn't pay attention to the case that a buffer is narrowed. In such a case, when the called Lisp functions try to access the buffer region between START and END, an error happens. I think the attached change fixes this bug. I'll install it after testing it for a while. --- Ken'ichi HANDA handa@m17n.org 2003-06-10 Kenichi Handa * fileio.c (build_annotations_unwind): Arg changed. Restore narrowing if any. (Fwrite_region): For auto-saving, widen the buffer. *** fileio.c.~1.487.~ Sat May 31 10:52:35 2003 --- fileio.c Tue Jun 10 15:44:38 2003 *************** *** 4659,4674 **** -- K.Handa */ static Lisp_Object ! build_annotations_unwind (buf) ! Lisp_Object buf; { Lisp_Object tembuf; ! if (XBUFFER (buf) == current_buffer) ! return Qnil; ! tembuf = Fcurrent_buffer (); ! Fset_buffer (buf); ! Fkill_buffer (tembuf); return Qnil; } --- 4659,4680 ---- -- K.Handa */ static Lisp_Object ! build_annotations_unwind (buf_and_region) ! Lisp_Object buf_and_region; { + Lisp_Object buf = XCAR (buf_and_region); + Lisp_Object begv_pos = XCAR (XCDR (buf_and_region)); + Lisp_Object zv_pos = XCAR (XCDR (XCDR (buf_and_region))); Lisp_Object tembuf; ! if (XBUFFER (buf) != current_buffer) ! { ! tembuf = Fcurrent_buffer (); ! Fset_buffer (buf); ! Fkill_buffer (tembuf); ! } ! if (XINT (begv_pos) > BEG || XINT (zv_pos) < Z) ! Fnarrow_to_region (begv_pos, zv_pos); return Qnil; } *************** *** 4892,4905 **** return val; } /* Special kludge to simplify auto-saving. */ if (NILP (start)) { XSETFASTINT (start, BEG); XSETFASTINT (end, Z); } - record_unwind_protect (build_annotations_unwind, Fcurrent_buffer ()); count1 = SPECPDL_INDEX (); given_buffer = current_buffer; --- 4898,4914 ---- return val; } + record_unwind_protect (build_annotations_unwind, + list3 (Fcurrent_buffer (), + make_number (BEGV), make_number (ZV))); /* Special kludge to simplify auto-saving. */ if (NILP (start)) { XSETFASTINT (start, BEG); XSETFASTINT (end, Z); + Fwiden (); } count1 = SPECPDL_INDEX (); given_buffer = current_buffer;