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

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

Re: Replacement


From: hufflen jean-michel
Subject: Re: Replacement
Date: Thu, 3 Nov 2005 17:33:29 +0100 (CET)

>From address@hidden  Fri Oct 28 08:14:34 2005
>(...)

   Thanks for your answer.

>>> Let us consider a source text for LateX and assume that we want to
>>> replace the command for an accented letter by the accented letter
>>> itself. For example, replacing \`{a} by =C3 using the accurate
>>> coding.  If we look into the documentation and would like to
>>> perform this operation by means of a Lisp code, that should be:
>>> (beginning-of-buffer)
>>> (while (re-search-forward "\\\B`{a}" nil t)
>>>   (replace-match "=C3 " nil nil))
>>> Unfortunately, the replacement is \`{a} =3D=3D=3D=3D> \=C3=20
>>
>> "\\\B..." is the same as "\\B...".  I think you meant "\\\\B..."
>
>Unquoted string "\\\\B" is `\\B' which matches two characters `\' and `B'.
>I don't think this is what is wanted.

   In fact, I suspect that the problem is more complicated...  Unless I miss
something about the regular expressions handled by emacs.  If I wish the
following replacement:

\^{a} or \^a ====> â

and program:

(while (re-search-forward "\\^{?a}?" ...) (replace-match "â" ...))

it results: \^{a} or \^a ====> \â

If the replacement I wish is:

\`{a} or \`a ====> à

then (while (re-search-forward "\\`{?a}?" ...) (replace-match "à" ...))

does not work.  I thought that a better result would be got by separating the
` character from backslashes and that is why I put:

(while (re-search-forward "\\\B`{?a}?" ...) (replace-match "à" ...))

the result is the same than for the circumflex accent, that is:

\`{a} or \`a ====> \à

   Yours sincerely,

J.-M. H.




reply via email to

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