From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel 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) Message-ID: <200512300347.jBU3l3E00108@raven.dms.auburn.edu> References: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1135914598 27653 80.91.229.2 (30 Dec 2005 03:49:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2005 03:49:58 +0000 (UTC) Cc: drew.adams@oracle.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 30 04:49:51 2005 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EsBH0-0000fR-6g for ged-emacs-devel@m.gmane.org; Fri, 30 Dec 2005 04:49:46 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EsBIM-0005Cu-TD for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2005 22:51:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EsBI8-00059f-JS for emacs-devel@gnu.org; Thu, 29 Dec 2005 22:50:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EsBI7-00059A-SQ for emacs-devel@gnu.org; Thu, 29 Dec 2005 22:50:56 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EsBI7-00058U-GT for emacs-devel@gnu.org; Thu, 29 Dec 2005 22:50:55 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EsBIW-0001mf-PR; Thu, 29 Dec 2005 22:51:20 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.13.3+Sun/8.13.3) with ESMTP id jBU3nJ7V029268; Thu, 29 Dec 2005 21:49:19 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id jBU3l3E00108; Thu, 29 Dec 2005 21:47:03 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: (rms@gnu.org) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.1 (manatee.dms.auburn.edu [131.204.53.104]); Thu, 29 Dec 2005 21:49:19 -0600 (CST) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48530 Archived-At: 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; ============================================================