summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/elisp/urweb-mode.el11
-rw-r--r--tests/select.ur20
-rw-r--r--tests/sql_indent.ur5
3 files changed, 26 insertions, 10 deletions
diff --git a/src/elisp/urweb-mode.el b/src/elisp/urweb-mode.el
index 9bfa0c96..5e217e1a 100644
--- a/src/elisp/urweb-mode.el
+++ b/src/elisp/urweb-mode.el
@@ -512,6 +512,12 @@ If anyone has a good algorithm for this..."
(beginning-of-line)
(current-indentation)))
+(defconst urweb-sql-starters
+ '("FROM" "WHERE" "GROUP" "ORDER" "HAVING" "LIMIT" "OFFSET"))
+
+(defconst urweb-sql-starters-re
+ (urweb-syms-re urweb-sql-starters))
+
(defun urweb-calculate-indentation ()
(save-excursion
(beginning-of-line) (skip-chars-forward "\t ")
@@ -566,6 +572,11 @@ If anyone has a good algorithm for this..."
(urweb-indent-default 'noindent)
(current-column))))
+ (and (looking-at urweb-sql-starters-re)
+ (save-excursion
+ (and (re-search-backward urweb-sql-starters-re nil t)
+ (current-indentation))))
+
(and (setq data (assoc sym urweb-close-paren))
(urweb-indent-relative sym data))
diff --git a/tests/select.ur b/tests/select.ur
index d97e6a55..ff3908e9 100644
--- a/tests/select.ur
+++ b/tests/select.ur
@@ -1,13 +1,13 @@
-val handler = fn x => <html><body>
+val handler = fn x => <xml><body>
You entered: {cdata x.A}
-</body></html>
+</body></xml>
-val main = fn () => <html><body>
- <lform>
- <lselect{#A}>
- <loption value="A">A</loption>
- <loption value="B">B</loption>
- </lselect>
+val main = fn () => <xml><body>
+ <form>
+ <select{#A}>
+ <option value="A">A</option>
+ <option value="B">B</option>
+ </select>
<submit action={handler}/>
- </lform>
-</body></html>
+ </form>
+</body></xml>
diff --git a/tests/sql_indent.ur b/tests/sql_indent.ur
new file mode 100644
index 00000000..c4a46d71
--- /dev/null
+++ b/tests/sql_indent.ur
@@ -0,0 +1,5 @@
+table t1 : {A : int, B : string, C : float}
+
+val q1 = (SELECT *
+ FROM t1
+ WHERE A = 0)