all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* quick 'perform last replace again'
@ 2008-04-21 10:12 Phil Carmody
  2008-04-21 11:49 ` David Kastrup
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Carmody @ 2008-04-21 10:12 UTC (permalink / raw)
  To: help-gnu-emacs

Subject line seems to describe the question succinctly.

I've been inserting some typedefs in some C code, and using 
query-replace to turn uint8_t's into whatever_t's. However,
I'm only changing a small proportion of each match, so it 
became a drag. I'd rather just have the ability to move and 
scroll around the file (so _not_ in query-replace mode), and 
when I spot something that needs to be changed I'd like to 
just move the cursor onto the line containing it, press some 
magic key sequence, and have it replace either the first 
(or all) instances of the most-recently-used match with the
most-recently-used replacement on the current line. I do not
want to be left in query-replace mode - I want to then 
continue editing.

And by 'match' I don't mean the most recently used incremental
search, I mean the last thing used as a FROM-STRING in a 
replace-string or query-replace.

I'm quite prepared to have a solution which wraps those
functions in order to store some state.

It looks like it should be quite an easy task, but I'm
exceptionally rusty currently.

Cheers,
Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration


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

* Re: quick 'perform last replace again'
  2008-04-21 10:12 quick 'perform last replace again' Phil Carmody
@ 2008-04-21 11:49 ` David Kastrup
  2008-04-21 20:15   ` Phil Carmody
  0 siblings, 1 reply; 7+ messages in thread
From: David Kastrup @ 2008-04-21 11:49 UTC (permalink / raw)
  To: help-gnu-emacs

Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:

> Subject line seems to describe the question succinctly.
>
> I've been inserting some typedefs in some C code, and using 
> query-replace to turn uint8_t's into whatever_t's. However,
> I'm only changing a small proportion of each match, so it 
> became a drag. I'd rather just have the ability to move and 
> scroll around the file (so _not_ in query-replace mode), and 
> when I spot something that needs to be changed I'd like to 
> just move the cursor onto the line containing it, press some 
> magic key sequence, and have it replace either the first 
> (or all) instances of the most-recently-used match with the
> most-recently-used replacement on the current line. I do not
> want to be left in query-replace mode - I want to then 
> continue editing.

C-x ESC ESC RET

Do the replacement with . (which is bound to act-and-exit).

Or use just M-% RET (which uses the defaults) and then . for
act-and-exit.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


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

* Re: quick 'perform last replace again'
  2008-04-21 11:49 ` David Kastrup
@ 2008-04-21 20:15   ` Phil Carmody
  2008-04-21 20:43     ` David Kastrup
  2008-04-21 21:33     ` Peter Dyballa
  0 siblings, 2 replies; 7+ messages in thread
From: Phil Carmody @ 2008-04-21 20:15 UTC (permalink / raw)
  To: help-gnu-emacs

David Kastrup <dak@gnu.org> writes:
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
> > Subject line seems to describe the question succinctly.
> >
> > I've been inserting some typedefs in some C code, and using 
> > query-replace to turn uint8_t's into whatever_t's. However,
> > I'm only changing a small proportion of each match, so it 
> > became a drag. I'd rather just have the ability to move and 
> > scroll around the file (so _not_ in query-replace mode), and 
> > when I spot something that needs to be changed I'd like to 
> > just move the cursor onto the line containing it, press some 
> > magic key sequence, and have it replace either the first 
> > (or all) instances of the most-recently-used match with the
> > most-recently-used replacement on the current line. I do not
> > want to be left in query-replace mode - I want to then 
> > continue editing.
> 
> C-x ESC ESC RET

Fails horribly. And for good reason:

<<<
C-x ESC ESC runs the command repeat-complex-command
   which is an interactive compiled Lisp function in `simple'.
(repeat-complex-command ARG)

Edit and re-evaluate last complex command, or ARGth from last.
...
>>>

I don't want to do the last complex command, which may have
been a file open, or an incremental search, or practically
anything. I want to redo the last search and replace. I did 
say "perform last replace again" in my subject line for a 
reason. A file open, or an incremental search, or killing a 
buffer, or whatever, is not the last replace.
 
> Do the replacement with . (which is bound to act-and-exit).
> 
> Or use just M-% RET (which uses the defaults) and then . for
> act-and-exit.

That seems to also fail horribly. 

