diff options
author | Mike Williams <mdub@bigfoot.com> | 2002-04-02 11:26:12 +0000 |
---|---|---|
committer | Mike Williams <mdub@bigfoot.com> | 2002-04-02 11:26:12 +0000 |
commit | f6ab0573f9a497a7dad07a349da44750bb69d567 (patch) | |
tree | 05b65f26f1d626e38ebabfcd1d53c1ad070b5a88 /lisp/textmodes/sgml-mode.el | |
parent | 02dfca16b129fe6573b008cc33977ec370a66aeb (diff) | |
download | emacs-f6ab0573f9a497a7dad07a349da44750bb69d567.tar.gz |
(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.
Diffstat (limited to 'lisp/textmodes/sgml-mode.el')
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 8f3ba9c6a78..4b01d4d2917 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -99,6 +99,7 @@ This takes effect when first loading the `sgml-mode' library.") (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 @@ Behaves electrically if `sgml-quick-keys' is non-nil." (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 @@ Leave point at the beginning of the tag." (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 @@ Leave point at the beginning of the tag." (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 @@ immediately enclosing the current position." (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 @@ If FULL is non-nil, parse back to the beginning of the buffer." ;; 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." |