From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: drew.adams@oracle.com, emacs-devel@gnu.org
Subject: Re: set-text-properties, remove-set-properties, add-text-properties: 1) doc string 2) return value
Date: Thu, 29 Dec 2005 21:47:03 -0600 (CST) [thread overview]
Message-ID: <200512300347.jBU3l3E00108@raven.dms.auburn.edu> (raw)
In-Reply-To: <E1Es9qz-000677-Jq@fencepost.gnu.org> (rms@gnu.org)
Richard Stallman wrote:
I can see from the C source that set-text-properties returns t
if that text had any properties before, nil if it had none.
Well, it is a little bit more complex than that. It returns nil if
the _entire_ string or buffer had no text properties and the
PROPERTIES arg is nil. But it also returns nil if set-text-properties
specifies an empty interval. I believe that the function returns nil
if it _knows_ that no text properties were changed, but that it makes
no effort to determine reliably whether any text properties were
changed.
There is an inconsistency. If a string has no text properties and
set-text-properties wants to remove all text-properties from _part_ of
the string, the return value is nil (makes sense). If it wants to
remove them from the entire string, the return value is t (makes no
sense):
ELISP> (setq str "123456789")
"123456789"
ELISP> (set-text-properties 0 9 nil str)
t
ELISP> (set-text-properties 0 8 nil str)
nil
This appears to be a small buglet. The patch below fixes the buglet
and documents, I believe, the return value more accurately. I can
install if desired.
===File ~/textprop.c-diff===================================
*** textprop.c 07 Aug 2005 10:28:42 -0500 1.143
--- textprop.c 29 Dec 2005 21:04:56 -0600
***************
*** 1316,1323 ****
properties PROPERTIES. OBJECT is the buffer or string containing
the text. OBJECT nil means use the current buffer.
SIGNAL_AFTER_CHANGE_P nil means don't signal after changes. Value
! is non-nil if properties were replaced; it is nil if there weren't
! any properties to replace. */
Lisp_Object
set_text_properties (start, end, properties, object, signal_after_change_p)
--- 1316,1323 ----
properties PROPERTIES. OBJECT is the buffer or string containing
the text. OBJECT nil means use the current buffer.
SIGNAL_AFTER_CHANGE_P nil means don't signal after changes. Value
! is nil if the function _knows_ that it did not replace any
! properties, non-nil otherwise. */
Lisp_Object
set_text_properties (start, end, properties, object, signal_after_change_p)
***************
*** 1341,1347 ****
&& XFASTINT (end) == SCHARS (object))
{
if (! STRING_INTERVALS (object))
! return Qt;
STRING_SET_INTERVALS (object, NULL_INTERVAL);
return Qt;
--- 1341,1347 ----
&& XFASTINT (end) == SCHARS (object))
{
if (! STRING_INTERVALS (object))
! return Qnil;
STRING_SET_INTERVALS (object, NULL_INTERVAL);
return Qt;
============================================================
next prev parent reply other threads:[~2005-12-30 3:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-28 21:59 set-text-properties, remove-set-properties, add-text-properties: 1) doc string 2) return value Drew Adams
2005-12-29 3:18 ` Stefan Monnier
2005-12-29 4:15 ` Drew Adams
2005-12-30 2:18 ` Richard M. Stallman
2005-12-30 3:47 ` Luc Teirlinck [this message]
2005-12-30 3:57 ` Luc Teirlinck
2005-12-30 11:24 ` David Kastrup
2005-12-29 11:10 ` Kim F. Storm
2005-12-29 16:03 ` Drew Adams
2005-12-29 19:41 ` Kevin Rodgers
2005-12-30 0:57 ` Juri Linkov
2006-02-18 19:37 ` Drew Adams
2006-02-19 15:14 ` Stefan Monnier
2005-12-29 22:41 ` Kim F. Storm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200512300347.jBU3l3E00108@raven.dms.auburn.edu \
--to=teirllm@dms.auburn.edu \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).