From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Sam Vilain Newsgroups: gmane.emacs.devel Subject: eLisp fontlock with mmm-mode Date: Tue, 12 Aug 2003 12:18:22 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200308121218.24831.sam@vilain.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1060687403 12215 80.91.224.253 (12 Aug 2003 11:23:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Aug 2003 11:23:23 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Aug 12 13:23:21 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mXFJ-0000s4-00 for ; Tue, 12 Aug 2003 13:23:21 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19mXMz-0002lg-00 for ; Tue, 12 Aug 2003 13:31:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mXBQ-0000x9-03 for emacs-devel@quimby.gnus.org; Tue, 12 Aug 2003 07:19:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mXB8-0000t6-5G for emacs-devel@gnu.org; Tue, 12 Aug 2003 07:19:02 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mXAb-0000gU-Ij for emacs-devel@gnu.org; Tue, 12 Aug 2003 07:19:00 -0400 Original-Received: from [213.208.107.129] (helo=betelgeuse.dev.surreytech.co.uk) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mXAa-0000f7-0f for emacs-devel@gnu.org; Tue, 12 Aug 2003 07:18:28 -0400 Original-Received: from sv by betelgeuse.dev.surreytech.co.uk with local (Exim 3.35 #1 (Debian)) id 19mXAW-0000xV-00 for ; Tue, 12 Aug 2003 12:18:24 +0100 Original-To: emacs-devel@gnu.org User-Agent: KMail/1.5.2 Content-Disposition: inline X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:15901 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15901 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 \\b\\|\\bINSERT\\b\\|\\bINCLUDE\\b\\|\\bBLOCK\\b\\|\\bEND\\b\\| \\bPROCESS\\b\\|\\bWRAPPER\\b\\|\\bIF\\b\\|\\bUNLESS\\b\\|\\bELSIF \\b\\|\\bELSE\\b\\|\\bSWITCH\\b\\|\\bCASE\\b\\|\\bFOREACH\\b\\| \\bWHILE\\b\\|\\bFILTER\\b\\|\\bUSE\\b\\|\\bMACRO\\b\\|\\bPERL \\b\\|\\bRAWPERL\\b\\|\\bTRY\\b\\|\\bTHROW\\b\\|\\bCATCH\\b\\| \\bFINAL\\b\\|\\bLAST\\b\\|\\bRETURN\\b\\|\\bSTOP\\b\\|\\bCLEAR \\b\\|\\bMETA\\b\\|\\bTAGS") (defvar tt-font-lock-keywords (list ;; 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 "\\[%[-+]? *\\(" tt-keywords "\\)") 1 font-lock-keyword-face t) ) "Expressions to font-lock in tt-mode.") (defun tt-mode () "Major mode for editing Template Toolkit files" (interactive) (kill-all-local-variables) (setq major-mode 'tt-mode) (setq mode-name "TT") (if (string-match "Xemacs" emacs-version) (progn (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)) ) (font-lock-mode) (run-hooks tt-mode-hook)) (provide 'tt-mode) Much appreciated, -- Sam Vilain, sam@vilain.net "This is an object-oriented system. If we change anything, the users object."