Function: sqlind-find-join-start

sqlind-find-join-start is a natively compiled function defined in sql-indent.el.

Signature

(sqlind-find-join-start START LIMIT)

Documentation

Look backwards for the start of a JOIN statement, begin looking for it at the START position in the buffer, and look backwards until LIMIT is reached. Returns the buffer position where the JOIN condition starts, or nil if no JOIN statement is found.

Source Code

;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-find-join-start (start limit)
  "Look backwards for the start of a JOIN statement,
begin looking for it at the START position in the buffer, and
look backwards until LIMIT is reached.  Returns the buffer
position where the JOIN condition starts, or nil if no JOIN
statement is found."
  (save-excursion
    (when (sqlind-search-backward start "\\bjoin\\b" limit)
      (let ((candidate (point)))
        (forward-char -1)
        (sqlind-backward-syntactic-ws)
        (backward-word)
        (if (looking-at sqlind-select-join-regexp)
            (point)
          ;; The "outer" keyword is composed with a "left" or "right" keyword
          ;; so we need to move backwards one more word.
          (if (looking-at "\\bouter\\b")
              (progn
                (forward-char -1)
                (sqlind-backward-syntactic-ws)
                (backward-word)
                (if (looking-at "\\b\\(left\\|right\\)\\b")
                    (point)
                  candidate))
            candidate))))))