;;; Connection handling
-(defun sql-read-connection (prompt &optional initial default)
- "Read a connection name."
- (let ((completion-ignore-case t))
- (completing-read prompt
- (mapcar #'car sql-connection-alist)
- nil t initial 'sql-connection-history default)))
-
;;;###autoload
(defun sql-connect (connection &optional buf-name)
"Connect to an interactive session using CONNECTION settings.
;; Prompt for the connection from those defined in the alist
(interactive
(if sql-connection-alist
- (list (sql-read-connection "Connection: ")
+ (list (completing-read
+ "Connection: "
+ (completion-table-dynamic
+ (lambda (&rest _)
+ (mapcar (compose #'symbol-name #'car)
+ sql-connection-alist)))
+ nil t nil 'sql-connection-history)
current-prefix-arg)
(user-error "No SQL Connections defined")))
(user-error "No SQL Connections defined")
nil))
+(put 'sql-connect 'minibuffer-action
+ (cons (lambda (c)
+ (save-selected-window
+ (sql-connect c)))
+ "connect"))
+
(defun sql-save-connection (name)
"Captures the connection information of the current SQLi session.