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

    classify select columns start start with a comma as select-column
    
    This helps with indenting SQL statements that use a comma at the start of 
the
    column, like this:
    
            SELECT col1
                   ,col2
            FROM ...
    
    This is also consistent with how we classify select-table syntaxes
---
 sql-indent.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/sql-indent.el b/sql-indent.el
index f92b1a7..e0a9edf 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -703,13 +703,16 @@ See also `sqlind-beginning-of-block'"
              ((looking-at "select\\(\\s *\\_<\\(top\\s 
+[0-9]+\\|distinct\\|unique\\)\\_>\\)?")
               ;; we are in the column selection section.
               (goto-char pos)
-              (sqlind-backward-syntactic-ws)
-              (throw 'finished
-                (cons (if (or (eq (match-end 0) (1+ (point)))
-                              (looking-at ","))
-                          'select-column
-                          'select-column-continuation)
-                      match-pos)))
+               (if (looking-at ",")
+                   (throw 'finished (cons 'select-column match-pos))
+                 (progn
+                   (sqlind-backward-syntactic-ws)
+                   (throw 'finished
+                     (cons (if (or (eq (match-end 0) (1+ (point)))
+                                   (looking-at ","))
+                               'select-column
+                             'select-column-continuation)
+                           match-pos)))))
 
              ((looking-at "from")
               ;; FROM is only keyword if the previous char is NOT a

Reply via email to