Reputation: 21572
What's the correct method for defining multi-line comments in an emacs mode (like C's /* */)? The elisp examples I see are for comments that start with a single delimiter and end at the end of the line (like C++'s // or perl's #).
Upvotes: 10
Views: 4063
Reputation: 67
This is an excellent guide for adding comment goo to an emacs mode. Link
Upvotes: 3
Reputation: 42674
Tom's answer covers creating comments; if you want your mode to be aware of comments, you need to fixup the syntax table.
Relevant reading:
http://www.gnu.org/software/emacs/elisp/html_node/Syntax-Tables.html#Syntax-Tables
Upvotes: 3
Reputation: 5907
It's like this:
(define-derived-mode my-mode
awk-mode "my"
"My mode"
(setq comment-multi-line nil) ; maybe
(setq comment-start "/* ")
(setq comment-end "*/"))
But there are subtleties; maybe you want
/* line one */
/* line two */
/* line three */
or maybe you want
/*
line one
line two
line three
*/
This is affected by your comment-style
, which you can customize (M-x customize-variable comment-style
). For something like the first example choose indent
, for the second example, extra-line
.
It's all defined in newcomment.el
, which you can read about if you M-x describe-variable comment-start
.
Upvotes: 16