bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: forward-comment doesn't (quite) match its documentation


From: Alan Mackenzie
Subject: Re: forward-comment doesn't (quite) match its documentation
Date: 27 Nov 2001 12:26:00 +0100
Date: Tue, 27 Nov 2001 11:15:56 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Stefan Monnier <monnier+gnu.emacs.bug/news/@rum.cs.yale.edu> wrote on 25
Nov 2001 15:16:29 -0500:
>>>>>> "Alan" == Alan Mackenzie <none@example.invalid> writes:

>> When I read "this function moves point forward across COUNT comments"
>> I expected just that.  I.e. across things which _are_ comments, not
>> things which look like comments but aren't.  Font lock, for example,
>> seems to make this distinction.

> I guess what's missing from the doc is that forward-comment assumes
> that the starting point is outside of any comment or string.  But
> that's a common assumption in Emacs, shared with forward-sexp.

OK.  I subconsciously put forward-comment into the same category as
things like end/beginning-of-line or c-end/beginning-of-statement, which
do work from the middle.  My gut feel for a comment is that it is an
unstructured mass of characters (just like a text line), whereas I see a
sexp as a highly structured assembly of parentheses.

But I do understand the difficulties of making forward-comment start from
inside a comment (I took a brief peek inside syntax.c ;-).

> Now, I'd be interested to know in what context you wanted to "move over
> half a comment" (i.e. skip the end of the current comment).

I'm working on getting awk-mode (derived from cc-mode) working again.
The sort of thing I'm trying to do is: (i) go back to end of previous
line;  (ii) check for a backslash line-continuation;  (iii) Go back over
any comment.  Unfortunately, (foward-comment -1) doesn't work quite like
I'd like it to for (iii) because it regards the /n as part of the
comment, and so will only work when point is at the start of the next
line.  It's not possible to specify that comments extend from '#' up to
(but not including) \n, which I think is a pity.

awk is a syntactic jungle:  '/' is sometimes a regexp delimiter (which
will have string syntax), sometimes a division sign.  That means I'll
have to do the work to check that a '#' (comment start) is not within
'/'s (when they are regexp brackets).

It's not that foward-comment is bad.  It's just that I suffered some
frustration when I realised that my code was failing not because it was
buggy as such, but because I had misunderstood what forward-comment does.

>       Stefan

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove one of them (leaving, say, "a").




reply via email to

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