Function: sql--completion-table

sql--completion-table is a byte-compiled function defined in sql.el.gz.

Signature

(sql--completion-table STRING PRED ACTION)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sql.el.gz
(defun sql--completion-table (string pred action)
  (when sql-completion-sqlbuf
    (with-current-buffer sql-completion-sqlbuf
      (let ((schema (and (string-match "\\`\\(\\sw\\(?:\\sw\\|\\s_\\)*\\)[.]" string)
                         (downcase (match-string 1 string)))))

        ;; If we haven't loaded any object name yet, load local schema
        (unless sql-completion-object
          (sql-build-completions nil))

        ;; If they want another schema, load it if we haven't yet
        (when schema
          (let ((schema-dot (concat schema "."))
                (schema-len (1+ (length schema)))
                (names sql-completion-object)
                has-schema)

            (while (and (not has-schema) names)
              (setq has-schema (and
                                (>= (length (car names)) schema-len)
                                (string= schema-dot
                                         (downcase (substring (car names)
                                                              0 schema-len))))
                    names (cdr names)))
            (unless has-schema
              (sql-build-completions schema)))))

      ;; Try to find the completion
      (complete-with-action action sql-completion-object string pred))))