help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what can I do with regexp match?


From: Lennart Borgman (gmail)
Subject: Re: what can I do with regexp match?
Date: Mon, 14 May 2007 17:09:22 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.666

Seweryn Kokot wrote:
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

Seweryn Kokot wrote:
Hello,

I would like to have a function that visits all the tex files included
in main.tex file. I wrote the following function:
(defun my-document-files ()
  "Open all document files"
  (interactive)
  (while (re-search-forward "\\\\include{\\(.*\\)}")
         (find-file (concat "~/nauka/doktorat/thesis/" "\\1" ".tex"))))

But it doesn't work since \\1 is not replaced by regexp match. The
result is that the function visits \1.tex file. The question is how to
process the regexp match to make it argument for find-file or more
general question how to save the match in a variable or list?

(match-string 1) ;; At least in Emacs 22
Thanks, the prolbem with \1 is solved but then the function only finds
first occurrence of \include{filename} and then I get in the echo buffer: while: Search failed: "\\\\include{\\(.*\\)}"

Now my function is:
(defun my-document-files ()
  "Open all document files"
  (interactive)
  (while (re-search-forward "\\\\include{\\(.*\\)}")
         (find-file (concat "~/nauka/doktorat/thesis/" (match-string 1) 
".tex"))))

why it failed although I have much more occurences of \include{...} in
the main.tex file? Any idea?

Read the documentation for find-file.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]