Skip to content

Instantly share code, notes, and snippets.

@cabo
Created August 7, 2012 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabo/3282903 to your computer and use it in GitHub Desktop.
Save cabo/3282903 to your computer and use it in GitHub Desktop.
Little helpers for nxml
(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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment