From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Reading text properties from a yanked text Date: Sun, 27 Nov 2022 09:10:33 +0200 Message-ID: <83bkosrhxy.fsf@gnu.org> References: <83lenwrkjo.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29917"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: "Nicolas P. Rougier (inria)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 27 08:10:46 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 1ozBoM-0007Uj-3z for ged-emacs-devel@m.gmane-mx.org; Sun, 27 Nov 2022 08:10:46 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozBnu-00045f-8h; Sun, 27 Nov 2022 02:10:18 -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 1ozBnr-00040M-7B for emacs-devel@gnu.org; Sun, 27 Nov 2022 02:10:16 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozBnp-0008Ei-Vp; Sun, 27 Nov 2022 02:10:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=3MWu3ankd3+cED1VDUUf3tSMXefk8iq93+jeBiduXJ8=; b=hwScAlQZ6uB0 mNdKJoClrmZTN/GJJqavX1p41MwoCoJ2wqOiXzI0MIK5TQ381rU8uzRiiOhdjVOrqJG1NlzEy25N2 zR6/MmONyms6tommRHXTlCRtMycrmZBOhKi5LP7Qh100DzG5ut8dZBasz3Q/b6wHQQLIbvpGo6gI0 hmRY6hJ5qoq/bIryT5svjOWAXBmYHvnZUVQOvjNs5FuDig5r11zUh/q551iZ2IiJB+r5cJ5iiFVuA GtvC38a2eokNy8LijtO2sSONvbtQ7YKpGsvF8SxW8ofGASTgtJTlT6MQujamNEu0VkuelEDaCF75w elkKt0dturB3BMIQWRetUg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozBni-0005oj-4b; Sun, 27 Nov 2022 02:10:12 -0500 In-Reply-To: (nicolas.rougier@inria.fr) 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:300615 Archived-At: > From: "Nicolas P. Rougier (inria)" > Cc: emacs-devel@gnu.org > Date: Sun, 27 Nov 2022 07:16:45 +0100 > > 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)) Because once again what you pass to text-properties-at is a different string. You are confusing how a string looks on display when inserted into a buffer with another string that just happens to have the same text. Try this instead: (with-temp-buffer (insert (propertize "Hello" 'face 'bold)) (kill-region (point-min) (point-max)) (insert (format "(text-properties-at 0 \"%s\")" (current-kill 0))) (text-properties-at 0 (buffer-substring 24 29)))