From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: transpose-regions Date: Fri, 23 Mar 2007 13:34:12 -0400 Message-ID: <877it76ezv.fsf@stupidchicken.com> References: <46026277.7060305@gmx.at> <87zm64kau0.fsf@stupidchicken.com> <87ircst5jn.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1174671290 14919 80.91.229.12 (23 Mar 2007 17:34:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2007 17:34:50 +0000 (UTC) Cc: Andreas Schwab , emacs-devel , martin rudalics , "Kim F. Storm" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 23 18:34:41 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 1HUnes-0000Uy-Tl for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 18:34:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUngo-0004JU-1Q for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 12:36:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HUngg-0003xa-PD for emacs-devel@gnu.org; Fri, 23 Mar 2007 13:36:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUngg-0003vF-6U for emacs-devel@gnu.org; Fri, 23 Mar 2007 12:36:26 -0500 Original-Received: from south-station-annex.mit.edu ([18.72.1.2]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HUnek-0005BL-9w for emacs-devel@gnu.org; Fri, 23 Mar 2007 13:34:26 -0400 Original-Received: from grand-central-station.mit.edu (GRAND-CENTRAL-STATION.MIT.EDU [18.7.21.82]) by south-station-annex.mit.edu (8.13.6/8.9.2) with ESMTP id l2NHYLJT003048; Fri, 23 Mar 2007 12:34:22 -0500 (EST) Original-Received: from outgoing-legacy.mit.edu (OUTGOING-LEGACY.MIT.EDU [18.7.22.104]) by grand-central-station.mit.edu (8.13.6/8.9.2) with ESMTP id l2NHYDWO004138; Fri, 23 Mar 2007 13:34:14 -0400 (EDT) Original-Received: from localhost ([18.19.7.211]) ) by outgoing-legacy.mit.edu (8.13.6/8.12.4) with ESMTP id l2NHYCsQ027438; Fri, 23 Mar 2007 13:34:12 -0400 (EDT) Original-Received: from cyd by localhost with local (Exim 3.36 #1 (Debian)) id 1HUneW-0006w1-00; Fri, 23 Mar 2007 13:34:12 -0400 In-Reply-To: (Stefan Monnier's message of "Fri\, 23 Mar 2007 12\:42\:00 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux) X-Scanned-By: MIMEDefang 2.42 X-Spam-Score: 0.001 X-detected-kernel: Solaris 9.1 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:68422 Archived-At: Stefan Monnier writes: > I think I see the problem: intervals are not Lisp objects and thus they are > not detected by the conservative stack scanning (and they can't be GCPRO'd > either). Aha! Yes, this is indeed the problem. > Personally, I think the best solution is to rewrite transpose-regions in > Lisp. After all, it's only called from gnus/deuglify.el and from > games/hanoi.el (and interactively as well, of course). This is probably the long-term solution, but for Emacs 22 I think it's not wise to change all that code. Instead, I suggest setting inhibit_garbage_collection around the calls to Fset_text_properties. I have verified that this indeed solves the original bug. *** emacs/src/editfns.c.~1.436.~ 2007-03-23 13:21:29.000000000 -0400 --- emacs/src/editfns.c 2007-03-23 13:29:29.000000000 -0400 *************** *** 4118,4123 **** --- 4118,4124 ---- unsigned char *start1_addr, *start2_addr, *temp; INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2; + int count; cur_intv = BUF_INTERVALS (current_buffer); validate_region (&startr1, &endr1); *************** *** 4224,4231 **** --- 4225,4234 ---- tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval2 = copy_intervals (cur_intv, start2, len2); + count = inhibit_garbage_collection (); Fset_text_properties (make_number (start1), make_number (end2), Qnil, Qnil); + unbind_to (count, Qnil); /* First region smaller than second. */ if (len1_byte < len2_byte) *************** *** 4281,4290 **** --- 4284,4295 ---- record_change (start2, len2); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval2 = copy_intervals (cur_intv, start2, len2); + count = inhibit_garbage_collection (); Fset_text_properties (make_number (start1), make_number (end1), Qnil, Qnil); Fset_text_properties (make_number (start2), make_number (end2), Qnil, Qnil); + unbind_to (count, Qnil); SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); *************** *** 4310,4317 **** --- 4315,4324 ---- tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); tmp_interval2 = copy_intervals (cur_intv, start2, len2); + count = inhibit_garbage_collection (); Fset_text_properties (make_number (start1), make_number (end2), Qnil, Qnil); + unbind_to (count, Qnil); /* holds region 2 */ SAFE_ALLOCA (temp, unsigned char *, len2_byte); *************** *** 4341,4349 **** tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); tmp_interval2 = copy_intervals (cur_intv, start2, len2); Fset_text_properties (make_number (start1), make_number (end2), Qnil, Qnil); ! /* holds region 1 */ SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); --- 4348,4357 ---- tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); tmp_interval2 = copy_intervals (cur_intv, start2, len2); + count = inhibit_garbage_collection (); Fset_text_properties (make_number (start1), make_number (end2), Qnil, Qnil); ! unbind_to (count, Qnil); /* holds region 1 */ SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte);