aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-03-27 18:07:04 +0000
committerStefan Monnier2002-03-27 18:07:04 +0000
commit3521e4b3ff1d1c03468c13a1777fa349e38df173 (patch)
tree2a56e42c39f8406689be2f66382d5af7348b2337
parentc6094cae44552562a174bd630f029f24acf3178c (diff)
downloademacs-3521e4b3ff1d1c03468c13a1777fa349e38df173.tar.gz
emacs-3521e4b3ff1d1c03468c13a1777fa349e38df173.zip
Don't require `custom'.
(xml-lite-parse-tag-name): Properly treat non-ASCII chars. (xml-lite-parse-tag-backward): Obey sgml-empty-tags. (xml-lite-get-context): Drop nested tags not just for comments. (xml-lite-indent-line): Be more careful about moving point. (xml-lite-insert-end-tag, xml-lite-slash): Use indent-according-to-mode instead of xml-lite-indent-line. (xml-lite-mode): Make xml-lite-orig-indent-line-function buffer-local. Set sgml-xml-mode. Don't call force-mode-line-update. (xml-lite-mode-map): Don't bind TAB.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/textmodes/xml-lite.el83
2 files changed, 47 insertions, 49 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1de63915ff4..93ae41fec99 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12002-03-27 Stefan Monnier <monnier@cs.yale.edu>
2
3 * textmodes/xml-lite.el: Don't require `custom'.
4 (xml-lite-parse-tag-name): Properly treat non-ASCII chars.
5 (xml-lite-parse-tag-backward): Obey sgml-empty-tags.
6 (xml-lite-get-context): Drop nested tags not just for comments.
7 (xml-lite-indent-line): Be more careful about moving point.
8 (xml-lite-insert-end-tag, xml-lite-slash):
9 Use indent-according-to-mode instead of xml-lite-indent-line.
10 (xml-lite-mode): Make xml-lite-orig-indent-line-function buffer-local.
11 Set sgml-xml-mode. Don't call force-mode-line-update.
12 (xml-lite-mode-map): Don't bind TAB.
13
12002-03-27 Zoltan Kemenczy <zoltan@ieee.org> 142002-03-27 Zoltan Kemenczy <zoltan@ieee.org>
2 15
3 * gud.el (gud-jdb-sourcepath): New variable, saves jdb -sourcepath 16 * gud.el (gud-jdb-sourcepath): New variable, saves jdb -sourcepath
diff --git a/lisp/textmodes/xml-lite.el b/lisp/textmodes/xml-lite.el
index 3b777479277..0318e0b339e 100644
--- a/lisp/textmodes/xml-lite.el
+++ b/lisp/textmodes/xml-lite.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Mike Williams <mdub@bigfoot.com> 5;; Author: Mike Williams <mdub@bigfoot.com>
6;; Created: February 2001 6;; Created: February 2001
7;; Version: $Revision: 1.28 $ 7;; Version: $Revision: 1.2 $
8;; Keywords: xml 8;; Keywords: xml
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -47,7 +47,6 @@
47 47
48(eval-when-compile (require 'cl)) 48(eval-when-compile (require 'cl))
49(require 'sgml-mode) 49(require 'sgml-mode)
50(require 'custom)
51 50
52 51
53;; Variables 52;; Variables
@@ -127,9 +126,8 @@ Set this to nil if you don't want a modeline indicator for xml-lite-mode."
127 126
128(defsubst xml-lite-parse-tag-name () 127(defsubst xml-lite-parse-tag-name ()
129 "Skip past a tag-name, and return the name." 128 "Skip past a tag-name, and return the name."
130 (let ((here (point))) 129 (buffer-substring-no-properties
131 (if (> (skip-chars-forward "-._:A-Za-z0-9") 0) 130 (point) (progn (skip-syntax-forward "w_") (point))))
132 (buffer-substring-no-properties here (point)))))
133 131
134(defsubst xml-lite-looking-back-at (s) 132(defsubst xml-lite-looking-back-at (s)
135 (let ((limit (max (- (point) (length s)) (point-min)))) 133 (let ((limit (max (- (point) (length s)) (point-min))))
@@ -206,7 +204,9 @@ Set this to nil if you don't want a modeline indicator for xml-lite-mode."
206 name (xml-lite-parse-tag-name) 204 name (xml-lite-parse-tag-name)
207 name-end (point)) 205 name-end (point))
208 ;; check whether it's an empty tag 206 ;; check whether it's an empty tag
209 (if (and tag-end (eq ?/ (char-before (- tag-end 1)))) 207 (if (or (and tag-end (eq ?/ (char-before (- tag-end 1))))
208 (and (not sgml-xml-mode)
209 (member-ignore-case name sgml-empty-tags)))
210 (setq tag-type 'empty)))) 210 (setq tag-type 'empty))))
211 211
212 (cond 212 (cond
@@ -243,6 +243,13 @@ immediately enclosing the current position."
243 (not (xml-lite-at-indentation-p))) 243 (not (xml-lite-at-indentation-p)))
244 (setq tag-info (xml-lite-parse-tag-backward))) 244 (setq tag-info (xml-lite-parse-tag-backward)))
245 245
246 ;; This tag may enclose things we thought were tags. If so,
247 ;; discard them.
248 (while (and context
249 (> (xml-lite-tag-end tag-info)
250 (xml-lite-tag-end (car context))))
251 (setq context (cdr context)))
252
246 (cond 253 (cond
247 254
248 ;; inside a tag ... 255 ;; inside a tag ...
@@ -253,20 +260,13 @@ immediately enclosing the current position."
253 ((eq (xml-lite-tag-type tag-info) 'open) 260 ((eq (xml-lite-tag-type tag-info) 'open)
254 (setq ignore-depth (1- ignore-depth)) 261 (setq ignore-depth (1- ignore-depth))
255 (when (= ignore-depth -1) 262 (when (= ignore-depth -1)
256 (setq context (cons tag-info context)) 263 (push tag-info context)
257 (setq ignore-depth 0))) 264 (setq ignore-depth 0)))
258 265
259 ;; end-tag 266 ;; end-tag
260 ((eq (xml-lite-tag-type tag-info) 'close) 267 ((eq (xml-lite-tag-type tag-info) 'close)
261 (setq ignore-depth (1+ ignore-depth))) 268 (setq ignore-depth (1+ ignore-depth)))
262 269
263 ((eq (xml-lite-tag-type tag-info) 'comment)
264 ;; this comment may enclose things we thought were tags
265 (while (and context
266 (> (xml-lite-tag-end tag-info)
267 (xml-lite-tag-end (car context))))
268 (setq context (cdr context))))
269
270 ))) 270 )))
271 271
272 ;; return context 272 ;; return context
@@ -342,30 +342,17 @@ If FULL is non-nil, parse back to the beginning of the buffer."
342(defun xml-lite-indent-line () 342(defun xml-lite-indent-line ()
343 "Indent the current line as XML." 343 "Indent the current line as XML."
344 (interactive) 344 (interactive)
345 (let ((origin-point (point)) 345 (let* ((savep (point))
346 bol-point indent-point 346 (indent-col
347 indent-col) 347 (save-excursion
348 348 (beginning-of-line)
349 ;; save beginning of line 349 (skip-chars-forward " \t")
350 (beginning-of-line) 350 (if (>= (point) savep) (setq savep nil))
351 (setq bol-point (point)) 351 ;; calculate basic indent
352 ;; save current indent 352 (xml-lite-calculate-indent))))
353 (skip-chars-forward " \t") 353 (if savep
354 (setq indent-point (point)) 354 (save-excursion (indent-line-to indent-col))
355 355 (indent-line-to indent-col))))
356 ;; calculate basic indent
357 (setq indent-col (xml-lite-calculate-indent))
358
359 (unless (eq (current-column) indent-col)
360 ;; re-indent, adjusting origin point for indentation change
361 (delete-region bol-point (point))
362 (indent-to indent-col)
363 (setq origin-point (+ origin-point (- (point) indent-point))))
364
365 (if (> origin-point (point))
366 (goto-char origin-point))
367
368 ))
369 356
370 357
371;; Editing shortcuts 358;; Editing shortcuts
@@ -395,7 +382,7 @@ If FULL is non-nil, parse back to the beginning of the buffer."
395 ;; inside an element 382 ;; inside an element
396 ((eq type 'open) 383 ((eq type 'open)
397 (insert "</" (xml-lite-tag-name tag-info) ">") 384 (insert "</" (xml-lite-tag-name tag-info) ">")
398 (xml-lite-indent-line)) 385 (indent-according-to-mode))
399 386
400 (t 387 (t
401 (error "Nothing to close"))))) 388 (error "Nothing to close")))))
@@ -409,7 +396,7 @@ Behaves electrically if `xml-lite-electric-slash' is non-nil."
409 (insert-char ?/ arg)) 396 (insert-char ?/ arg))
410 ((eq xml-lite-electric-slash 'indent) 397 ((eq xml-lite-electric-slash 'indent)
411 (insert-char ?/ 1) 398 (insert-char ?/ 1)
412 (xml-lite-indent-line)) 399 (indent-according-to-mode))
413 ((eq xml-lite-electric-slash 'close) 400 ((eq xml-lite-electric-slash 'close)
414 (delete-backward-char 1) 401 (delete-backward-char 1)
415 (xml-lite-insert-end-tag)) 402 (xml-lite-insert-end-tag))
@@ -421,7 +408,6 @@ Behaves electrically if `xml-lite-electric-slash' is non-nil."
421 408
422(defvar xml-lite-mode-map 409(defvar xml-lite-mode-map
423 (let ((map (make-sparse-keymap))) 410 (let ((map (make-sparse-keymap)))
424 (define-key map "\t" 'indent-for-tab-command)
425 (define-key map "\C-c/" 'xml-lite-insert-end-tag) 411 (define-key map "\C-c/" 'xml-lite-insert-end-tag)
426 (define-key map "\C-c\C-s" 'xml-lite-show-context) 412 (define-key map "\C-c\C-s" 'xml-lite-show-context)
427 (define-key map "/" 'xml-lite-slash) 413 (define-key map "/" 'xml-lite-slash)
@@ -446,14 +432,13 @@ Key bindings:
446 'xml-lite-mode-map ; keymap 432 'xml-lite-mode-map ; keymap
447 (if xml-lite-mode 433 (if xml-lite-mode
448 (progn 434 (progn
449 (if (eq major-mode 'fundamental-mode) 435 (if (eq major-mode 'fundamental-mode) (sgml-mode))
450 (sgml-mode)) 436 (set (make-local-variable 'sgml-xml-mode) t)
451 (make-local-variable 'indent-line-function) 437 (set (make-local-variable 'xml-lite-orig-indent-line-function)
452 (setq xml-lite-mode t 438 indent-line-function)
453 xml-lite-orig-indent-line-function indent-line-function 439 (set (make-local-variable 'indent-line-function) 'xml-lite-indent-line))
454 indent-line-function 'xml-lite-indent-line)) 440 (kill-local-variable 'sgml-xml-mode)
455 (setq indent-line-function xml-lite-orig-indent-line-function)) 441 (setq indent-line-function xml-lite-orig-indent-line-function)))
456 (force-mode-line-update))
457 442
458(provide 'xml-lite) 443(provide 'xml-lite)
459 444