M-% RET does not use what I used in my last search and replace.
Quite what it does use, I don't know, but after a file open,
an incremental search, and killing a buffer, it doesn't have
any default. In fact, immediately after the M-%, there is no 
default either, it just thinks that I want to search for ''. 
I'm running GNU Emacs 21.4.1 and 21.2.1 on a variety of archs, 
they all behave the same way.

'.', however, was a useful addition to my day-to-day emacs-use
armory, so thanks for that.

Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration


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

* Re: quick 'perform last replace again'
  2008-04-21 20:15   ` Phil Carmody
@ 2008-04-21 20:43     ` David Kastrup
  2008-04-21 20:45       ` Sven Joachim
  2008-04-21 21:33     ` Peter Dyballa
  1 sibling, 1 reply; 7+ messages in thread
From: David Kastrup @ 2008-04-21 20:43 UTC (permalink / raw)
  To: help-gnu-emacs

Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> Or use just M-% RET (which uses the defaults) and then . for
>> act-and-exit.
>
> That seems to also fail horribly. 
>
> M-% RET does not use what I used in my last search and replace.
> Quite what it does use, I don't know, but after a file open,
> an incremental search, and killing a buffer, it doesn't have
> any default. In fact, immediately after the M-%, there is no 
> default either, it just thinks that I want to search for ''. 
> I'm running GNU Emacs 21.4.1 and 21.2.1 on a variety of archs, 
> they all behave the same way.

If you insist on running outdated versions (I mean, even Debian stable
has switched to 22.1 quite some time ago), you should mention that in
your questions.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


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

* Re: quick 'perform last replace again'
  2008-04-21 20:43     ` David Kastrup
@ 2008-04-21 20:45       ` Sven Joachim
  2008-04-22 13:58         ` Joel J. Adamson
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Joachim @ 2008-04-21 20:45 UTC (permalink / raw)
  To: help-gnu-emacs

On 2008-04-21 22:43 +0200, David Kastrup wrote:

> If you insist on running outdated versions (I mean, even Debian stable
> has switched to 22.1 quite some time ago)

I wish that were true.  Unfortunately, 22.1 only came out two months
after the latest Debian stable release.

> , you should mention that in your questions.

Sven


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

* Re: quick 'perform last replace again'
  2008-04-21 20:15   ` Phil Carmody
  2008-04-21 20:43     ` David Kastrup
@ 2008-04-21 21:33     ` Peter Dyballa
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2008-04-21 21:33 UTC (permalink / raw)
  To: Phil Carmody; +Cc: help-gnu-emacs


Am 21.04.2008 um 22:15 schrieb Phil Carmody:

> I don't want to do the last complex command,


I have bound replace-string and replace-regexp to keys. When I press  
them again, GNU Emacs knows the from and to expressions – sometimes  
those from the other key, but never data from another command.

Could be this is a feature of GNU Emacs 22, too: C-x Esc Esc allows  
me to go back and forth in the chain of commands – by using cursor keys.

--
Greetings

   Pete

A morning without coffee is like something without something else.








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

* Re: quick 'perform last replace again'
  2008-04-21 20:45       ` Sven Joachim
@ 2008-04-22 13:58         ` Joel J. Adamson
  0 siblings, 0 replies; 7+ messages in thread
From: Joel J. Adamson @ 2008-04-22 13:58 UTC (permalink / raw)
  To: Sven Joachim; +Cc: help-gnu-emacs

Sven Joachim <svenjoac@gmx.de> writes:

> On 2008-04-21 22:43 +0200, David Kastrup wrote:
>
>> If you insist on running outdated versions (I mean, even Debian stable
>> has switched to 22.1 quite some time ago)
>
> I wish that were true.  Unfortunately, 22.1 only came out two months
> after the latest Debian stable release.

Well, how's this then: Slackware-current now includes Emacs 22!  I was
disappointed that they didn't include it in Slackware 12.0, but they now
include 22.2, and will for a probable 12.1 release.  I thought that was
a little overboard in their habit of only including stable software
(even Emacs 23 only crashes on me once a week or so, and I can handle
that for the added benefits).

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109
Public key: http://pgp.mit.edu

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.







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

end of thread, other threads:[~2008-04-22 13:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-21 10:12 quick 'perform last replace again' Phil Carmody
2008-04-21 11:49 ` David Kastrup
2008-04-21 20:15   ` Phil Carmody
2008-04-21 20:43     ` David Kastrup
2008-04-21 20:45       ` Sven Joachim
2008-04-22 13:58         ` Joel J. Adamson
2008-04-21 21:33     ` Peter Dyballa

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.