If u use Emacs 21 (maybe even 20.7) use this small, but efficient addition
to sgml/xml-mode.
sgml/xml-mode provides the colouring of the tags (it is xml after all) - the
hack provide indention and auto-completion of end tags.
Completion of the tags is not possible without a DTD, but for this I just
use hippie-expand or dabbrev-expand.
Hope it helps:
; The functions is "stolen"/modfied from xslide.el
;
; It adds support for indention of tags and automatic insertion of end
; tags in xml files (without the need for DTD's)
;
; Alternatively PSGML could be used but it seems to be overkill for regular
xml editing.
; e.g. it require a DTD for proper fontification and indention.
(defun xml-electric-tab ()
"Function called when TAB is pressed in XML mode."
(interactive)
(save-excursion
(beginning-of-line)
(delete-horizontal-space)
(if (looking-at "</")
(indent-to (max 0 (- (xml-calculate-indent) 2)))
(indent-to (xml-calculate-indent))))
(if (and
(bolp)
(looking-at "[ \t]+"))
(goto-char (match-end 0))))
(defun xml-calculate-indent ()
"Calculate what the indent should be for the current line"
(interactive)
(save-excursion
(if (re-search-backward "^\\([ \t]*\\)<" nil t)
(goto-char (match-end 1))
(beginning-of-line))
(if (or
(save-excursion
(re-search-forward "\\(</[^<>]+>\\|<[^/][^<>]+/>\\)[ \t]*$"
(save-excursion (end-of-line) (1+ (point)))
t))
(bobp))
(current-column)
(+ (current-column) 2))))
(defun xml-electric-return ()
"Function called when enter/return is pressed in xml mode"
(interactive)
(insert "\n")
(xml-electric-tab))
(defun xml-electric-less-than ()
"Function called when \"<\" is pressed in xml mode"
(interactive)
(insert "<")
(xml-electric-tab))
(defun xml-electric-slash ()
"Function called when \"/\" is pressed in xml mode"
(interactive)
(insert "/")
(xml-electric-tab)
(if (looking-at "$")
(let ((element-name
(save-excursion
(backward-char 2)
(if (looking-at "</")
(catch 'start-tag
(while (re-search-backward "<" nil t)
(cond
((looking-at "</\\([^/> \t]+\\)>")
;; (message "End tag: %s" (match-string 1))
(re-search-backward
(concat "<" (match-string 1) "[ \t\n\r>]") nil t))
((looking-at "<\\(\\([^/>]\\|/[^>]\\)+\\)/>"))
;; (message "Empty tag: %s" (match-string 1)))
((looking-at "<!--[^-]*\\(-[^-]+\\)*-->"))
((looking-at "<\\([^/> \t]+\\)")
;; (message "Start tag: %s" (match-string 1))
(throw 'start-tag (match-string 1)))
((bobp)
(throw 'start-tag nil)))))
nil))))
(if element-name
(insert (concat element-name ">"))))))
; register additional keybindings in xml
(add-hook 'sgml-mode-hook
'(lambda ()
(progn
(define-key sgml-mode-map [tab] 'xml-electric-tab)
(define-key sgml-mode-map "/" 'xml-electric-slash)
(define-key sgml-mode-map "<" 'xml-electric-less-than)
)
)
)
""Jeff Rancier"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> You could try http://xae.sunsite.dk
>
> Jeff
>
> -----Original Message-----
> From: Eric Chastan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 12, 2001 3:52 AM
> To: [EMAIL PROTECTED]
> Subject: best mode to edit Ant files ?
>
>
> Hello,
>
> Do you know a good mode to edit Ant files (with colorization,
> indentation, completion ...) ?
>
> Eric.
>