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/xml-lite.el


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el
Date: Wed, 27 Mar 2002 17:25:45 -0500

Index: emacs/lisp/textmodes/xml-lite.el
diff -c emacs/lisp/textmodes/xml-lite.el:1.3 
emacs/lisp/textmodes/xml-lite.el:1.4
*** emacs/lisp/textmodes/xml-lite.el:1.3        Wed Mar 27 13:02:36 2002
--- emacs/lisp/textmodes/xml-lite.el    Wed Mar 27 17:25:45 2002
***************
*** 1,10 ****
  ;;; xml-lite.el --- an indentation-engine for XML
  
! ;; Copyright (C) 2001   Mike Williams <address@hidden>
  
  ;; Author:     Mike Williams <address@hidden>
  ;; Created:    February 2001
- ;; Version:    $Revision: 1.3 $
  ;; Keywords:   xml
  
  ;; This file is part of GNU Emacs.
--- 1,9 ----
  ;;; xml-lite.el --- an indentation-engine for XML
  
! ;; Copyright (C) 2002  Free Software Foundation, Inc.
  
  ;; Author:     Mike Williams <address@hidden>
  ;; Created:    February 2001
  ;; Keywords:   xml
  
  ;; This file is part of GNU Emacs.
***************
*** 32,42 ****
  ;;
  ;; xml-lite is designed to be used in conjunction with the default GNU
  ;; Emacs sgml-mode, to provide a lightweight XML-editing environment.
- ;;
- ;; Updates will be made available at:
- ;;     http://www.bigfoot.com/~mdub/software/xml-lite.el
- ;;
- ;; Note: the font-lock support that was in this package has been removed.
  
  ;;; Thanks:
  ;;
--- 31,36 ----
***************
*** 56,69 ****
    :group 'languages
    )
  
! (defcustom xml-lite-indent-offset 4
!   "*Specifies the default indentation level for `xml-lite-indent-line'."
!   :type 'integer
!   :group 'xml-lite
!   )
! 
! (defcustom xml-lite-indent-comment-offset 5
!   "*Specifies the indentation level for XML comments."
    :type 'integer
    :group 'xml-lite
    )
--- 50,57 ----
    :group 'languages
    )
  
! (defcustom xml-lite-basic-offset 2
!   "*Specifies the basic indentation level for `xml-lite-indent-line'."
    :type 'integer
    :group 'xml-lite
    )
***************
*** 119,129 ****
  
  
  ;; Parsing
- 
  (defstruct (xml-lite-tag
              (:constructor xml-lite-make-tag (type start end name name-end)))
    type start end name name-end)
- 
  (defsubst xml-lite-parse-tag-name ()
    "Skip past a tag-name, and return the name."
    (buffer-substring-no-properties
--- 107,115 ----
***************
*** 133,139 ****
    (let ((limit (max (- (point) (length s)) (point-min))))
      (equal s (buffer-substring-no-properties limit (point)))))
  
! (defsubst xml-lite-looking-at (s)  
    (let ((limit (min (+ (point) (length s)))))
      (equal s (buffer-substring-no-properties (point) limit))))
  
--- 119,125 ----
    (let ((limit (max (- (point) (length s)) (point-min))))
      (equal s (buffer-substring-no-properties limit (point)))))
  
! (defsubst xml-lite-looking-at (s)
    (let ((limit (min (+ (point) (length s)))))
      (equal s (buffer-substring-no-properties (point) limit))))
  
