emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading text properties from a yanked text


From: Eli Zaretskii
Subject: Re: Reading text properties from a yanked text
Date: Sun, 27 Nov 2022 09:10:33 +0200

> From: "Nicolas P. Rougier (inria)" <nicolas.rougier@inria.fr>
> 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]