From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#17507: Documentation for `add-text-property' and relatives Date: Wed, 14 Aug 2019 16:57:44 -0700 Message-ID: <87a7cbti4n.fsf@mouse.gnus.org> References: <21365.44878.936634.958813@home.barzilay.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="59648"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 17507@debbugs.gnu.org To: Eli Barzilay Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 15 01:58:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hy39f-000FOe-GS for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Aug 2019 01:58:11 +0200 Original-Received: from localhost ([::1]:36664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy39e-0000uu-2O for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Aug 2019 19:58:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59985) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy39W-0000u0-Vw for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 19:58:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hy39V-0002Vj-PI for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 19:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41056) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hy39V-0002Va-M4 for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 19:58:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hy39V-0007zw-J0 for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 19:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Aug 2019 23:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17507 X-GNU-PR-Package: emacs Original-Received: via spool by 17507-submit@debbugs.gnu.org id=B17507.156582707330710 (code B ref 17507); Wed, 14 Aug 2019 23:58:01 +0000 Original-Received: (at 17507) by debbugs.gnu.org; 14 Aug 2019 23:57:53 +0000 Original-Received: from localhost ([127.0.0.1]:49874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy39M-0007zF-Pz for submit@debbugs.gnu.org; Wed, 14 Aug 2019 19:57:53 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:58030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy39L-0007z8-43 for 17507@debbugs.gnu.org; Wed, 14 Aug 2019 19:57:52 -0400 Original-Received: from 24-104-73-23-ip-static.hfc.comcastbusiness.net ([24.104.73.23] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hy39G-0005YA-Jp; Thu, 15 Aug 2019 01:57:49 +0200 In-Reply-To: <21365.44878.936634.958813@home.barzilay.org> (Eli Barzilay's message of "Fri, 16 May 2014 02:25:18 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164991 Archived-At: Eli Barzilay writes: > What I was surprised to find out is that > > (let ((s "foo")) (put-text-property 0 3 'foo 'bar s) s) > > works. It's probably obvious for elisp hackers, but coming from > most other lisps/schemes, I kind of assumed that the #("foo" ...) > thing is made of the "foo" string in some vector-like container that > holds the properties. Given that unconscious assumption, I assumed > that it wouldn't work, and that I'll need some uglier hack like > > (let ((s (propertize "foo" 'foo nil))) > (put-text-property 0 3 'foo 'bar s) s) > > so that `s' points to an object that can be mutated inside. > > So I think that it would be a good idea to add a comment in the docs > (of all of these functions) that notes that when given a string, they > mutate it, and it works even if the input is property-less. Or just > make it easier with showing a example as the above. > > (Hopefully the above makes sense -- I wonder how many lispers who are > not native e-lispers have that assumption...) (I'm going through old bug reports that have unfortunately gotten no responses yet.) Hm... I think the doc string is pretty clear here: --- If the optional fifth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. --- I understand that if you come from a C background (or something like that) your assumption may be that a string is just a bunch of bytes with a null at the end, so you can't add any properties to it -- but that's not the case in most languages, where a string is an object with lots of different qualities in addition to the text itself. So I don't think this is something that's desirable to explain in this specific context, and I'm closing this bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no