I tried to use your modifications but it seems like it brakes the functionallity :(
When editing ant build files the indention and auto-end-tag-complete stops working (where it used to work fine) :( ""Reilly, Peter"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > This is an excellent addon to sgml-mode. All the other xml stuff for > emacs seem to need DTD and/or java parsing. However I found some small > problems with the code and have made some modifications to > * handle comments > * leave stuff in <script> alone > * indent by 4 if in a tag (for attributes) > * indent-region > > ; > ; 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. > ; author: Max Rydahl Andersen [[EMAIL PROTECTED]] > ; modified: Peter Reilly [[EMAIL PROTECTED]] > > > > (defun xml-calculate-indent () > "Calculate what the indent should be for the current line > (-indent if in script" > (interactive) > (let ((done nil) (current (point)) (pos 0) (script nil)) > (save-excursion > (beginning-of-line) > (if (re-search-backward "^\\([ \t]*\\)<" nil t) > (progn > (goto-char (match-end 1)) > (setq pos (current-column))) > (setq done t)) > (if (not done) > (if (looking-at "<!") > (setq done t))) > (if (not done) > (if (looking-at "</") > (setq done t))) > (if (not done) > (progn > (if (looking-at "<script") > (setq script t)) > (search-forward ">" current t) > (backward-char 1) > (if (not (looking-at ">")) > (setq pos (+ pos 4)) > (progn > (backward-char 1) > (if (not (looking-at "/>")) > (setq pos (+ pos 2))))))) > (if script > (* -1 pos) > pos)))) > > (defun xml-indent-region(start end &optional column) > "Function to indent a region in XML mode" > (interactive "r\nP") > (goto-char start) > (let ((done nil) (lineret 0)) > (while (not done) > (xml-electric-tab) > (if (not (eq (forward-line) 0)) > (setq done t)) > (end-of-line) > (if (<= end (point)) > (setq done t))))) > > > (defun xml-electric-tab () > "Function called when TAB is pressed in XML mode." > (interactive) > (save-excursion > (beginning-of-line) > (let > ((position (xml-calculate-indent))) > (if (> 0 position) > (progn > (skip-chars-forward " \t") > (if (looking-at "</") > (setq position (* -1 position)) > (setq position nil)))) > (if position > (progn > (delete-horizontal-space) > (if (looking-at "</") > (indent-to (max 0 (- position 2))) > (indent-to position)) > (if (and > (bolp) > (looking-at "[ \t]+")) > (goto-char (match-end 0)))))))) > > > (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 > (make-local-variable 'indent-region-function) > (setq indent-region-function 'xml-indent-region) > (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) > ) > ) > ) > > -----Original Message----- > From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 12, 2001 1:57 PM > To: [EMAIL PROTECTED] > Subject: Re: best mode to edit Ant files ? > > > 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: > > .... >> code deleted >
