From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: insert-file-contents and format-decode Date: Sun, 17 Jun 2007 15:34:08 +0200 Message-ID: <46753850.2090708@gmx.at> References: <4666BF5F.5030301@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000505020601010008000802" X-Trace: sea.gmane.org 1182087891 1092 80.91.229.12 (17 Jun 2007 13:44:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Jun 2007 13:44:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 17 15:44:50 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hzv3f-0000tI-OK for ged-emacs-devel@m.gmane.org; Sun, 17 Jun 2007 15:44:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hzv3f-0006FK-Aw for ged-emacs-devel@m.gmane.org; Sun, 17 Jun 2007 09:44:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hzv3c-0006Ex-8X for emacs-devel@gnu.org; Sun, 17 Jun 2007 09:44:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hzv3b-0006Ej-IB for emacs-devel@gnu.org; Sun, 17 Jun 2007 09:44:43 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hzv3b-0006Eg-CS for emacs-devel@gnu.org; Sun, 17 Jun 2007 09:44:43 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Hzv3a-0001Pr-My for emacs-devel@gnu.org; Sun, 17 Jun 2007 09:44:43 -0400 Original-Received: (qmail invoked by alias); 17 Jun 2007 13:44:40 -0000 Original-Received: from N823P022.adsl.highway.telekom.at (EHLO [62.47.46.214]) [62.47.46.214] by mail.gmx.net (mp044) with SMTP; 17 Jun 2007 15:44:40 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+5djdoR5e5QsEvB2T9KlqenTGk5aTrwJ2C7wx2Dq X+lnIlpyaIR+yw User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:73148 Archived-At: This is a multi-part message in MIME format. --------------000505020601010008000802 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > Can you please write and test a fix for this bug? I test the attached patch for a week now and didn't encounter any problems. In addition to fixing the bug I described it moves the call of after-change hooks _after_ the call to `after-insert-file-functions'. The earlier behavior was IMO wrong. Someone more familiar with the code of fileio.c should have a look at that though. --------------000505020601010008000802 Content-Type: text/plain; name="fileio.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fileio.patch" *** fileio.c.~1.581.~ Sun Jun 10 17:46:54 2007 --- fileio.c Sun Jun 17 15:08:20 2007 *************** *** 4715,4729 **** current_buffer->undo_list = Qt; } ! insval = call3 (Qformat_decode, ! Qnil, make_number (inserted), visit); ! CHECK_NUMBER (insval); ! inserted = XFASTINT (insval); if (!NILP (visit)) current_buffer->undo_list = empty_undo_list_p ? Qnil : Qt; } /* Call after-change hooks for the inserted text, aside from the case of normal visiting (not with REPLACE), which is done in a new buffer "before" the buffer is changed. */ --- 4715,4789 ---- current_buffer->undo_list = Qt; } ! if (NILP (replace)) ! { ! insval = call3 (Qformat_decode, ! Qnil, make_number (inserted), visit); ! CHECK_NUMBER (insval); ! inserted = XFASTINT (insval); ! } ! else ! { ! /* Suppose replace is non-nil and we succeeded in not replacing the ! beginning or end of the buffer text with the file's contents. In this ! case we neverthelss have to call format-decode with `point' positioned ! at the beginning of the buffer and `inserted' equalling the number of ! characters in the buffer. Otherwise, format-decode might fail to ! correctly analyze the beginning or end of the buffer. Hence we ! temporarily save `point' and `inserted' here and restore `point' iff ! format-decode didn't insert or delete any text. Otherwise we leave ! `point' at point-min. */ ! int opoint = PT; ! int opoint_byte = PT_BYTE; ! int oinserted = ZV - BEGV; ! ! TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); ! insval = call3 (Qformat_decode, ! Qnil, make_number (oinserted), visit); ! CHECK_NUMBER (insval); ! if (insval = oinserted) ! SET_PT_BOTH (opoint, opoint_byte); ! inserted = XFASTINT (insval); ! } if (!NILP (visit)) current_buffer->undo_list = empty_undo_list_p ? Qnil : Qt; } + p = Vafter_insert_file_functions; + while (CONSP (p)) + { + if (NILP (replace)) + { + insval = call1 (XCAR (p), make_number (inserted)); + if (!NILP (insval)) + { + CHECK_NUMBER (insval); + inserted = XFASTINT (insval); + } + } + else + { + /* For the rationale of this see the comment on format-decode above. */ + int opoint = PT; + int opoint_byte = PT_BYTE; + int oinserted = ZV - BEGV; + + TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); + insval = call1 (XCAR (p), make_number (oinserted)); + if (!NILP (insval)) + { + CHECK_NUMBER (insval); + if (insval = oinserted) + SET_PT_BOTH (opoint, opoint_byte); + inserted = XFASTINT (insval); + } + } + + QUIT; + p = XCDR (p); + } + /* Call after-change hooks for the inserted text, aside from the case of normal visiting (not with REPLACE), which is done in a new buffer "before" the buffer is changed. */ *************** *** 4734,4752 **** update_compositions (PT, PT, CHECK_BORDER); } - p = Vafter_insert_file_functions; - while (CONSP (p)) - { - insval = call1 (XCAR (p), make_number (inserted)); - if (!NILP (insval)) - { - CHECK_NUMBER (insval); - inserted = XFASTINT (insval); - } - QUIT; - p = XCDR (p); - } - if (!NILP (visit) && current_buffer->modtime == -1) { --- 4794,4799 ---- --------------000505020601010008000802 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------000505020601010008000802--