unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 9871@debbugs.gnu.org
Subject: bug#9871: `query-replace' and friends break text properties
Date: Mon, 19 Aug 2019 10:43:49 +0200	[thread overview]
Message-ID: <8736hx35q2.fsf_-_@gmail.com> (raw)
In-Reply-To: <878srq3ttb.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Sun, 18 Aug 2019 17:03:28 -0700, Sun, 18 Aug 2019 17:57:18 -0700 (PDT)")

On Sun, 18 Aug 2019 17:03:28 -0700
Lars Ingebrigtsen wrote:

> I guess the question becomes -- what text properties should be in the
> result?
>
> If you have
>
> (with-temp-buffer
>   (insert (propertize "hel" 'face 'bold))
>   (insert (propertize "lo" 'face 'underline))
>   (goto-char (point-min))
>   (replace-regexp "ell" "yes, well")
>   (buffer-string))
>
> should "yes, well" be in bold or underline?  Or a mix?  I don't really
> think there's any solution here that will satisfy anybody.
                                                    ^^^^^^^
I assume you meant "everybody".

> But I guess it would make some sense to view this as "delete the text,
> and then pretend we're inserting text as if by `self-insert-command'",
> which would make the new text bold here.

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 don't know...  all solutions here seem kinda ad hoc, so perhaps the
> current behaviour is the least surprising.  Any opinions?

I definitely don't consider it the least surprising, but I guess you're
rather asking for the opinion of other people.

On Sun, 18 Aug 2019 17:57:18 -0700 (PDT)
Drew Adams wrote:

[...]

> If a user specifies replacement text that has
> text properties then it should be used as is:
> its properties should remain when it takes the
> place of text in the buffer.

[...]

Sure. For the yanking (i.e., interactive) case there's also
`yank-handled-properties' and `yank-excluded-properties'.

-- 
Štěpán





  parent reply	other threads:[~2019-08-19  8:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 22:20 bug#9871: `query-replace' and friends break text properties Štěpán Němec
2019-08-19  0:03 ` Lars Ingebrigtsen
2019-08-19  0:57   ` Drew Adams
2019-08-19  8:43   ` Štěpán Němec [this message]
2019-08-19 20:37     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736hx35q2.fsf_-_@gmail.com \
    --to=stepnem@gmail.com \
    --cc=9871@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).