From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#9642: move-overlay creates an empty overlay with the evaporate property Date: Fri, 30 Sep 2011 15:55:02 -0700 Organization: UCLA Computer Science Department Message-ID: <4E8648C6.5050905@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1317423371 17881 80.91.229.12 (30 Sep 2011 22:56:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Sep 2011 22:56:11 +0000 (UTC) To: 9642@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 01 00:56:07 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R9lzv-0007Pc-U2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Oct 2011 00:56:04 +0200 Original-Received: from localhost ([::1]:57569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lzv-0004aj-12 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Sep 2011 18:56:03 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lzn-0004T5-8y for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:56:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9lzl-0000FE-VM for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:55:55 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lzl-0000FA-Tn for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:55:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1R9m0s-0002j4-32 for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Sep 2011 22:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9642 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.131742338810435 (code B ref -1); Fri, 30 Sep 2011 22:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Sep 2011 22:56:28 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9m0J-0002iF-22 for submit@debbugs.gnu.org; Fri, 30 Sep 2011 18:56:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9m0D-0002i3-VQ for submit@debbugs.gnu.org; Fri, 30 Sep 2011 18:56:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9lz6-00009P-Bp for submit@debbugs.gnu.org; Fri, 30 Sep 2011 18:55:13 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:53445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lz6-00009L-AO for submit@debbugs.gnu.org; Fri, 30 Sep 2011 18:55:12 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lz5-0004P7-Al for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:55:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9lz3-00009A-Vg for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:55:11 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:38277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9lz3-00008g-LV for bug-gnu-emacs@gnu.org; Fri, 30 Sep 2011 18:55:09 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 831F839E8109 for ; Fri, 30 Sep 2011 15:55:07 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jS2xh08jmcNe for ; Fri, 30 Sep 2011 15:55:06 -0700 (PDT) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id BFD9D39E80D2 for ; Fri, 30 Sep 2011 15:55:06 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Thunderbird/3.1.14 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 30 Sep 2011 18:57:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:52012 Archived-At: Package: Emacs Version: 24.0.90 Tags: patch In a nonempty buffer, the following: (let ((o (make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1)) returns an empty overlay that has the evaporate property. But this is not supposed to happen: when an overlay with that property becomes empty, it's supposed to be deleted. Here's a patch that I'd like to install after a bit more testing. * buffer.c (Fmove_overlay): Delete an evaporating overlay if it becomes empty after its bounds are adjusted to fit within its buffer. Without this fix, in a nonempty buffer (let ((o (make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1)) yields an empty overlay that has the evaporate property, which is not supposed to happen. === modified file 'src/buffer.c' --- src/buffer.c 2011-09-30 20:22:01 +0000 +++ src/buffer.c 2011-09-30 22:29:34 +0000 @@ -3673,6 +3673,7 @@ struct buffer *b, *ob; Lisp_Object obuffer; int count = SPECPDL_INDEX (); + ptrdiff_t n_beg, n_end; CHECK_OVERLAY (overlay); if (NILP (buffer)) @@ -3691,15 +3692,20 @@ CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); - if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate))) + if (XINT (beg) > XINT (end)) + { + Lisp_Object temp; + temp = beg; beg = end; end = temp; + } + + Fset_marker (OVERLAY_START (overlay), beg, buffer); + Fset_marker (OVERLAY_END (overlay), end, buffer); + n_beg = marker_position (OVERLAY_START (overlay)); + n_end = marker_position (OVERLAY_END (overlay)); + + if (n_beg == n_end && ! NILP (Foverlay_get (overlay, Qevaporate))) return Fdelete_overlay (overlay); - if (XINT (beg) > XINT (end)) - { - Lisp_Object temp; - temp = beg; beg = end; end = temp; - } - specbind (Qinhibit_quit, Qt); obuffer = Fmarker_buffer (OVERLAY_START (overlay)); @@ -3722,7 +3728,7 @@ } /* Redisplay where the overlay is going to be. */ - modify_overlay (b, XINT (beg), XINT (end)); + modify_overlay (b, n_beg, n_end); } else /* Redisplay the area the overlay has just left, or just enclosed. */ @@ -3732,16 +3738,12 @@ o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); - if (o_beg == XINT (beg)) - modify_overlay (b, o_end, XINT (end)); - else if (o_end == XINT (end)) - modify_overlay (b, o_beg, XINT (beg)); + if (o_beg == n_beg) + modify_overlay (b, o_end, n_end); + else if (o_end == n_end) + modify_overlay (b, o_beg, n_beg); else - { - if (XINT (beg) < o_beg) o_beg = XINT (beg); - if (XINT (end) > o_end) o_end = XINT (end); - modify_overlay (b, o_beg, o_end); - } + modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end)); } if (!NILP (obuffer)) @@ -3753,12 +3755,8 @@ eassert (XOVERLAY (overlay)->next == NULL); } - Fset_marker (OVERLAY_START (overlay), beg, buffer); - Fset_marker (OVERLAY_END (overlay), end, buffer); - /* Put the overlay on the wrong list. */ - end = OVERLAY_END (overlay); - if (OVERLAY_POSITION (end) < b->overlay_center) + if (n_end < b->overlay_center) { XOVERLAY (overlay)->next = b->overlays_after; b->overlays_after = XOVERLAY (overlay);