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: Gregory Heytings
Subject: Re: Reading text properties from a yanked text
Date: Sun, 27 Nov 2022 07:10:57 +0000



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))


The Lisp reader does not see the text properties of the text it reads. Unless you use the special "#(...)" construct, in which text properties are explicitly specified, and case you'll get them. E.g. you can eval the following

(text-properties-at 0 #("Hello" 0 4 (face bold)))

to get what you want.



reply via email to

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