Mercurial > emacs
comparison src/editfns.c @ 51042:edeae7524de9
(get_pos_property): Don't assume that `object' = nil.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 17 May 2003 18:47:04 +0000 |
parents | 2a57a6e6b390 |
children | beceb827c1ce |
comparison
equal
deleted
inserted
replaced
51041:4370ce3fabb3 | 51042:edeae7524de9 |
---|---|
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, 2002 | 2 Copyright (C) 1985,86,87,89,93,94,95,96,97,98, 1999, 2000, 2001, 02, 2003 |
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 |
397 Lisp_Object | 397 Lisp_Object |
398 get_pos_property (position, prop, object) | 398 get_pos_property (position, prop, object) |
399 Lisp_Object position, object; | 399 Lisp_Object position, object; |
400 register Lisp_Object prop; | 400 register Lisp_Object prop; |
401 { | 401 { |
402 struct window *w = 0; | |
403 | |
404 CHECK_NUMBER_COERCE_MARKER (position); | 402 CHECK_NUMBER_COERCE_MARKER (position); |
405 | 403 |
406 if (NILP (object)) | 404 if (NILP (object)) |
407 XSETBUFFER (object, current_buffer); | 405 XSETBUFFER (object, current_buffer); |
408 | 406 else if (WINDOWP (object)) |
409 if (WINDOWP (object)) | 407 object = XWINDOW (object)->buffer; |
410 { | 408 |
411 w = XWINDOW (object); | 409 if (!BUFFERP (object)) |
412 object = w->buffer; | 410 /* pos-property only makes sense in buffers right now, since strings |
413 } | 411 have no overlays and no notion of insertion for which stickiness |
414 if (BUFFERP (object)) | 412 could be obeyed. */ |
413 return Fget_text_property (position, prop, object); | |
414 else | |
415 { | 415 { |
416 int posn = XINT (position); | 416 int posn = XINT (position); |
417 int noverlays; | 417 int noverlays; |
418 Lisp_Object *overlay_vec, tem; | 418 Lisp_Object *overlay_vec, tem; |
419 struct buffer *obuf = current_buffer; | 419 struct buffer *obuf = current_buffer; |
455 return tem; | 455 return tem; |
456 } | 456 } |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 } | 460 { /* Now check the text-properties. */ |
461 | 461 int stickiness = text_property_stickiness (prop, position, object); |
462 { /* Now check the text-properties. */ | 462 if (stickiness > 0) |
463 int stickiness = text_property_stickiness (prop, position); | 463 return Fget_text_property (position, prop, object); |
464 if (stickiness > 0) | 464 else if (stickiness < 0 |
465 return Fget_text_property (position, prop, Qnil); | 465 && XINT (position) > BUF_BEGV (XBUFFER (object))) |
466 else if (stickiness < 0 && XINT (position) > BEGV) | 466 return Fget_text_property (make_number (XINT (position) - 1), |
467 return Fget_text_property (make_number (XINT (position) - 1), | 467 prop, object); |
468 prop, Qnil); | 468 else |
469 else | 469 return Qnil; |
470 return Qnil; | 470 } |
471 } | 471 } |
472 } | 472 } |
473 | 473 |
474 /* Find the field surrounding POS in *BEG and *END. If POS is nil, | 474 /* Find the field surrounding POS in *BEG and *END. If POS is nil, |
475 the value of point is used instead. If BEG or END null, | 475 the value of point is used instead. If BEG or END null, |
476 means don't store the beginning or end of the field. | 476 means don't store the beginning or end of the field. |