How to use elisp to create a sqlite specific shell?

elisp, emacs, shell, sqlite

Solution

Here's the code:

(defun sqlite3 (file)
  (interactive "fDB file name:\n")
  (term-send-string
   (ansi-term "bash" "sqlite3")
   (format "sqlite3 %s\n" file)))

Problem

I'm trying to learn how to use elisp to customize my development environment. I've included the following function to create the command `M-x ipython` which opens an IPython shell: ``` (defun ipython () (interactive) (ansi-term "/usr/bin/ipython" "ipython")) ``` I'm using sqlite on a project, and I wanted to make it easier to open a sqlite command shell in emacs. This is similar to the above example, but has the catch that I need to specify a database file. If I modify the above as follows: ``` (defun sqlite3 (filename) (interactive "FDB file name: \n") (ansi-term "/usr/bin/sqlite3" "sqlite3")) ;; Oops, what do I do with the file name? ``` I'm stuck, because the `ansi-term` function only takes two arguments, one being the program to be run, and the other being the optional name to rename the shell. Is there an easy way to create a function that would allow me to easily open a sqlite shell with opportunity to provide the file argument to be passed to sqlite?

Original source