emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/sgml-mode.el


From: Mike Williams
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/sgml-mode.el
Date: Tue, 02 Apr 2002 06:26:12 -0500

Index: emacs/lisp/textmodes/sgml-mode.el
diff -c emacs/lisp/textmodes/sgml-mode.el:1.73 
emacs/lisp/textmodes/sgml-mode.el:1.74
*** emacs/lisp/textmodes/sgml-mode.el:1.73      Mon Apr  1 18:32:15 2002
--- emacs/lisp/textmodes/sgml-mode.el   Tue Apr  2 06:26:12 2002
***************
*** 99,104 ****
--- 99,105 ----
      (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,467 ****
      (indent-according-to-mode))
     ((eq sgml-quick-keys 'close)
      (delete-backward-char 1)
!     (sgml-insert-end-tag))
     (t
      (sgml-slash-matching arg))))
  
--- 462,468 ----
      (indent-according-to-mode))
     ((eq sgml-quick-keys 'close)
      (delete-backward-char 1)
!     (sgml-close-tag))
     (t
      (sgml-slash-matching arg))))
  
***************
*** 993,1000 ****
           (forward-char 1)
           (setq tag-type 'close
                 name (sgml-parse-tag-name)))
!         ((?% ?#)                        ; JSP tags etc
!          (setq tag-type 'unknown))
          (t                              ; open or empty tag
           (setq tag-type 'open
                 name (sgml-parse-tag-name))
--- 994,1001 ----
           (forward-char 1)
           (setq tag-type 'close
                 name (sgml-parse-tag-name)))
!         (?%                             ; JSP tags
!          (setq tag-type 'jsp))
          (t                              ; open or empty tag
           (setq tag-type 'open
                 name (sgml-parse-tag-name))
***************
*** 1004,1016 ****
      (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.
--- 1005,1010 ----
***************
*** 1047,1056 ****
             
        (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
--- 1041,1046 ----
***************
*** 1095,1129 ****
  
  ;; Editing shortcuts
  
! (defun sgml-insert-end-tag ()
!   "Insert an end-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")))))
  
  (defun sgml-empty-tag-p (tag-name)
    "Return non-nil if TAG-NAME is an implicitly empty tag."
--- 1085,1107 ----
  
  ;; Editing shortcuts
  
! (defun sgml-close-tag ()
!   "Insert an close-tag for the current element."
    (interactive)
!   (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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]