aboutsummaryrefslogtreecommitdiffstats
path: root/src/textprop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c100
1 files changed, 35 insertions, 65 deletions
diff --git a/src/textprop.c b/src/textprop.c
index 5db6033670b..350892cdad6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -47,16 +47,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47 47
48 48
49/* Types of hooks. */ 49/* Types of hooks. */
50Lisp_Object Qmouse_left; 50static Lisp_Object Qmouse_left;
51Lisp_Object Qmouse_entered; 51static Lisp_Object Qmouse_entered;
52Lisp_Object Qpoint_left; 52Lisp_Object Qpoint_left;
53Lisp_Object Qpoint_entered; 53Lisp_Object Qpoint_entered;
54Lisp_Object Qcategory; 54Lisp_Object Qcategory;
55Lisp_Object Qlocal_map; 55Lisp_Object Qlocal_map;
56 56
57/* Visual properties text (including strings) may have. */ 57/* Visual properties text (including strings) may have. */
58Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple; 58static Lisp_Object Qforeground, Qbackground, Qunderline;
59Lisp_Object Qinvisible, Qread_only, Qintangible, Qmouse_face; 59Lisp_Object Qfont;
60static Lisp_Object Qstipple;
61Lisp_Object Qinvisible, Qintangible, Qmouse_face;
62static Lisp_Object Qread_only;
60Lisp_Object Qminibuffer_prompt; 63Lisp_Object Qminibuffer_prompt;
61 64
62/* Sticky properties */ 65/* Sticky properties */
@@ -69,10 +72,12 @@ Lisp_Object Qfront_sticky, Qrear_nonsticky;
69 72
70/* verify_interval_modification saves insertion hooks here 73/* verify_interval_modification saves insertion hooks here
71 to be run later by report_interval_modification. */ 74 to be run later by report_interval_modification. */
72Lisp_Object interval_insert_behind_hooks; 75static Lisp_Object interval_insert_behind_hooks;
73Lisp_Object interval_insert_in_front_hooks; 76static Lisp_Object interval_insert_in_front_hooks;
74 77
75static void text_read_only (Lisp_Object) NO_RETURN; 78static void text_read_only (Lisp_Object) NO_RETURN;
79static Lisp_Object Fprevious_property_change (Lisp_Object, Lisp_Object,
80 Lisp_Object);
76 81
77 82
78/* Signal a `text-read-only' error. This function makes it easier 83/* Signal a `text-read-only' error. This function makes it easier
@@ -228,7 +233,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
228 if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2)))) 233 if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2))))
229 return 0; 234 return 0;
230 235
231 /* Property has same value on both lists; go to next one. */ 236 /* Property has same value on both lists; go to next one. */
232 found = 1; 237 found = 1;
233 break; 238 break;
234 } 239 }
@@ -243,7 +248,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
243/* Return nonzero if the plist of interval I has any of the 248/* Return nonzero if the plist of interval I has any of the
244 properties of PLIST, regardless of their values. */ 249 properties of PLIST, regardless of their values. */
245 250
246static INLINE int 251static inline int
247interval_has_some_properties (Lisp_Object plist, INTERVAL i) 252interval_has_some_properties (Lisp_Object plist, INTERVAL i)
248{ 253{
249 register Lisp_Object tail1, tail2, sym; 254 register Lisp_Object tail1, tail2, sym;
@@ -265,7 +270,7 @@ interval_has_some_properties (Lisp_Object plist, INTERVAL i)
265/* Return nonzero if the plist of interval I has any of the 270/* Return nonzero if the plist of interval I has any of the
266 property names in LIST, regardless of their values. */ 271 property names in LIST, regardless of their values. */
267 272
268static INLINE int 273static inline int
269interval_has_some_properties_list (Lisp_Object list, INTERVAL i) 274interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
270{ 275{
271 register Lisp_Object tail1, tail2, sym; 276 register Lisp_Object tail1, tail2, sym;
@@ -494,7 +499,7 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
494/* Remove all properties from interval I. Return non-zero 499/* Remove all properties from interval I. Return non-zero
495 if this changes the interval. */ 500 if this changes the interval. */
496 501
497static INLINE int 502static inline int
498erase_properties (INTERVAL i) 503erase_properties (INTERVAL i)
499{ 504{
500 if (NILP (i->plist)) 505 if (NILP (i->plist))
@@ -509,7 +514,7 @@ erase_properties (INTERVAL i)
509 POSITION is BEG-based. */ 514 POSITION is BEG-based. */
510 515
511INTERVAL 516INTERVAL
512interval_of (int position, Lisp_Object object) 517interval_of (EMACS_INT position, Lisp_Object object)
513{ 518{
514 register INTERVAL i; 519 register INTERVAL i;
515 EMACS_INT beg, end; 520 EMACS_INT beg, end;
@@ -833,8 +838,8 @@ In a buffer, it runs to (point-min), and the value cannot be less than that.
833The property values are compared with `eq'. 838The property values are compared with `eq'.
834If the property is constant all the way to the start of OBJECT, return the 839If the property is constant all the way to the start of OBJECT, return the
835first valid position in OBJECT. 840first valid position in OBJECT.
836If the optional fourth argument LIMIT is non-nil, don't search 841If the optional fourth argument LIMIT is non-nil, don't search back past
837back past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 842position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */)
838 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) 843 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
839{ 844{
840 if (STRINGP (object)) 845 if (STRINGP (object))
@@ -974,37 +979,6 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
974 return make_number (next->position); 979 return make_number (next->position);
975} 980}
976 981
977/* Return 1 if there's a change in some property between BEG and END. */
978
979int
980property_change_between_p (EMACS_INT beg, EMACS_INT end)
981{
982 register INTERVAL i, next;
983 Lisp_Object object, pos;
984
985 XSETBUFFER (object, current_buffer);
986 XSETFASTINT (pos, beg);
987
988 i = validate_interval_range (object, &pos, &pos, soft);
989 if (NULL_INTERVAL_P (i))
990 return 0;
991
992 next = next_interval (i);
993 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next))
994 {
995 next = next_interval (next);
996 if (NULL_INTERVAL_P (next))
997 return 0;
998 if (next->position >= end)
999 return 0;
1000 }
1001
1002 if (NULL_INTERVAL_P (next))
1003 return 0;
1004
1005 return 1;
1006}
1007
1008DEFUN ("next-single-property-change", Fnext_single_property_change, 982DEFUN ("next-single-property-change", Fnext_single_property_change,
1009 Snext_single_property_change, 2, 4, 0, 983 Snext_single_property_change, 2, 4, 0,
1010 doc: /* Return the position of next property change for a specific property. 984 doc: /* Return the position of next property change for a specific property.
@@ -1374,15 +1348,18 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1374 register EMACS_INT s, len; 1348 register EMACS_INT s, len;
1375 INTERVAL unchanged; 1349 INTERVAL unchanged;
1376 1350
1377 s = XINT (start); 1351 if (XINT (start) < XINT (end))
1378 len = XINT (end) - s; 1352 {
1379 if (len == 0) 1353 s = XINT (start);
1380 return; 1354 len = XINT (end) - s;
1381 if (len < 0) 1355 }
1356 else if (XINT (end) < XINT (start))
1382 { 1357 {
1383 s = s + len; 1358 s = XINT (end);
1384 len = - len; 1359 len = XINT (start) - s;
1385 } 1360 }
1361 else
1362 return;
1386 1363
1387 if (i == 0) 1364 if (i == 0)
1388 i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s); 1365 i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
@@ -1410,8 +1387,8 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1410 i = next_interval (i); 1387 i = next_interval (i);
1411 } 1388 }
1412 1389
1413 /* We are starting at the beginning of an interval, I */ 1390 /* We are starting at the beginning of an interval I. LEN is positive. */
1414 while (len > 0) 1391 do
1415 { 1392 {
1416 if (i == 0) 1393 if (i == 0)
1417 abort (); 1394 abort ();
@@ -1443,6 +1420,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1443 1420
1444 i = next_interval (i); 1421 i = next_interval (i);
1445 } 1422 }
1423 while (len > 0);
1446} 1424}
1447 1425
1448DEFUN ("remove-text-properties", Fremove_text_properties, 1426DEFUN ("remove-text-properties", Fremove_text_properties,
@@ -1781,15 +1759,9 @@ text_property_stickiness (Lisp_Object prop, Lisp_Object pos, Lisp_Object buffer)
1781} 1759}
1782 1760
1783 1761
1784/* I don't think this is the right interface to export; how often do you 1762/* Copying properties between objects. */
1785 want to do something like this, other than when you're copying objects
1786 around?
1787
1788 I think it would be better to have a pair of functions, one which
1789 returns the text properties of a region as a list of ranges and
1790 plists, and another which applies such a list to another object. */
1791 1763
1792/* Add properties from SRC to SRC of SRC, starting at POS in DEST. 1764/* Add properties from START to END of SRC, starting at POS in DEST.
1793 SRC and DEST may each refer to strings or buffers. 1765 SRC and DEST may each refer to strings or buffers.
1794 Optional sixth argument PROP causes only that property to be copied. 1766 Optional sixth argument PROP causes only that property to be copied.
1795 Properties are copied to DEST as if by `add-text-properties'. 1767 Properties are copied to DEST as if by `add-text-properties'.
@@ -2037,7 +2009,8 @@ call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end)
2037 those hooks in order, with START and END - 1 as arguments. */ 2009 those hooks in order, with START and END - 1 as arguments. */
2038 2010
2039void 2011void
2040verify_interval_modification (struct buffer *buf, int start, int end) 2012verify_interval_modification (struct buffer *buf,
2013 EMACS_INT start, EMACS_INT end)
2041{ 2014{
2042 register INTERVAL intervals = BUF_INTERVALS (buf); 2015 register INTERVAL intervals = BUF_INTERVALS (buf);
2043 register INTERVAL i; 2016 register INTERVAL i;
@@ -2328,7 +2301,4 @@ inherits it if NONSTICKINESS is nil. The `front-sticky' and
2328 defsubr (&Sremove_list_of_text_properties); 2301 defsubr (&Sremove_list_of_text_properties);
2329 defsubr (&Stext_property_any); 2302 defsubr (&Stext_property_any);
2330 defsubr (&Stext_property_not_all); 2303 defsubr (&Stext_property_not_all);
2331/* defsubr (&Serase_text_properties); */
2332/* defsubr (&Scopy_text_properties); */
2333} 2304}
2334