|
From: | Arjan Bos |
Subject: | Re: syntax table entries for comments |
Date: | Wed, 10 Sep 2003 15:35:54 +0200 |
User-agent: | Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 |
Stefan Monnier wrote:
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.
To bad. At least I won't have to look for it in the docs anymore.
(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'.
I found it via Emacs Wiki. On page http://www.emacswiki.org/cgi-bin/wiki/ModeTutorial, they link to the following mode tutorial:
http://two-wugs.net/emacs/mode-tutorial.html which I followed and used as an inspiration.Could you please enlighten me as to why your way is better? I'm no (e)lisp expert, but I'm doing allright with a bit of voodoo programming[1].
I tried the latter, but then strings within the `--' comment will undo the comment highlighting. So I'll try to voodoo hack src/syntax.cThis 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.
Thanks a lot, Arjan Bos[1] voodoo programming: Change something and see if it works. Keep on changing things until it does what you want. This way I can change most sources with only a minimum of knowledge about the language it's written in, by repeating the constructs already used. Downside is of course that you don't learn new language constructs. ;-)
[Prev in Thread] | Current Thread | [Next in Thread] |