branch: externals/sql-indent
commit 094cae35adf6f13e6adc5f2f8f38a7eb25efe604
Author: Alex Harsanyi <[email protected]>
Commit: Alex Harsanyi <[email protected]>

    update alignment rules to handle variable declarations with assignments
    
    This is further work on pull request #13
---
 sql-indent.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sql-indent.el b/sql-indent.el
index b20e155..2cd18cf 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1809,11 +1809,18 @@ determine how to indent each type of syntactic element."
      (repeat . t))
     ;; Line up the two sides of an assigment
     (sql-assign-lineup
-     (regexp . "\\(\\s-*\\):=\\(\\s-*\\)")
+     (regexp . "^\\s-*\\S-+\\(\\s-*\\):=\\(\\s-*\\)")
      (modes quote (sql-mode))
      (group 1 2)
      (case-fold . t)
      (repeat . t))
+    ;; lineup a variable declaration with an assignment
+    (sql-assign-lineup-2
+     (regexp . "^\\s-*\\S-+\\(\\s-+\\)\\S-+\\(\\s-*\\):=\\(\\s-*\\)")
+     (modes quote (sql-mode))
+     (group 1 2 3)
+     (case-fold . t)
+     (repeat . t))
     ;; Line up the two sides of in / out / in out parameter
     (sql-param-lineup-in-out
      (regexp . "\\(\\s-+\\)\\(in out\\|in\\|out\\)\\(\\s-+\\)")
@@ -1823,7 +1830,7 @@ determine how to indent each type of syntactic element."
      (repeat . t))
     ;; Line up the two sides of an equal sign in an update expression
     (sql-equals
-     (regexp . "\\(\\s-*[^:]\\)=\\([^>]\\s-*\\)")
+     (regexp . "[^:]\\(\\s-*\\)=\\(\\s-*\\)[^>]")
      (modes quote (sql-mode))
      (group 1 2)
      (case-fold . t)

Reply via email to