Function: sqlind-beginning-of-block
sqlind-beginning-of-block is an interactive and natively compiled
function defined in sql-indent.el.
Signature
(sqlind-beginning-of-block &optional END-STATEMENT-STACK)
Documentation
Find the start of the current block and return its syntax.
END-STATEMENT-STACK contains a list of "end" syntaxes in reverse order (a stack) and is used to skip over nested blocks.
Key Bindings
sqlind-minor-mode-map C-M-<home> sqlind-minor-mode-map C-M-a sqlind-minor-mode-map ESC C-<home>
Source Code
;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-beginning-of-block (&optional end-statement-stack)
"Find the start of the current block and return its syntax.
END-STATEMENT-STACK contains a list of \"end\" syntaxes in
reverse order (a stack) and is used to skip over nested blocks."
(interactive)
;; This function works as follows: `sqlind-start-block-regexp` defines the
;; keywords where it stops to inspect the code. Each time it stops at one
;; of these keywords, it checks to see if the keyword is inside a comment or
;; string. If the keyworkd is not inside a comment or string, the
;; `sqlind-maybe-*` functions are called to check if the keyword is valid.
;; Each of these functions will do one of the following:
;;
;; * throw a syntax object with a 'finished tag, if they decide that the
;; keyword is valid
;;
;; * return t to indicate that they decided that the keyword is not valid
;; and `sqlind-beginning-of-block` should search for the next keyword
;;
;; * return nil to indicate that they don't recognize the keyword and
;; another `sqlind-maybe-*` function should be called
;;
;; Some of these `sqlind-maybe-*` functions are specific to the
;; `sql-product` and are only invoked for the speficied SQL dialect.
(catch 'finished
(let ((sqlind-end-stmt-stack end-statement-stack))
(while (re-search-backward sqlind-start-block-regexp sqlind-search-limit 'noerror)
(or (sqlind-in-comment-or-string (point))
(when (looking-at ")") (forward-char 1) (forward-sexp -1) t)
(sqlind-maybe-end-statement)
(sqlind-maybe-if-statement)
(sqlind-maybe-case-statement)
(sqlind-maybe-then-statement)
(sqlind-maybe-exception-statement)
(sqlind-maybe-else-statement)
(sqlind-maybe-loop-statement)
(sqlind-maybe-begin-statement)
(when (memq sql-product '(oracle postgres))
;; declare statements only start blocks in PL/SQL and PostgresSQL
(sqlind-maybe-declare-statement))
(when (eq sql-product 'postgres)
(sqlind-maybe-$$-statement))
(sqlind-maybe-create-statement)
(sqlind-maybe-defun-statement))))
'toplevel))