aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/sql.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/sql.el')
-rw-r--r--lisp/progmodes/sql.el57
1 files changed, 36 insertions, 21 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 030cc02f3f4..3d5abc4df62 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Alex Schroeder <alex@gnu.org> 5;; Author: Alex Schroeder <alex@gnu.org>
6;; Maintainer: Michael Mauger <mmaug@yahoo.com> 6;; Maintainer: Michael Mauger <mmaug@yahoo.com>
7;; Version: 3.0 7;; Version: 3.1
8;; Keywords: comm languages processes 8;; Keywords: comm languages processes
9;; URL: http://savannah.gnu.org/projects/emacs/ 9;; URL: http://savannah.gnu.org/projects/emacs/
10 10
@@ -218,9 +218,12 @@
218;; Michael Mauger <mmaug@yahoo.com> -- improved product support 218;; Michael Mauger <mmaug@yahoo.com> -- improved product support
219;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support 219;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support
220;; Harald Maier <maierh@myself.com> -- sql-send-string 220;; Harald Maier <maierh@myself.com> -- sql-send-string
221;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; code polish 221;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections;
222;; code polish
222;; Paul Sleigh <bat@flurf.net> -- MySQL keyword enhancement 223;; Paul Sleigh <bat@flurf.net> -- MySQL keyword enhancement
223;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug 224;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug
225;; Ian Bjorhovde <idbjorh@dataproxy.com> -- db2 escape newlines
226;; incorrectly enabled by default
224 227
225 228
226 229
@@ -265,9 +268,8 @@
265 268
266(defcustom sql-password "" 269(defcustom sql-password ""
267 "Default password. 270 "Default password.
268 271If you customize this, the value will be stored in your init
269Storing your password in a textfile such as ~/.emacs could be dangerous. 272file. Since that is a plaintext file, this could be dangerous."
270Customizing your password will store it in your ~/.emacs file."
271 :type 'string 273 :type 'string
272 :group 'SQL 274 :group 'SQL
273 :risky t) 275 :risky t)
@@ -879,6 +881,16 @@ In older versions of SQL*Plus, this was the SET SCAN OFF command."
879 :type 'boolean 881 :type 'boolean
880 :group 'SQL) 882 :group 'SQL)
881 883
884(defcustom sql-db2-escape-newlines nil
885 "Non-nil if newlines should be escaped by a backslash in DB2 SQLi.
886
887When non-nil, Emacs will automatically insert a space and
888backslash prior to every newline in multi-line SQL statements as
889they are submitted to an interactive DB2 session."
890 :version "24.3"
891 :type 'boolean
892 :group 'SQL)
893
882;; Customization for SQLite 894;; Customization for SQLite
883 895
884(defcustom sql-sqlite-program (or (executable-find "sqlite3") 896(defcustom sql-sqlite-program (or (executable-find "sqlite3")
@@ -1272,8 +1284,8 @@ Based on `comint-mode-map'.")
1272 ["List all objects" sql-list-all (sql-get-product-feature sql-product :list-all)] 1284 ["List all objects" sql-list-all (sql-get-product-feature sql-product :list-all)]
1273 ["List table details" sql-list-table (sql-get-product-feature sql-product :list-table)])) 1285 ["List table details" sql-list-table (sql-get-product-feature sql-product :list-table)]))
1274 1286
1275;; Abbreviations -- if you want more of them, define them in your 1287;; Abbreviations -- if you want more of them, define them in your init
1276;; ~/.emacs file. Abbrevs have to be enabled in your ~/.emacs, too. 1288;; file. Abbrevs have to be enabled in your init file, too.
1277 1289
1278(defvar sql-mode-abbrev-table nil 1290(defvar sql-mode-abbrev-table nil
1279 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") 1291 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.")
@@ -3188,20 +3200,23 @@ Placeholders are words starting with an ampersand like &this."
3188 3200
3189;; Using DB2 interactively, newlines must be escaped with " \". 3201;; Using DB2 interactively, newlines must be escaped with " \".
3190;; The space before the backslash is relevant. 3202;; The space before the backslash is relevant.
3203
3191(defun sql-escape-newlines-filter (string) 3204(defun sql-escape-newlines-filter (string)
3192 "Escape newlines in STRING. 3205 "Escape newlines in STRING.
3193Every newline in STRING will be preceded with a space and a backslash." 3206Every newline in STRING will be preceded with a space and a backslash."
3194 (let ((result "") (start 0) mb me) 3207 (if (not sql-db2-escape-newlines)
3195 (while (string-match "\n" string start) 3208 string
3196 (setq mb (match-beginning 0) 3209 (let ((result "") (start 0) mb me)
3197 me (match-end 0) 3210 (while (string-match "\n" string start)
3198 result (concat result 3211 (setq mb (match-beginning 0)
3199 (substring string start mb) 3212 me (match-end 0)
3200 (if (and (> mb 1) 3213 result (concat result
3201 (string-equal " \\" (substring string (- mb 2) mb))) 3214 (substring string start mb)
3202 "" " \\\n")) 3215 (if (and (> mb 1)
3203 start me)) 3216 (string-equal " \\" (substring string (- mb 2) mb)))
3204 (concat result (substring string start)))) 3217 "" " \\\n"))
3218 start me))
3219 (concat result (substring string start)))))
3205 3220
3206 3221
3207 3222
@@ -3699,8 +3714,8 @@ For information on how to create multiple SQLi buffers, see
3699`sql-interactive-mode'. 3714`sql-interactive-mode'.
3700 3715
3701Note that SQL doesn't have an escape character unless you specify 3716Note that SQL doesn't have an escape character unless you specify
3702one. If you specify backslash as escape character in SQL, 3717one. If you specify backslash as escape character in SQL, you
3703you must tell Emacs. Here's how to do that in your `~/.emacs' file: 3718must tell Emacs. Here's how to do that in your init file:
3704 3719
3705\(add-hook 'sql-mode-hook 3720\(add-hook 'sql-mode-hook
3706 (lambda () 3721 (lambda ()
@@ -3790,7 +3805,7 @@ cause the window to scroll to the end of the buffer.
3790If you want to make SQL buffers limited in length, add the function 3805If you want to make SQL buffers limited in length, add the function
3791`comint-truncate-buffer' to `comint-output-filter-functions'. 3806`comint-truncate-buffer' to `comint-output-filter-functions'.
3792 3807
3793Here is an example for your .emacs file. It keeps the SQLi buffer a 3808Here is an example for your init file. It keeps the SQLi buffer a
3794certain length. 3809certain length.
3795 3810
3796\(add-hook 'sql-interactive-mode-hook 3811\(add-hook 'sql-interactive-mode-hook