[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20153: 24.4.91; destructive add-face-text-property and string deep c
From: |
Oleh Krehel |
Subject: |
bug#20153: 24.4.91; destructive add-face-text-property and string deep copying |
Date: |
Fri, 20 Mar 2015 13:28:00 +0100 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#20153: 24.4.91; destructive add-face-text-property and string deep copying,
Oleh Krehel <=