[Top][All Lists]
[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 13:02:36 -0500 |
Index: emacs/lisp/textmodes/xml-lite.el
diff -c emacs/lisp/textmodes/xml-lite.el:1.2
emacs/lisp/textmodes/xml-lite.el:1.3
*** emacs/lisp/textmodes/xml-lite.el:1.2 Tue Mar 26 19:06:19 2002
--- emacs/lisp/textmodes/xml-lite.el Wed Mar 27 13:02:36 2002
***************
*** 4,10 ****
;; Author: Mike Williams <address@hidden>
;; Created: February 2001
! ;; Version: $Revision: 1.2 $
;; Keywords: xml
;; This file is part of GNU Emacs.
--- 4,10 ----
;; Author: Mike Williams <address@hidden>
;; Created: February 2001
! ;; Version: $Revision: 1.3 $
;; Keywords: xml
;; This file is part of GNU Emacs.
***************
*** 47,53 ****
(eval-when-compile (require 'cl))
(require 'sgml-mode)
- (require 'custom)
;; Variables
--- 47,52 ----
***************
*** 127,135 ****
(defsubst xml-lite-parse-tag-name ()
"Skip past a tag-name, and return the name."
! (let ((here (point)))
! (if (> (skip-chars-forward "-._:A-Za-z0-9") 0)
! (buffer-substring-no-properties here (point)))))
(defsubst xml-lite-looking-back-at (s)
(let ((limit (max (- (point) (length s)) (point-min))))
--- 126,133 ----
(defsubst xml-lite-parse-tag-name ()
"Skip past a tag-name, and return the name."
! (buffer-substring-no-properties
! (point) (progn (skip-syntax-forward "w_") (point))))
(defsubst xml-lite-looking-back-at (s)
(let ((limit (max (- (point) (length s)) (point-min))))
***************
*** 206,212 ****
name (xml-lite-parse-tag-name)
name-end (point))
;; check whether it's an empty tag
! (if (and tag-end (eq ?/ (char-before (- tag-end 1))))
(setq tag-type 'empty))))
(cond
--- 204,212 ----
name (xml-lite-parse-tag-name)
name-end (point))
;; check whether it's an empty tag
! (if (or (and tag-end (eq ?/ (char-before (- tag-end 1))))
! (and (not sgml-xml-mode)
! (member-ignore-case name sgml-empty-tags)))
(setq tag-type 'empty))))
(cond
***************
*** 243,248 ****
--- 243,255 ----
(not (xml-lite-at-indentation-p)))
(setq tag-info (xml-lite-parse-tag-backward)))
+ ;; This tag may enclose things we thought were tags. If so,
+ ;; discard them.
+ (while (and context
+ (> (xml-lite-tag-end tag-info)
+ (xml-lite-tag-end (car context))))
+ (setq context (cdr context)))
+
(cond
;; inside a tag ...
***************
*** 253,272 ****
((eq (xml-lite-tag-type tag-info) 'open)
(setq ignore-depth (1- ignore-depth))
(when (= ignore-depth -1)
! (setq context (cons tag-info context))
(setq ignore-depth 0)))
;; end-tag
((eq (xml-lite-tag-type tag-info) 'close)
(setq ignore-depth (1+ ignore-depth)))
- ((eq (xml-lite-tag-type tag-info) 'comment)
- ;; this comment may enclose things we thought were tags
- (while (and context
- (> (xml-lite-tag-end tag-info)
- (xml-lite-tag-end (car context))))
- (setq context (cdr context))))
-
)))
;; return context
--- 260,272 ----
((eq (xml-lite-tag-type tag-info) 'open)
(setq ignore-depth (1- ignore-depth))
(when (= ignore-depth -1)
! (push tag-info context)
(setq ignore-depth 0)))
;; end-tag
((eq (xml-lite-tag-type tag-info) 'close)
(setq ignore-depth (1+ ignore-depth)))
)))
;; return context
***************
*** 342,371 ****
(defun xml-lite-indent-line ()
"Indent the current line as XML."
(interactive)
! (let ((origin-point (point))
! bol-point indent-point
! indent-col)
!
! ;; save beginning of line
! (beginning-of-line)
! (setq bol-point (point))
! ;; save current indent
! (skip-chars-forward " \t")
! (setq indent-point (point))
!
! ;; calculate basic indent
! (setq indent-col (xml-lite-calculate-indent))
!
! (unless (eq (current-column) indent-col)
! ;; re-indent, adjusting origin point for indentation change
! (delete-region bol-point (point))
! (indent-to indent-col)
! (setq origin-point (+ origin-point (- (point) indent-point))))
!
! (if (> origin-point (point))
! (goto-char origin-point))
!
! ))
;; Editing shortcuts
--- 342,358 ----
(defun xml-lite-indent-line ()
"Indent the current line as XML."
(interactive)
! (let* ((savep (point))
! (indent-col
! (save-excursion
! (beginning-of-line)
! (skip-chars-forward " \t")
! (if (>= (point) savep) (setq savep nil))
! ;; calculate basic indent
! (xml-lite-calculate-indent))))
! (if savep
! (save-excursion (indent-line-to indent-col))
! (indent-line-to indent-col))))
;; Editing shortcuts
***************
*** 395,401 ****
;; inside an element
((eq type 'open)
(insert "</" (xml-lite-tag-name tag-info) ">")
! (xml-lite-indent-line))
(t
(error "Nothing to close")))))
--- 382,388 ----
;; inside an element
((eq type 'open)
(insert "</" (xml-lite-tag-name tag-info) ">")
! (indent-according-to-mode))
(t
(error "Nothing to close")))))
***************
*** 409,415 ****
(insert-char ?/ arg))
((eq xml-lite-electric-slash 'indent)
(insert-char ?/ 1)
! (xml-lite-indent-line))
((eq xml-lite-electric-slash 'close)
(delete-backward-char 1)
(xml-lite-insert-end-tag))
--- 396,402 ----
(insert-char ?/ arg))
((eq xml-lite-electric-slash 'indent)
(insert-char ?/ 1)
! (indent-according-to-mode))
((eq xml-lite-electric-slash 'close)
(delete-backward-char 1)
(xml-lite-insert-end-tag))
***************
*** 421,427 ****
(defvar xml-lite-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map "\t" 'indent-for-tab-command)
(define-key map "\C-c/" 'xml-lite-insert-end-tag)
(define-key map "\C-c\C-s" 'xml-lite-show-context)
(define-key map "/" 'xml-lite-slash)
--- 408,413 ----
***************
*** 446,459 ****
'xml-lite-mode-map ; keymap
(if xml-lite-mode
(progn
! (if (eq major-mode 'fundamental-mode)
! (sgml-mode))
! (make-local-variable 'indent-line-function)
! (setq xml-lite-mode t
! xml-lite-orig-indent-line-function indent-line-function
! indent-line-function 'xml-lite-indent-line))
! (setq indent-line-function xml-lite-orig-indent-line-function))
! (force-mode-line-update))
(provide 'xml-lite)
--- 432,444 ----
'xml-lite-mode-map ; keymap
(if xml-lite-mode
(progn
! (if (eq major-mode 'fundamental-mode) (sgml-mode))
! (set (make-local-variable 'sgml-xml-mode) t)
! (set (make-local-variable 'xml-lite-orig-indent-line-function)
! indent-line-function)
! (set (make-local-variable 'indent-line-function) 'xml-lite-indent-line))
! (kill-local-variable 'sgml-xml-mode)
! (setq indent-line-function xml-lite-orig-indent-line-function)))
(provide 'xml-lite)
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/03
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/26
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/27
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/27
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/28
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/29
- [Emacs-diffs] Changes to emacs/lisp/textmodes/xml-lite.el, Stefan Monnier, 2002/03/29