My typical usage of sql-mode in emacs is to:
a. open a foo.sql file and begin editing
b. decide I want to run it using the key bindings for sql-send-region
c. fire up my custom (db-connect) function to connect to an appropriate db and create a *SQL* buffer.
However the foo.sql doesn't know about the existence of the *SQL* buffer unless I perform a "m-x sql-mode" in the buffer in order to refresh its environment and detect that such a buffer exists at this point. I would like to embed some code in my custom db-connect function to visit all buffers using sql-mode and update the sql-buffer variable. I am sure several stack overflow members must have done this or something similar before.
Thanks,
SetJmp
A quick look in the sql.el
file revealed the command sql-set-sqli-buffer-generally
, maybe this is something for you?
Another way you could hand this is to kill the buffer-local variant of sql-buffer
by calling kill-local-variable
in your major-mode hook. (That way, the effect would be that all SQL buffers would talk to the latest SQL buffer.)
Disclaimer: I don't know anything about SQL or SQL mode, only Emacs in general.