From: Eli Barzilay <eli@barzilay.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 17507@debbugs.gnu.org
Subject: bug#17507: Documentation for `add-text-property' and relatives
Date: Thu, 15 Aug 2019 06:41:17 +0300 [thread overview]
Message-ID: <CALO-guvv0VYEKxP9tJ0anFAsEntVqsKxgM3CoTtRN2EUhUKpBg@mail.gmail.com> (raw)
In-Reply-To: <87a7cbti4n.fsf@mouse.gnus.org>
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 <larsi@gnus.org> wrote:
>
> Eli Barzilay <eli@barzilay.org> 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!
next prev parent reply other threads:[~2019-08-15 3:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 6:25 bug#17507: Documentation for `add-text-property' and relatives Eli Barzilay
2019-08-14 23:57 ` Lars Ingebrigtsen
2019-08-15 3:41 ` Eli Barzilay [this message]
2019-08-15 14:30 ` Eli Zaretskii
2019-08-16 1:35 ` Eli Barzilay
2019-08-16 8:46 ` Eli Zaretskii
2019-08-16 20:04 ` Lars Ingebrigtsen
2019-08-17 6:47 ` Eli Zaretskii
2019-08-17 22:22 ` Richard Stallman
2019-08-16 23:49 ` Eli Barzilay
2019-08-17 6:41 ` Eli Zaretskii
2019-08-17 12:40 ` Eli Barzilay
2019-08-17 12:46 ` Eli Zaretskii
2019-08-16 1:20 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALO-guvv0VYEKxP9tJ0anFAsEntVqsKxgM3CoTtRN2EUhUKpBg@mail.gmail.com \
--to=eli@barzilay.org \
--cc=17507@debbugs.gnu.org \
--cc=larsi@gnus.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.