aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/sql.el
diff options
context:
space:
mode:
authorMichael Mauger2012-09-10 15:22:53 -0400
committerMichael Mauger2012-09-10 15:22:53 -0400
commit04e082b0dd7d290036e2e691f65c467d8ac606c0 (patch)
tree44a5b1f5940d1da8f77777eb53160d851a93b789 /lisp/progmodes/sql.el
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.
Diffstat (limited to 'lisp/progmodes/sql.el')
-rw-r--r--lisp/progmodes/sql.el42
1 files changed, 29 insertions, 13 deletions
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