Mercurial > urweb
comparison src/elisp/urweb-mode.el @ 375:d3de57ce4bca
Fixing overzealous SQL paren-nester
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 16 Oct 2008 17:31:24 -0400 |
parents | 1099d083a702 |
children | ef43ed6cd1de |
comparison
equal
deleted
inserted
replaced
374:1099d083a702 | 375:d3de57ce4bca |
---|---|
533 (concat "(" urweb-sql-main-starters-re)) | 533 (concat "(" urweb-sql-main-starters-re)) |
534 | 534 |
535 (defun urweb-in-sql () | 535 (defun urweb-in-sql () |
536 "Check if the point is in a block of SQL syntax." | 536 "Check if the point is in a block of SQL syntax." |
537 (save-excursion | 537 (save-excursion |
538 (let ((depth 0) | 538 (let ((start-pos (point)) |
539 done) | 539 (depth 0) |
540 (while (and (not done) | 540 done |
541 (re-search-backward "[()]" nil t)) | 541 (good t)) |
542 (cond | 542 (when (re-search-backward urweb-sql-main-starters-paren-re nil t) |
543 ((looking-at ")") | 543 (forward-char) |
544 (decf depth)) | 544 (while (and (not done) (re-search-forward "[()]" start-pos t)) |
545 ((looking-at "(") | 545 (save-excursion |
546 (if (looking-at urweb-sql-main-starters-paren-re) | 546 (backward-char) |
547 (setq done t) | 547 (cond |
548 (incf depth))))) | 548 ((looking-at ")") |
549 (and (>= depth 0) | 549 (cond |
550 (looking-at urweb-sql-main-starters-paren-re))))) | 550 ((= depth 0) (setq done t) (setq good nil)) |
551 (t (decf depth)))) | |
552 ((looking-at "(") | |
553 (incf depth))))) | |
554 good)))) | |
551 | 555 |
552 (defun urweb-sql-depth () | 556 (defun urweb-sql-depth () |
553 "Check if the point is in a block of SQL syntax. | 557 "Check if the point is in a block of SQL syntax. |
554 Returns the paren nesting depth if so, and nil otherwise." | 558 Returns the paren nesting depth if so, and nil otherwise." |
555 (save-excursion | 559 (save-excursion |