Run Emacs command in another window

I am looking for a way to send the output of an arbitrary Emacs command (in my case sql-send-region) to another window. I would prefer to keep the focus in the window in which I was now, in order to effectively give me one window for editing queries and one window for viewing output.

+4
source share
2 answers

I managed to write Emacs Lisp to solve my problem:

(defun sql-send-region-and-return (start end) (interactive "r") (let ((oldbuf (buffer-name))) (sql-send-region start end) (switch-to-buffer oldbuf))) 

This sends the result of your region to the SQL buffer and returns back to your current buffer, effectively performing the specified task.

Thanks justinhj for giving me some new solutions to solve my problem.

+3
source

You tried to set this variable to t, it looks like the behavior you want.

SQL-pop-to-buffer-after-send-region

After calling sql-send-region' or sql-send-buffer', the window is broken and the SQLi buffer is displayed. If this variable is not equal to zero, this buffer window will be selected by calling pop-to-buffer'. If this variable is nil, that buffer is shown using pop-to-buffer'. If this variable is nil, that buffer is shown using display-buffer '.

+2
source

All Articles