Re: How to use the syntax table?

Ralf Angeli <[email protected]>
Newsgroups gmane.emacs.auc-tex
Message-ID <[email protected]>
* Plamen Tanovski (2005-02-26) writes:

> how can I match the argument of a LaTeX command in a
> query-replace-regexp? Let us have
>
> \gogo{asdfas \bobo{adfasd}a adsf} asdf \gogo{adfasd}
>
> Neither \\gogo{.*\s) nor \\gogo{.*?\s) do the right match. And also
> how can I find  braces across the lines?

AFAICT this is not possible.  That's why all the code in AUCTeX
dealing with macro arguments determines argument boundaries
differently.

In case you don't need the functionality of being asked for what to do
for every match, you could use something like the following function:

(defun my-TeX-replace-macro-arg (macro string)
  "Search for MACRO and replace content of first argument with STRING."
  (interactive "sMacro: \nsReplace content with: ")
  (save-excursion
    (let (start)
      (while (re-search-forward (concat "\\\\" macro "{") nil t)
      (setq start (point))
      (goto-char (TeX-find-closing-brace))
      (store-match-data (list start (1- (point))))
      (replace-match string)))))

The function is very basic.  It does not have any error handling and
matches only macros which have exactly a form of "\foo{bar}".

> At least, why is ` punctuation (and ' not)?

Hm, ' explicitely was given word syntax in AUCTeX as well as in the
default LaTeX mode of Emacs.  Unfortunately I don't know why.

-- 
Ralf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.