Mercurial > urweb
changeset 372:fe018cbdd41e
Indenting SELECT sub-clauses properly
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 16 Oct 2008 16:15:17 -0400 |
parents | 782ef3ad8c28 |
children | 008afab3a5ce |
files | src/elisp/urweb-mode.el tests/select.ur tests/sql_indent.ur |
diffstat | 3 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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 => <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>