summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-08-02 17:28:37 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-08-02 17:28:37 -0400
commit3f9bd117b37c9feb9f37a6e9ac84bbb4697f86d3 (patch)
treedccc75e711b9c9a05ea3566c3a7af5be139a2016
parentb219af5f765fbc789a7f54f50862e6730ae141fd (diff)
Improve detection of XML in urweb-mode; small tutorial improvement
-rw-r--r--doc/intro.ur12
-rw-r--r--src/elisp/urweb-mode.el33
2 files changed, 17 insertions, 28 deletions
diff --git a/doc/intro.ur b/doc/intro.ur
index 02adfdd2..e3611567 100644
--- a/doc/intro.ur
+++ b/doc/intro.ur
@@ -259,20 +259,24 @@ signature STACK = sig
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 <b>functors</b>, which are functions from modules to modules. *)
diff --git a/src/elisp/urweb-mode.el b/src/elisp/urweb-mode.el
index c9fe5f19..c4cb3476 100644
--- a/src/elisp/urweb-mode.el
+++ b/src/elisp/urweb-mode.el
@@ -170,7 +170,7 @@ See doc for the variable `urweb-mode-info'."
(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 @@ See doc for the variable `urweb-mode-info'."
(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 "<xml>")
+ (if (> depth 0)
+ (decf depth)
+ (progn
+ (setq answer t)
+ (setq finished t))))
+ ((looking-at "</xml>")
+ (incf depth))))
answer)))
(defun amAttribute (face)