From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.help Subject: Re: syntax table entries for comments Date: Tue, 09 Sep 2003 13:34:55 GMT Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: 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 X-Trace: sea.gmane.org 1063116020 11230 80.91.224.253 (9 Sep 2003 14:00:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 9 Sep 2003 14:00:20 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 09 16:00:18 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 19wj2Y-0000tj-00 for ; Tue, 09 Sep 2003 16:00:18 +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 19wj1Q-0000RW-VV for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Sep 2003 09:59:08 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-NNTP-Posting-Host: 132.204.26.236 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1063114495 132.204.26.236 (Tue, 09 Sep 2003 09:34:55 EDT) Original-NNTP-Posting-Date: Tue, 09 Sep 2003 09:34:55 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:116460 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:12380 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12380 > 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