unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Replacement
@ 2005-10-27 15:44 hufflen jean-michel
  2005-10-27 18:48 ` Replacement Kevin Rodgers
  0 siblings, 1 reply; 5+ messages in thread
From: hufflen jean-michel @ 2005-10-27 15:44 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

   Dear GNU Emacs developers,

   I think I found a bug in the replacement operation.  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
à 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 "à" nil nil))

Unfortunately, the replacement is \`{a} ====> \à

   Sincerely yours,

			    J.-M. Hufflen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Replacement
  2005-10-27 15:44 Replacement hufflen jean-michel
@ 2005-10-27 18:48 ` Kevin Rodgers
  2005-10-28  6:03   ` Replacement Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2005-10-27 18:48 UTC (permalink / raw)


hufflen jean-michel wrote:
>    Dear GNU Emacs developers,
> 
>    I think I found a bug in the replacement operation.  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
> Ã  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 "Ã " nil nil))
> 
> Unfortunately, the replacement is \`{a} ====> \Ã 

"\\\B..." is the same as "\\B...".  I think you meant "\\\\B..." or more
likely "\\B\\...".

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Replacement
  2005-10-27 18:48 ` Replacement Kevin Rodgers
@ 2005-10-28  6:03   ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2005-10-28  6:03 UTC (permalink / raw)
  Cc: bug-gnu-emacs, hufflen

>> 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 à 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 "Ã " nil nil))
>> Unfortunately, the replacement is \`{a} ====> \Ã 
>
> "\\\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.  But "\\\\\\B" will work fine, since,
when unquoted, it is equal to `\\\B' which matches one character `\',
and the empty string not at word boundary with `\B'.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Replacement
@ 2005-11-03 16:33 hufflen jean-michel
  2005-11-03 17:59 ` Replacement Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: hufflen jean-michel @ 2005-11-03 16:33 UTC (permalink / raw)
  Cc: bug-gnu-emacs, hufflen

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]

>From juri@jurta.org  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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Replacement
  2005-11-03 16:33 Replacement hufflen jean-michel
@ 2005-11-03 17:59 ` Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2005-11-03 17:59 UTC (permalink / raw)
  Cc: ihs_4664, bug-gnu-emacs

hufflen@lifc.univ-fcomte.fr (hufflen jean-michel) writes:

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

To match a backslash you must use the regex "\\\\".

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

It results in ^{a} or ^a ===> â.  The backslash is not part of the match.

> If the replacement I wish is:
>
> \`{a} or \`a ====> à
>
> then (while (re-search-forward "\\`{?a}?" ...) (replace-match "à" ...))

This will only match "{a}" or "{a" or "a}" or "a" at the beginning of the
buffer, because \` only matches there.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-11-03 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-27 15:44 Replacement hufflen jean-michel
2005-10-27 18:48 ` Replacement Kevin Rodgers
2005-10-28  6:03   ` Replacement Juri Linkov
  -- strict thread matches above, loose matches on Subject: below --
2005-11-03 16:33 Replacement hufflen jean-michel
2005-11-03 17:59 ` Replacement Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).