From: Eshel Yaron Date: Sun, 7 Jul 2024 14:13:49 +0000 (+0200) Subject: (sql-connect): Add 'minibuffer-action' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c3e510940e04b8f7a81c3b0bd287b6f7e30f44d9;p=emacs.git (sql-connect): Add 'minibuffer-action' --- diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 5273ba2bee1..11a4aa75445 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4364,13 +4364,6 @@ Sentinels will always get the two parameters PROCESS and EVENT." ;;; 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. @@ -4384,7 +4377,13 @@ is specified in the 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"))) @@ -4444,6 +4443,12 @@ is specified in the connection settings." (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.