[Zope] dtml-mode patch: works with gnu emacs, new-style tags

Erno Kuusela erno@iki.fi
Mon, 24 Jan 2000 19:43:39 +0200


--tmoQ0UElFV5VgXgH
Content-Type: text/plain; charset=us-ascii

hello,

i suppose this is quite trivial, but it took me half an hour as i can't
write elisp and didn't know what point-at-bol did :)

i haven't tested it much, but it seems to work at first sight.

hope someone finds it useful.

   -- erno

--tmoQ0UElFV5VgXgH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="dtml-mode.diff"

--- dtml-mode-0.1/dtml-mode.el	Sat May  8 19:38:48 1999
+++ dtml-mode-0.1.newtags+emacs/dtml-mode.el	Mon Jan 24 19:36:27 2000
@@ -29,11 +29,11 @@
 
 (defconst dt-version "0.1" "`dtml-mode' version number.")
 
-(defcustom dtml-comment-start "<!--#comment-->" 
+(defcustom dtml-comment-start "<dtml-comment>" 
   "*String used by \\[comment-region] to comment out a block of code."
   :type 'string :group 'dtml)
 
-(defcustom dtml-comment-end "<!--#/comment-->" 
+(defcustom dtml-comment-end "</dtml-comment>" 
 "*String used by \\[comment-region] to comment out a block of code."
 :type 'string :group 'dtml)
 
@@ -43,8 +43,8 @@
   :group 'dtml)
 
 (defvar dtml-font-lock-keywords
-  '(("<!--" 0 font-lock-comment-face t)
-    ("-->"  0 font-lock-comment-face t))
+  '(("<dtml-" 0 font-lock-comment-face t)
+    (">"  0 font-lock-comment-face t))
     "*Keywords to highlight in DTML code.")
 
 (defvar dtml-keywords
@@ -55,13 +55,21 @@
     "unless"
     ))
 
+
+(defun point-at-bol ()
+  (save-excursion
+    (beginning-of-line)
+    (point)))
+
+
+
 (defun dtml-keyword-template (s)
   (list (format "\\(#[/]?[ ]*%s\\)[ -]" s ) 1 font-lock-keyword-face t))
 
 (defvar dtml-font-lock-keywords-1 
-  (append '(("<!--" 0 font-lock-comment-face t)
-	     ("\\(\w\\)+[ ]*-->" 1 font-lock-string-face nil)
-	     ("-->"  0 font-lock-comment-face t))
+  (append '(("<dtml-" 0 font-lock-comment-face t)
+	     ("\\(\w\\)+[ ]*>" 1 font-lock-string-face nil)
+	     (">"  0 font-lock-comment-face t))
 
 	  (mapcar '(lambda (s) (dtml-keyword-template s))
 		  dtml-keywords)))
@@ -90,59 +98,59 @@
 
 (define-skeleton dtml-var 
   "DTML var tag"
-  "args: " "<!--#var " str "-->" _ nil)
+  "args: " "<dtml-var " str ">" _ nil)
 
 (define-skeleton dtml-if
   "Insert a DTML if statement."
   "condition: "
-  "<!--#if " str " -->" \n
+  "<dtml-if " str " >" \n
   _ \n
-  ( "other condition, %s: " "<!--#elif " str " -->" \n
+  ( "other condition, %s: " "<dtml-elif " str " >" \n
      _ \n )
-  "<!--#else-->" \n
+  "<dtml-else>" \n
    _ \n
   resume:
-  "<!--#/if-->")
+  "</dtml-if>")
 
 
 (define-skeleton dtml-in
   "Insert a DTML in tag."
-  "args: " "<!--#in " str "-->" \n _ \n "<!--#/in-->"
+  "args: " "<dtml-in " str ">" \n _ \n "</dtml-in>"
 )
 
 (define-skeleton dtml-with
   "Insert a DTML #with tag."
-  "args: " "<!--#with " str "-->" \n _ \n "<!--#/with-->"
+  "args: " "<dtml-with " str ">" \n _ \n "</dtml-with>"
 )
 
 (define-skeleton dtml-sendmail
   "Insert a DTML #sendmail tag."
-  "args: " "<!--#sendmail " str "-->" \n _ \n "<!--#/sendmail-->"
+  "args: " "<dtml-sendmail " str ">" \n _ \n "</dtml-sendmail>"
 )
 
 (define-skeleton dtml-unless
   "Insert a DTML #unless tag."
-  "args: " "<!--#unless " str "-->"\n _ \n "<!--#/unless-->"
+  "args: " "<dtml-unless " str ">"\n _ \n "</dtml-unless>"
 )
 
 (define-skeleton dtml-tree
   "Insert a DTML #tree tag."
-  "args: " "<!--#tree " str "-->" \n _ \n "<!--#/tree-->"
+  "args: " "<dtml-tree " str ">" \n _ \n "</dtml-tree>"
 )
 
 (define-skeleton dtml-call
   "Insert a DTML #call tag."
-  "args: " "<!--#call " str "-->" nil
+  "args: " "<dtml-call " str ">" nil
 )
 
 (define-skeleton dtml-raise
   "Insert a DTML #call tag."
-  "type: " "<!--#raise type=\"" str "\"-->" \n _ \n "<!--#/raise-->" nil
+  "type: " "<dtml-raise type=\"" str "\">" \n _ \n "</dtml-raise>" nil
 )
 
 ;(define-skeleton dtml-set-local
 ;  "Insert a DTML #call tag."
-;  "varname:" "<!--#call \"REQUEST.set(\'" str "\', " "expr:" str nil resume: ")\"-->" nil
+;  "varname:" "<dtml-call \"REQUEST.set(\'" str "\', " "expr:" str nil resume: ")\">" nil
 ;)
 
 (defun dtml-mode ()
@@ -191,13 +199,13 @@
 
 (defun dtml-line-for-indent-p ()
   "Is this a line we consider for indentation purposes?"
-  ;; looking-at <!--#[/]*[a-zA-Z]+ .*?-->
-;;  (looking-at "<!--#[/]?[ ]*[a-zA-Z]+.*?-->")
-  ;;(looking-at "<!--#")
+  ;; looking-at <dtml-[/]*[a-zA-Z]+ .*?>
+;;  (looking-at "<dtml-[/]?[ ]*[a-zA-Z]+.*?>")
+  ;;(looking-at "<dtml-")
   t
 )
 
-(defvar dtml-open-tag-re "[ ]*<!--[ ]*#[ ]*\\(if\\|with\\|in\\|calendar\\try\\|sendmail\\|elif\\|else\\|tree\\|raise\\|unless\\)")
+(defvar dtml-open-tag-re "[ ]*<dtml-[ ]*#[ ]*\\(if\\|with\\|in\\|calendar\\try\\|sendmail\\|elif\\|else\\|tree\\|raise\\|unless\\)")
 
 (defun dtml-open-tag-p ()
   "Is this a DTML open tag?"
@@ -205,7 +213,7 @@
 
 (defun dtml-closing-tag-p ()
   "Is this a DTML close tag?"
-  (looking-at "[ ]*<!--[ ]*#[ ]*\\(else\\|elif\\|/\\)"))
+  (looking-at "[ ]*<dtml-[ ]*#[ ]*\\(else\\|elif\\|/\\)"))
 
 
 (defun dtml-new-block-p ()

--tmoQ0UElFV5VgXgH--