diff src/elisp/urweb-mode.el @ 2140:2b0f6b7ebf4f

Add urweb-mode command to close current XML tag Bound to "C-c /" by default to match nxml-mode's nxml-finish-element command.
author Julian Squires <julian@cipht.net>
date Mon, 04 May 2015 16:15:01 -0400
parents 3dc020fb2aa1
children 3288e3c9948b
line wrap: on
line diff
--- a/src/elisp/urweb-mode.el	Fri Apr 24 16:21:55 2015 -0400
+++ b/src/elisp/urweb-mode.el	Mon May 04 16:15:01 2015 -0400
@@ -401,6 +401,7 @@
   (unless (boundp 'skeleton-positions) (set (make-local-variable '@) nil))
 
   (local-set-key (kbd "C-c C-c") 'compile)
+  (local-set-key (kbd "C-c /") 'urweb-close-matching-tag)
 
   (urweb-mode-variables))
 
@@ -542,6 +543,16 @@
     (beginning-of-line)
     (current-indentation)))
 
+(defun urweb-close-matching-tag ()
+  "Insert a closing XML tag for whatever tag is open at the point."
+  (interactive)
+  (assert (urweb-in-xml))
+  (save-excursion
+   (urweb-tag-matcher)
+   (re-search-forward "<\\([^ ={/>]+\\)" nil t))
+  (let ((tag (match-string-no-properties 1)))
+    (insert "</" tag ">")))
+
 (defconst urweb-sql-main-starters
   '("SQL" "SELECT" "INSERT" "UPDATE" "DELETE" "FROM" "SELECT1" "WHERE"))