From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Nicolas P. Rougier (inria)" Newsgroups: gmane.emacs.devel Subject: Re: Reading text properties from a yanked text Date: Sun, 27 Nov 2022 07:16:45 +0100 Message-ID: References: <83lenwrkjo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34792"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.11; emacs 28.2 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 27 07:54:20 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ozBYS-0008qd-Ly for ged-emacs-devel@m.gmane-mx.org; Sun, 27 Nov 2022 07:54:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozBXh-0000Mx-BT; Sun, 27 Nov 2022 01:53:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozBXf-0000MY-Ch for emacs-devel@gnu.org; Sun, 27 Nov 2022 01:53:31 -0500 Original-Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozBXd-0005hd-8J; Sun, 27 Nov 2022 01:53:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=references:from:to:cc:subject:date:in-reply-to: message-id:mime-version:content-transfer-encoding; bh=LwhIPeWdDnOqPp1L5cNU2uCn0250sqYppMOphdBpY+U=; b=S/EggddRqsCxQtGKly5pWUbgkdq4Scvx+HfftUMgTJeO+JuvSON6v2GY JQWi9sWg8R4G3qASh9QnWQr0S/yipXPx5NpCHwpKasXRrt8GptcvUUYmk yL/ziRRRF6F4fOHxyPy5778p+OrtKEeZgbMHJRT8wpnelslOIaXfDdVdL k=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=nicolas.rougier@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.96,197,1665439200"; d="scan'208";a="80239677" Original-Received: from 91-160-114-139.subs.proxad.net (HELO M-E7-NPR) ([91.160.114.139]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2022 07:53:25 +0100 In-reply-to: <83lenwrkjo.fsf@gnu.org> Received-SPF: pass client-ip=192.134.164.83; envelope-from=nicolas.rougier@inria.fr; helo=mail2-relais-roc.national.inria.fr X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300613 Archived-At: Eli Zaretskii [2022-11-27 at 08:14] wrote: > Because "Hello" is just a string, with no properties. The=20 > "Hello" that you > propertized and inserted is long gone by the time you evaluate=20 > case 2. The > mere fact that both strings have the same text "Hello" doesn't=20 > mean they are > the same string object. And text properties in Emacs are=20 > properties of > specific objects. >=20 > Try this instead: >=20 > (let ((str (propertize "Hello" 'face 'bold))) > (insert str) > (text-properties-at 0 str)) >=20 > This makes sure the same string that gets inserted is passed to > text-properties-at, and produces the results you expect. Thanks for the explanation. I think I get it (but it is still is a=20 bit confusing to me). For example this returns (face bold): (with-temp-buffer (insert (propertize "Hello" 'face 'bold)) (kill-region (point-min) (point-max)) (yank) (text-properties-at 0 (buffer-substring (point-min) (point-max)))) While this returns nil: (with-temp-buffer (insert (propertize "Hello" 'face 'bold)) (kill-region (point-min) (point-max)) (insert (format "(text-properties-at 0 \"%s\")" (current-kill 0))) (eval-buffer)) Nicolas --=20 Nicolas P. Rougier =E2=80=94=E2=80=94 www.labri.fr/perso/nrougier Institute of Neurodegenerative Diseases, Bordeaux