[Top][All Lists]

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

Re: Apparent problem with looking-at?

From: Kim F. Storm
Subject: Re: Apparent problem with looking-at?
Date: 18 Jun 2002 11:42:00 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

address@hidden (Peter Milliken) writes:

> Hi, I have some elisp that has been unchanged for several major versions of
> EMacs now - it nolonger works in version 21.2.1. 

Your code is seriously flawed, so if it worked with older emacs versions,
they must have been buggy too :-)

Notice that looking-at arg is a REGEXP, not a STRING.
So "/*" matches the empty string  (zero or more /'es).
And "/* " matches zero or more /'es followed by a space.

So it is obvious that "/*" will match "/*..." 
(as it starts with one slash),

while "/* " does not match "/*..."
(as there is a * and not a space following the /).

According to its doc string, the comment-start variable is a STRING
for INSERTING the comment start.  It cannot be used as a regexp
directly.  To do that, use
        (looking-at (regexp-quote comment-start))

> I am currently running Emacs 21.2.1 built using cygwin tools on a NT
> platform. The situation is that I (normally) comment out lines in code files
> I am working on and then wish to remove the comments later on i.e.
> /* <some text> */
> Note that the comment start (.c file) is located at the beginning of line.
> The elisp code snippet looks like this:
>    (beginning-of-line)
>    (if (looking-at comment-start)
> The (looking-at comment-start) returns nil. I don't believe it should return
> nil and never has in previous versions of Emacs. If I alter the code snippet
> to (looking-at "/*") then it works (note the absence of the space after the
> '*'). Also, if I place a space character at the start of the line i.e.
>  /* <some text> */
> and run the original code (testing for comment-start with point at the BOL)
> then the test returns t.
> Thanks
> Peter
> Peter Milliken
> Software Engineer
> ResMed
> Phone: +61 2 9886-5059

Kim F. Storm  http://www.cua.dk

reply via email to

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