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

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

Re: comment character


From: rgb
Subject: Re: comment character
Date: 18 May 2005 08:11:02 -0700
User-agent: G2/0.2

> > Where is the comment character defined for each programming mode?
C-u C-h a
> > didn't show me a variable name either.
> > Jeff
>
> comment-start, comment-end, comment-add

These will, at best, show one type of comment.  Languages often
have several.

There can be no definitive place to store such information.
Some languages require an entire keyword whose position might be
significant.  For example
ECHO THIS REM IS NOT A COMMENT. THIS ENTIRE STRING WILL PRINT.
REM ECHO THIS ECHO COMMAND IS COMMENTED OUT BY A REM COMMAND
Cobol has comments in a particular set of columns.
No character actually marks the comment.
Anything in those columns is simply ignored by the compiler.

For many languages the syntax table often has them all however
modes support comment syntax that can't be represented by the
syntax table.  In this case the mode designer has a couple options.
The most common is probably to use font-lock-syntactic-keywords.
Basically a function looks at the text and determines if any of
it is comment and marks it by putting the comment start or comment
fence syntax property on a particular character and the comment
end (or another fence) on another.
But there are other ways to handle comments depending on the goals
of the mode writer.  It's generally easier to detect comments in
a mode than it is to generically create them.



reply via email to

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