comparison src/elisp/urweb-mode.el @ 373:008afab3a5ce

Indenting simple DML properly
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Oct 2008 16:24:19 -0400
parents fe018cbdd41e
children 1099d083a702
comparison
equal deleted inserted replaced
372:fe018cbdd41e 373:008afab3a5ce
510 (search-backward "</" nil t) 510 (search-backward "</" nil t)
511 (urweb-tag-matcher) 511 (urweb-tag-matcher)
512 (beginning-of-line) 512 (beginning-of-line)
513 (current-indentation))) 513 (current-indentation)))
514 514
515 (defconst urweb-sql-main-starters
516 '("SELECT" "INSERT" "UPDATE" "DELETE"))
517
515 (defconst urweb-sql-starters 518 (defconst urweb-sql-starters
516 '("FROM" "WHERE" "GROUP" "ORDER" "HAVING" "LIMIT" "OFFSET")) 519 (append urweb-sql-main-starters
517 520 '("^\\s-+FROM" "WHERE" "GROUP" "ORDER" "HAVING" "LIMIT" "OFFSET"
521 "VALUES" "SET")))
522
523 (defconst urweb-sql-main-starters-re
524 (urweb-syms-re urweb-sql-main-starters))
518 (defconst urweb-sql-starters-re 525 (defconst urweb-sql-starters-re
519 (urweb-syms-re urweb-sql-starters)) 526 (urweb-syms-re urweb-sql-starters))
520 527
521 (defun urweb-calculate-indentation () 528 (defun urweb-calculate-indentation ()
522 (save-excursion 529 (save-excursion
573 (current-column)))) 580 (current-column))))
574 581
575 (and (looking-at urweb-sql-starters-re) 582 (and (looking-at urweb-sql-starters-re)
576 (save-excursion 583 (save-excursion
577 (and (re-search-backward urweb-sql-starters-re nil t) 584 (and (re-search-backward urweb-sql-starters-re nil t)
578 (current-indentation)))) 585 (if (looking-at urweb-sql-main-starters-re)
586 (current-column)
587 (current-indentation)))))
579 588
580 (and (setq data (assoc sym urweb-close-paren)) 589 (and (setq data (assoc sym urweb-close-paren))
581 (urweb-indent-relative sym data)) 590 (urweb-indent-relative sym data))
582 591
583 (and (member sym urweb-starters-syms) 592 (and (member sym urweb-starters-syms)