From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Johnson Newsgroups: gmane.emacs.help Subject: Derived Mode 101 HOWTO Date: Mon, 06 Mar 2006 17:59:01 -0000 Organization: Alaska Internet Solutions Message-ID: Reply-To: tim@johnsons-web.com NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1141687977 13820 80.91.229.2 (6 Mar 2006 23:32:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Mar 2006 23:32:57 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 07 00:32:55 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 1FGPC6-0002SM-Ms for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Mar 2006 00:32:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGPC5-0003og-3H for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Mar 2006 18:32:49 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.astraweb.com!router2.astraweb.com!216.168.1.164.MISMATCH!sn-xt-sjc-04!sn-xt-sjc-09!sn-post-01!supernews.com!news.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: slrn/0.9.8.0 (Linux) Original-X-Complaints-To: abuse@supernews.com Original-Lines: 65 Original-Xref: shelby.stanford.edu gnu.emacs.help:137978 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: , 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:33605 Archived-At: This builds on the topic from another thread. "Restricting 'add-hook to a specific file extension" Here's the goal: From the simple (and non-working) example using 'add-hook, create a derived mode using 'scheme-mode and a supporting the newlisp programming language which is based on lisp. AND 1)Add two *new* faces, one for user libraries, and another for multi-line strings. 2)Override two existing faces and re-populate with newlisp-specific syntax. 3)Add a menu 4)Add keybinding. Compatibility: Must be usable by both forks. Xemacs *does not* support font-lock-add-keywords. Must use a menuing approach compatible to both emacs and Xemacs. HISTORICALLY: Much of these goals have been implemented albeit crudely, using 'font-lock-add-faces and the 'add-hook approach. Compatible to GNU emacs only. When finished, I'll add in the keyword-based help system I've built, I'm actually kind of proud of it. Definitely is useful. Sample code follows. First thing to tackle is syntax highlighting. I'm big on that 'cuz my vision sucks. ;; Results thus far: This file is loaded without error, but ;; The syntax highlight scheme does not work. (defface font-lock-newlisp-keywords-face '((((class color) (background dark)) (:foreground "tan")) (((class color) (background light)) (:foreground "green4")) (((class grayscale) (background light)) (:foreground "DimGray" :italic t)) (((class grayscale) (background dark)) (:foreground "LightGray" :italic t)) (t (:bold t))) "Font Lock mode face used to highlight keywords for Newlisp programming language." :group 'font-lock-faces) (defvar font-lock-newlisp-keywords-face 'font-lock-newlisp-keywords-face) (defconst word-begin "\\b\\(") (defconst word-end "\\)\\b") (defconst newlisp-keywords ;; just a few (regexp-opt '( "acos" "add" "and" "append" "append" "apply" "args" "array" ) ) ) (defvar newlisp-font-lock-keywords nil "List of newlisp keywords and faces") (add-hook 'scheme-mode-hook (lambda () (progn (require 'font-lock) (setq newlisp-font-lock-keywords (list '((concat word-begin newlisp-keywords word-end) font-lock-newlisp-keywords-face ) )) (setq scheme-font-lock-keywords (append scheme-font-lock-keywords newlisp-font-lock-keywords)) (message "Newlisp extensions added for Xemacs")))) (provide 'newlisp++) ;; highlight doesn't work... Looking forward to input. -- Tim Johnson http://www.alaska-internet-solutions.com