[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: syntax table entries for comments
From: |
Stefan Monnier |
Subject: |
Re: syntax table entries for comments |
Date: |
Tue, 09 Sep 2003 13:34:55 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> language that contains two types of comments. The first is for large blocks
> and is the familiar /* */ construction. This I can do by looking at the
> examples. The second one is a single-line comment that consists of two
> hyphens, like:
> -- this is a comment.
Emacs does not properly support this, as you've discovered.
> (defvar nrx-mode-syntax-table nil
> "Syntax table in use in NRX-mode buffers.")
> (defun nrx-create-syntax-table ()
> (if nrx-mode-syntax-table
> ()
> (setq nrx-mode-syntax-table (make-syntax-table))
> (modify-syntax-entry ?. "." nrx-mode-syntax-table)
> (modify-syntax-entry ?- ". 12b" nrx-mode-syntax-table)
> (modify-syntax-entry ?/ ". 14" nrx-mode-syntax-table)
> (modify-syntax-entry ?* ". 23" nrx-mode-syntax-table)
> (modify-syntax-entry ?\n "> b" nrx-mode-syntax-table)
> (modify-syntax-entry ?\' "\"" nrx-mode-syntax-table))
> (set-syntax-table nrx-mode-syntax-table))
Could you tell me the place from which this code was inspired so we can
fix it ? It should look like:
(defvar nrx-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ...)
(modify-syntax-entry ...)
...
st))
and the `set-syntax-table' is commonly done implicitly by
`define-derived-mode'.
> This works but also renders the combination -* and *- as comment start and
> end, which is wrong. Could anyone please tell me what I'm missing?
Nothing, really, other than the fact that it's a limitation of current
syntax-tables. You can either hack on src/syntax.c to add support for
such cases, or use font-lock-syntactic-keywords to recognize `--'
and mark it as a comment starter.
Stefan