branch: externals/sql-indent
commit 2d57588cf67c3833bf143eea34c30edf6e58f1d9
Author: Alex Harsanyi <[email protected]>
Commit: Alex Harsanyi <[email protected]>
sqlind-beginning-of-statement-1 -- don't look inside comments, fixes #15
---
sql-indent.el | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/sql-indent.el b/sql-indent.el
index d8b82df..65bcef4 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -237,24 +237,25 @@ But don't go before LIMIT."
(when (re-search-backward
";\\|\\b\\(begin\\|loop\\|if\\|then\\|else\\|elsif\\)\\b\\|)"
limit 'noerror)
- (let ((candidate-pos (match-end 0)))
- (cond ((looking-at ")")
- ;; Skip parenthesis expressions, we don't want to find one
- ;; of the keywords inside one of them and think this is a
- ;; statement start.
- (progn (forward-char 1) (forward-sexp -1)))
- ((looking-at "\\b\\(then\\|else\\)\\b")
- ;; then and else start statements when they are inside
- ;; blocks, not expressions.
- (sqlind-backward-syntactic-ws)
- (when (looking-at ";")
- ;; Statement begins after the keyword
- (throw 'done candidate-pos)))
- ((looking-at "\\b\\(if\\|elsif\\)\\b")
- ;; statement begins at the start of the keyword
- (throw 'done (point)))
- ((not (sqlind-in-comment-or-string (point)))
- (throw 'done candidate-pos)))))))))
+ (unless (sqlind-in-comment-or-string (point))
+ (let ((candidate-pos (match-end 0)))
+ (cond ((looking-at ")")
+ ;; Skip parenthesis expressions, we don't want to find one
+ ;; of the keywords inside one of them and think this is a
+ ;; statement start.
+ (progn (forward-char 1) (forward-sexp -1)))
+ ((looking-at "\\b\\(then\\|else\\)\\b")
+ ;; then and else start statements when they are inside
+ ;; blocks, not expressions.
+ (sqlind-backward-syntactic-ws)
+ (when (looking-at ";")
+ ;; Statement begins after the keyword
+ (throw 'done candidate-pos)))
+ ((looking-at "\\b\\(if\\|elsif\\)\\b")
+ ;; statement begins at the start of the keyword
+ (throw 'done (point)))
+ ((not (sqlind-in-comment-or-string (point)))
+ (throw 'done candidate-pos))))))))))
(defun sqlind-beginning-of-statement ()
"Move point to the beginning of the current statement."