From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Derived Mode 101 HOWTO
Date: Tue, 07 Mar 2006 13:01:02 -0500 [thread overview]
Message-ID: <87mzg2jgdy.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: slrne0os3j.s7q.tim@linus.johnson.com
Place at the beginning of your newlisp.el file:
(require 'scheme)
> (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")
Every global name you define should use the "newlisp-" prefix.
> (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")
Initialize it directly:
(defvar newlisp-font-lock-keywords
`(,@scheme-font-lock-keywords
(,(concat "\\<\\(" newlisp-keywords "\\)\\>")
. font-lock-newlisp-keywords-face))
"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"))))
Replace by define-derived-mode:
(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")))))))
Also check (again?) sample-mode.el.
Stefan
next prev parent reply other threads:[~2006-03-07 18:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-06 17:59 Derived Mode 101 HOWTO Tim Johnson
2006-03-07 18:01 ` Stefan Monnier [this message]
2006-03-08 2:58 ` Tim Johnson
2006-03-08 5:46 ` Stefan Monnier
2006-03-08 16:58 ` Tim Johnson
2006-03-11 17:15 ` Stefan Monnier
2006-03-12 0:57 ` Tim Johnson
2006-03-12 13:49 ` Stefan Monnier
2006-03-13 1:48 ` Tim Johnson
2006-03-13 10:10 ` Johan Bockgård
2006-03-13 17:57 ` Tim Johnson
2006-03-13 21:35 ` Johan Bockgård
2006-03-13 23:57 ` Tim Johnson
2006-03-12 5:29 ` Johan Bockgård
2006-03-12 17:50 ` Tim Johnson
2006-03-12 18:14 ` Johan Bockgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mzg2jgdy.fsf-monnier+gnu.emacs.help@gnu.org \
--to=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).