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

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

Re: how do I have a mode where '#' is a comment but '.#.' isn't?


From: rgb
Subject: Re: how do I have a mode where '#' is a comment but '.#.' isn't?
Date: Wed, 24 Dec 2008 09:42:32 -0800 (PST)
User-agent: G2/1.0

I've had similar problems with several major modes I've written.

Cobol for example doesn't even have a comment character, anything
after a particular column is a comment
TAL uses ! as both begin and end and eol is also an implicit end....

So ! this is a comment!but this isn't! and this is
but this isn't

Anyway, the only really good way to get useful results is by
specifying
font-lock-syntactic-keywords in your font-lock-defaults statement.

It's not a terribly simple process.
Some years ago, when I was writing all those modes, I was pretty
fluent and could spout off just exactly how to do it. Fortunately I
answered several how-to questions in several Emacs NGs so my notes are
available.

Try this thread.  I think it's pretty complete in covering what you
need to know.

http://groups.google.com/group/comp.emacs/browse_thread/thread/c1b7de4489be181


stuart wrote:
> I have been working on a mode for a program where a hash mark by
> itself is a comment character (#) whereas a hash mark surrounded by
> dots (.#.) is not. Currently, I'm using this:
>
> ;; Change the interpretation of particular chars in Emacs' syntax
> table
> (defvar fst-mode-syntax-table
>   (let ( (fst-mode-syntax-table (make-syntax-table) ) )
>     (modify-syntax-entry  ?#   "<"   fst-mode-syntax-table)  ; start
> comment
>     (modify-syntax-entry  ?\n  ">"   fst-mode-syntax-table)  ; end
> comment
>     (modify-syntax-entry  ?\\  "_"   fst-mode-syntax-table)  ; don't
> escape quote
>     (modify-syntax-entry  ?%   "/"   fst-mode-syntax-table)  ;
> functions as escape char
>     fst-mode-syntax-table )
>   "Syntax table for fst-mode" )
>
> But it doesn't do the right thing--i.e., it treats '.#.' as a dot
> followed by a comment. Is there any easy fix here? Thanks in advance.


reply via email to

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