all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "Lars Ingebrigtsen" <larsi@gnus.org>, "Štěpán Němec" <stepnem@gmail.com>
Cc: 9871@debbugs.gnu.org
Subject: bug#9871: `query-replace' and friends break text properties
Date: Sun, 18 Aug 2019 17:57:18 -0700 (PDT)	[thread overview]
Message-ID: <b5e2329a-4ec0-484d-b0d4-909843e9cd6f@default> (raw)
In-Reply-To: <878srq3ttb.fsf@mouse.gnus.org>

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

I take a slightly different position from both
of you, I guess.

I'd say that the replacement text should replace
the text to replace as if `delete-selection-mode'
were turned on and you (1) selected the text to
replace and then ` yanked the replacement text
from the kill ring to replace it.  The text props
are copied to the kill-ring as part of the text.
And yanking the text gives you copies that also
have those text properties.  Why shouldn't the
same behavior be available for query-replace?

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.

E.g. Copy some buffer text that has properties
into the kill ring. Then use `M-%' and yank that
copied, propertized text as the replacement text.
The places where it now appears as replacement
should all have the same text properties.  But
they don't seem to.





  reply	other threads:[~2019-08-19  0:57 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 [this message]
2019-08-19  8:43   ` Štěpán Němec
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

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

  git send-email \
    --in-reply-to=b5e2329a-4ec0-484d-b0d4-909843e9cd6f@default \
    --to=drew.adams@oracle.com \
    --cc=9871@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=stepnem@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.