Subject: Re: bug#9871: `query-replace' and friends break text properties

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 19 Aug 2019 13:37:08 -0700

Štěpán Němec <[email-masked]> writes:

> Yes it would. I also think that the straightforward case where all the
> text has the same value for a property will be much more frequent than
> your contrived example (note my property wasn't even visible at all; in
> case of font-locking for example I'd expect the result to get
> refontified as usual anyway).

I just used a face because that's visible; the same applies to any text
property.

Thinking about it a bit more, I don't really feel that
delete-then-insert semantics will be very nice as a feature, either.

(with-temp-buffer
  (insert (propertize "hello" 'face 'bold))
  (goto-char (point-min))
  (replace-regexp "hello" "hey")
  (buffer-string))

If you replace a phrase that has one face with a different phrase, if
text properties are preserved, surely you'd expect that "hey" to also be
bold.  But it won't be, since the "hello" was deleted first and then
"hey" was inserted.

So I don't really think there's any way to DWIM here that is "what I
mean", and if you want to copy over text properties in one form of
another, you have to write some code to express what you want to have
happen.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no