changeset 368:b6be16792584

Removed handling of <,> as operators, for now
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Oct 2008 14:17:55 -0400
parents 28d3d7210687
children 226c977faa9c
files src/elisp/urweb-mode.el src/elisp/urweb-move.el tests/crud.ur
diffstat 3 files changed, 40 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/elisp/urweb-mode.el	Thu Oct 16 13:30:40 2008 -0400
+++ b/src/elisp/urweb-mode.el	Thu Oct 16 14:17:55 2008 -0400
@@ -500,22 +500,10 @@
 (defun urweb-tag-matching-indent ()
   "Seek back to a matching opener tag and get its line's indent"
   (save-excursion
-    (let ((depth 0)
-          (done nil))
-      (while (and (not done) (search-backward ">" nil t))
-        (if (save-excursion (backward-char 1) (looking-at "/"))
-            (when (not (search-backward "<" nil t))
-              (setq done t))
-          (if (search-backward "<" nil t)
-              (if (looking-at "</")
-                  (incf depth)
-                (if (= depth 0)
-                    (setq done t)
-                  (decf depth)))
-            (setq done t))))
-      (if (looking-at "<xml")
-          (+ (current-indentation) 2)
-        (current-indentation)))))
+    (urweb-tag-matcher)
+    (if (looking-at "<xml")
+        (+ (current-indentation) 2)
+      (current-indentation))))
 
 (defun urweb-calculate-indentation ()
   (save-excursion
--- a/src/elisp/urweb-move.el	Thu Oct 16 13:30:40 2008 -0400
+++ b/src/elisp/urweb-move.el	Thu Oct 16 14:17:55 2008 -0400
@@ -73,7 +73,7 @@
   (urweb-preproc-alist
    '((("UNION" "INTERSECT" "EXCEPT") . 0)
      (("AND" "OR") . 1)
-     ((">" ">=" "<>" "<" "<=" "=") . 4)
+     ((">=" "<>" "<=" "=") . 4)
      (("+" "-" "^") . 6)
      (("/" "*" "%") . 7)
      (("NOT") 9)))
@@ -223,6 +223,22 @@
 	   (t sym)))))))
     
 
+(defun urweb-tag-matcher ()
+  "Seek back to a matching opener tag"
+  (let ((depth 0)
+        (done nil))
+    (while (and (not done) (search-backward ">" nil t))
+      (if (save-excursion (backward-char 1) (looking-at "/"))
+          (when (not (search-backward "<" nil t))
+            (setq done t))
+        (if (search-backward "<" nil t)
+            (if (looking-at "</")
+                (incf depth)
+              (if (= depth 0)
+                  (setq done t)
+                (decf depth)))
+          (setq done t))))))
+
 (defun urweb-backward-sexp (prec)
   "Move one sexp backward if possible, or one char else.
 Returns t if the move indeed moved through one sexp and nil if not.
@@ -234,6 +250,12 @@
 	   (op-prec (urweb-op-prec op 'back))
 	   match)
       (cond
+        ((save-excursion (backward-char 5)
+                         (looking-at "</xml>"))
+         (backward-char 6)
+         (urweb-tag-matcher)
+         (backward-char 1)
+         (urweb-backward-sexp prec))
        ((not op)
 	(let ((point (point)))
 	  (ignore-errors (let ((forward-sexp-function nil)) (backward-sexp 1)))
@@ -256,6 +278,11 @@
        ;; this reproduces the usual backward-sexp, but it might be bogus
        ;; in this case since !@$% is a perfectly fine symbol
        (t t))))) ;(or (string-match "\\sw" op) (urweb-backward-sexp prec))
+;;   (when (save-excursion (backward-char 5) (looking-at "</xml>"))
+;;     (backward-char 5)
+;;     (urweb-tag-matcher)
+;;     (backward-char)
+;;     (urweb-backward-sexp prec)))
 
 (defun urweb-forward-sexp (prec)
   "Moves one sexp forward if possible, or one char else.
@@ -307,6 +334,7 @@
 	   (goto-char point)
 	   (error "Containing expression ends prematurely")))))))
 
+
 (defun urweb-user-forward-sexp (&optional count)
   "Like `forward-sexp' but tailored to the Ur/Web syntax."
   (interactive "p")
@@ -323,7 +351,7 @@
 ;;(defun urweb-forward-thing ()
 ;;  (if (= ?w (char-syntax (char-after))) (forward-word 1) (forward-char 1)))
 
-(defun urweb-backward-arg () (urweb-backward-sexp 1000))
+(defun urweb-backward-arg () (interactive) (urweb-backward-sexp 1000))
 (defun urweb-forward-arg () (urweb-forward-sexp 1000))
 
 
--- a/tests/crud.ur	Thu Oct 16 13:30:40 2008 -0400
+++ b/tests/crud.ur	Thu Oct 16 14:17:55 2008 -0400
@@ -12,10 +12,10 @@
             name : colMeta (t, string) =
     {Nam = name,
      Show = txt _,
-     Widget = fn nm :: Name => <xml><textbox{nm}/></xml>,
+     Widget = fn nm :: Name => (<xml><textbox{nm}/></xml>),
      WidgetPopulated = fn (nm :: Name) n =>
-       <xml><textbox{nm} value={show _ n}/></xml>,
-     Parse = readError _,
+                          (<xml><textbox{nm} value={show _ n}/></xml>),
+     Parse = readError _,e
      Inject = _}
 
 val int = default _ _ _
@@ -24,9 +24,9 @@
 
 fun bool name = {Nam = name,
                  Show = txt _,
-                 Widget = fn nm :: Name => <xml><checkbox{nm}/></xml>,
+                 Widget = fn nm :: Name => (<xml><checkbox{nm}/></xml>),
                  WidgetPopulated = fn (nm :: Name) b =>
-                   <xml><checkbox{nm} checked={b}/></xml>,
+                                      (<xml><checkbox{nm} checked={b}/></xml>),
                  Parse = fn x => x,
                  Inject = _}
 
@@ -96,7 +96,7 @@
 fun delete (id : int) =
     () <- dml (DELETE FROM tab WHERE Id = {id});
     return <xml><body>
-        The deed is done.
+      The deed is done.
     </body></xml>
 
 fun confirm (id : int) = return <xml><body>