# HG changeset patch # User Adam Chlipala # Date 1224188117 14400 # Node ID fe018cbdd41e22eab93e2e6e981eaf6d47011e88 # Parent 782ef3ad8c28ab728bea40d513292cdfbc2d7a57 Indenting SELECT sub-clauses properly diff -r 782ef3ad8c28 -r fe018cbdd41e src/elisp/urweb-mode.el --- a/src/elisp/urweb-mode.el Thu Oct 16 16:00:58 2008 -0400 +++ b/src/elisp/urweb-mode.el Thu Oct 16 16:15:17 2008 -0400 @@ -512,6 +512,12 @@ (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 @@ (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 -r 782ef3ad8c28 -r fe018cbdd41e tests/select.ur --- a/tests/select.ur Thu Oct 16 16:00:58 2008 -0400 +++ b/tests/select.ur Thu Oct 16 16:15:17 2008 -0400 @@ -1,13 +1,13 @@ -val handler = fn x => +val handler = fn x => You entered: {cdata x.A} - + -val main = fn () => - - - A - B - +val main = fn () => +
+ + + + - - + +
diff -r 782ef3ad8c28 -r fe018cbdd41e tests/sql_indent.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sql_indent.ur Thu Oct 16 16:15:17 2008 -0400 @@ -0,0 +1,5 @@ +table t1 : {A : int, B : string, C : float} + +val q1 = (SELECT * + FROM t1 + WHERE A = 0)