all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Johnson <tim@johnsons-web.com>
Subject: Derived Mode 101 HOWTO
Date: Mon, 06 Mar 2006 17:59:01 -0000	[thread overview]
Message-ID: <slrne0os3j.s7q.tim@linus.johnson.com> (raw)

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 <tim@johnsons-web.com>
      http://www.alaska-internet-solutions.com

             reply	other threads:[~2006-03-06 17:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-06 17:59 Tim Johnson [this message]
2006-03-07 18:01 ` Derived Mode 101 HOWTO Stefan Monnier
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrne0os3j.s7q.tim@linus.johnson.com \
    --to=tim@johnsons-web.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.