aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mauger2012-09-10 15:22:53 -0400
committerMichael Mauger2012-09-10 15:22:53 -0400
commit04e082b0dd7d290036e2e691f65c467d8ac606c0 (patch)
tree44a5b1f5940d1da8f77777eb53160d851a93b789
parent399a361b882606ab0e67a164f8fb7af6464f3235 (diff)
downloademacs-04e082b0dd7d290036e2e691f65c467d8ac606c0.tar.gz
emacs-04e082b0dd7d290036e2e691f65c467d8ac606c0.zip
* progmodes/sql.el: Version 3.1
(sql-db2-escape-newlines): New variable. (sql-escape-newlines-filter): Use it.
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/sql.el42
3 files changed, 43 insertions, 13 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 9f46e49b96f..ef68e2e561e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -344,6 +344,14 @@ python-describe-symbol | python-eldoc-at-point
344 344
345*** Accepts \r and \f as whitespace. 345*** Accepts \r and \f as whitespace.
346 346
347** SQL Mode
348
349*** DB2 added `sql-db2-escape-newlines'
350
351If non-nil, newlines sent to the command interpreter will be escaped
352by a backslash. The default does not escape the newlines and assumes
353that the sql statement will be terminated by a semicolon.
354
347** Diff mode 355** Diff mode
348 356
349Faces for changes now use the same diff color scheme as in modern VCSes 357Faces for changes now use the same diff color scheme as in modern VCSes
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0f1b744f427..a8bf45b6f90 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-09-10 Michael R. Mauger <mmaug@yahoo.com>
2
3 * progmodes/sql.el: Version 3.1
4 (sql-db2-escape-newlines): New variable.
5 (sql-escape-newlines-filter): Use it.
6
12012-09-10 Juanma Barranquero <lekktu@gmail.com> 72012-09-10 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * custom.el (custom-theme-load-confirm): Remove unneeded assignment. 9 * custom.el (custom-theme-load-confirm): Remove unneeded assignment.
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 030cc02f3f4..f3ecbe3fc3d 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
@@ -879,6 +882,16 @@ In older versions of SQL*Plus, this was the SET SCAN OFF command."
879 :type 'boolean 882 :type 'boolean
880 :group 'SQL) 883 :group 'SQL)
881 884
885(defcustom sql-db2-escape-newlines nil
886 "Non-nil if newlines should be escaped by a backslash in DB2 SQLi.
887
888When non-nil, Emacs will automatically insert a space and
889backslash prior to every newline in multi-line SQL statements as
890they are submitted to an interactive DB2 session."
891 :version "24.3"
892 :type 'boolean
893 :group 'SQL)
894
882;; Customization for SQLite 895;; Customization for SQLite
883 896
884(defcustom sql-sqlite-program (or (executable-find "sqlite3") 897(defcustom sql-sqlite-program (or (executable-find "sqlite3")
@@ -3188,20 +3201,23 @@ Placeholders are words starting with an ampersand like &this."
3188 3201
3189;; Using DB2 interactively, newlines must be escaped with " \". 3202;; Using DB2 interactively, newlines must be escaped with " \".
3190;; The space before the backslash is relevant. 3203;; The space before the backslash is relevant.
3204
3191(defun sql-escape-newlines-filter (string) 3205(defun sql-escape-newlines-filter (string)
3192 "Escape newlines in STRING. 3206 "Escape newlines in STRING.
3193Every newline in STRING will be preceded with a space and a backslash." 3207Every newline in STRING will be preceded with a space and a backslash."
3194 (let ((result "") (start 0) mb me) 3208 (if (not sql-db2-escape-newlines)
3195 (while (string-match "\n" string start) 3209 string
3196 (setq mb (match-beginning 0) 3210 (let ((result "") (start 0) mb me)
3197 me (match-end 0) 3211 (while (string-match "\n" string start)
3198 result (concat result 3212 (setq mb (match-beginning 0)
3199 (substring string start mb) 3213 me (match-end 0)
3200 (if (and (> mb 1) 3214 result (concat result
3201 (string-equal " \\" (substring string (- mb 2) mb))) 3215 (substring string start mb)
3202 "" " \\\n")) 3216 (if (and (> mb 1)
3203 start me)) 3217 (string-equal " \\" (substring string (- mb 2) mb)))
3204 (concat result (substring string start)))) 3218 "" " \\\n"))
3219 start me))
3220 (concat result (substring string start)))))
3205 3221
3206 3222
3207 3223