cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@cup.hp.com>
Subject emacs editing functions for XSL/XSP
Date Thu, 28 Sep 2000 23:46:44 GMT
Hi,

For those of you that use Emacs/Xemacs to edit XSL/XSP pages, here are some
handy functions you can use in your .emacs to speed up the editing. They insert
the commonly used tags in the current buffer, indented and nicely formatted.
They were developed and used on Xemacs 21.1, but they should work on GNU Emacs
as well.

I'd be curious to know what other little things people use in emacs to speed up
development.

--

(require 'tempo)

(defun get-value-from-minibuffer (display format-string)
  (let ((input (read-from-minibuffer display)))
    (if (string= input "")
	""
      (format format-string input))))

(tempo-define-template "xsl-template"
 '('&'o'> "<xsl:template"
   (get-value-from-minibuffer "Template name: " " match=\"%s\"")
   ">" 'n'>'n
   "</xsl:template>" '>
   (end-of-line 0)))

(tempo-define-template "xsl-if"
 '('&'o'> "<xsl:if"
   (get-value-from-minibuffer "Test expression: " " test=\"%s\"")
   ">" 'n'>'n
   "</xsl:if>" '>
   (end-of-line 0)))

(tempo-define-template "xsl-for-each"
 '('&'o'> "<xsl:for-each"
   (get-value-from-minibuffer "Select expression: " " select=\"%s\"")
   ">" 'n'>'n
   "</xsl:for-each>" '>
   (end-of-line 0)))

(tempo-define-template "xsp-logic"
 '('&'o'> "<xsp:logic>" '>'n'>'n
   "</xsp:logic>" '>'n
   (end-of-line -1)))

(tempo-define-template "xsp-expr"
 '('&'o'> "<xsp:expr>" '>'n'>'n
   "</xsp:expr>" '>'n
   (end-of-line -1)))

(tempo-define-template "xsl-value-of"
 '('> "<xsl:value-of"
   (get-value-from-minibuffer "Value: " " select=\"%s\"")
   "/>" '>))

(tempo-define-template "xsl-apply-templates"
 '('> "<xsl:apply-templates"
   (get-value-from-minibuffer "Select: " " select=\"%s\"")
   "/>" '>))

(defun my-xml-templates-hook()
  (define-key xml-mode-map "\C-ct" 'tempo-template-xsl-template)
  (define-key xml-mode-map "\C-ci" 'tempo-template-xsl-if)
  (define-key xml-mode-map "\C-cf" 'tempo-template-xsl-for-each)
  (define-key xml-mode-map "\C-cv" 'tempo-template-xsl-value-of)
  (define-key xml-mode-map "\C-ca" 'tempo-template-xsl-apply-templates)
  (define-key xml-mode-map "\C-cl" 'tempo-template-xsp-logic)
  (define-key xml-mode-map "\C-ce" 'tempo-template-xsp-expr))

(add-hook 'xml-mode-hook 'my-xml-templates-hook)


Have fun,
Ovidiu

-- 
Ovidiu Predescu <ovidiu@cup.hp.com>
http://orion.nsr.hp.com/ (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/




Mime
View raw message