From 04413dc3ba7a8a899a5bdab58798a5b44ac25f27 Mon Sep 17 00:00:00 2001
From: Sam Steingold <sds@gnu.org>
Date: Mon, 8 Sep 2014 08:38:53 -0400
Subject: [PATCH] (sql-default-directory): New user option.

* lisp/progmodes/sql.el (sql-default-directory): New user option.
(sql-product-interactive): Bind `default-directory' to it to
enable remote connections using Tramp.
---
 etc/NEWS              | 11 ++++++++++-
 lisp/ChangeLog        |  3 +++
 lisp/progmodes/sql.el | 11 ++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 796d0935683..75cf583a864 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -146,6 +146,15 @@ protocols as well as for "telnet" and "ftp" are passed to Tramp.
 
 *** New connection method "nc", which allows to access dumb busyboxes.
 
+** SQL mode
+
+*** New user variable `sql-default-directory' enables remote
+connections using Tramp.
+
+*** New command `sql-send-line-and-next' sends the current line to the
+interactive buffer and advances to the next line, skipping whitespace
+and comments.
+
 ** VC and related modes
 
 *** New option `vc-annotate-background-mode' controls whether
@@ -209,7 +218,7 @@ position list returned for such events is now nil.
 * Lisp Changes in Emacs 24.5
 
 *** call-process-shell-command and process-file-shell-command
-don't take "&rest args" an more.
+don't take "&rest args" any more.
 
 ** New function `funcall-interactively', which works like `funcall'
 but makes `called-interactively-p' treat the function as (you guessed it)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 28f0ef0c520..d12138f3ead 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -4,6 +4,9 @@
 	bound to C-c C-n.
 	(sql-show-sqli-buffer): Display the buffer instead of its name and
 	bind the command to C-c C-z.
+	(sql-default-directory): New user option.
+	(sql-product-interactive): Bind `default-directory' to it to
+	enable remote connections using Tramp.
 
 2014-09-08  Glenn Morris  <rgm@gnu.org>
 
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index c63339d98c8..486e6b651d2 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -282,6 +282,13 @@ file.  Since that is a plaintext file, this could be dangerous."
   :group 'SQL
   :safe 'numberp)
 
+(defcustom sql-default-directory nil
+  "Default directory for SQL processes."
+  :version "24.5"
+  :type 'string
+  :group 'SQL
+  :safe 'stringp)
+
 ;; Login parameter type
 
 (define-widget 'sql-login-params 'lazy
@@ -4173,7 +4180,9 @@ the call to \\[sql-product-interactive] with
                     (sql-password   (default-value 'sql-password))
                     (sql-server     (default-value 'sql-server))
                     (sql-database   (default-value 'sql-database))
-                    (sql-port       (default-value 'sql-port)))
+                    (sql-port       (default-value 'sql-port))
+                    (default-directory (or sql-default-directory
+                                           default-directory)))
                 (funcall (sql-get-product-feature product :sqli-comint-func)
                          product
                          (sql-get-product-feature product :sqli-options)))
-- 
2.39.5