# HG changeset patch # User Oleksandr Gavenko # Date 1525337554 -10800 # Node ID 9f4456fcac0eb12454755494c0c114f5d7e1d865 # Parent a7bb0608855b6e45bbd8bb2ab1033145da07ad36 Added pretty-print XML function. diff -r a7bb0608855b -r 9f4456fcac0e .emacs-my --- a/.emacs-my Sat Apr 14 17:15:52 2018 +0300 +++ b/.emacs-my Thu May 03 11:52:34 2018 +0300 @@ -3502,6 +3502,17 @@ (my--eval-after-load nxml-mode (define-key nxml-mode-map [C-return] 'nxml-complete)) +(defun my-nxml-pp () + "Pretty-print XML." + (interactive) + (goto-char (point-min)) + (while (re-search-forward ">[ \t\n\r]+<" nil t) + (replace-match ">\n<")) + (while (re-search-forward "><" nil t) + (replace-match ">\n<")) + (indent-region (point-min) (point-max)) + (goto-char (point-min))) + (defun my-nxml-where (&optional prefix) "Display the hierarchy of XML elements the point is on as a path." (interactive "P")