私は適切な文字列を持っています。元の文字列のプロパティを保持しながら、それを深くコピーしてプロパティを追加したいと思います。どうすれば(簡単に)できますか?
例
1つずつ評価:
(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)
そしてその結果:
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))
バグを報告していただきありがとうございます。残念ながら、まだ誰もそれに応答していません。このユーティリティ関数(Cでコード化)を修正するとよいでしょう。
—
2015
add-face-text-property
ます。リストが他のユーザーによって参照されていると失敗するため、リストを破壊的に変更しないでください。