From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Arjan Bos Newsgroups: gmane.emacs.help Subject: Re: syntax table entries for comments Date: Wed, 10 Sep 2003 15:35:54 +0200 Organization: Wanadoo Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3F5F28BA.3020704@icu.nl> References: <3f5db647$0$35674$1b62eedf@news.wanadoo.nl> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1063201772 7126 80.91.224.253 (10 Sep 2003 13:49:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 10 Sep 2003 13:49:32 +0000 (UTC) Cc: monnier@iro.umontreal.ca Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 10 15:49:29 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19x5Ld-0000de-00 for ; Wed, 10 Sep 2003 15:49:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19x5KS-00042f-NM for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Sep 2003 09:48:16 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!news2.euro.net!postnews1.euro.net!news.wanadoo.nl!not-for-mail User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 78 Original-NNTP-Posting-Date: 10 Sep 2003 13:36:31 GMT Original-NNTP-Posting-Host: p4782.vwr.wanadoo.nl Original-X-Trace: 1063200991 willi.euronet.nl 34890 62.234.192.182:28798 Original-X-Complaints-To: abuse@wanadoo.nl Original-Xref: shelby.stanford.edu gnu.emacs.help:116499 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12419 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12419 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]. > > >>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. I tried the latter, but then strings within the `--' comment will undo the comment highlighting. So I'll try to voodoo hack src/syntax.c 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. ;-)