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

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

Re: How to implement comments that always start at the beginning of a li


From: Stefan Monnier
Subject: Re: How to implement comments that always start at the beginning of a line
Date: Tue, 24 Oct 2006 12:01:32 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I'm writing my own Emacs major mode for a language in with all comments
> start with an starisk at the beginning of a line. Unfortunately, I haven't
> found a way to implement this in the syntax table. 

> I tried to do a two-character comment sequence, with the first character
> being a newline and the 2nd character an asterisk. This would neglect
> comments in the first line of a buffer, but it would be better than nothing.
> The lines I used were

>               (modify-syntax-entry ?\n ">1" form-mode-syntax-table)
>               (modify-syntax-entry ?* ".2" form-mode-syntax-table)

Firt, the syntax of the string passed as second argument treats the frst two
chars specially, so the "1" and "2" need to be placed further:

 (modify-syntax-entry ?\n "> 1" form-mode-syntax-table)
 (modify-syntax-entry ?*  ". 2" form-mode-syntax-table)

but this likely won't work because this kind of mixing a close-comment with
a begin-comment in the same char-sequence was not expected by the (latest)
coder of the comment-handling code (i.e. myself).  And even if I had
expected it, it's not clear how I'd have interpreted it: /*/ in c-mode
(and -- in snmp-mode) either closes or opens a comment, but not both.

> but that didn't work the way I expected. Does anybody have an idea how to
> solve this?

font-lock-syntactic-keywords is the onl thing that springs to my mind.
See fortran.el for an example.



        Stefan


reply via email to

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