Some nxml macros from my .emacs file

2006-12-08

I seem to remember defining some .emacs macros to make nxml mimic psgml more closely. I don't remember which ones they are, so I'm just posting these candidates from my .emacs file if anyone's interested.

(defun nxml-beginning-of-element ()
  "Jump to point after start-tag."
  (interactive)
  (nxml-backward-up-element)
  (forward-sexp)
)
(global-set-key [?\C-c (home)] 'nxml-beginning-of-element)


(defun nxml-end-of-element ()
  "Jump to point before end-tag."
  (interactive)
  (nxml-up-element)
  (backward-sexp)
)
(global-set-key [?\C-c (end)] 'nxml-end-of-element)

(defun nxml-kill-to-eoelement ()
  "Kill to end of element."
  (interactive)
  (let ((start (point)))
  (nxml-end-of-element)
  (kill-region start (point))))

(global-set-key "k" 'nxml-kill-to-eoelement) ; that's a ^Ck

; from 2005-08-03T22:12 posting to nxml list
    (defun surround-region-with-tag (tag-name beg end)
      (interactive "sTag name: \nr")
      (save-excursion
        (goto-char beg)
        (insert "<" tag-name ">")
        (goto-char (+ end 2 (length tag-name)))
        (insert "</" tag-name ">")))

(global-set-key "r" 'surround-region-with-tag)  ; that's a ^Cr