aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/xml-lite.el101
1 files changed, 5 insertions, 96 deletions
diff --git a/lisp/textmodes/xml-lite.el b/lisp/textmodes/xml-lite.el
index ccab39365f4..65394aea952 100644
--- a/lisp/textmodes/xml-lite.el
+++ b/lisp/textmodes/xml-lite.el
@@ -43,49 +43,6 @@
43(require 'sgml-mode) 43(require 'sgml-mode)
44 44
45 45
46;; Variables
47
48(defgroup xml-lite nil
49 "Customizable variables for XML-Lite mode."
50 :group 'languages
51 )
52
53(defcustom xml-lite-basic-offset 2
54 "*Specifies the basic indentation level for `xml-lite-indent-line'."
55 :type 'integer
56 :group 'xml-lite
57 )
58
59(defcustom xml-lite-electric-slash 'close
60 "*If non-nil, inserting a '/' after a '<' behaves electrically.
61If set to `indent', typing '</' just triggers reindentation.
62If set to `close', typing '</' inserts an end-tag for the
63enclosing XML element."
64 :type '(choice (const :tag "Indent" indent)
65
66 (const :tag "Close" close)
67 (const :tag "No" nil))
68
69 :group 'xml-lite
70 )
71
72(defcustom xml-lite-mode-line-string " XML"
73 "*String to display in the modeline when `xml-lite-mode' is active.
74Set this to nil if you don't want a modeline indicator for xml-lite-mode."
75 :type 'string
76 :group 'xml-lite)
77
78(defcustom xml-lite-mode-hook nil
79 "*Hook called by `xml-lite-mode'."
80 :type 'hook
81 :group 'xml-lite)
82
83;;;###autoload
84(defvar xml-lite-mode nil
85 "Non-nil if `xml-lite-mode' is enabled.")
86(make-variable-buffer-local 'xml-lite-mode)
87
88
89;; Syntax analysis 46;; Syntax analysis
90 47
91(defsubst xml-lite-at-indentation-p () 48(defsubst xml-lite-at-indentation-p ()
@@ -94,15 +51,6 @@ Set this to nil if you don't want a modeline indicator for xml-lite-mode."
94 (skip-chars-backward " \t") 51 (skip-chars-backward " \t")
95 (bolp))) 52 (bolp)))
96 53
97(defun xml-lite-in-string-p (&optional limit)
98 "Determine whether point is inside a string. If it is, return the
99position of the character starting the string, else return nil.
100
101Parse begins from LIMIT, which defaults to the preceding occurence of a tag
102at the beginning of a line."
103 (let ((context (sgml-lexical-context limit)))
104 (if (eq (car context) 'string) (cdr context))))
105
106 54
107;; Parsing 55;; Parsing
108(defstruct (xml-lite-tag 56(defstruct (xml-lite-tag
@@ -222,7 +170,8 @@ immediately enclosing the current position."
222 ;; enclosing start-tags we'll have to ignore. 170 ;; enclosing start-tags we'll have to ignore.
223 (skip-chars-backward " \t\n") ; Make sure we're not at indentation. 171 (skip-chars-backward " \t\n") ; Make sure we're not at indentation.
224 (while 172 (while
225 (and (or ignore (not (if full (eq full 'empty) context)) 173 (and (or ignore
174 (not (if full (eq full 'empty) context))
226 (not (xml-lite-at-indentation-p)) 175 (not (xml-lite-at-indentation-p))
227 (and (not sgml-xml-mode) context 176 (and (not sgml-xml-mode) context
228 (/= (point) (xml-lite-tag-start (car context))) 177 (/= (point) (xml-lite-tag-start (car context)))
@@ -233,9 +182,9 @@ immediately enclosing the current position."
233 ;; This tag may enclose things we thought were tags. If so, 182 ;; This tag may enclose things we thought were tags. If so,
234 ;; discard them. 183 ;; discard them.
235 (while (and context 184 (while (and context
236 (> (xml-lite-tag-end tag-info) 185 (> (xml-lite-tag-end tag-info)
237 (xml-lite-tag-end (car context)))) 186 (xml-lite-tag-end (car context))))
238 (setq context (cdr context))) 187 (setq context (cdr context)))
239 188
240 (cond 189 (cond
241 190
@@ -289,9 +238,6 @@ If FULL is non-nil, parse back to the beginning of the buffer."
289 (pp (save-excursion (xml-lite-get-context full))))) 238 (pp (save-excursion (xml-lite-get-context full)))))
290 239
291 240
292;; Indenting
293
294
295;; Editing shortcuts 241;; Editing shortcuts
296 242
297(defun xml-lite-insert-end-tag () 243(defun xml-lite-insert-end-tag ()
@@ -340,43 +286,6 @@ Behaves electrically if `xml-lite-electric-slash' is non-nil."
340 (t 286 (t
341 (insert-char ?/ arg)))) 287 (insert-char ?/ arg))))
342 288
343
344;; Keymap
345
346(defvar xml-lite-mode-map
347 (let ((map (make-sparse-keymap)))
348 (define-key map "\C-c/" 'xml-lite-insert-end-tag)
349 (define-key map "\C-c\C-s" 'xml-lite-show-context)
350 (define-key map "/" 'xml-lite-slash)
351 map)
352 "Key bindings for `xml-lite-mode'.")
353
354
355;; Minor mode
356
357;;;###autoload
358(define-minor-mode xml-lite-mode
359 "Toggle `xml-lite-mode'.
360With ARG, enable xml-lite-mode if and only if ARG is positive.
361
362xml-lite-mode provides indentation for XML tags. The value of
363`xml-lite-basic-offset' determines the amount of indentation.
364
365Key bindings:
366\\{xml-lite-mode-map}"
367 nil ; initial value
368 " XML" ; mode indicator
369 'xml-lite-mode-map ; keymap
370 (if xml-lite-mode
371 (progn
372 (if (eq major-mode 'fundamental-mode) (sgml-mode))
373 (set (make-local-variable 'sgml-xml-mode) t)
374 (set (make-local-variable 'xml-lite-orig-indent-line-function)
375 indent-line-function)
376 (set (make-local-variable 'indent-line-function) 'sgml-indent-line))
377 (kill-local-variable 'sgml-xml-mode)
378 (setq indent-line-function xml-lite-orig-indent-line-function)))
379
380(provide 'xml-lite) 289(provide 'xml-lite)
381 290
382;;; xml-lite.el ends here 291;;; xml-lite.el ends here