Function: sql-beginning-of-statement

sql-beginning-of-statement is an interactive and byte-compiled function defined in sql.el.gz.

Signature

(sql-beginning-of-statement ARG)

Documentation

Move to the beginning of the current SQL statement.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sql.el.gz
(defun sql-beginning-of-statement (arg)
  "Move to the beginning of the current SQL statement."
  (interactive "p")

  (let ((here (point))
        (regexp (sql-statement-regexp sql-product))
        last next)

    ;; Go to the end of the statement before the start we desire
    (setq last (or (sql-end-of-statement (- arg))
                   (point-min)))
    ;; And find the end after that
    (setq next (or (sql-end-of-statement 1)
                   (point-max)))

    ;; Our start must be between them
    (goto-char last)
    ;; Find a beginning-of-stmt that's not in a string or comment
    (while (and (re-search-forward regexp next t 1)
                (or (nth 3 (syntax-ppss))
                    (nth 7 (syntax-ppss))))
      (goto-char (match-end 0)))
    (goto-char
     (if (match-data)
        (match-beginning 0)
       last))
    (beginning-of-line)
    ;; If we didn't move, try again
    (when (= here (point))
      (sql-beginning-of-statement (* 2 (cl-signum arg))))))