From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Hansen Newsgroups: gmane.emacs.devel Subject: Re: Bugs in remove-list-of-text-properties and a patch [WAS: before-change-functions called twice at yank] Date: Mon, 17 Apr 2006 10:51:21 +0200 Message-ID: <44435709.3070001@soem.dk> References: <443ADE3B.7000800@soem.dk> <444141FF.9000007@soem.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030202000608030008040103" X-Trace: sea.gmane.org 1145263956 26412 80.91.229.2 (17 Apr 2006 08:52:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 17 Apr 2006 08:52:36 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 17 10:52:36 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FVPTB-0001ig-Do for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2006 10:52:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVPTA-0000rk-P8 for ged-emacs-devel@m.gmane.org; Mon, 17 Apr 2006 04:52:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FVPS9-0000ji-Us for emacs-devel@gnu.org; Mon, 17 Apr 2006 04:51:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FVPS9-0000jJ-1b for emacs-devel@gnu.org; Mon, 17 Apr 2006 04:51:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVPS8-0000jF-E2 for emacs-devel@gnu.org; Mon, 17 Apr 2006 04:51:24 -0400 Original-Received: from [212.99.225.245] (helo=odin.broadcom.dk) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FVPSk-0001d9-9r for emacs-devel@gnu.org; Mon, 17 Apr 2006 04:52:02 -0400 Original-Received: from pppoe3-ves.broadcom.dk ([212.99.255.42] helo=[10.17.0.48]) by odin.broadcom.dk with esmtp (Exim 4.24; FreeBSD) id 1FVPRO-000Pcu-65 for emacs-devel@gnu.org; Mon, 17 Apr 2006 10:50:38 +0200 User-Agent: Debian Thunderbird 1.0.2 (X11/20051002) X-Accept-Language: en-us, en Original-To: emacs-devel@gnu.org In-Reply-To: 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:52953 Archived-At: This is a multi-part message in MIME format. --------------030202000608030008040103 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Richard Stallman wrote: > if (! interval_has_some_properties_list (properties, i)) > ! if (modified) > ! { > ! if (BUFFERP (object)) > ! signal_after_change (XINT (start), XINT (end) - XINT (start), > ! XINT (end) - XINT (start)); > >I'm not confident about that code. It runs the after-change hook, but >in this case, where is the before-change hook run? > > The before-change-functions are run by modify_region called immediately before the changes are done by remove_properties. Actually, I have changed that part of the code a bit to make it more readable, see the attached patch. The general idea is: Fremove_list_of_text_properties has a for (;;) loop that loops over the parts of the interval. It updates the flag `modified' recording if changes have been done. To make things work right, we must call modify_region before calling remove_properties iff modified == 0, and we must call signal_after_change before returning iff modified != 0. --------------030202000608030008040103 Content-Type: text/x-patch; name="textprop.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="textprop.diff" *** textprop.c.~1.145.~ 2006-04-15 18:10:14.000000000 +0200 --- textprop.c 2006-04-16 18:44:25.318950490 +0200 *************** *** 1602,1610 **** } } - if (BUFFERP (object)) - modify_region (XBUFFER (object), XINT (start), XINT (end)); - /* We are at the beginning of an interval, with len to scan */ for (;;) { --- 1602,1607 ---- *************** *** 1614,1623 **** if (LENGTH (i) >= len) { if (! interval_has_some_properties_list (properties, i)) ! return modified ? Qt : Qnil; if (LENGTH (i) == len) { remove_properties (Qnil, properties, i, object); if (BUFFERP (object)) signal_after_change (XINT (start), XINT (end) - XINT (start), --- 1611,1630 ---- if (LENGTH (i) >= len) { if (! interval_has_some_properties_list (properties, i)) ! if (modified) ! { ! if (BUFFERP (object)) ! signal_after_change (XINT (start), XINT (end) - XINT (start), ! XINT (end) - XINT (start)); ! return Qt; ! } ! else ! return Qnil; if (LENGTH (i) == len) { + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); remove_properties (Qnil, properties, i, object); if (BUFFERP (object)) signal_after_change (XINT (start), XINT (end) - XINT (start), *************** *** 1629,1634 **** --- 1636,1643 ---- unchanged = i; i = split_interval_left (i, len); copy_properties (unchanged, i); + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); remove_properties (Qnil, properties, i, object); if (BUFFERP (object)) signal_after_change (XINT (start), XINT (end) - XINT (start), *************** *** 1636,1643 **** return Qt; } len -= LENGTH (i); - modified += remove_properties (Qnil, properties, i, object); i = next_interval (i); } } --- 1645,1658 ---- return Qt; } + if (interval_has_some_properties_list (properties, i)) + { + if (!modified && BUFFERP (object)) + modify_region (XBUFFER (object), XINT (start), XINT (end)); + remove_properties (Qnil, properties, i, object); + modified = 1; + } len -= LENGTH (i); i = next_interval (i); } } --------------030202000608030008040103 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 --------------030202000608030008040103--