# HG changeset patch # User Adam Chlipala # Date 1224188659 14400 # Node ID 008afab3a5ce31f4397f2611902ebd1fe06edbd7 # Parent fe018cbdd41e22eab93e2e6e981eaf6d47011e88 Indenting simple DML properly diff -r fe018cbdd41e -r 008afab3a5ce src/elisp/urweb-mode.el --- a/src/elisp/urweb-mode.el Thu Oct 16 16:15:17 2008 -0400 +++ b/src/elisp/urweb-mode.el Thu Oct 16 16:24:19 2008 -0400 @@ -512,9 +512,16 @@ (beginning-of-line) (current-indentation))) +(defconst urweb-sql-main-starters + '("SELECT" "INSERT" "UPDATE" "DELETE")) + (defconst urweb-sql-starters - '("FROM" "WHERE" "GROUP" "ORDER" "HAVING" "LIMIT" "OFFSET")) + (append urweb-sql-main-starters + '("^\\s-+FROM" "WHERE" "GROUP" "ORDER" "HAVING" "LIMIT" "OFFSET" + "VALUES" "SET"))) +(defconst urweb-sql-main-starters-re + (urweb-syms-re urweb-sql-main-starters)) (defconst urweb-sql-starters-re (urweb-syms-re urweb-sql-starters)) @@ -575,7 +582,9 @@ (and (looking-at urweb-sql-starters-re) (save-excursion (and (re-search-backward urweb-sql-starters-re nil t) - (current-indentation)))) + (if (looking-at urweb-sql-main-starters-re) + (current-column) + (current-indentation))))) (and (setq data (assoc sym urweb-close-paren)) (urweb-indent-relative sym data)) diff -r fe018cbdd41e -r 008afab3a5ce tests/sql_indent.ur --- a/tests/sql_indent.ur Thu Oct 16 16:15:17 2008 -0400 +++ b/tests/sql_indent.ur Thu Oct 16 16:24:19 2008 -0400 @@ -3,3 +3,12 @@ val q1 = (SELECT * FROM t1 WHERE A = 0) + +val a1 = (INSERT INTO t1 + VALUES (0, "1", 2.0)) + +val a2 = (UPDATE t1 + SET A = 3, B = "4", C = 5.0) + +val a3 = (DELETE FROM t1 + WHERE B <> "good")