Ar an t-ochtú lá de mí Eanair, scríobh Uwe Brauer:
>>>>> "Stephen" == Stephen J Turnbull
<stephen(a)xemacs.org> writes:
> Aidan Kehoe writes:
>> What you need to do is rewrite the code to use
>> #'posix-search-forward, which guarantees that it will return the
>> longest match (that is, it will always try to match "\\infty" if
>> possible, and only then look for "\in".)
> I don't think so: this code is almost surely trying each car in
> order. Something like:
I’m not sure that we guarantee that we will always try things in order. I
hope not.
> (progn
> (search-forward (regexp-opt (mapcar #'car replacement-alist)))
> (goto-char (match-begin 0))
> (when (looking-at target-string)
> (replace-match replacement-string)))
As I said in my mail to Adian: that is the main part of the code
(seems less sophisticated than yours, though)
Here’s an implementation with the nice property that where many TeX escape
sequences map to a single character, repeated calls to #'TeX-to-char-region
followed by #'char-to-TeX-region will preserve the original TeX escape:
http://www.parhasard.net/xemacs/TeX-escape-region.el.html
Requires this patch to regexp-opt.el:
http://www.parhasard.net/xemacs/regexp-opt.el.diff
and also the latest beta of the the elib package; or you can stick Simon
Marshall’s unique.el somewhere in your load path.
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghé, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta