[Top][All Lists]

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

eLisp fontlock with mmm-mode

From: Sam Vilain
Subject: eLisp fontlock with mmm-mode
Date: Tue, 12 Aug 2003 12:18:22 +0100
User-agent: KMail/1.5.2

Hi all,

When I try to mix two modes using mmm-ify-by-regexp, there are
problems when the context of one interferes with the other.

  see http://www.vilain.net/emacs/

     00-control.png is a screenshot of the buffer in fundamental mode
     01-html-mode.png is the buffer in HTML mode
     02-tt-mode.png is the buffer in TT mode, below
     03-html[tt]-mmm.png is the buffer mmm-ify'd using the elisp
        expression on the fourth line.
     tt-mode.el is the source code for the TT mode (included below)

Before taking each screenshot, I used font-lock-fontify-buffer to
re-do the highlighting.

I would like the mode within the mmm-mode to ignore the current
highlighting context of the base mode.  Is this possible?

If it is more likely a bug in the tt-mode, is there a simple problem
with the following syntax highlighting definition that would cause
this to happen?

I'll include it, because it's quite short:

(require 'font-lock)

(defvar tt-mode-hook nil
  "List of functions to call when entering TT mode")

(defvar tt-keywords "\\bGET\\b\\|\\bCALL\\b\\|\\bSET\\b\\|\\bDEFAULT

(defvar tt-font-lock-keywords 
    ;; Fontify [& ... &] expressions
      (1 font-lock-string-face t)
      (2 font-lock-variable-name-face t)
      (3 font-lock-string-face t))
    ;; Look for keywords within those expressions
    (list (concat
           "\\[%[-+]? *\\("
          1 font-lock-keyword-face t)
  "Expressions to font-lock in tt-mode.")

(defun tt-mode ()
  "Major mode for editing Template Toolkit files"
  (setq major-mode 'tt-mode)
  (setq mode-name "TT")
  (if (string-match "Xemacs" emacs-version)
        (make-local-variable 'font-lock-keywords)
        (setq font-lock-keywords tt-font-lock-keywords))
    ;; Emacs
    (make-local-variable 'font-lock-defaults)
    (setq font-lock-defaults '(tt-font-lock-keywords nil t))
  (run-hooks tt-mode-hook))

(provide 'tt-mode)

Much appreciated,
Sam Vilain, address@hidden

"This is an object-oriented system.
 If we change anything, the users object." 

reply via email to

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