X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/4867a28394c1af8f26428bb8e7f2e17d3823fba0..c7fea3257f7198b8381dc4ec39c1a306042610ce:/src/intervals.c diff --git a/src/intervals.c b/src/intervals.c index a9e36f8b9b..8bbab5a2a2 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -1,5 +1,6 @@ /* Code for doing intervals. - Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -15,8 +16,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ /* NOTES: @@ -790,14 +791,14 @@ update_interval (i, pos) /* Move right. */ if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) { - i->right->position = INTERVAL_LAST_POS (i) + - LEFT_TOTAL_LENGTH (i->right); + i->right->position = INTERVAL_LAST_POS (i) + + LEFT_TOTAL_LENGTH (i->right); i = i->right; /* Move to the right child */ } else if (NULL_PARENT (i)) - error ("Point after end of properties"); + error ("Point %d after end of properties", pos); else - i = INTERVAL_PARENT (i); + i = INTERVAL_PARENT (i); continue; } else @@ -1712,6 +1713,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) { register INTERVAL under, over, this, prev; register INTERVAL tree; + int over_used; tree = BUF_INTERVALS (buffer); @@ -1745,6 +1747,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) XSETBUFFER (buf, buffer); BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); BUF_INTERVALS (buffer)->position = BEG; + BUF_INTERVALS (buffer)->up_obj = 1; /* Explicitly free the old tree here? */ @@ -1767,6 +1770,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) { BUF_INTERVALS (buffer) = reproduce_tree (source, INTERVAL_PARENT (tree)); BUF_INTERVALS (buffer)->position = BEG; + BUF_INTERVALS (buffer)->up_obj = 1; /* Explicitly free the old tree here. */ return; @@ -1814,21 +1818,42 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) adjust_intervals_for_insertion, so stickiness has already been taken care of. */ + /* OVER is the interval we are copying from next. + OVER_USED says how many characters' worth of OVER + have already been copied into target intervals. + UNDER is the next interval in the target. */ + over_used = 0; while (! NULL_INTERVAL_P (over)) { - if (LENGTH (over) < LENGTH (under)) + /* If UNDER is longer than OVER, split it. */ + if (LENGTH (over) - over_used < LENGTH (under)) { - this = split_interval_left (under, LENGTH (over)); + this = split_interval_left (under, LENGTH (over) - over_used); copy_properties (under, this); } else this = under; - copy_properties (over, this); + + /* THIS is now the interval to copy or merge into. + OVER covers all of it. */ if (inherit) merge_properties (over, this); else copy_properties (over, this); - over = next_interval (over); + + /* If THIS and OVER end at the same place, + advance OVER to a new source interval. */ + if (LENGTH (this) == LENGTH (over) - over_used) + { + over = next_interval (over); + over_used = 0; + } + else + /* Otherwise just record that more of OVER has been used. */ + over_used += LENGTH (this); + + /* Always advance to a new target interval. */ + under = next_interval (this); } if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) @@ -1875,11 +1900,13 @@ lookup_char_property (plist, prop, textprop) return fallback; /* Check for alternative properties */ tail = Fassq (prop, Vchar_property_alias_alist); - if (NILP (tail)) - return tail; - tail = XCDR (tail); - for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail)) - fallback = Fplist_get (plist, XCAR (tail)); + if (! NILP (tail)) + { + tail = XCDR (tail); + for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail)) + fallback = Fplist_get (plist, XCAR (tail)); + } + if (textprop && NILP (fallback) && CONSP (Vdefault_text_properties)) fallback = Fplist_get (Vdefault_text_properties, prop); return fallback; @@ -2009,8 +2036,7 @@ set_point_both (buffer, charpos, bytepos) if (charpos > BUF_ZV (buffer) || charpos < BUF_BEGV (buffer)) abort (); - have_overlays = (! NILP (buffer->overlays_before) - || ! NILP (buffer->overlays_after)); + have_overlays = (buffer->overlays_before || buffer->overlays_after); /* If we have no text properties and overlays, then we can do it quickly. */ @@ -2250,6 +2276,10 @@ move_if_not_intangible (position) pos = Fnext_char_property_change (pos, Qnil); } + else if (position < BEGV) + position = BEGV; + else if (position > ZV) + position = ZV; /* If the whole stretch between PT and POSITION isn't intangible, try moving to POSITION (which means we actually move farther @@ -2335,10 +2365,6 @@ get_local_map (position, buffer, type) BUF_BEGV_BYTE (buffer) = BUF_BEG_BYTE (buffer); BUF_ZV_BYTE (buffer) = BUF_Z_BYTE (buffer); - /* There are no properties at the end of the buffer, so in that case - check for a local map on the last character of the buffer instead. */ - if (position == BUF_Z (buffer) && BUF_Z (buffer) > BUF_BEG (buffer)) - --position; XSETFASTINT (lispy_position, position); XSETBUFFER (lispy_buffer, buffer); /* First check if the CHAR has any property. This is because when @@ -2592,3 +2618,6 @@ set_intervals_multibyte (multi_flag) set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, BEG, BEG_BYTE, Z, Z_BYTE); } + +/* arch-tag: 3d402b60-083c-4271-b4a3-ebd9a74bfe27 + (do not change this comment) */