all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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.