all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* eLisp fontlock with mmm-mode
@ 2003-09-03  0:41 Sam Vilain
  0 siblings, 0 replies; 11+ messages in thread
From: Sam Vilain @ 2003-09-03  0:41 UTC (permalink / raw)


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." 

^ permalink raw reply	[flat|nested] 11+ messages in thread
* eLisp fontlock with mmm-mode
@ 2003-08-12 11:18 Sam Vilain
  0 siblings, 0 replies; 11+ messages in thread
From: Sam Vilain @ 2003-08-12 11:18 UTC (permalink / raw)


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." 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-09-13  2:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.34.1062553939.18171.help-gnu-emacs@gnu.org>
2003-09-03 14:59 ` eLisp fontlock with mmm-mode Joe Kelsey
2003-09-03 17:02   ` Kevin Rodgers
2003-09-05 15:02     ` Joe Kelsey
2003-09-11 22:28       ` Alan Mackenzie
2003-09-12 15:46         ` Joe Kelsey
2003-09-12 21:55           ` Alan Mackenzie
2003-09-12 22:39             ` Stefan Monnier
2003-09-12 23:38               ` Bug in delete-char ???? (Emacs 21.2.2) Greg Hill
     [not found]               ` <mailman.228.1063410048.21628.bug-gnu-emacs@gnu.org>
2003-09-13  2:19                 ` Johan Bockgård
2003-09-03  0:41 eLisp fontlock with mmm-mode Sam Vilain
  -- strict thread matches above, loose matches on Subject: below --
2003-08-12 11:18 Sam Vilain

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.