help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Derived Mode 101 HOWTO


From: Tim Johnson
Subject: Re: Derived Mode 101 HOWTO
Date: Wed, 08 Mar 2006 02:58:45 -0000
User-agent: slrn/0.9.8.0 (Linux)

I have written a file called newlisp-mode.el, based on Stefan's
instructions, as best as I can follow.
Results are as follows:
When loading a .lsp file with GNU emacs, newlisp-mode is loaded without
complaint.
eval->major-mode gives me "newlisp-mode". 

However syntax highlighting for 'newlisp-font-lock-keywords fails.

eval->font-lock-defaults shows that the dotted list composed from
  newlisp-keywords and font-lock-newlisp-keywords-face
  is present. 

The scheme font-lock-keywords-face and  font-lock-function-name-face
are successfully implemented.

As for Xemacs, loading the file and the mode fails with the following
error message: (may be wrapped and obfuscated by mailer)
 Wrong type argument: symbolp,
   ("\\<\\(a\\(?:cos\\|dd\\|nd\\|pp\\(?:end\\(?:\\)?\\|
   ly\\)\\|r\\(?:gs\\|ray\\)\\)\\)\\>"
   . font-lock-newlisp-keywords-face)
NOTE: This refers to the same dotted list constructed as a component of
      newlisp-font-lock-keywords

;; Code follows:
(require 'scheme)
;; ==========================================================================
(defface font-lock-newlisp-keywords-face
  '((((class color) (background dark)) (:foreground "yellow"))
    (((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)
;; ==========================================================================
(defconst
  newlisp-keywords ;; just a few
   (regexp-opt '(
    "acos" "add" "and" "append" "append" "apply" "args" "array"
    )))
;; ==========================================================================
(defvar newlisp-font-lock-keywords
   `(,@scheme-font-lock-keywords
     (,(concat "\\<\\(" newlisp-keywords "\\)\\>")
      . font-lock-newlisp-keywords-face))
   "List of newlisp keywords and faces")
;; ==========================================================================
(define-derived-mode newlisp-mode scheme-mode "newlisp"
  "A major mode for Newlisp."
  (set (make-local-variable 'font-lock-defaults)
       (cons newlisp-font-lock-keywords
             ;; Copy the rest of font-lock-defaults from
             ;; scheme-mode if available.
             (or (cdr font-lock-defaults)
                 '(nil t (("+-*/.<>=!?$%_&~^:" . "w")))))))
-- 
Tim Johnson <tim@johnsons-web.com>
      http://www.alaska-internet-solutions.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]