aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Williams2002-04-11 21:59:45 +0000
committerMike Williams2002-04-11 21:59:45 +0000
commit2871b07a8940301a85d266008daee5b8bf28198a (patch)
tree8baf18af088eaa7aca6d12c56cddde7564b3b1d1
parent851476d4ab677cf88859ea959a49e626a2e86192 (diff)
downloademacs-2871b07a8940301a85d266008daee5b8bf28198a.tar.gz
emacs-2871b07a8940301a85d266008daee5b8bf28198a.zip
(sgml-guess-indent): New function.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/textmodes/sgml-mode.el21
2 files changed, 22 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ff6ad3b4795..82eff1a7346 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12002-04-12 Mike Williams <mdub@bigfoot.com>
2
3 * textmodes/sgml-mode.el (sgml-guess-indent): New function.
4
12002-04-11 Pavel Jan,Bm(Bk <Pavel@Janik.cz> 52002-04-11 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
2 6
3 * menu-bar.el (menu-bar-adv-search-menu): Add incremental search. 7 * menu-bar.el (menu-bar-adv-search-menu): Add incremental search.
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 9df19cc1180..2a410554de6 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -889,7 +889,7 @@ If nil, start from a preceding tag at indentation."
889 (unless (search-forward "]]>" pos 'move) 889 (unless (search-forward "]]>" pos 'move)
890 (list 0 nil nil 'cdata nil nil nil nil cdata-start)))) 890 (list 0 nil nil 'cdata nil nil nil nil cdata-start))))
891 (t 891 (t
892 ;; We've reached a tag. Parse it. 892 ;; We've reached a tag. Parse it.
893 ;; FIXME: Handle net-enabling start-tags 893 ;; FIXME: Handle net-enabling start-tags
894 (parse-partial-sexp (point) pos 0)))))) 894 (parse-partial-sexp (point) pos 0))))))
895 (cond 895 (cond
@@ -1031,7 +1031,7 @@ immediately enclosing the current position."
1031 ;; enclosing start-tags we'll have to ignore. 1031 ;; enclosing start-tags we'll have to ignore.
1032 (skip-chars-backward " \t\n") ; Make sure we're not at indentation. 1032 (skip-chars-backward " \t\n") ; Make sure we're not at indentation.
1033 (while 1033 (while
1034 (and (or ignore 1034 (and (or ignore
1035 (not (if full (eq full 'empty) context)) 1035 (not (if full (eq full 'empty) context))
1036 (not (sgml-at-indentation-p)) 1036 (not (sgml-at-indentation-p))
1037 (and context 1037 (and context
@@ -1104,7 +1104,7 @@ If FULL is non-nil, parse back to the beginning of the buffer."
1104 (text 1104 (text
1105 (let ((context (save-excursion (sgml-get-context)))) 1105 (let ((context (save-excursion (sgml-get-context))))
1106 (if context 1106 (if context
1107 (progn 1107 (progn
1108 (insert "</" (sgml-tag-name (car (last context))) ">") 1108 (insert "</" (sgml-tag-name (car (last context))) ">")
1109 (indent-according-to-mode))))) 1109 (indent-according-to-mode)))))
1110 (otherwise 1110 (otherwise
@@ -1227,6 +1227,21 @@ If FULL is non-nil, parse back to the beginning of the buffer."
1227 (save-excursion (indent-line-to indent-col)) 1227 (save-excursion (indent-line-to indent-col))
1228 (indent-line-to indent-col)))) 1228 (indent-line-to indent-col))))
1229 1229
1230(defun sgml-guess-indent ()
1231 "Guess an appropriate value for `sgml-basic-offset'.
1232Base the guessed identation level on the first indented tag in the buffer.
1233Add this to `sgml-mode-hook' for convenience."
1234 (interactive)
1235 (save-excursion
1236 (goto-char (point-min))
1237 (if (re-search-forward "^\\([ \t]+\\)<" 100 'noerror)
1238 (progn
1239 (set (make-local-variable 'sgml-basic-offset)
1240 (length (match-string 1)))
1241 (message "Guessed sgml-basic-offset = %d"
1242 sgml-basic-offset)
1243 ))))
1244
1230(defun sgml-parse-dtd () 1245(defun sgml-parse-dtd ()
1231 "Simplistic parse of the current buffer as a DTD. 1246 "Simplistic parse of the current buffer as a DTD.
1232Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)." 1247Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)."