unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Apparent problem with looking-at?
@ 2002-06-17 23:39 Peter Milliken
  2002-06-18  9:42 ` Kim F. Storm
  2002-06-19  2:24 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Milliken @ 2002-06-17 23:39 UTC (permalink / raw)


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

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

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

* Re: Apparent problem with looking-at?
  2002-06-17 23:39 Apparent problem with looking-at? Peter Milliken
@ 2002-06-18  9:42 ` Kim F. Storm
  2002-06-19  2:24 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Kim F. Storm @ 2002-06-18  9:42 UTC (permalink / raw)


PeterM@resmed.com.au (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

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

* Re: Apparent problem with looking-at?
  2002-06-17 23:39 Apparent problem with looking-at? Peter Milliken
  2002-06-18  9:42 ` Kim F. Storm
@ 2002-06-19  2:24 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2002-06-19  2:24 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Would you please provide a complete self-contained test case
so that we can reproduce the problem and debug it?

    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.

Note that "/*" is a regexp that matches zero or more slashes.

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

* RE: Apparent problem with looking-at?
@ 2002-06-19  5:17 Peter Milliken
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Milliken @ 2002-06-19  5:17 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Richard,

I believe the problem was that when I originally coded this defun (some
years ago now) I had an incomplete and faulty understanding of some of the
elisp defuns I was using - in this case, it was looking-at :-).

The code should have been (As Kim Storm kindly pointed out in
gnu.emacs.bugs):

(looking-at (regexp-quote comment-start))

using this works perfectly well (and was what I originally intended :-)). I
suspect that the "bug" has existed in my code all of this time because I
rarely code in C and thus the particular fact that a C comment-start is
actually a regular expression meant that I never noticed the problem i.e. I
normally use this code snippet with other languages and thus other
comment-start definitions and was thusly (falsely) under the impression that
this code had only failed with Emacs 21.2.1 - my apologies :-).

Thankyou for your help, I fixed "my" problem :-)

Regards,
Peter

-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: Wednesday, June 19, 2002 12:24 PM
To: Peter Milliken
Cc: bug-gnu-emacs@gnu.org
Subject: Re: Apparent problem with looking-at?


Would you please provide a complete self-contained test case
so that we can reproduce the problem and debug it?

    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.

Note that "/*" is a regexp that matches zero or more slashes.


Warning:  Copyright ResMed.  Where the contents of this email and/or attachment includes materials prepared by ResMed, the use of those materials is subject exclusively to the conditions of engagement between ResMed and the intended recipient.

This communication is confidential and may contain legally privileged information. By the use of email over the Internet or other communication systems, ResMed is not waiving either confidentiality of, or legal privilege in,the content of the email and of any attachments.
If the recipient of this message is not the intended addressee, please call ResMed immediately on (02) 9886 5000 Sydney, Australia.

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

end of thread, other threads:[~2002-06-19  5:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-17 23:39 Apparent problem with looking-at? Peter Milliken
2002-06-18  9:42 ` Kim F. Storm
2002-06-19  2:24 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2002-06-19  5:17 Peter Milliken

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