Function: sqlind-maybe-declare-statement
sqlind-maybe-declare-statement is a natively compiled function defined
in sql-indent.el.
Signature
(sqlind-maybe-declare-statement)
Documentation
If (point) is on a DECLARE statement, report its syntax.
Only keywords in program code are matched, not the ones inside expressions, also we don't match DECLARE directives here.
See also sqlind-beginning-of-block
Source Code
;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-maybe-declare-statement ()
"If (point) is on a DECLARE statement, report its syntax.
Only keywords in program code are matched, not the ones inside
expressions, also we don't match DECLARE directives here.
See also `sqlind-beginning-of-block'"
(when (looking-at "declare")
;; In Postgres, a DECLARE statement can be a block, or define a cursor
;; (see pr67.sql, pr92.sql for examples). It is somewhat tricky to
;; determine which is which, so we use the heuristic that a declare
;; statement immediately following a $$ is a block, otherwise it is not.
(when (or (not (eq sql-product 'postgres))
(save-excursion
(sqlind-backward-syntactic-ws)
(skip-syntax-backward "_w") ; note that the $$ is symbol constituent!
(looking-at "\\(\\$\\$\\)\\|begin\\|then\\|else\\|\\(<<[a-z0-9_]+>>\\)")))
(throw 'finished
(if (null sqlind-end-stmt-stack)
'declare-statement
(list 'syntax-error "nested declare block" (point) (point)))))))