* A query-replace question
@ 2010-08-15 11:15 Rodolfo Medina
2010-08-15 11:49 ` David Kastrup
0 siblings, 1 reply; 3+ messages in thread
From: Rodolfo Medina @ 2010-08-15 11:15 UTC (permalink / raw)
To: help-gnu-emacs
Hi to all Emacs users.
In a large .tex file, I wish to replace all `x' with `a', but only those
occurrences of x that lay between two dollars symbols: e.g., $x = y$. Could
that be ever possible with Emacs, and how?
Thanks for any help
Rodolfo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: A query-replace question
2010-08-15 11:15 A query-replace question Rodolfo Medina
@ 2010-08-15 11:49 ` David Kastrup
2010-08-15 16:36 ` B. T. Raven
0 siblings, 1 reply; 3+ messages in thread
From: David Kastrup @ 2010-08-15 11:49 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
> Hi to all Emacs users.
>
> In a large .tex file, I wish to replace all `x' with `a', but only those
> occurrences of x that lay between two dollars symbols: e.g., $x = y$. Could
> that be ever possible with Emacs, and how?
M-: (require 'texmathp) RET
C-M-% x RET \,(if (texmathp) "a" \&) RET
Note that this includes \max and similar, so you might want to use
something like
\_<x\_>
as your search expression for doing the matching.
--
David Kastrup
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: A query-replace question
2010-08-15 11:49 ` David Kastrup
@ 2010-08-15 16:36 ` B. T. Raven
0 siblings, 0 replies; 3+ messages in thread
From: B. T. Raven @ 2010-08-15 16:36 UTC (permalink / raw)
To: help-gnu-emacs
David Kastrup wrote:
> Rodolfo Medina <rodolfo.medina@gmail.com> writes:
>
>> Hi to all Emacs users.
>>
>> In a large .tex file, I wish to replace all `x' with `a', but only those
>> occurrences of x that lay between two dollars symbols: e.g., $x = y$. Could
>> that be ever possible with Emacs, and how?
>
> M-: (require 'texmathp) RET
>
> C-M-% x RET \,(if (texmathp) "a" \&) RET
>
> Note that this includes \max and similar, so you might want to use
> something like
> \_<x\_>
> as your search expression for doing the matching.
>
This seems like it should work but doesn't:
C-M-% \(\$.?\)x\(.?\$\) RET \1a\2 RET
Running the following two in succession finds x in $x = y$ and $y = x$
C-M-% \(\$.+\)x\(.?\$\) RET \1a\2 RET
C-M-% \(\$.?\)x\(.+\$\) RET \1a\2 RET
Is there a regexp guru out there who knows if this approach is possible
or is it necessary to look for the texmath environment as David does
with texmathp? Is wildcard greediness at play here?
Ed
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-15 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-15 11:15 A query-replace question Rodolfo Medina
2010-08-15 11:49 ` David Kastrup
2010-08-15 16:36 ` B. T. Raven
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).