Subject: bug#17052: substitute-command-keys strips text properties

From: Eli Zaretskii <[email-masked]>
Date: Mon, 19 Aug 2019 18:27:32 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: Stefan Kangas <[email-masked]>,  [email-masked],
>   [email-masked],  [email-masked]
> Date: Sun, 18 Aug 2019 15:43:35 -0700
> 
> But if you look at that function in particular, it's written in a very
> C-ey fashion, what with copying over characters one by one etc.  It
> could be rewritten (in C) to use the proper primitives we have that
> preserve text properties (Fsubstring etc), but then you'd just end up
> with a more long-winded version that would be Lisp-in-C, so we might as
> well just rewrite it in Lisp.

AFAIU, the problematic parts are not those which copy characters one
by one, the problematic parts are those which _substitute_ one text
with another.  In that case, you need to adjust the text properties or
cons them out of thin air.