summaryrefslogtreecommitdiff
path: root/src/elisp/urweb-mode.el
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-16 17:31:24 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-16 17:31:24 -0400
commit85eef6345dc591887e783b73b6f5c337ab5703c3 (patch)
treef6a6e1280ea96de0684ecb657af833055fe635d8 /src/elisp/urweb-mode.el
parentac3729041810d3277c5e3ad68b93f1208d3cd602 (diff)
Fixing overzealous SQL paren-nester
Diffstat (limited to 'src/elisp/urweb-mode.el')
-rw-r--r--src/elisp/urweb-mode.el30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/elisp/urweb-mode.el b/src/elisp/urweb-mode.el
index f0696ee4..73b67a17 100644
--- a/src/elisp/urweb-mode.el
+++ b/src/elisp/urweb-mode.el
@@ -535,19 +535,23 @@ If anyone has a good algorithm for this..."
(defun urweb-in-sql ()
"Check if the point is in a block of SQL syntax."
(save-excursion
- (let ((depth 0)
- done)
- (while (and (not done)
- (re-search-backward "[()]" nil t))
- (cond
- ((looking-at ")")
- (decf depth))
- ((looking-at "(")
- (if (looking-at urweb-sql-main-starters-paren-re)
- (setq done t)
- (incf depth)))))
- (and (>= depth 0)
- (looking-at urweb-sql-main-starters-paren-re)))))
+ (let ((start-pos (point))
+ (depth 0)
+ done
+ (good t))
+ (when (re-search-backward urweb-sql-main-starters-paren-re nil t)
+ (forward-char)
+ (while (and (not done) (re-search-forward "[()]" start-pos t))
+ (save-excursion
+ (backward-char)
+ (cond
+ ((looking-at ")")
+ (cond
+ ((= depth 0) (setq done t) (setq good nil))
+ (t (decf depth))))
+ ((looking-at "(")
+ (incf depth)))))
+ good))))
(defun urweb-sql-depth ()
"Check if the point is in a block of SQL syntax.