From: Lars Ingebrigtsen Date: Thu, 28 Apr 2022 11:04:28 +0000 (+0200) Subject: Document the non-effect of narrowing on get-text-property X-Git-Tag: emacs-29.0.90~1931^2~245 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6db90a412ac3aac6ff44d0d92ac26b2ecb228071;p=emacs.git Document the non-effect of narrowing on get-text-property * doc/lispref/text.texi (Examining Properties): Document surprising non-effect of narrowing (bug#16413). * src/textprop.c (Ftext_properties_at, Fget_text_property): Mention narrowing. --- diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index ab9abd0495b..ca6a483c541 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -2969,6 +2969,12 @@ character after position @var{pos} in @var{object} (a buffer or string). The argument @var{object} is optional and defaults to the current buffer. +If @var{position} is at the end of @var{object}, the value is +@code{nil}, but note that buffer narrowing does not affect the value. +That is, if @var{object} is a buffer or @code{nil}, and the buffer is +narrowed and @var{position} is at the end of the narrowed buffer, the +result may be non-@code{nil}. + If there is no @var{prop} property strictly speaking, but the character has a property category that is a symbol, then @code{get-text-property} returns the @var{prop} property of that symbol. @@ -3021,6 +3027,12 @@ properties take precedence over this variable. This function returns the entire property list of the character at @var{position} in the string or buffer @var{object}. If @var{object} is @code{nil}, it defaults to the current buffer. + +If @var{position} is at the end of @var{object}, the value is +@code{nil}, but note that buffer narrowing does not affect the value. +That is, if @var{object} is a buffer or @code{nil}, and the buffer is +narrowed and @var{position} is at the end of the narrowed buffer, the +result may be non-@code{nil}. @end defun @defvar default-text-properties diff --git a/src/textprop.c b/src/textprop.c index c6c9e102e34..072aac28667 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -561,8 +561,13 @@ DEFUN ("text-properties-at", Ftext_properties_at, doc: /* Return the list of properties of the character at POSITION in OBJECT. If the optional second argument OBJECT is a buffer (or nil, which means the current buffer), POSITION is a buffer position (integer or marker). + If OBJECT is a string, POSITION is a 0-based index into it. -If POSITION is at the end of OBJECT, the value is nil. + +If POSITION is at the end of OBJECT, the value is nil, but note that +buffer narrowing does not affect the value. That is, if OBJECT is a +buffer or nil, and the buffer is narrowed and POSITION is at the end +of the narrowed buffer, the result may be non-nil. If you want to display the text properties at point in a human-readable form, use the `describe-text-properties' command. */) @@ -590,7 +595,11 @@ DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0, doc: /* Return the value of POSITION's property PROP, in OBJECT. OBJECT should be a buffer or a string; if omitted or nil, it defaults to the current buffer. -If POSITION is at the end of OBJECT, the value is nil. */) + +If POSITION is at the end of OBJECT, the value is nil, but note that +buffer narrowing does not affect the value. That is, if the buffer is +narrowed and POSITION is at the end of the narrowed buffer, the result +may be non-nil. */) (Lisp_Object position, Lisp_Object prop, Lisp_Object object) { return textget (Ftext_properties_at (position, object), prop);