comparison src/editfns.c @ 43897:46cd50d89b5b

(text_property_stickiness): Function moved to `textprop.c'. (char_property_eq): Function removed.
author Miles Bader <miles@gnu.org>
date Thu, 14 Mar 2002 08:11:03 +0000
parents 7263004fcb03
children 01b93e5e53a7
comparison
equal deleted inserted replaced
43896:fccc867cca64 43897:46cd50d89b5b
1 /* Lisp functions pertaining to editing. 1 /* Lisp functions pertaining to editing.
2 Copyright (C) 1985,86,87,89,93,94,95,96,97,98, 1999, 2000, 2001 2 Copyright (C) 1985,86,87,89,93,94,95,96,97,98, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
319 Watch out! Moving this marker changes the mark position. 319 Watch out! Moving this marker changes the mark position.
320 If you set the marker not to point anywhere, the buffer will have no mark. */) 320 If you set the marker not to point anywhere, the buffer will have no mark. */)
321 () 321 ()
322 { 322 {
323 return current_buffer->mark; 323 return current_buffer->mark;
324 }
325
326
327 #if 0 /* Not used. */
328
329 /* Return nonzero if POS1 and POS2 have the same value
330 for the text property PROP. */
331
332 static int
333 char_property_eq (prop, pos1, pos2)
334 Lisp_Object prop;
335 Lisp_Object pos1, pos2;
336 {
337 Lisp_Object pval1, pval2;
338
339 pval1 = Fget_char_property (pos1, prop, Qnil);
340 pval2 = Fget_char_property (pos2, prop, Qnil);
341
342 return EQ (pval1, pval2);
343 }
344
345 #endif /* 0 */
346
347 /* Return the direction from which the text-property PROP would be
348 inherited by any new text inserted at POS: 1 if it would be
349 inherited from the char after POS, -1 if it would be inherited from
350 the char before POS, and 0 if from neither. */
351
352 static int
353 text_property_stickiness (prop, pos)
354 Lisp_Object prop;
355 Lisp_Object pos;
356 {
357 Lisp_Object prev_pos, front_sticky;
358 int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */
359
360 if (XINT (pos) > BEGV)
361 /* Consider previous character. */
362 {
363 Lisp_Object rear_non_sticky;
364
365 prev_pos = make_number (XINT (pos) - 1);
366 rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil);
367
368 if (!NILP (CONSP (rear_non_sticky)
369 ? Fmemq (prop, rear_non_sticky)
370 : rear_non_sticky))
371 /* PROP is rear-non-sticky. */
372 is_rear_sticky = 0;
373 }
374
375 /* Consider following character. */
376 front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil);
377
378 if (EQ (front_sticky, Qt)
379 || (CONSP (front_sticky)
380 && !NILP (Fmemq (prop, front_sticky))))
381 /* PROP is inherited from after. */
382 is_front_sticky = 1;
383
384 /* Simple cases, where the properties are consistent. */
385 if (is_rear_sticky && !is_front_sticky)
386 return -1;
387 else if (!is_rear_sticky && is_front_sticky)
388 return 1;
389 else if (!is_rear_sticky && !is_front_sticky)
390 return 0;
391
392 /* The stickiness properties are inconsistent, so we have to
393 disambiguate. Basically, rear-sticky wins, _except_ if the
394 property that would be inherited has a value of nil, in which case
395 front-sticky wins. */
396 if (XINT (pos) == BEGV || NILP (Fget_text_property (prev_pos, prop, Qnil)))
397 return 1;
398 else
399 return -1;
400 } 324 }
401 325
402 326
403 /* Find the field surrounding POS in *BEG and *END. If POS is nil, 327 /* Find the field surrounding POS in *BEG and *END. If POS is nil,
404 the value of point is used instead. If BEG or END null, 328 the value of point is used instead. If BEG or END null,