# HG changeset patch # User Adam Chlipala # Date 1312320517 14400 # Node ID a479947efbcd12d73f90ba968360cbee03923b93 # Parent a71223513c77d59de09d7fccae7ee4008d5bfe38 Improve detection of XML in urweb-mode; small tutorial improvement diff -r a71223513c77 -r a479947efbcd doc/intro.ur --- a/doc/intro.ur Tue Aug 02 17:04:14 2011 -0400 +++ b/doc/intro.ur Tue Aug 02 17:28:37 2011 -0400 @@ -259,20 +259,24 @@ con t :: Type -> Type val empty : a ::: Type -> t a val push : a ::: Type -> t a -> a -> t a - val pop : a ::: Type -> t a -> option a + val peek : a ::: Type -> t a -> option a + val pop : a ::: Type -> t a -> option (t a) end structure Stack : STACK = struct con t = list val empty [a] = [] fun push [a] (t : t a) (x : a) = x :: t + fun peek [a] (t : t a) = case t of + [] => None + | x :: _ => Some x fun pop [a] (t : t a) = case t of - [] => None - | x :: _ => Some x + [] => None + | _ :: t' => Some t' end (* begin eval *) -Stack.pop (Stack.push (Stack.push Stack.empty "A") "B") +Stack.peek (Stack.push (Stack.push Stack.empty "A") "B") (* end *) (* Ur also inherits the ML concept of functors, which are functions from modules to modules. *) diff -r a71223513c77 -r a479947efbcd src/elisp/urweb-mode.el --- a/src/elisp/urweb-mode.el Tue Aug 02 17:04:14 2011 -0400 +++ b/src/elisp/urweb-mode.el Tue Aug 02 17:28:37 2011 -0400 @@ -170,7 +170,7 @@ (finished nil) (answer nil) ) - (while (and (not finished) (re-search-backward "[<>{}]" nil t)) + (while (and (not finished) (re-search-backward "[<{}]" nil t)) (cond ((looking-at "{") (if (> depth 0) @@ -178,29 +178,14 @@ (setq finished t))) ((looking-at "}") (incf depth)) - ((save-excursion (backward-char 1) (or (looking-at "=>") - (looking-at "->") - (looking-at "<>"))) - nil) - ((or (looking-at "< ") (looking-at "<=")) - nil) - ((looking-at "<") - (setq finished t)) - ((save-excursion (backward-char 1) (looking-at " >")) - nil) - ((looking-at ">") - (cond - ((> depth 0) - (if (not (re-search-backward "<" nil t)) - (setq finished t))) - ((save-excursion (backward-char 1) (looking-at " ")) - (setq finished t)) - (t - (progn (backward-char 4) - (setq answer (not (or - (looking-at "/xml") - (looking-at "xml/")))) - (setq finished t))))))) + ((looking-at "") + (if (> depth 0) + (decf depth) + (progn + (setq answer t) + (setq finished t)))) + ((looking-at "") + (incf depth)))) answer))) (defun amAttribute (face)