Function: sqlind-syntax-in-with

sqlind-syntax-in-with is a natively compiled function defined in sql-indent.el.

Signature

(sqlind-syntax-in-with POS START)

Documentation

Return the syntax at POS which is part of a "with" statement at START.

Source Code

;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-syntax-in-with (pos start)
  "Return the syntax at POS which is part of a \"with\" statement at START."
  (save-excursion
    (catch 'finished
      (goto-char pos)
      (cond
        ((looking-at sqlind-with-clauses-regexp)
         (throw 'finished (cons 'with-clause start)))
        ((and (looking-at "\\_<select\\_>")
              (sqlind-same-level-statement (point) start))
         (throw 'finished (cons 'with-clause start))))
      (while (re-search-backward "\\_<select\\_>" start 'noerror)
        (when (sqlind-same-level-statement (point) start)
          (throw 'finished (sqlind-syntax-in-select pos (point)))))
      (goto-char pos)
      (when (looking-at "\\_<as\\_>")
        (throw 'finished (cons 'with-clause-cte-cont start)))
      (sqlind-backward-syntactic-ws)
      (when (looking-at ",")
        (throw 'finished (cons 'with-clause-cte start)))
      (forward-word -1)
      (when (looking-at sqlind-with-clauses-regexp)
        ;; We're right after the with (recursive keyword)
        (throw 'finished (cons 'with-clause-cte start)))
      (throw 'finished (cons 'with-clause-cte-cont start)))))