***************
*** 254,260 ****
  
           ;; inside a tag ...
           ((xml-lite-inside-tag-p tag-info here)
!           (setq context (cons tag-info context)))
  
           ;; start-tag
           ((eq (xml-lite-tag-type tag-info) 'open)
--- 240,246 ----
  
           ;; inside a tag ...
           ((xml-lite-inside-tag-p tag-info here)
!           (push tag-info context))
  
           ;; start-tag
           ((eq (xml-lite-tag-type tag-info) 'open)
***************
*** 294,316 ****
        (cond
  
         ;; no context
!        ((null context)
!         0)
  
         ;; inside a comment
         ((eq 'comment (xml-lite-tag-type last-tag-info))
!         (goto-char (xml-lite-tag-start last-tag-info))
!         (+ (current-column) xml-lite-indent-comment-offset))
  
         ;; inside a tag
         ((xml-lite-inside-tag-p last-tag-info here)
          
!         (let ((in-string
                 (xml-lite-in-string-p (xml-lite-tag-start last-tag-info))))
            (cond
!            ;; inside a string
!            (in-string
!             (goto-char (nth 1 in-string))
              (1+ (current-column)))
             ;; if we have a tag-name, base indent on that
             ((and (xml-lite-tag-name-end last-tag-info)
--- 280,306 ----
        (cond
  
         ;; no context
!        ((null context) 0)
  
         ;; inside a comment
         ((eq 'comment (xml-lite-tag-type last-tag-info))
!         (let ((mark (looking-at "--")))
!           (goto-char (xml-lite-tag-start last-tag-info))
!         (forward-char 2)
!         (if mark (current-column)
!           (forward-char 2)
!           (+ (if (zerop (skip-chars-forward " \t")) 1 0)
!              (current-column)))))
  
         ;; inside a tag
         ((xml-lite-inside-tag-p last-tag-info here)
          
!         (let ((start-of-enclosing-string
                 (xml-lite-in-string-p (xml-lite-tag-start last-tag-info))))
            (cond
!            ;; inside an attribute value
!            (start-of-enclosing-string
!             (goto-char start-of-enclosing-string)
              (1+ (current-column)))
             ;; if we have a tag-name, base indent on that
             ((and (xml-lite-tag-name-end last-tag-info)
***************
*** 321,341 ****
             ;; otherwise, add indent-offset
             (t
              (goto-char (xml-lite-tag-start last-tag-info))
!             (+ (current-column) xml-lite-indent-offset)))))
  
         ;; inside an element
         (t
          ;; indent to start of tag
!         (let ((here (point))
!               indent-col)
            (goto-char (xml-lite-tag-start ref-tag-info))
!           (setq indent-col (current-column))
!           (goto-char here)
!           ;; add xml-lite-indent-offset, unless we're looking at the matching
!           ;; end-tag
!           (unless (and (eq (length context) 1) (looking-at "</"))
!             (setq indent-col (+ indent-col xml-lite-indent-offset)))
!           indent-col))
  
         ))))
  
--- 311,329 ----
             ;; otherwise, add indent-offset
             (t
              (goto-char (xml-lite-tag-start last-tag-info))
!             (+ (current-column) xml-lite-basic-offset)))))
  
         ;; inside an element
         (t
          ;; indent to start of tag
!         (let ((indent-offset xml-lite-basic-offset))
!           ;; add xml-lite-basic-offset, unless we're looking at the
!           ;; matching end-tag
!           (if (and (eq (length context) 1)
!                    (xml-lite-looking-at "</"))
!               (setq indent-offset 0))
            (goto-char (xml-lite-tag-start ref-tag-info))
!           (+ (current-column) indent-offset)))
  
         ))))
  
***************
*** 371,383 ****
  
       ;; inside a tag
       ((xml-lite-inside-tag-p tag-info)
!       (cond
!        ((eq type 'open)       (insert " />"))
!        ((eq type 'comment)    (insert " -->"))
!        ((eq type 'cdata)      (insert "]]>"))
!        ((eq type 'jsp)                (insert "%>"))
!        ((eq type 'pi)                 (insert "?>"))
!        (t                     (insert ">"))))
  
       ;; inside an element
       ((eq type 'open)
--- 359,371 ----
  
       ;; inside a tag
       ((xml-lite-inside-tag-p tag-info)
!       (insert (cond
!              ((eq type 'open)         " />")
!              ((eq type 'comment)      " -->")
!              ((eq type 'cdata)        "]]>")
!              ((eq type 'jsp)          "%>")
!              ((eq type 'pi)           "?>")
!              (t                       ">"))))
  
       ;; inside an element
       ((eq type 'open)
***************
*** 423,429 ****
  With ARG, enable xml-lite-mode if and only if ARG is positive.
  
  xml-lite-mode provides indentation for XML tags.  The value of
! `xml-lite-indent-offset' determines the amount of indentation.
  
  Key bindings:
  \\{xml-lite-mode-map}"
--- 411,417 ----
  With ARG, enable xml-lite-mode if and only if ARG is positive.
  
  xml-lite-mode provides indentation for XML tags.  The value of
! `xml-lite-basic-offset' determines the amount of indentation.
  
  Key bindings:
  \\{xml-lite-mode-map}"



reply via email to

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