GNU bug report logs - #20153
24.4.91; destructive add-face-text-property and string deep copying

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Oleh Krehel <ohwoeowho@HIDDEN>; merged with #27433; dated Fri, 20 Mar 2015 12:33:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 20153 27433. Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Mar 2015 12:32:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 20 08:32:52 2015
Received: from localhost ([127.0.0.1]:58859 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1YYw6e-0004bd-9e
	for submit <at> debbugs.gnu.org; Fri, 20 Mar 2015 08:32:52 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37467)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6b-0004bN-Gs
 for submit <at> debbugs.gnu.org; Fri, 20 Mar 2015 08:32:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6V-00072M-9m
 for submit <at> debbugs.gnu.org; Fri, 20 Mar 2015 08:32:44 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:36938)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6V-00072I-6i
 for submit <at> debbugs.gnu.org; Fri, 20 Mar 2015 08:32:43 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39186)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6U-0007yI-5q
 for bug-gnu-emacs@HIDDEN; Fri, 20 Mar 2015 08:32:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6R-000711-Bn
 for bug-gnu-emacs@HIDDEN; Fri, 20 Mar 2015 08:32:42 -0400
Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:37609)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ohwoeowho@HIDDEN>) id 1YYw6R-00070u-5n
 for bug-gnu-emacs@HIDDEN; Fri, 20 Mar 2015 08:32:39 -0400
Received: by wixw10 with SMTP id w10so19086068wix.0
 for <bug-gnu-emacs@HIDDEN>; Fri, 20 Mar 2015 05:32:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:to:subject:date:message-id:mime-version:content-type;
 bh=KFi0siMjo6bwfl5YMc00DhmKQL9fO3X2YirA5dwYSa0=;
 b=F8lq/walk5cntbT6yem4PSmQ4fysPsSyJgPLDDiX7uDYmMAl2ekYamUzxmN9sKbi9r
 sgcM4WXzkkBasDUo3YbzpJsQEI+E6LfG61QuWVROOstVKDBS4/8iNw0SB1QxXu+leb4A
 uacEXiOgsTQ6bFBW1mICWte6rcfQLOCLmIy751GF0vLoz73eTcO5eDt9aF+a+v51qZeb
 KMc6FouiHOtCyOptGrX5XVse8DB09w0UnSXZEQ/a7TTGXYUIt/+QlkthZ34sJyCCSDec
 TYaRe087oVafnveP1V3rUFk3dSQ9x/BWgmLGxl3Ex3RVcewXtVo4MIbsfThf1Yjoz199
 gTgw==
X-Received: by 10.180.90.166 with SMTP id bx6mr4842510wib.65.1426854758475;
 Fri, 20 Mar 2015 05:32:38 -0700 (PDT)
Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45])
 by mx.google.com with ESMTPSA id ax10sm6179222wjc.26.2015.03.20.05.32.37
 for <bug-gnu-emacs@HIDDEN>
 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
 Fri, 20 Mar 2015 05:32:37 -0700 (PDT)
From: Oleh Krehel <ohwoeowho@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.4.91; destructive add-face-text-property and string deep copying
Date: Fri, 20 Mar 2015 13:28:00 +0100
Message-ID: <87bnjnyhtb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)


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




Acknowledgement sent to Oleh Krehel <ohwoeowho@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#20153; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 16 Jul 2017 14:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.