From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Barzilay Newsgroups: gmane.emacs.bugs Subject: bug#17507: Documentation for `add-text-property' and relatives Date: Fri, 16 May 2014 02:25:18 -0400 Message-ID: <21365.44878.936634.958813@home.barzilay.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1400221595 25446 80.91.229.3 (16 May 2014 06:26:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 May 2014 06:26:35 +0000 (UTC) To: 17507@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 16 08:26:29 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WlBb9-00072Q-PR for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 May 2014 08:26:27 +0200 Original-Received: from localhost ([::1]:33597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBb9-0000RN-BT for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 May 2014 02:26:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBb0-0000QR-Cg for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:26:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlBal-0005LX-9i for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:26:18 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBal-0005LT-6k for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:26:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WlBak-0003lA-Et for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Barzilay Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 May 2014 06:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.140022155614434 (code B ref -1); Fri, 16 May 2014 06:26:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 May 2014 06:25:56 +0000 Original-Received: from localhost ([127.0.0.1]:36647 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WlBab-0003ki-44 for submit@debbugs.gnu.org; Fri, 16 May 2014 02:25:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47106) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WlBaV-0003kL-Tm for submit@debbugs.gnu.org; Fri, 16 May 2014 02:25:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlBaJ-0005Ey-LR for submit@debbugs.gnu.org; Fri, 16 May 2014 02:25:42 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:38581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBaJ-0005Eq-HP for submit@debbugs.gnu.org; Fri, 16 May 2014 02:25:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBaD-0000Ny-DV for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:25:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlBa6-0005Bp-BW for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:25:29 -0400 Original-Received: from mail-qg0-f47.google.com ([209.85.192.47]:42128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlBa6-0005BY-7r for bug-gnu-emacs@gnu.org; Fri, 16 May 2014 02:25:22 -0400 Original-Received: by mail-qg0-f47.google.com with SMTP id j107so3460048qga.6 for ; Thu, 15 May 2014 23:25:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject; bh=gviJym2jmJAYO8fAo0F4tKrEnuwSoUnIFqEQE1mCx7g=; b=HsH8GmEZCBPeexuZlupV4Co84wJA5JvqiamTKQPTdu+eyvXqatbNpNv73WsTbyvdzA d+LpIAfidyqnWl+7Pnl0cNaeHjYoHE9R+8HmnEg9KELRw6rFoZS/06iox6GwatsfVIuF PIYC5Em1J4Fgidqr6qmblzqiWtvsNW38X86BAgql1CORQH/0oFSJVwIXR+3lLn7A30zE 1J6FGDNr7m3bioVMUG2mTH3xU1SwsEAwciUuC56wkEeDNSR1srRAHGe2j899F4jJk30j dH5MHMnfKJgP/9fC/gbnq7LWK+/hddEEK0KyHiPqNk6l9DgvfgDCrzHAULROHdqZyHQf lTlg== X-Gm-Message-State: ALoCoQmJsbPrGACx318E0+nD9NYPCFo7Zfnz8W4SIDPhmD7u6ggrGdNFEIBnCqFzedX5fPA/DcXH X-Received: by 10.224.47.130 with SMTP id n2mr20004572qaf.26.1400221520907; Thu, 15 May 2014 23:25:20 -0700 (PDT) Original-Received: from home.barzilay.org (c-24-60-254-179.hsd1.ma.comcast.net. [24.60.254.179]) by mx.google.com with ESMTPSA id r6sm11556365qab.40.2014.05.15.23.25.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 May 2014 23:25:20 -0700 (PDT) X-Mailer: VM 8.2.0b under 24.3.1 (x86_64-redhat-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:89147 Archived-At: It was unclear to me how to use `add-text-property' and its relatives (I actually started with `font-lock-append-text-property') with strings, since they don't return the string. It also looks like it won't be practical to ask for a change where they do return the string (if given one) since `add-text-properties' actually has a specified return value (which is arguably not as useful as getting back a string...). In any case, I eventually found out what I need to do, but it took me a while because I was confused. This is a bit verbose, but please bear with me... 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...) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!