2

I have written an interactive function to connect to multiple mysql databases

(defun mysql-connect (name)
  "Connect to a predefined MySQL connection."
  (interactive
   (list
    (completing-read "Connect to: " sql-connection-alist
             nil t nil 'pyvenv-workon-history nil nil)))
  (when (not (or (equal name "")
             (equal name nil)))
    (mysql-connect-preset name)))

If I run M-x mysql-connect, it will prompt user to select available options. But I want to invoke it via script.

If I run (mysql-connect 'some-choice) it will work, but I dont want that. I just want to invoke mysql-connect and let user to select choice.

How can I just invoke that function?

Chillar Anand
  • 4,042
  • 1
  • 23
  • 52

1 Answers1

3

You need to use call-interactively here.

Usage example:

(call-interactively #'foo)

You can learn more about it by doing C-h i g (elisp) Interactive Call and C-h f call-interactively.

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179