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: Xah Lee
Subject: Re: how do I have a mode where '#' is a comment but '.#.' isn't?
Date: Wed, 17 Dec 2008 04:18:13 -0800 (PST)
User-agent: G2/1.0

On Dec 16, 3:54 pm, stuart <stu...@zapata.org> 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.
>
> P.S. Here's the entire mode file:
> ...

it is my guess that you can't use syntax table for it.

my feeling of recent study of emacs syntax table is that, it's rather
a hacked up system to address some simple syntax issues. In
particular, you can see how the code in syntax tables for comments
basically just address 3 classes of comments, e.g. A: “/* ... */”,
“(* ... *)” , B: “// ... \n”, C: “# ...\n”. I can't say conclusively,
but it is my guess you won't be able to use syntax table to do
comments for anything more complex. I think perhaps you'll have to
resort to the syntax coloring system itself for the comment syntax of
your lang's mode.

I think that the emacs's syntax table system, besides addressing
things like forward-word, and simple comment syntax, that's about all
its power and use. For any simplest parsing issues, it is not useful.

The syntax of emacs's syntax table system also seems a simple hack. In
particular, quite cryptic.

One particular question i have is, whether ALL chars in unicode must
have a syntax table entry. (unicode has some at least 4 thousand
chars) It appears to me yes. One curiosity question is where can i
find the lisp or C code that defines the default syntax table where
every mode inherits.

  Xah
∑ http://xahlee.org/

reply via email to

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