unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
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)	[thread overview]
Message-ID: <1c71984d-9178-4c67-bb35-f46c50421afd@r15g2000prd.googlegroups.com> (raw)
In-Reply-To: 5fd737ce-449e-4da0-bd54-a467d23faef2@w39g2000prb.googlegroups.com

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	other threads:[~2008-12-17 12:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 23:54 how do I have a mode where '#' is a comment but '.#.' isn't? stuart
2008-12-17 12:18 ` Xah Lee [this message]
2008-12-17 14:06   ` Juanma Barranquero
2008-12-24 17:42 ` rgb
2008-12-30 18:35   ` rgb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c71984d-9178-4c67-bb35-f46c50421afd@r15g2000prd.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).