From: Oleh Krehel <ohwoeowho@gmail.com>
To: 20153@debbugs.gnu.org
Subject: bug#20153: 24.4.91; destructive add-face-text-property and string deep copying
Date: Fri, 20 Mar 2015 13:28:00 +0100 [thread overview]
Message-ID: <87bnjnyhtb.fsf@gmail.com> (raw)
Here's an example of what I'm trying to do:
(setq test-str-1
#(";; This `is' a test"
0 3 (fontified nil face font-lock-comment-delimiter-face)
3 9 (fontified nil face font-lock-comment-face)
9 11 (fontified nil face (font-lock-constant-face font-lock-comment-face))
11 19 (fontified nil face font-lock-comment-face)))
(setq test-str-2 (concat test-str-1))
(add-face-text-property 0 (length test-str-2) 'foobar t test-str-2)
I would like to modify `test-str-2' without touching `test-str-1'.
For that, I either need `add-face-text-property' to be non-destructive,
either w.r.t. the string or at least w.r.t. the properties of the
string, or a way to deep-copy a string.
Here's the result of evaling the code above:
test-str-2
;; =>
#(";; This `is' a test" 0 3 (fontified nil face (font-lock-comment-delimiter-face foobar))
3 9 (fontified nil face (font-lock-comment-face foobar))
9 11 (fontified nil face (font-lock-constant-face font-lock-comment-face foobar))
11 19 (fontified nil face (font-lock-comment-face foobar)))
test-str-1
;; =>
#(";; This `is' a test" 0 3 (face font-lock-comment-delimiter-face fontified nil)
3 9 (face font-lock-comment-face fontified nil)
9 11 (face (font-lock-constant-face font-lock-comment-face foobar) ; <= foobar is here
fontified nil)
11 19 (face font-lock-comment-face fontified nil))
As you see, `test-str-1' was modified.
I'd like to know a straightforward solution to the problem itself, I'm
fine with either way of implementation.
Oleh
next reply other threads:[~2015-03-20 12:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-20 12:28 Oleh Krehel [this message]
2019-10-09 2:25 ` bug#20153: 24.4.91; destructive add-face-text-property and string deep copying Lars Ingebrigtsen
2019-10-09 3:04 ` Lars Ingebrigtsen
2019-10-09 8:24 ` Oleh Krehel
2019-10-09 17:10 ` Eli Zaretskii
2019-10-09 17:45 ` Lars Ingebrigtsen
2019-10-09 18:06 ` Eli Zaretskii
2019-10-09 18:09 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bnjnyhtb.fsf@gmail.com \
--to=ohwoeowho@gmail.com \
--cc=20153@debbugs.gnu.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).