]> git.eshelyaron.com Git - emacs.git/commitdiff
(sql-connect): Add 'minibuffer-action'
authorEshel Yaron <me@eshelyaron.com>
Sun, 7 Jul 2024 14:13:49 +0000 (16:13 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 7 Jul 2024 14:13:49 +0000 (16:13 +0200)
lisp/progmodes/sql.el

index 5273ba2bee1633b827896f04f0a4eafd6d5d6e2d..11a4aa75445d78d09d442dd43c204fd1c88b2e8c 100644 (file)
@@ -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.