unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Curious: Why is there no binding for replace-string "out of the box"?
@ 2024-03-06 21:12 T.V Raman
  2024-03-06 21:59 ` Andreas Schwab
  2024-03-07  6:38 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: T.V Raman @ 2024-03-06 21:12 UTC (permalink / raw)
  To: emacs-devel

As someone who has now used emacs for approx 35 years, I've always
assumed that M-r was bound to replace-string -- that's a binding I've
always had:-) I just realized that out-of-the-box, emacs -q binds
replace-regex to M-% but does not  bind replace-string. So just curious:

1. Is the above an oversight or intentional?
2.  Should we perhaps pick a binding for replace-string -- note: I dont
    care what we pick, but not having a key for it feels strange.
-- 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-06 21:12 Curious: Why is there no binding for replace-string "out of the box"? T.V Raman
@ 2024-03-06 21:59 ` Andreas Schwab
  2024-03-07  2:15   ` T.V Raman
  2024-03-07  6:38 ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2024-03-06 21:59 UTC (permalink / raw)
  To: T.V Raman; +Cc: emacs-devel

On Mär 06 2024, T.V Raman wrote:

> I just realized that out-of-the-box, emacs -q binds
> replace-regex to M-%

M-% binds query-replace, and replace-regexp is not bound.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-06 21:59 ` Andreas Schwab
@ 2024-03-07  2:15   ` T.V Raman
  2024-03-07  6:17     ` Yuri Khan
  2024-03-09  2:47     ` Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: T.V Raman @ 2024-03-07  2:15 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

more importantly replace-string is not bound. That is what I was trying to say> On Mär 06 2024, T.V Raman wrote:
>
>> I just realized that out-of-the-box, emacs -q binds
>> replace-regex to M-%
>
> M-% binds query-replace, and replace-regexp is not bound.

-- 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-07  2:15   ` T.V Raman
@ 2024-03-07  6:17     ` Yuri Khan
  2024-03-07  7:15       ` Eli Zaretskii
  2024-03-09  2:47     ` Richard Stallman
  1 sibling, 1 reply; 8+ messages in thread
From: Yuri Khan @ 2024-03-07  6:17 UTC (permalink / raw)
  To: T.V Raman; +Cc: Andreas Schwab, emacs-devel

On Thu, 7 Mar 2024 at 09:16, T.V Raman <raman@google.com> wrote:
>
> Andreas Schwab <schwab@linux-m68k.org> writes:
>
> more importantly replace-string is not bound. That is what I was trying to say

The user-facing difference between replace-string and query-replace is
that the former replaces unconditionally while the latter asks for
confirmation (with a possibility to type ‘!’ to confirm replacement
for all remaining occurrences). Similarly, replace-regexp vs
query-replace-regexp.

Both confirming commands are bound by default: query-replace to M-%,
query-replace-regexp to C-M-%.

Replacing without confirmation could be seen as an advanced feature —
if you are already comfortable with undo, you’re ready to use it; if
not, it’s scary.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-06 21:12 Curious: Why is there no binding for replace-string "out of the box"? T.V Raman
  2024-03-06 21:59 ` Andreas Schwab
@ 2024-03-07  6:38 ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-03-07  6:38 UTC (permalink / raw)
  To: T.V Raman; +Cc: emacs-devel

> From: "T.V Raman" <raman@google.com>
> Date: Wed, 06 Mar 2024 13:12:49 -0800
> 
> As someone who has now used emacs for approx 35 years, I've always
> assumed that M-r was bound to replace-string -- that's a binding I've
> always had:-) I just realized that out-of-the-box, emacs -q binds
> replace-regex to M-% but does not  bind replace-string. So just curious:
> 
> 1. Is the above an oversight or intentional?
> 2.  Should we perhaps pick a binding for replace-string -- note: I dont
>     care what we pick, but not having a key for it feels strange.

We bind M-% to query-replace, which is a superset of replace-string.
Why would you want to use replace-string instead? what can it do that
query-replace cannot?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-07  6:17     ` Yuri Khan
@ 2024-03-07  7:15       ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-03-07  7:15 UTC (permalink / raw)
  To: Yuri Khan; +Cc: raman, schwab, emacs-devel

> From: Yuri Khan <yuri.v.khan@gmail.com>
> Date: Thu, 7 Mar 2024 13:17:42 +0700
> Cc: Andreas Schwab <schwab@linux-m68k.org>, emacs-devel@gnu.org
> 
> The user-facing difference between replace-string and query-replace is
> that the former replaces unconditionally while the latter asks for
> confirmation (with a possibility to type ‘!’ to confirm replacement
> for all remaining occurrences). Similarly, replace-regexp vs
> query-replace-regexp.
> 
> Both confirming commands are bound by default: query-replace to M-%,
> query-replace-regexp to C-M-%.
> 
> Replacing without confirmation could be seen as an advanced feature —
> if you are already comfortable with undo, you’re ready to use it; if
> not, it’s scary.

All it takes to make unconditional replacements is to type '!' once.
TBH, I fail to see how that single keystroke could be significant when
what you gain is a much more powerful command.

Users can always bind replace-string to a key if they want, but
allocating a key binding to it by default would be unwise, given how
scarce the free keys are.  So I don't think we should do that by
default.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-07  2:15   ` T.V Raman
  2024-03-07  6:17     ` Yuri Khan
@ 2024-03-09  2:47     ` Richard Stallman
  2024-03-09 16:55       ` T.V Raman
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2024-03-09  2:47 UTC (permalink / raw)
  To: T.V Raman; +Cc: schwab, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > more importantly replace-string is not bound. That is what I was trying to say>

The useful key bindings are limited, so we have to choose the most
important uses of them.  Given there is a binding for quere-replace,
and you can get the effect of replace-string with quere-replace followed by !,
I decided there was no need to use up a binding for replace-string.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Curious: Why is there no binding for replace-string "out of the box"?
  2024-03-09  2:47     ` Richard Stallman
@ 2024-03-09 16:55       ` T.V Raman
  0 siblings, 0 replies; 8+ messages in thread
From: T.V Raman @ 2024-03-09 16:55 UTC (permalink / raw)
  To: Richard Stallman; +Cc: schwab, emacs-devel

Thanks, this is the explanation I was looking for.

-- 



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-09 16:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 21:12 Curious: Why is there no binding for replace-string "out of the box"? T.V Raman
2024-03-06 21:59 ` Andreas Schwab
2024-03-07  2:15   ` T.V Raman
2024-03-07  6:17     ` Yuri Khan
2024-03-07  7:15       ` Eli Zaretskii
2024-03-09  2:47     ` Richard Stallman
2024-03-09 16:55       ` T.V Raman
2024-03-07  6:38 ` Eli Zaretskii

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