1

This question already has an answer here:

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?

marked as duplicate by Mark Karpov, Community Sep 17 '15 at 13:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Doesn't simply evaluating (mysql-connect) offer you the choices in the same manner as an interactive call? – suvayu Sep 17 '15 at 13:32
  • No, it will throw error as it requires one argument. – ChillarAnand Sep 17 '15 at 13:34
2

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.