all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Regexp replacement
@ 2006-10-27 22:37 Jim Dai
  2006-10-27 22:45 ` David Kastrup
  0 siblings, 1 reply; 8+ messages in thread
From: Jim Dai @ 2006-10-27 22:37 UTC (permalink / raw)


I would like to delete \redtext{long text} with "long text" being kept.
I have any instances in a file, with "long text" varying that may include
other latex symbols like _ $. (assume there are not any {} pairs inside the
text.

How can I use regexp replacement to achieve the desired changes?
Thanks.

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

* Re: Regexp replacement
  2006-10-27 22:37 Regexp replacement Jim Dai
@ 2006-10-27 22:45 ` David Kastrup
  2006-10-28  1:16   ` Jim Dai
  2006-10-28 19:11   ` Jim Dai
  0 siblings, 2 replies; 8+ messages in thread
From: David Kastrup @ 2006-10-27 22:45 UTC (permalink / raw)


Jim Dai <jgjimdai_p@yahoo.com> writes:

> I would like to delete \redtext{long text} with "long text" being kept.
> I have any instances in a file, with "long text" varying that may include
> other latex symbols like _ $. (assume there are not any {} pairs inside the
> text.
>
> How can I use regexp replacement to achieve the desired changes?

M-x query-replace-regexp RET \\redtext{\([^}]*\)} RET \1 RET

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Regexp replacement
  2006-10-27 22:45 ` David Kastrup
@ 2006-10-28  1:16   ` Jim Dai
  2006-10-28  7:09     ` David Kastrup
  2006-10-28 19:11   ` Jim Dai
  1 sibling, 1 reply; 8+ messages in thread
From: Jim Dai @ 2006-10-28  1:16 UTC (permalink / raw)


Hmm, I missed \( \) and \1 combination in my own try.

How can create a key-binding such as C-c C-r in LaTeX mode? Thanks.
Jim



On 10/27/06 6:45 PM, in article 85iri5nzt0.fsf@lola.goethe.zz, "David
Kastrup" <dak@gnu.org> wrote:

> Jim Dai <jgjimdai_p@yahoo.com> writes:
> 
>> I would like to delete \redtext{long text} with "long text" being kept.
>> I have any instances in a file, with "long text" varying that may include
>> other latex symbols like _ $. (assume there are not any {} pairs inside the
>> text.
>> 
>> How can I use regexp replacement to achieve the desired changes?
> 
> M-x query-replace-regexp RET \\redtext{\([^}]*\)} RET \1 RET

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

* Re: Regexp replacement
  2006-10-28  1:16   ` Jim Dai
@ 2006-10-28  7:09     ` David Kastrup
  2006-10-28  7:36       ` Ralf Angeli
  0 siblings, 1 reply; 8+ messages in thread
From: David Kastrup @ 2006-10-28  7:09 UTC (permalink / raw)


Jim Dai <jgjimdai_p@yahoo.com> writes:

> Hmm, I missed \( \) and \1 combination in my own try.
>
> How can create a key-binding such as C-c C-r in LaTeX mode? Thanks.

(define-key LaTeX-mode-map (kbd "C-c C-r") 'beep)

Or probably (if in .emacs) rather

(add-hook 'LaTeX-mode-hook
  (lambda nil
    (define-key ...

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Regexp replacement
  2006-10-28  7:09     ` David Kastrup
@ 2006-10-28  7:36       ` Ralf Angeli
  0 siblings, 0 replies; 8+ messages in thread
From: Ralf Angeli @ 2006-10-28  7:36 UTC (permalink / raw)


* David Kastrup (2006-10-28) writes:

> Jim Dai <jgjimdai_p@yahoo.com> writes:
>
>> Hmm, I missed \( \) and \1 combination in my own try.
>>
>> How can create a key-binding such as C-c C-r in LaTeX mode? Thanks.

Such binding should be reserved for major modes.  User bindings should
be of the form `C-c <letter>', see (info "(emacs)Keymaps").

