From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bj Newsgroups: gmane.emacs.help Subject: Re: How to enable the syntax highlighting for comments within files having a specific extension? Date: Thu, 16 Jul 2009 06:13:11 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1247805038 15649 80.91.229.12 (17 Jul 2009 04:30:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Jul 2009 04:30:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 17 06:30:16 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MRf5L-0008D8-7G for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jul 2009 06:30:15 +0200 Original-Received: from localhost ([127.0.0.1]:35750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRf5K-00046h-K0 for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jul 2009 00:30:14 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!24g2000yqm.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 61 Original-NNTP-Posting-Host: 80.75.192.70 Original-X-Trace: posting.google.com 1247749991 8556 127.0.0.1 (16 Jul 2009 13:13:11 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 16 Jul 2009 13:13:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 24g2000yqm.googlegroups.com; posting-host=80.75.192.70; posting-account=m5mUNAoAAACclRRo3KuF4zL6ydgW80wn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 chbad-s-sa1px01.ch.abb.com:8080 (squid/2.5.STABLE12) Original-Xref: news.stanford.edu gnu.emacs.help:170953 comp.emacs:98412 X-Mailman-Approved-At: Fri, 17 Jul 2009 00:29:36 -0400 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: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:66159 Archived-At: Dear Xah, Thanks for your help. I have partly reached my goals. Here is the jou-mode.el file which I built on the basis of your tutorials: <--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8--- ><--8---><--8---><--8---> ;; the command to comment/uncomment text (defun jou-comment-dwim (arg) "Comment or uncomment current line or region in a smart way. For detail, see `comment-dwim'." (interactive "*P") (require 'newcomment) (let ((deactivate-mark nil) (comment-start "/") (comment-end "")) (comment-dwim arg))) (setq myKeywords `( ) ) ;; define the major mode. (define-derived-mode jou-mode fundamental-mode "you are in jou-mode" (setq font-lock-defaults '(myKeywords)) (setq comment-start "/") (define-key jou-mode-map [remap comment-dwim] 'jou-comment-dwim) (modify-syntax-entry ?/ "< b" jou-mode-syntax-table) (modify-syntax-entry ?\n "> b" jou-mode-syntax-table) ) <--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8---><--8--- ><--8---><--8---><--8---> The comment syntax highlighting works, but I still have few questions. 1) Is the line (setq comment-start "/") which I have added really needed? 2) I don't need the keywords, but if I remove the relevant entries in the jou-mode.el file (i.e. lines 9-12, 17), the commented lines are no longer in red. 3) if the comment string "/" is in the middle of a line, like the division sign in an expression, then the characters to the right of it are turned into red. Do you know how to avoid this? Thanks for your help gento