Mercurial > emacs
changeset 44333:efbd9e76f0a4
(sgml-close-tag): Rename from
sgml-insert-end-tag. Simplify by using sgml-lexical-context.
(sgml-get-context): Remove use of sgml-inside-tag-p.
(sgml-inside-tag-p): Remove.
author | Mike Williams <mdub@bigfoot.com> |
---|---|
date | Tue, 02 Apr 2002 11:26:12 +0000 |
parents | bdf6c2baa447 |
children | 3aa56f622b1b |
files | lisp/textmodes/sgml-mode.el |
diffstat | 1 files changed, 20 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/sgml-mode.el Tue Apr 02 03:23:26 2002 +0000 +++ b/lisp/textmodes/sgml-mode.el Tue Apr 02 11:26:12 2002 +0000 @@ -99,6 +99,7 @@ (define-key map "\C-c\C-d" 'sgml-delete-tag) (define-key map "\C-c\^?" 'sgml-delete-tag) (define-key map "\C-c?" 'sgml-tag-help) + (define-key map "\C-c/" 'sgml-close-tag) (define-key map "\C-c8" 'sgml-name-8bit-mode) (define-key map "\C-c\C-v" 'sgml-validate) (when sgml-quick-keys @@ -461,7 +462,7 @@ (indent-according-to-mode)) ((eq sgml-quick-keys 'close) (delete-backward-char 1) - (sgml-insert-end-tag)) + (sgml-close-tag)) (t (sgml-slash-matching arg)))) @@ -993,8 +994,8 @@ (forward-char 1) (setq tag-type 'close name (sgml-parse-tag-name))) - ((?% ?#) ; JSP tags etc - (setq tag-type 'unknown)) + (?% ; JSP tags + (setq tag-type 'jsp)) (t ; open or empty tag (setq tag-type 'open name (sgml-parse-tag-name)) @@ -1004,13 +1005,6 @@ (goto-char tag-start) (sgml-make-tag tag-type tag-start tag-end name))) -(defsubst sgml-inside-tag-p (tag-info &optional point) - "Return true if TAG-INFO contains the POINT." - (let ((end (sgml-tag-end tag-info)) - (point (or point (point)))) - (or (null end) - (> end point)))) - (defun sgml-get-context (&optional full) "Determine the context of the current position. If FULL is `empty', return even if the context is empty (i.e. @@ -1047,10 +1041,6 @@ (cond - ;; inside a tag ... - ((sgml-inside-tag-p tag-info here) - (push tag-info context)) - ;; start-tag ((eq (sgml-tag-type tag-info) 'open) (cond @@ -1095,35 +1085,23 @@ ;; Editing shortcuts -(defun sgml-insert-end-tag () - "Insert an end-tag for the current element." +(defun sgml-close-tag () + "Insert an close-tag for the current element." (interactive) - (let* ((context (save-excursion (sgml-get-context))) - (tag-info (car (last context))) - (type (and tag-info (sgml-tag-type tag-info)))) - - (cond - - ((null context) - (error "Nothing to close")) - - ;; inside a tag - ((sgml-inside-tag-p tag-info) - (insert (cond - ((eq type 'empty) " />") - ((eq type 'comment) " -->") - ((eq type 'cdata) "]]>") - ((eq type 'jsp) "%>") - ((eq type 'pi) "?>") - (t ">")))) - - ;; inside an element - ((eq type 'open) - (insert "</" (sgml-tag-name tag-info) ">") - (indent-according-to-mode)) - - (t - (error "Nothing to close"))))) + (case (car (sgml-lexical-context)) + (comment (insert " -->")) + (cdata (insert "]]>")) + (pi (insert " ?>")) + (jsp (insert " %>")) + (tag (insert " />")) + (text + (let ((context (save-excursion (sgml-get-context)))) + (if context + (progn + (insert "</" (sgml-tag-name (car (last context))) ">") + (indent-according-to-mode))))) + (otherwise + (error "Nothing to close")))) (defun sgml-empty-tag-p (tag-name) "Return non-nil if TAG-NAME is an implicitly empty tag."