From: unknown Date: Mon, 5 Mar 2012 13:21:50 +0000 (+0100) Subject: New nxml.el completion functionality X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=b91865af3dfbb7153fc38ae1101995a136cd9541;p=emacs-init.git New nxml.el completion functionality --- diff --git a/setup/nxml.el b/setup/nxml.el index 208e587..123e6b3 100644 --- a/setup/nxml.el +++ b/setup/nxml.el @@ -127,25 +127,47 @@ ("step" . ("para" "procedure")) ("mathphrase" . ("replaceable" "superscript" "subscript")) ("title" . ("code" "replaceable")) - ("literallayout" . ("replaceable" "emphasis" "code")))) + ("literallayout" . ("replaceable" "emphasis" "code")) + ("table" . ("title" . "tgroup")) + ("tgroup" . ("colspec" "thead" "tbody")) + ("thead" . ("row")) + ("tbody" . ("row")) + ("row". ("entry")) + ("entry" . ("emphasis" "code")))) (defvar nxml-docbook-last-common-element nil) -(defun nxml-docbook-make-common-element () - (interactive) +(defun nxml-docbook-make-common-element (&optional surrounding) + (interactive "P") (let ((start (set-marker (make-marker) (point))) (end (set-marker (make-marker) (point))) do-region) (when (or (region-active-p) (and (eq real-last-command 'nxml-docbook-make-common-element) - (car nxml-docbook-last-common-element))) - (set-marker start (region-beginning)) - (set-marker end (region-end)) + (car nxml-docbook-last-common-element)) + surrounding) + (save-excursion + (set-marker start + (if (region-active-p) + (region-beginning) + (nxml-backward-up-element) + (save-excursion + (skip-chars-forward "^>") + (forward-char 1) + (point)))) + (set-marker end + (if (region-active-p) + (region-end) + (nxml-forward-balanced-item) + (skip-chars-backward "^<") + (forward-char -1) + (point)))) (message "do-mark %s %s" start end) (setq do-region t)) (message "cycle? %s %s" real-last-command nxml-docbook-last-common-element) - (when (and (eq real-last-command 'nxml-docbook-make-common-element) - (cdr nxml-docbook-last-common-element)) + (when (or (and (eq real-last-command 'nxml-docbook-make-common-element) + (cdr nxml-docbook-last-common-element)) + surrounding) (delete-region (save-excursion (skip-chars-backward "^<") (1- (point))) start) (delete-region end (save-excursion (skip-chars-forward "^>") (1+ (point))))) (let* ((token-end (nxml-token-before)) @@ -165,6 +187,8 @@ (nxml-scan-element-backward token-end t))) (context (xmltok-start-tag-qname)) (elements (cdr (assoc context nxml-docbook-common-elements))) +; List valid start tags at point (using schema): +; (let ((lt-pos (point))) (rng-set-state-after lt-pos) (loop for (ns . name) in (rng-match-possible-start-tag-names) collect name)) (index (if (and elements (eq real-last-command 'nxml-docbook-make-common-element) (cdr nxml-docbook-last-common-element))