[Utils] Simpler pretty printer for XML
This commit is contained in:
parent
83c1dfbed1
commit
a08432b23b
3
init.el
3
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))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue