From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Barzilay Newsgroups: gmane.emacs.bugs Subject: bug#17507: Documentation for `add-text-property' and relatives Date: Thu, 15 Aug 2019 06:41:17 +0300 Message-ID: References: <21365.44878.936634.958813@home.barzilay.org> <87a7cbti4n.fsf@mouse.gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="118489"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 17507@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 15 05:42:11 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 1hy6eR-000UgB-B5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Aug 2019 05:42:11 +0200 Original-Received: from localhost ([::1]:38156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy6eQ-0002gU-AE for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Aug 2019 23:42:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59167) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy6eJ-0002gL-JU for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 23:42:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hy6eI-00058A-8z for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 23:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hy6eH-000582-RA for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 23:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hy6eH-00082y-NM for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 23:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Barzilay Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Aug 2019 03:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 17507-submit@debbugs.gnu.org id=B17507.156584049830895 (code B ref 17507); Thu, 15 Aug 2019 03:42:01 +0000 Original-Received: (at 17507) by debbugs.gnu.org; 15 Aug 2019 03:41:38 +0000 Original-Received: from localhost ([127.0.0.1]:50243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy6dt-00082F-JO for submit@debbugs.gnu.org; Wed, 14 Aug 2019 23:41:37 -0400 Original-Received: from mail-vs1-f65.google.com ([209.85.217.65]:34292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy6dr-000822-4f for 17507@debbugs.gnu.org; Wed, 14 Aug 2019 23:41:36 -0400 Original-Received: by mail-vs1-f65.google.com with SMTP id b20so758544vso.1 for <17507@debbugs.gnu.org>; Wed, 14 Aug 2019 20:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=barzilay-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KSsM395OuRB75NChzxwaJtEolB4By6m9gn3wU9IRN6U=; b=VUiq6TXkYX6YBNW9sn+be01w4AlnbxFxqk69TeoSzL78yc0hIi+fbn38dInXT6bF6A IoAkNnObJtNhbSSU0EcLTaoN/ARWVaykO/GznS/g6l6D2mkKvBt54sxq81LwHw20qYIR W3amSr340hM/5BcYDE33oPilQxiRhT7Q17vTeHKKhYqHNpDqbSjSJ/5bC6ecz5PzrQLB ODOKapneplOlKE1AFiuizDdZKbxud3uQ18Be3EsQBlKibezswa2imIfnzTkbMaz63gFc i5lZ4mA0brMWFVVElEulCc+22foSnB5802GYuCB+adwXoOPFiaPJ3rBhOYi4t6oNZ5I2 B++Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KSsM395OuRB75NChzxwaJtEolB4By6m9gn3wU9IRN6U=; b=jtSgR4ydpfc4n+tgPuxZaMzWDkMevMalfm43kRkpG0tFY8YfqMABbnSIyqnLFFFjIi j3bZiJFRLu4O3PhO89AbPiadsLVpE4kwJBBnRygRFucVtebeyuD1DoYQ5dXDym1BlVbZ 5q8/d+1aB68ldbrX2Bjze9asdxqgtG9jU1zpj3KKm207q+UfrVaUKC9z9reKpt7uWPfb s2kT2Q1lsHoHPgJ8olZMhYTzHuqPmEL9eDPJjfu0Y1vbYeDKxUUyuyl4li0VghGjr+8I w67nKhYNvApsmZijmtaLG77CrwMuBs42bmuwWEAXf7tIymN3W1ZJ+qaV/q/AfEL2yKWy nqOg== X-Gm-Message-State: APjAAAV8WvqYJrjR+euL7wggvTVNGMExIY0L8griNYfelbVg3ZSM7pw3 3ewegEsNPanU1c3fvG39vgdwv+o79VHGq0wT9p5vjk/QAgA= X-Google-Smtp-Source: APXvYqzoXAhNK0vAEZgCU/iYoJLgXUReGU84JoAHJjFq7IYNpxlmMthYPWv4GXX3rShgiIyd/5JSeB1fpSBK51Qfkgg= X-Received: by 2002:a67:e8c3:: with SMTP id y3mr2039016vsn.94.1565840489037; Wed, 14 Aug 2019 20:41:29 -0700 (PDT) In-Reply-To: <87a7cbti4n.fsf@mouse.gnus.org> 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:165030 Archived-At: Um... Note that I referred *explicitly* to other lisps and schemes. The assumption that I'm talking about would hold for people who are used to CL too: a string is indeed more than just a pointer bytes with a NUL at the end, yet there is no way to change a *property* of "foo" and end up with #("foo" stuff...). On Thu, Aug 15, 2019 at 2:57 AM Lars Ingebrigtsen wrote: > > 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 -- ((x=>x(x))(x=>x(x))) Eli Barzilay: http://barzilay.org/ Maze is Life!