diff --git a/init.el b/init.el index 546cc31..1dcc49c 100644 --- a/init.el +++ b/init.el @@ -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)) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 8b60b53..0a1ccc6 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -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