> (define-key LaTeX-mode-map (kbd "C-c C-r") 'beep)
>
> Or probably (if in .emacs) rather
>
> (add-hook 'LaTeX-mode-hook
>   (lambda nil
>     (define-key ...

Or use `local-set-key' if one does not want to think about the name of
the local keymap.

-- 
Ralf

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

* Re: Regexp replacement
  2006-10-27 22:45 ` David Kastrup
  2006-10-28  1:16   ` Jim Dai
@ 2006-10-28 19:11   ` Jim Dai
  2006-10-28 23:44     ` David Kastrup
  1 sibling, 1 reply; 8+ messages in thread
From: Jim Dai @ 2006-10-28 19:11 UTC (permalink / raw)


Once again, thanks for the solution. It basically solved my problem.

Two more questions:
1) 
I wonder if there is an easy improvement on the current method so that I
have nested {} inside the text.
E.g. I would like to replace \redtext{some formula $\frac{a}{b}$} to
Some formula $\frac{a}{b}$.

2)  I did not make it clear when I asked a key binding question. How can I
bind the entire key strokes M-x query-replace-regexp RET
\\redtext{\([^}]*\)} RET \1 RET into an emacs key?

This key binding is to  be used in LaTeX mode.

Thanks.







On 10/27/06 6:45 PM, in article 85iri5nzt0.fsf@lola.goethe.zz, "David
Kastrup" <dak@gnu.org> wrote:

> Jim Dai <jgjimdai_p@yahoo.com> writes:
> 
>> I would like to delete \redtext{long text} with "long text" being kept.
>> I have any instances in a file, with "long text" varying that may include
>> other latex symbols like _ $. (assume there are not any {} pairs inside the
>> text.
>> 
>> How can I use regexp replacement to achieve the desired changes?
> 
> M-x query-replace-regexp RET \\redtext{\([^}]*\)} RET \1 RET

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

* Re: Regexp replacement
  2006-10-28 19:11   ` Jim Dai
@ 2006-10-28 23:44     ` David Kastrup
  2006-10-29 20:10       ` Jim Dai
  0 siblings, 1 reply; 8+ messages in thread
From: David Kastrup @ 2006-10-28 23:44 UTC (permalink / raw)



Please don't toppost with fullquote below.  If you refer to anything,
it is a pain to dig the context up from the bottom, and try to guess
what you actually might be referring to.

Please cut away anything not relevant to your reply, and put your
reply below the stuff you are replying to.

Jim Dai <jgjimdai_p@yahoo.com> writes:

> Once again, thanks for the solution. It basically solved my problem.
>
> Two more questions:
> 1) 
> I wonder if there is an easy improvement on the current method so that I
> have nested {} inside the text.

No.  You need to revert to Elisp in this case and parse the argument
using something like forward-sexp.

> 2)  I did not make it clear when I asked a key binding question. How can I
> bind the entire key strokes M-x query-replace-regexp RET
> \\redtext{\([^}]*\)} RET \1 RET into an emacs key?
>
> This key binding is to  be used in LaTeX mode.

Use C-x Esc Esc after the command in order to get a versino in Elisp.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Regexp replacement
  2006-10-28 23:44     ` David Kastrup
@ 2006-10-29 20:10       ` Jim Dai
  0 siblings, 0 replies; 8+ messages in thread
From: Jim Dai @ 2006-10-29 20:10 UTC (permalink / raw)




On 10/28/06 7:44 PM, in article 85zmbgknts.fsf@lola.goethe.zz, "David
Kastrup" <dak@gnu.org> wrote:

> Please cut away anything not relevant to your reply, and put your
> reply below the stuff you are replying to.

Got it. Very much appreciate your helpful answers.
Jim

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

end of thread, other threads:[~2006-10-29 20:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-27 22:37 Regexp replacement Jim Dai
2006-10-27 22:45 ` David Kastrup
2006-10-28  1:16   ` Jim Dai
2006-10-28  7:09     ` David Kastrup
2006-10-28  7:36       ` Ralf Angeli
2006-10-28 19:11   ` Jim Dai
2006-10-28 23:44     ` David Kastrup
2006-10-29 20:10       ` Jim Dai

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.