* Feature request: yank-with-replace
@ 2002-11-08 21:02 Luke Hutchison
2002-11-09 4:11 ` Miles Bader
2002-11-10 18:07 ` Richard Stallman
0 siblings, 2 replies; 3+ messages in thread
From: Luke Hutchison @ 2002-11-08 21:02 UTC (permalink / raw)
I have a request for a small feature that I think would be very useful.
(I hope this is the right list for it!)
It would be very nice to replace values as a region is being yanked: for
example, you have some code that performs operations on the
x-coordinates of something, and you want to duplicate the code for the
y-coordinates, so you select it, kill it, yank it and then go back and
change all the 'x's to 'y's. This can leave you with inconsistent code,
if you don't catch them all (ever hear the expression, "Cut'n'paste gets
you every time"?)...
I propose adding yank-with-replace, which asks you for a search and
replace string before the kill buffer is yanked-from, to take care of
situations like this. yank-with-replace-query-regexp would probably be
useful too, which would yank and then run a query-regexp on the region
that you just yanked.
I can't seem to find this feature in emacs, and don't have any emacs
development background, but I imagine that adding this would be trivial
for an emacs programmer.
Does it seem that this feature would be useful?
Thanks,
Luke Hutchison.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Feature request: yank-with-replace
2002-11-08 21:02 Feature request: yank-with-replace Luke Hutchison
@ 2002-11-09 4:11 ` Miles Bader
2002-11-10 18:07 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Miles Bader @ 2002-11-09 4:11 UTC (permalink / raw)
Cc: emacs-devel
On Fri, Nov 08, 2002 at 02:02:27PM -0700, Luke Hutchison wrote:
> It would be very nice to replace values as a region is being yanked: for
> example, you have some code that performs operations on the
> x-coordinates of something, and you want to duplicate the code for the
> y-coordinates, so you select it, kill it, yank it and then go back and
> change all the 'x's to 'y's.
>
> I propose adding yank-with-replace, which asks you for a search and
> replace string before the kill buffer is yanked-from, to take care of
> situations like this. yank-with-replace-query-regexp would probably be
> useful too, which would yank and then run a query-regexp on the region
> that you just yanked.
To be honest, this sounds like a sort of clumsy way of accomplishing the task.
In many situations where you want to replicate a piece of text with some part
of it changed, you can (1) use normal yank to duplicate the text a bunch of
times, and then (2) use `query-replace-regexp-eval' to change the variable
part.
If you really want to replace the variable part with a user-entered string,
you can do that do using query-replace-regexp-eval. For instance, take the
text:
#define FLAG_FOO...
and duplicate it a bunch of times. Then do something like:
M-x query-replace-regexp-eval RET
FOO... RET
(format "%s\t0x%x" (read-string "Flag name: ") (lsh 1 replace-count)) RET
It will prompt you for each flag name, and then automatically fill in an
appropriate bit value for the flag (it will also prompt you if you really
want to do the replace each time; in this case it's best to just hit `!' to
make it replace them all; hmmm, it'd be nice if there were a
`replace-regexp-eval' function that just never asked you).
For instance, using the above I just duplicated the pattern line 4 times, did
the query-replace-regexp-eval, and typed `a', `b', `c', and `d' for the flag
names, and got:
#define FLAG_a 0x1
#define FLAG_b 0x2
#define FLAG_c 0x4
#define FLAG_d 0x8
-Miles
--
Would you like fries with that?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Feature request: yank-with-replace
2002-11-08 21:02 Feature request: yank-with-replace Luke Hutchison
2002-11-09 4:11 ` Miles Bader
@ 2002-11-10 18:07 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2002-11-10 18:07 UTC (permalink / raw)
Cc: emacs-devel
It is better to narrow to the region after yanking.
Then you can use various replace commands to operate
on what you yanked.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-10 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-08 21:02 Feature request: yank-with-replace Luke Hutchison
2002-11-09 4:11 ` Miles Bader
2002-11-10 18:07 ` Richard Stallman
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.