comparison src/textprop.c @ 6063:233fffcfb6c8

(Fget_char_property): New function.
author Karl Heuer <kwzh@gnu.org>
date Thu, 24 Feb 1994 19:18:32 +0000
parents 9e5b5196aae9
children bdfff039f6e3
comparison
equal deleted inserted replaced
6062:e9768f0d0653 6063:233fffcfb6c8
19 19
20 #include <config.h> 20 #include <config.h>
21 #include "lisp.h" 21 #include "lisp.h"
22 #include "intervals.h" 22 #include "intervals.h"
23 #include "buffer.h" 23 #include "buffer.h"
24 #include "window.h"
24 25
25 26
26 /* NOTES: previous- and next- property change will have to skip 27 /* NOTES: previous- and next- property change will have to skip
27 zero-length intervals if they are implemented. This could be done 28 zero-length intervals if they are implemented. This could be done
28 inside next_interval and previous_interval. 29 inside next_interval and previous_interval.
515 since no character follows. */ 516 since no character follows. */
516 if (XINT (pos) == LENGTH (i) + i->position) 517 if (XINT (pos) == LENGTH (i) + i->position)
517 return Qnil; 518 return Qnil;
518 519
519 return textget (i->plist, prop); 520 return textget (i->plist, prop);
521 }
522
523 DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
524 "Return the value of position POS's property PROP, in OBJECT.\n\
525 OBJECT is optional and defaults to the current buffer.\n\
526 If POSITION is at the end of OBJECT, the value is nil.\n\
527 If OBJECT is a buffer, then overlay properties are considered as well as\n\
528 text properties.
529 If OBJECT is a window, then that window's buffer is used, but window-specific
530 overlays are considered only if they are associated with OBJECT.")
531 (pos, prop, object)
532 Lisp_Object pos, object;
533 register Lisp_Object prop;
534 {
535 struct window *w = 0;
536
537 CHECK_NUMBER_COERCE_MARKER (pos, 0);
538
539 if (NILP (object))
540 XSET (object, Lisp_Buffer, current_buffer);
541
542 if (WINDOWP (object))
543 {
544 w = XWINDOW (object);
545 XSET (object, Lisp_Buffer, w->buffer);
546 }
547 if (BUFFERP (object))
548 {
549 int posn = XINT (pos);
550 int noverlays;
551 Lisp_Object *overlay_vec, tem;
552 int next_overlay;
553 int len;
554
555 /* First try with room for 40 overlays. */
556 len = 40;
557 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
558
559 noverlays = overlays_at (posn, 0, &overlay_vec, &len, &next_overlay);
560
561 /* If there are more than 40,
562 make enough space for all, and try again. */
563 if (noverlays > len)
564 {
565 len = noverlays;
566 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
567 noverlays = overlays_at (posn, 0, &overlay_vec, &len, &next_overlay);
568 }
569 noverlays = sort_overlays (overlay_vec, noverlays, w);
570
571 /* Now check the overlays in order of decreasing priority. */
572 while (--noverlays >= 0)
573 {
574 tem = Foverlay_get (overlay_vec[noverlays], prop);
575 if (!NILP (tem))
576 return (tem);
577 }
578 }
579 /* Not a buffer, or no appropriate overlay, so fall through to the
580 simpler case. */
581 return (Fget_text_property (pos, prop, object));
520 } 582 }
521 583
522 DEFUN ("next-property-change", Fnext_property_change, 584 DEFUN ("next-property-change", Fnext_property_change,
523 Snext_property_change, 1, 3, 0, 585 Snext_property_change, 1, 3, 0,
524 "Return the position of next property change.\n\ 586 "Return the position of next property change.\n\