all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: no-spam@cua.dk (Kim F. Storm)
Subject: Re: Apparent problem with looking-at?
Date: 18 Jun 2002 11:42:00 +0200	[thread overview]
Message-ID: <5xfzzkrkif.fsf@kfs2.cua.dk> (raw)
In-Reply-To: 9E217BAD4019CE4095869023168429A9CCF918@vulture.corp.resmed.org

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

  reply	other threads:[~2002-06-18  9:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17 23:39 Apparent problem with looking-at? Peter Milliken
2002-06-18  9:42 ` Kim F. Storm [this message]
2002-06-19  2:24 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2002-06-19  5:17 Peter Milliken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xfzzkrkif.fsf@kfs2.cua.dk \
    --to=no-spam@cua.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.