diff --git a/customizations/functions.el b/customizations/functions.el index 3f223ec..88b67e1 100644 --- a/customizations/functions.el +++ b/customizations/functions.el @@ -1,6 +1,23 @@ ;;Custom functions ;;Seems to be needed for search-at-point +;;Found at http://www.emacswiki.org/emacs/CompilationMode (defun delete-this-overlay(overlay is-after begin end &optional len) (delete-overlay overlay) ) + +;;See http://blog.bookworm.at/2007/03/pretty-print-xml-with-emacs.html +(defun bf-pretty-print-xml-region (begin end) + "Pretty format XML markup in region. You need to have nxml-mode +http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do +this. The function inserts linebreaks to separate tags that have +nothing but whitespace between them. It then indents the markup +by using nxml's indentation rules." + (interactive "r") + (save-excursion + (nxml-mode) + (goto-char begin) + (while (search-forward-regexp "\>[ \\t]*\<" nil t) + (backward-char) (insert "\n")) + (indent-region begin end)) + (message "Ah, much better!"))