[Utils] Simpler pretty printer for XML

This commit is contained in:
Daniel - 2018-11-21 10:38:05 +01:00
parent 83c1dfbed1
commit a08432b23b
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
2 changed files with 18 additions and 1 deletions

View File

@ -528,7 +528,8 @@
hydra-zoom/body
hydra-rectangle/body
db/two-monitors-xrandr
db/one-monitor-xrandr))
db/one-monitor-xrandr
db/pretty-print-xml))
(use-package hydra
:commands (defhydra))

View File

@ -234,6 +234,22 @@ are assumed to be of the form *.crt."
(interactive)
(electric-pair-local-mode -1))
(defun db/pretty-print-xml ()
"Stupid function to pretty print XML content in current buffer."
(interactive)
(unless (eq major-mode 'nxml-mode)
(require 'nxml-mode)
(nxml-mode))
(save-mark-and-excursion
(goto-char (point-min))
(while (re-search-forward "\n[[:space:]]*" nil 'no-error)
(replace-match ""))
(goto-char (point-min))
(while (re-search-forward ">[[:space:]]*<" nil 'no-error)
(replace-match ">\n<"))
(mark-whole-buffer)
(indent-region (point-min) (point-max))))
;;; helm configuration