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: modify-syntax-entry with single and two character comments Date: Wed, 27 Oct 2004 19:11:26 GMT Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <10nvo8bjdmul85@corp.supernews.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1098904356 4053 80.91.229.6 (27 Oct 2004 19:12:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Oct 2004 19:12:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 27 21:12:20 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CMtDW-0007Dy-00 for ; Wed, 27 Oct 2004 21:12:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CMtLH-0007yv-2j for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Oct 2004 15:20:19 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:v2yp8lYKRLBaR4eTcy6Cv380ZmU= Original-Lines: 51 Original-NNTP-Posting-Host: 132.204.24.84 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1098904286 132.204.24.84 (Wed, 27 Oct 2004 15:11:26 EDT) Original-NNTP-Posting-Date: Wed, 27 Oct 2004 15:11:26 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:126133 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 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:21513 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21513 > (modify-syntax-entry ?\n ">" st) > (modify-syntax-entry ?\| "<1b4b" st) > (modify-syntax-entry ?\* ".2b3b" st) The syntax string has the following structure: - 1st char is the main syntax category. - 2nd char is only used for ( and ) categories. - the rest are flags with no ordering. I.e. in your above code the "<1b4b" is equivalent to "< b4b" because the `1' is ignored. It's also equivalent to "< 4bb" (because ordering of flags is ignored) which is equivalent to "< 4b" (because turning ON a flag twice is the same as turning it ON once). A correct syntax-table would be: (modify-syntax-entry ?\n ">" st) (modify-syntax-entry ?\| "< 14" st) (modify-syntax-entry ?\* ". 23b" st) which says: - | starts a non-b comment and \n ends such a non-b comment. - | can be the 1nd char of a 2-char comment-starter or the 2nd char of a 2-char comment-ender. - * can be the 2nd char of a 2-char b-style comment-starter or the 3rd char of a 2-char b-style comment-ender. Sadly, this will not work because current Emacsen will immediately think that | starts the comment without checking the subsequent char to see if it's a *. Please report a bug via M-x report-emacs-bug about it. To work around this problem, two solutions: 1 - use "| " instead of "|" as the non-b comment-starter: (modify-syntax-entry ?\n ">" st) (modify-syntax-entry ?\| ". 14" st) (modify-syntax-entry ?\* ". 23b" st) (modify-syntax-entry ?\ " 2" st) Any char that can reasonably be expected to appear after a | comment-starter should then have the `2' flag added to its syntax :-( 2 - use font-lock-syntactic-keywords to change the syntax of | when it is followed by a *. This is less intrusive but will only work when font-lock is used and has been applied to the text. -- Stefan