unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* I can not understant a paragraph in Emacs Lisp Reference.
@ 2009-07-11 11:11 waterloo
  0 siblings, 0 replies; 6+ messages in thread
From: waterloo @ 2009-07-11 11:11 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

As a `\' is not special inside a character alternative, it can never
remove the special meaning of `-' or `]'.  So you should not quote
these characters when they have no special meaning either.  This would
not clarify anything, since backslashes can legitimately precede these
characters where they _have_ special meaning, as in `[^\]' (`"[^\\]"'
for Lisp string syntax), which matches any single character except a
backslash.

`[^\]'  or `"[^\\]"' , which is right ? what is Lisp string syntax for ?

thanks

[-- Attachment #2: Type: text/html, Size: 597 bytes --]

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

* Re: I can not understant a paragraph in Emacs Lisp Reference.
       [not found] <mailman.2276.1247310683.2239.help-gnu-emacs@gnu.org>
@ 2009-07-11 12:27 ` Anselm Helbig
  0 siblings, 0 replies; 6+ messages in thread
From: Anselm Helbig @ 2009-07-11 12:27 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hi!

> As a `\' is not special inside a character alternative, it can never
> remove the special meaning of `-' or `]'.  So you should not quote
> these characters when they have no special meaning either.  This would
> not clarify anything, since backslashes can legitimately precede these
> characters where they _have_ special meaning, as in `[^\]' (`"[^\\]"'
> for Lisp string syntax), which matches any single character except a
> backslash.
> 
> `[^\]'  or `"[^\\]"' , which is right ? what is Lisp string syntax for ?

Seems to be clear to me: the first one is correct, but the second one
also works, you're just specifying the same character twice, like in
`[^aa]'. So the elisp string would be "[^\\]". Do you know about 
M-x re-builder?

Happy hacking!

Anselm


-- 
Anselm Helbig 
mailto:anselm.helbig+news2009@googlemail.com


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

* Re: I can not understant a paragraph in Emacs Lisp Reference.
@ 2009-07-11 14:46 waterloo
  2009-07-11 15:05 ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: waterloo @ 2009-07-11 14:46 UTC (permalink / raw)
  To: help-gnu-emacs, anselm.helbig+news2009

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

I try with re-builder ,  find that `"[^\\]"' is corrct .
`"[^\]"' can not find anything .
Thanks

[-- Attachment #2: Type: text/html, Size: 136 bytes --]

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

* Re: I can not understant a paragraph in Emacs Lisp Reference.
       [not found] <mailman.2289.1247323589.2239.help-gnu-emacs@gnu.org>
@ 2009-07-11 14:55 ` Teemu Likonen
  0 siblings, 0 replies; 6+ messages in thread
From: Teemu Likonen @ 2009-07-11 14:55 UTC (permalink / raw)
  To: waterloo; +Cc: help-gnu-emacs, anselm.helbig+news2009

On 2009-07-11 22:46 (+0800), waterloo wrote:

> I try with re-builder ,  find that `"[^\\]"' is corrct .
> `"[^\]"' can not find anything .

Please note that in regexp-builder the regexp is built in a Lisp
string--in which you need to backslash-escape all backslashes. It means
that Lisp string "[^\\]" is really regexp [^\] .




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

* RE: I can not understant a paragraph in Emacs Lisp Reference.
  2009-07-11 14:46 I can not understant a paragraph in Emacs Lisp Reference waterloo
@ 2009-07-11 15:05 ` Drew Adams
  2009-07-11 15:10   ` waterloo
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2009-07-11 15:05 UTC (permalink / raw)
  To: 'waterloo', help-gnu-emacs, anselm.helbig+news2009

>>     `[^\]' (`"[^\\]"' for Lisp string syntax)

>> `[^\]'  or `"[^\\]"' , which is right ?
>> what is Lisp string syntax for ?

> I try with re-builder ,  find that `"[^\\]"' is corrct .
> `"[^\]"' can not find anything .

Lisp string syntax is the syntax used in Lisp code when you write a literal
string (constant). The Lisp reader (part of the Lisp interpreter) reads the
string syntax you enter and constructs a string constant accordingly.

In Lisp string syntax, you need to double each backslash that you want in the
string. So "\\" is Lisp string syntax for the string that has one character, a
backslash. This doubling is needed because Lisp string syntax uses the backslash
for special escape sequences: for example, \" represents a double-quote
character.

See the Elisp manual, node `Syntax for Strings'.





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

* Re: I can not understant a paragraph in Emacs Lisp Reference.
  2009-07-11 15:05 ` Drew Adams
@ 2009-07-11 15:10   ` waterloo
  0 siblings, 0 replies; 6+ messages in thread
From: waterloo @ 2009-07-11 15:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs, anselm.helbig+news2009

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

Thanks , the explanation is good enough.

2009/7/11 Drew Adams <drew.adams@oracle.com>

> >>     `[^\]' (`"[^\\]"' for Lisp string syntax)
>
> >> `[^\]'  or `"[^\\]"' , which is right ?
> >> what is Lisp string syntax for ?
>
> > I try with re-builder ,  find that `"[^\\]"' is corrct .
> > `"[^\]"' can not find anything .
>
> Lisp string syntax is the syntax used in Lisp code when you write a literal
> string (constant). The Lisp reader (part of the Lisp interpreter) reads the
> string syntax you enter and constructs a string constant accordingly.
>
> In Lisp string syntax, you need to double each backslash that you want in
> the
> string. So "\\" is Lisp string syntax for the string that has one
> character, a
> backslash. This doubling is needed because Lisp string syntax uses the
> backslash
> for special escape sequences: for example, \" represents a double-quote
> character.
>
> See the Elisp manual, node `Syntax for Strings'.
>
>

[-- Attachment #2: Type: text/html, Size: 1420 bytes --]

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

end of thread, other threads:[~2009-07-11 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-11 14:46 I can not understant a paragraph in Emacs Lisp Reference waterloo
2009-07-11 15:05 ` Drew Adams
2009-07-11 15:10   ` waterloo
     [not found] <mailman.2289.1247323589.2239.help-gnu-emacs@gnu.org>
2009-07-11 14:55 ` Teemu Likonen
     [not found] <mailman.2276.1247310683.2239.help-gnu-emacs@gnu.org>
2009-07-11 12:27 ` Anselm Helbig
  -- strict thread matches above, loose matches on Subject: below --
2009-07-11 11:11 waterloo

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).