Function: sql-comint

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

Signature

(sql-comint PRODUCT PARAMS &optional BUF-NAME)

Documentation

Set up a comint buffer to run the SQL processor.

PRODUCT is the SQL product. PARAMS is a list of strings which are passed as command line arguments. BUF-NAME is the name of the new buffer. If nil, a name is chosen for it.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sql.el.gz
(defun sql-comint (product params &optional buf-name)
  "Set up a comint buffer to run the SQL processor.

PRODUCT is the SQL product.  PARAMS is a list of strings which are
passed as command line arguments.  BUF-NAME is the name of the new
buffer.  If nil, a name is chosen for it."

  (let ((program (sql-get-product-feature product :sqli-program)))
    ;; Make sure we can find the program.  `executable-find' does not
    ;; work for remote hosts; we suppress the check there.
    (unless (or (file-remote-p default-directory)
		(executable-find program))
      (error "Unable to locate SQL program `%s'" program))

    ;; Make sure buffer name is unique.
    ;;   if not specified, try *SQL* then *SQL-product*, then *SQL-product1*, ...
    ;;   otherwise, use *buf-name*
    (if buf-name
        (unless (or (string-prefix-p " " buf-name)
                    (string-match-p "\\`[*].*[*]\\'" buf-name))
          (setq buf-name (concat "*" buf-name "*")))
      (setq buf-name (sql-generate-unique-sqli-buffer-name product nil)))
    (set-text-properties 0 (length buf-name) nil buf-name)

    ;; Create the buffer first, because we want to set it up before
    ;; comint starts to run.
    (set-buffer (get-buffer-create buf-name))
    ;; Set up the automatic population of passwords, if supported.
    (when (sql-get-product-feature product :password-in-comint)
      (setq comint-password-function #'sql-comint-automatic-password))

    ;; Start the command interpreter in the buffer
    ;;   PROC-NAME is BUF-NAME without enclosing asterisks
    (let ((proc-name (replace-regexp-in-string "\\`[*]\\(.*\\)[*]\\'" "\\1" buf-name)))
      (set-buffer
       (apply #'make-comint-in-buffer
              proc-name buf-name program nil params)))))