From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helfer Thomas Newsgroups: gmane.emacs.help Subject: How to make a new mode based on c++-mode Date: Fri, 01 Dec 2006 18:11:09 +0100 Message-ID: <1164993069.13163.10.camel@portableAsus> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1164993119 6687 80.91.229.2 (1 Dec 2006 17:11:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Dec 2006 17:11:59 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 01 18:11:47 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GqBv9-0000Rl-SM for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Dec 2006 18:11:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GqBv9-0003w2-BR for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Dec 2006 12:11:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GqBus-0003sP-44 for help-gnu-emacs@gnu.org; Fri, 01 Dec 2006 12:11:14 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GqBuq-0003o0-Cu for help-gnu-emacs@gnu.org; Fri, 01 Dec 2006 12:11:13 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GqBuq-0003nq-87 for help-gnu-emacs@gnu.org; Fri, 01 Dec 2006 12:11:12 -0500 Original-Received: from [212.27.42.65] (helo=smtp8-g19.free.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GqBup-00077J-Su for help-gnu-emacs@gnu.org; Fri, 01 Dec 2006 12:11:12 -0500 Original-Received: from [192.168.0.3] (lns-bzn-24-82-64-183-150.adsl.proxad.net [82.64.183.150]) by smtp8-g19.free.fr (Postfix) with ESMTP id 0E20D5503 for ; Fri, 1 Dec 2006 18:11:09 +0100 (CET) Original-To: help-gnu-emacs@gnu.org X-Mailer: Evolution 2.8.1 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:39176 Archived-At: Hello, I have created a parser which translates a file into C++ source code. The initial file has a syntax very close to C++ with some additional keywords. I would like to provide an emacs mode for editing those files. For the moment I have written this : ---------------------------------------------------------------------- ;;; -*-emacs-lisp-*- ;;; castfront.el --- ELisp package for making castfront related stuff easier. (provide 'castfront) (defconst castfront-keywords (list (list "\\(@\\(Coef\\)\\)\\>" '(0 font-lock-warning-face prepend)) )) (defun castfront-font-lock () "Turn on font-lock for CastFront keywords." (interactive) (if (functionp 'font-lock-add-keywords) (font-lock-add-keywords nil castfront-keywords) (let ((old (if (eq (car-safe font-lock-keywords) t) (cdr font-lock-keywords) font-lock-keywords))) (setq font-lock-keywords (append old castfront-keywords))))) ------------------------------------------------------------------------ I have then added the following line to my .emacs : (defun my-castfront-font-lock-hook () (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode)) (castfront-font-lock))) (add-hook 'font-lock-mode-hook 'my-castfront-font-lock-hook) This work pretty good. The only thing to do is to open my parsed file with c++-mode. However I want more. I want them to have their own mode, a mode that will automatically load the c++-mode to handle c++-construct a that will add my keywords as above. How can I make it ? Thank for help Sincerely, Helfer Thomas