public
Last active

Little helpers for nxml

  • Download Gist
nxml-hacks.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
(defun cabo:nxml-balanced-close-start-tag-block ()
"Close the start-tag before point with `>' and insert a balancing end-tag.
Point is left between the start-tag and the end-tag.
If there is nothing but whitespace before the `<' that opens the
start-tag, then put point on a blank line, and put the end-tag on
another line aligned with the start-tag."
(interactive "*")
(nxml-complete)
(nxml-balanced-close-start-tag-block))
 
(defun cabo:nxml-balanced-close-start-tag-inline ()
"Close the start-tag before point with `>' and insert a balancing end-tag.
Point is left between the start-tag and the end-tag.
No extra whitespace is inserted."
(interactive "*")
(nxml-complete)
(nxml-balanced-close-start-tag-inline))
 
(defun bind-nxml-mode-keys ()
(define-key nxml-mode-map "\C-c\C-b" 'cabo:nxml-balanced-close-start-tag-block)
(define-key nxml-mode-map "\C-c\C-i" 'cabo:nxml-balanced-close-start-tag-inline)
(define-key nxml-mode-map (kbd "<C-return>") 'completion-at-point))
 
(add-hook 'nxml-mode-hook 'bind-nxml-mode-keys)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.