From c3e510940e04b8f7a81c3b0bd287b6f7e30f44d9 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 7 Jul 2024 16:13:49 +0200 Subject: [PATCH] (sql-connect): Add 'minibuffer-action' --- lisp/progmodes/sql.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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. -- 2.39.2