Hello
Here is the scenario.
I have a very old LaTeX which is full of definitions like:
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\bqa{\begin{eqnarray}}
\def\eqa{\end{eqnarray}}
Etc. I want to replace the old definitions by the original LaTeX
commands (for many reasons)
Now I have some old code[1] which allows me to define a list and then all
in once.
The table structure is
(defvar old2new-trans-tab
'(
("\\al" "\\alpha")
("\\a" "\\\[0.2cm]")))
The relevant function which is doing the replacement is.
(defun ltxoldnew-translate-conventions (trans-tab)
"Use the translation table argument to translate the current buffer."
(save-excursion
(let ((beg (point-min-marker)) ; see the `(elisp)Narrowing' Info node
(end (point-max-marker)))
(unwind-protect
(progn
(widen)
(goto-char (point-min))
(let ((buffer-read-only nil) ; (inhibit-read-only t)?
(case-fold-search nil))
(while trans-tab
(save-excursion
(let ((trans-this (car trans-tab)))
(while (search-forward (car trans-this) nil t)
(replace-match (car (cdr trans-this)) t t)))
(setq trans-tab (cdr trans-tab))))))
(narrow-to-region beg end)))))
The problem is that there at least two constructs which have a similar
starting but different ending, \a an \al.
So I thought I replace
(while (search-forward (car trans-this) nil t)
by
(while (search-forward-regexp (car trans-this) nil t)
And the table
(defvar old2new-trans-tab
'(
("\b\al\b" "\\alpha")
("\b\a\b" "\\\[0.2cm]")))
But it does not work. Does anybody know how to add some
regexp-functionality like word boundaries in the code?
thanks
uwe Brauer
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta