views:

175

answers:

4

Let's say you have a *SQL* buffer already open in Emacs that is connected to a specific server and database. Now, your intention is to connect to a different server and database while keeping your other SQL buffer process active.

How exactly can you create a new *SQL* buffer process without killing your original SQL buffer? Can this be done? Is there a way to instead change your connection info for the existing buffer?

+7  A: 

Running:

M-x sql-rename-buffer

On a connected *SQL* buffer will rename the current buffer after the current connection. So:

*SQL*

Becomes:

*SQL user/database*

You can then do:

M-x sql-mysql

Or whatever your flavor of DB is to create another SQL buffer.

Sean Bright
+1  A: 
rzab
+2  A: 

As a slight simplification, you can just do:

(add-hook 'sql-interactive-mode-hook 'sql-rename-buffer)

(I.e., you don't need the lambda).

Jacob Gabrielson
A: 

@Jacob Sorry, cannot comment yet.

Yes, in this case lambda is not necessary.
But i use it all the time with add-hook, so i can specify arguments to the hook function.
add-hook always calls function (our lambda) without arguments.

rzab