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: Mon, 02 Jul 2007 10:27:09 +0200 Message-ID: <4688B6DD.9030600@gmx.at> References: <4666BF5F.5030301@gmx.at> <46753850.2090708@gmx.at> <46778ACB.1000704@gmx.at> <467E47AF.1080702@gmx.at> <4680B80E.5090709@gmx.at> <468204D8.8010700@gmx.at> <46863F67.20208@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020308040602010704080409" X-Trace: sea.gmane.org 1183364859 968 80.91.229.12 (2 Jul 2007 08:27:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Jul 2007 08:27:39 +0000 (UTC) Cc: Kenichi Handa , emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 02 10:27:35 2007 connect(): Connection refused 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 1I5HFu-0006fZ-RV for ged-emacs-devel@m.gmane.org; Mon, 02 Jul 2007 10:27:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I5HFu-0000w3-6b for ged-emacs-devel@m.gmane.org; Mon, 02 Jul 2007 04:27:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I5HFD-0000PX-9B for emacs-devel@gnu.org; Mon, 02 Jul 2007 04:26:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I5HFC-0000P8-QU for emacs-devel@gnu.org; Mon, 02 Jul 2007 04:26:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I5HFC-0000P1-M7 for emacs-devel@gnu.org; Mon, 02 Jul 2007 04:26:50 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1I5HFB-0006Tf-PO for emacs-devel@gnu.org; Mon, 02 Jul 2007 04:26:50 -0400 Original-Received: (qmail invoked by alias); 02 Jul 2007 08:26:48 -0000 Original-Received: from N739P001.adsl.highway.telekom.at (EHLO [62.47.36.65]) [62.47.36.65] by mail.gmx.net (mp036) with SMTP; 02 Jul 2007 10:26:48 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+Qz2lpR0OQK2+olpyBfhS+hDth6t3tAwqgQF7itQ n3SSIB+Pk7k/le 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:74177 Archived-At: This is a multi-part message in MIME format. --------------020308040602010704080409 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > So the only remaining change to be done is to inhibit execution of > certain hooks in `format-decode' and around the calls to > `after-insert-file-functions'. Please have a look at the attached patch (my acquaintance with C code is marginal). Handa-san could you please check whether such a patch would introduce conflicts with the unicode-2 branch. --------------020308040602010704080409 Content-Type: text/plain; name="fileio.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fileio.patch" *** fileio.c Mon Jul 2 07:27:56 2007 --- fileio.c Mon Jul 2 08:23:20 2007 *************** *** 3720,3727 **** register int how_much; register int unprocessed; int count = SPECPDL_INDEX (); ! struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; ! Lisp_Object handler, val, insval, orig_filename; Lisp_Object p; int total = 0; int not_regular = 0; --- 3720,3727 ---- register int how_much; register int unprocessed; int count = SPECPDL_INDEX (); ! struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; ! Lisp_Object handler, val, insval, orig_filename, old_undo; Lisp_Object p; int total = 0; int not_regular = 0; *************** *** 3744,3751 **** val = Qnil; p = Qnil; orig_filename = Qnil; ! GCPRO4 (filename, val, p, orig_filename); CHECK_STRING (filename); filename = Fexpand_file_name (filename, Qnil); --- 3744,3752 ---- val = Qnil; p = Qnil; orig_filename = Qnil; + old_undo = Qnil; ! GCPRO5 (filename, val, p, orig_filename, old_undo); CHECK_STRING (filename); filename = Fexpand_file_name (filename, Qnil); *************** *** 4704,4727 **** /* Decode file format */ if (inserted > 0) { ! int empty_undo_list_p = 0; ! ! /* If we're anyway going to discard undo information, don't ! record it in the first place. The buffer's undo list at this ! point is either nil or t when visiting a file. */ ! if (!NILP (visit)) { ! empty_undo_list_p = NILP (current_buffer->undo_list); ! 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 --- 4705,4806 ---- /* Decode file format */ if (inserted > 0) { ! /* Don't run point motion or modification hooks when decoding. */ ! int count = SPECPDL_INDEX (); ! specbind (Qinhibit_point_motion_hooks, Qt); ! specbind (Qinhibit_modification_hooks, Qt); ! ! /* Save old undo list and don't record undo for decoding. */ ! old_undo = current_buffer->undo_list; ! 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); } ! /* For consistency with format-decode call these now iff inserted > 0 ! (martin 2007-06-28) */ ! 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); ! } ! ! if (NILP (visit)) ! { ! Lisp_Object lbeg, lend; ! XSETINT (lbeg, PT); ! XSETINT (lend, PT + inserted); ! if (CONSP (old_undo)) ! { ! Lisp_Object tem = XCAR (old_undo); ! if (CONSP (tem) && INTEGERP (XCAR (tem)) && ! INTEGERP (XCDR (tem)) && (XCAR (tem)) == lbeg) ! /* In the non-visiting case record only the final insertion. */ ! current_buffer->undo_list = ! Fcons (Fcons (lbeg, lend), Fcdr (old_undo)); ! } ! } ! else ! /* In the visiting case restore the previous value. */ ! current_buffer->undo_list = old_undo; ! ! unbind_to (count, Qnil); } /* Call after-change hooks for the inserted text, aside from the case *************** *** 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) { --- 4813,4818 ---- --------------020308040602010704080409 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 --------------020308040602010704080409--