aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2020-03-14 15:39:31 -0400
committerStefan Monnier2020-03-14 15:39:31 -0400
commitb39b5647258297a411fae0adf58877bda85ad00d (patch)
tree2cb93a23db613466a7b65a6273fea1e0f95e486a /lisp
parente2a15c8ac4efe823c51c9a5750642532155199a8 (diff)
downloademacs-b39b5647258297a411fae0adf58877bda85ad00d.tar.gz
emacs-b39b5647258297a411fae0adf58877bda85ad00d.zip
* lisp/progmodes/sql.el: Try and avoid `eval`; use define-derived-mode
Remove redundant `:group` args. (sql-interactive-mode-map): `set-keymap-parent` is always fboundp. (sql-get-product-feature): Prefer `symbol-value` over `eval`. (sql--adjust-interactive-setup): New function, extracted from `sql-interactive-mode`. (sql-interactive-mode): Use it and `define-derived-mode`. (sql-connect, sql-connection-menu-filter): Prefer `cl-progv` over `eval`.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/sql.el200
1 files changed, 70 insertions, 130 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 5eb8701d08a..6fd750d3963 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -257,7 +257,6 @@
257(defcustom sql-user "" 257(defcustom sql-user ""
258 "Default username." 258 "Default username."
259 :type 'string 259 :type 'string
260 :group 'SQL
261 :safe 'stringp) 260 :safe 'stringp)
262 261
263(defcustom sql-password "" 262(defcustom sql-password ""
@@ -265,33 +264,28 @@
265If you customize this, the value will be stored in your init 264If you customize this, the value will be stored in your init
266file. Since that is a plaintext file, this could be dangerous." 265file. Since that is a plaintext file, this could be dangerous."
267 :type 'string 266 :type 'string
268 :group 'SQL
269 :risky t) 267 :risky t)
270 268
271(defcustom sql-database "" 269(defcustom sql-database ""
272 "Default database." 270 "Default database."
273 :type 'string 271 :type 'string
274 :group 'SQL
275 :safe 'stringp) 272 :safe 'stringp)
276 273
277(defcustom sql-server "" 274(defcustom sql-server ""
278 "Default server or host." 275 "Default server or host."
279 :type 'string 276 :type 'string
280 :group 'SQL
281 :safe 'stringp) 277 :safe 'stringp)
282 278
283(defcustom sql-port 0 279(defcustom sql-port 0
284 "Default port for connecting to a MySQL or Postgres server." 280 "Default port for connecting to a MySQL or Postgres server."
285 :version "24.1" 281 :version "24.1"
286 :type 'number 282 :type 'number
287 :group 'SQL
288 :safe 'numberp) 283 :safe 'numberp)
289 284
290(defcustom sql-default-directory nil 285(defcustom sql-default-directory nil
291 "Default directory for SQL processes." 286 "Default directory for SQL processes."
292 :version "25.1" 287 :version "25.1"
293 :type '(choice (const nil) string) 288 :type '(choice (const nil) string)
294 :group 'SQL
295 :safe 'stringp) 289 :safe 'stringp)
296 290
297;; Login parameter type 291;; Login parameter type
@@ -707,9 +701,9 @@ making new SQLi sessions."
707 (repeat :inline t 701 (repeat :inline t
708 (list :tab "Other" 702 (list :tab "Other"
709 (symbol :tag " Variable Symbol") 703 (symbol :tag " Variable Symbol")
704 ;; FIXME: Why "Value *Expression*"?
710 (sexp :tag "Value Expression"))))) 705 (sexp :tag "Value Expression")))))
711 :version "24.1" 706 :version "24.1")
712 :group 'SQL)
713 707
714(defvaralias 'sql-dialect 'sql-product) 708(defvaralias 'sql-dialect 'sql-product)
715 709
@@ -723,7 +717,6 @@ This allows highlighting buffers properly when you open them."
723 (capitalize (symbol-name (car prod-info)))) 717 (capitalize (symbol-name (car prod-info))))
724 ,(car prod-info))) 718 ,(car prod-info)))
725 sql-product-alist)) 719 sql-product-alist))
726 :group 'SQL
727 :safe 'symbolp) 720 :safe 'symbolp)
728 721
729;; SQL indent support 722;; SQL indent support
@@ -735,7 +728,6 @@ SQL statements with easy customizations to support varied layout
735requirements. 728requirements.
736 729
737The package must be available to be loaded and activated." 730The package must be available to be loaded and activated."
738 :group 'SQL
739 :link '(url-link "https://elpa.gnu.org/packages/sql-indent.html") 731 :link '(url-link "https://elpa.gnu.org/packages/sql-indent.html")
740 :type 'boolean 732 :type 'boolean
741 :version "27.1") 733 :version "27.1")
@@ -851,7 +843,6 @@ host key."
851See `sql-password-search-wallet-function' to understand how this value 843See `sql-password-search-wallet-function' to understand how this value
852is used to locate the password wallet." 844is used to locate the password wallet."
853 :type `(plist-get (symbol-plist 'auth-sources) 'custom-type) 845 :type `(plist-get (symbol-plist 'auth-sources) 'custom-type)
854 :group 'SQL
855 :version "27.1") 846 :version "27.1")
856 847
857(defvar sql-password-search-wallet-function #'sql-auth-source-search-wallet 848(defvar sql-password-search-wallet-function #'sql-auth-source-search-wallet
@@ -878,8 +869,7 @@ current input in the SQLi buffer to the process."
878 :type '(choice (const :tag "Nothing" nil) 869 :type '(choice (const :tag "Nothing" nil)
879 (const :tag "The semicolon `;'" semicolon) 870 (const :tag "The semicolon `;'" semicolon)
880 (const :tag "The string `go' by itself" go)) 871 (const :tag "The string `go' by itself" go))
881 :version "20.8" 872 :version "20.8")
882 :group 'SQL)
883 873
884(defcustom sql-send-terminator nil 874(defcustom sql-send-terminator nil
885 "When non-nil, add a terminator to text sent to the SQL interpreter. 875 "When non-nil, add a terminator to text sent to the SQL interpreter.
@@ -907,8 +897,7 @@ it automatically."
907 (cons :tag "Terminator Pattern and String" 897 (cons :tag "Terminator Pattern and String"
908 (regexp :tag "Terminator Pattern") 898 (regexp :tag "Terminator Pattern")
909 (string :tag "Terminator String"))) 899 (string :tag "Terminator String")))
910 :version "22.2" 900 :version "22.2")
911 :group 'SQL)
912 901
913(defvar sql-contains-names nil 902(defvar sql-contains-names nil
914 "When non-nil, the current buffer contains database names. 903 "When non-nil, the current buffer contains database names.
@@ -932,8 +921,7 @@ buffer."
932 :type '(choice (const :tag "Default" t) 921 :type '(choice (const :tag "Default" t)
933 (const :tag "No display" nil) 922 (const :tag "No display" nil)
934 (function :tag "Display Buffer function")) 923 (function :tag "Display Buffer function"))
935 :version "27.1" 924 :version "27.1")
936 :group 'SQL)
937 925
938;; imenu support for sql-mode. 926;; imenu support for sql-mode.
939 927
@@ -971,8 +959,7 @@ This is used to initialize `comint-input-ring-file-name'.
971Note that the size of the input history is determined by the variable 959Note that the size of the input history is determined by the variable
972`comint-input-ring-size'." 960`comint-input-ring-size'."
973 :type '(choice (const :tag "none" nil) 961 :type '(choice (const :tag "none" nil)
974 (file)) 962 (file)))
975 :group 'SQL)
976 963
977(defcustom sql-input-ring-separator "\n--\n" 964(defcustom sql-input-ring-separator "\n--\n"
978 "Separator between commands in the history file. 965 "Separator between commands in the history file.
@@ -987,21 +974,18 @@ does not have it, setting `sql-input-ring-separator' will have no
987effect. In that case multiline commands will be split into several 974effect. In that case multiline commands will be split into several
988commands when the input history is read, as if you had set 975commands when the input history is read, as if you had set
989`sql-input-ring-separator' to \"\\n\"." 976`sql-input-ring-separator' to \"\\n\"."
990 :type 'string 977 :type 'string)
991 :group 'SQL)
992 978
993;; The usual hooks 979;; The usual hooks
994 980
995(defcustom sql-interactive-mode-hook '(sql-indent-enable) 981(defcustom sql-interactive-mode-hook '(sql-indent-enable)
996 "Hook for customizing `sql-interactive-mode'." 982 "Hook for customizing `sql-interactive-mode'."
997 :type 'hook 983 :type 'hook
998 :group 'SQL
999 :version "27.1") 984 :version "27.1")
1000 985
1001(defcustom sql-mode-hook '(sql-indent-enable) 986(defcustom sql-mode-hook '(sql-indent-enable)
1002 "Hook for customizing `sql-mode'." 987 "Hook for customizing `sql-mode'."
1003 :type 'hook 988 :type 'hook
1004 :group 'SQL
1005 :version "27.1") 989 :version "27.1")
1006 990
1007(defcustom sql-set-sqli-hook '() 991(defcustom sql-set-sqli-hook '()
@@ -1009,8 +993,7 @@ commands when the input history is read, as if you had set
1009 993
1010This is called by `sql-set-sqli-buffer' when the value of `sql-buffer' 994This is called by `sql-set-sqli-buffer' when the value of `sql-buffer'
1011is changed." 995is changed."
1012 :type 'hook 996 :type 'hook)
1013 :group 'SQL)
1014 997
1015(defcustom sql-login-hook '() 998(defcustom sql-login-hook '()
1016 "Hook for interacting with a buffer in `sql-interactive-mode'. 999 "Hook for interacting with a buffer in `sql-interactive-mode'.
@@ -1018,8 +1001,7 @@ is changed."
1018This hook is invoked in a buffer once it is ready to accept input 1001This hook is invoked in a buffer once it is ready to accept input
1019for the first time." 1002for the first time."
1020 :version "24.1" 1003 :version "24.1"
1021 :type 'hook 1004 :type 'hook)
1022 :group 'SQL)
1023 1005
1024;; Customization for ANSI 1006;; Customization for ANSI
1025 1007
@@ -1033,8 +1015,7 @@ All products share this list; products should define a regexp to
1033identify additional keywords in a variable defined by 1015identify additional keywords in a variable defined by
1034the :statement feature." 1016the :statement feature."
1035 :version "24.1" 1017 :version "24.1"
1036 :type 'regexp 1018 :type 'regexp)
1037 :group 'SQL)
1038 1019
1039;; Customization for Oracle 1020;; Customization for Oracle
1040 1021
@@ -1046,27 +1027,23 @@ Starts `sql-interactive-mode' after doing some setup.
1046On Windows, \"sqlplus\" usually starts the sqlplus \"GUI\". In order 1027On Windows, \"sqlplus\" usually starts the sqlplus \"GUI\". In order
1047to start the sqlplus console, use \"plus33\" or something similar. 1028to start the sqlplus console, use \"plus33\" or something similar.
1048You will find the file in your Orant\\bin directory." 1029You will find the file in your Orant\\bin directory."
1049 :type 'file 1030 :type 'file)
1050 :group 'SQL)
1051 1031
1052(defcustom sql-oracle-options '("-L") 1032(defcustom sql-oracle-options '("-L")
1053 "List of additional options for `sql-oracle-program'." 1033 "List of additional options for `sql-oracle-program'."
1054 :type '(repeat string) 1034 :type '(repeat string)
1055 :version "24.4" 1035 :version "24.4")
1056 :group 'SQL)
1057 1036
1058(defcustom sql-oracle-login-params '(user password database) 1037(defcustom sql-oracle-login-params '(user password database)
1059 "List of login parameters needed to connect to Oracle." 1038 "List of login parameters needed to connect to Oracle."
1060 :type 'sql-login-params 1039 :type 'sql-login-params
1061 :version "24.1" 1040 :version "24.1")
1062 :group 'SQL)
1063 1041
1064(defcustom sql-oracle-statement-starters 1042(defcustom sql-oracle-statement-starters
1065 (regexp-opt '("declare" "begin" "with")) 1043 (regexp-opt '("declare" "begin" "with"))
1066 "Additional statement starting keywords in Oracle." 1044 "Additional statement starting keywords in Oracle."
1067 :version "24.1" 1045 :version "24.1"
1068 :type 'string 1046 :type 'string)
1069 :group 'SQL)
1070 1047
1071(defcustom sql-oracle-scan-on t 1048(defcustom sql-oracle-scan-on t
1072 "Non-nil if placeholders should be replaced in Oracle SQLi. 1049 "Non-nil if placeholders should be replaced in Oracle SQLi.
@@ -1082,8 +1059,7 @@ You need to issue the following command in SQL*Plus to be safe:
1082 1059
1083In older versions of SQL*Plus, this was the SET SCAN OFF command." 1060In older versions of SQL*Plus, this was the SET SCAN OFF command."
1084 :version "24.1" 1061 :version "24.1"
1085 :type 'boolean 1062 :type 'boolean)
1086 :group 'SQL)
1087 1063
1088(defcustom sql-db2-escape-newlines nil 1064(defcustom sql-db2-escape-newlines nil
1089 "Non-nil if newlines should be escaped by a backslash in DB2 SQLi. 1065 "Non-nil if newlines should be escaped by a backslash in DB2 SQLi.
@@ -1092,8 +1068,7 @@ When non-nil, Emacs will automatically insert a space and
1092backslash prior to every newline in multi-line SQL statements as 1068backslash prior to every newline in multi-line SQL statements as
1093they are submitted to an interactive DB2 session." 1069they are submitted to an interactive DB2 session."
1094 :version "24.3" 1070 :version "24.3"
1095 :type 'boolean 1071 :type 'boolean)
1096 :group 'SQL)
1097 1072
1098;; Customization for SQLite 1073;; Customization for SQLite
1099 1074
@@ -1103,21 +1078,18 @@ they are submitted to an interactive DB2 session."
1103 "Command to start SQLite. 1078 "Command to start SQLite.
1104 1079
1105Starts `sql-interactive-mode' after doing some setup." 1080Starts `sql-interactive-mode' after doing some setup."
1106 :type 'file 1081 :type 'file)
1107 :group 'SQL)
1108 1082
1109(defcustom sql-sqlite-options nil 1083(defcustom sql-sqlite-options nil
1110 "List of additional options for `sql-sqlite-program'." 1084 "List of additional options for `sql-sqlite-program'."
1111 :type '(repeat string) 1085 :type '(repeat string)
1112 :version "20.8" 1086 :version "20.8")
1113 :group 'SQL)
1114 1087
1115(defcustom sql-sqlite-login-params '((database :file nil 1088(defcustom sql-sqlite-login-params '((database :file nil
1116 :must-match confirm)) 1089 :must-match confirm))
1117 "List of login parameters needed to connect to SQLite." 1090 "List of login parameters needed to connect to SQLite."
1118 :type 'sql-login-params 1091 :type 'sql-login-params
1119 :version "26.1" 1092 :version "26.1")
1120 :group 'SQL)
1121 1093
1122;; Customization for MariaDB 1094;; Customization for MariaDB
1123 1095
@@ -1134,22 +1106,19 @@ Starts `sql-interactive-mode' after doing some setup."
1134 "Command to start mysql by Oracle. 1106 "Command to start mysql by Oracle.
1135 1107
1136Starts `sql-interactive-mode' after doing some setup." 1108Starts `sql-interactive-mode' after doing some setup."
1137 :type 'file 1109 :type 'file)
1138 :group 'SQL)
1139 1110
1140(defcustom sql-mysql-options nil 1111(defcustom sql-mysql-options nil
1141 "List of additional options for `sql-mysql-program'. 1112 "List of additional options for `sql-mysql-program'.
1142The following list of options is reported to make things work 1113The following list of options is reported to make things work
1143on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." 1114on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
1144 :type '(repeat string) 1115 :type '(repeat string)
1145 :version "20.8" 1116 :version "20.8")
1146 :group 'SQL)
1147 1117
1148(defcustom sql-mysql-login-params '(user password database server) 1118(defcustom sql-mysql-login-params '(user password database server)
1149 "List of login parameters needed to connect to MySQL." 1119 "List of login parameters needed to connect to MySQL."
1150 :type 'sql-login-params 1120 :type 'sql-login-params
1151 :version "24.1" 1121 :version "24.1")
1152 :group 'SQL)
1153 1122
1154;; Customization for Solid 1123;; Customization for Solid
1155 1124
@@ -1157,14 +1126,12 @@ on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
1157 "Command to start SOLID SQL Editor. 1126 "Command to start SOLID SQL Editor.
1158 1127
1159Starts `sql-interactive-mode' after doing some setup." 1128Starts `sql-interactive-mode' after doing some setup."
1160 :type 'file 1129 :type 'file)
1161 :group 'SQL)
1162 1130
1163(defcustom sql-solid-login-params '(user password server) 1131(defcustom sql-solid-login-params '(user password server)
1164 "List of login parameters needed to connect to Solid." 1132 "List of login parameters needed to connect to Solid."
1165 :type 'sql-login-params 1133 :type 'sql-login-params
1166 :version "24.1" 1134 :version "24.1")
1167 :group 'SQL)
1168 1135
1169;; Customization for Sybase 1136;; Customization for Sybase
1170 1137
@@ -1172,21 +1139,18 @@ Starts `sql-interactive-mode' after doing some setup."
1172 "Command to start isql by Sybase. 1139 "Command to start isql by Sybase.
1173 1140
1174Starts `sql-interactive-mode' after doing some setup." 1141Starts `sql-interactive-mode' after doing some setup."
1175 :type 'file 1142 :type 'file)
1176 :group 'SQL)
1177 1143
1178(defcustom sql-sybase-options nil 1144(defcustom sql-sybase-options nil
1179 "List of additional options for `sql-sybase-program'. 1145 "List of additional options for `sql-sybase-program'.
1180Some versions of isql might require the -n option in order to work." 1146Some versions of isql might require the -n option in order to work."
1181 :type '(repeat string) 1147 :type '(repeat string)
1182 :version "20.8" 1148 :version "20.8")
1183 :group 'SQL)
1184 1149
1185(defcustom sql-sybase-login-params '(server user password database) 1150(defcustom sql-sybase-login-params '(server user password database)
1186 "List of login parameters needed to connect to Sybase." 1151 "List of login parameters needed to connect to Sybase."
1187 :type 'sql-login-params 1152 :type 'sql-login-params
1188 :version "24.1" 1153 :version "24.1")
1189 :group 'SQL)
1190 1154
1191;; Customization for Informix 1155;; Customization for Informix
1192 1156
@@ -1194,14 +1158,12 @@ Some versions of isql might require the -n option in order to work."
1194 "Command to start dbaccess by Informix. 1158 "Command to start dbaccess by Informix.
1195 1159
1196Starts `sql-interactive-mode' after doing some setup." 1160Starts `sql-interactive-mode' after doing some setup."
1197 :type 'file 1161 :type 'file)
1198 :group 'SQL)
1199 1162
1200(defcustom sql-informix-login-params '(database) 1163(defcustom sql-informix-login-params '(database)
1201 "List of login parameters needed to connect to Informix." 1164 "List of login parameters needed to connect to Informix."
1202 :type 'sql-login-params 1165 :type 'sql-login-params
1203 :version "24.1" 1166 :version "24.1")
1204 :group 'SQL)
1205 1167
1206;; Customization for Ingres 1168;; Customization for Ingres
1207 1169
@@ -1209,14 +1171,12 @@ Starts `sql-interactive-mode' after doing some setup."
1209 "Command to start sql by Ingres. 1171 "Command to start sql by Ingres.
1210 1172
1211Starts `sql-interactive-mode' after doing some setup." 1173Starts `sql-interactive-mode' after doing some setup."
1212 :type 'file 1174 :type 'file)
1213 :group 'SQL)
1214 1175
1215(defcustom sql-ingres-login-params '(database) 1176(defcustom sql-ingres-login-params '(database)
1216 "List of login parameters needed to connect to Ingres." 1177 "List of login parameters needed to connect to Ingres."
1217 :type 'sql-login-params 1178 :type 'sql-login-params
1218 :version "24.1" 1179 :version "24.1")
1219 :group 'SQL)
1220 1180
1221;; Customization for Microsoft 1181;; Customization for Microsoft
1222 1182
@@ -1229,21 +1189,18 @@ Starts `sql-interactive-mode' after doing some setup."
1229 "Command to start osql by Microsoft. 1189 "Command to start osql by Microsoft.
1230 1190
1231Starts `sql-interactive-mode' after doing some setup." 1191Starts `sql-interactive-mode' after doing some setup."
1232 :type 'file 1192 :type 'file)
1233 :group 'SQL)
1234 1193
1235(defcustom sql-ms-options '("-w" "300" "-n") 1194(defcustom sql-ms-options '("-w" "300" "-n")
1236 ;; -w is the linesize 1195 ;; -w is the linesize
1237 "List of additional options for `sql-ms-program'." 1196 "List of additional options for `sql-ms-program'."
1238 :type '(repeat string) 1197 :type '(repeat string)
1239 :version "22.1" 1198 :version "22.1")
1240 :group 'SQL)
1241 1199
1242(defcustom sql-ms-login-params '(user password server database) 1200(defcustom sql-ms-login-params '(user password server database)
1243 "List of login parameters needed to connect to Microsoft." 1201 "List of login parameters needed to connect to Microsoft."
1244 :type 'sql-login-params 1202 :type 'sql-login-params
1245 :version "24.1" 1203 :version "24.1")
1246 :group 'SQL)
1247 1204
1248;; Customization for Postgres 1205;; Customization for Postgres
1249 1206
@@ -1251,8 +1208,7 @@ Starts `sql-interactive-mode' after doing some setup."
1251 "Command to start psql by Postgres. 1208 "Command to start psql by Postgres.
1252 1209
1253Starts `sql-interactive-mode' after doing some setup." 1210Starts `sql-interactive-mode' after doing some setup."
1254 :type 'file 1211 :type 'file)
1255 :group 'SQL)
1256 1212
1257(defcustom sql-postgres-options '("-P" "pager=off") 1213(defcustom sql-postgres-options '("-P" "pager=off")
1258 "List of additional options for `sql-postgres-program'. 1214 "List of additional options for `sql-postgres-program'.
@@ -1263,8 +1219,7 @@ name, add the string \"-u\" to the list of options. If you want to
1263provide a user name on the command line (newer versions such as 7.1), 1219provide a user name on the command line (newer versions such as 7.1),
1264add your name with a \"-U\" prefix (such as \"-Umark\") to the list." 1220add your name with a \"-U\" prefix (such as \"-Umark\") to the list."
1265 :type '(repeat string) 1221 :type '(repeat string)
1266 :version "20.8" 1222 :version "20.8")
1267 :group 'SQL)
1268 1223
1269(defcustom sql-postgres-login-params 1224(defcustom sql-postgres-login-params
1270 `((user :default ,(user-login-name)) 1225 `((user :default ,(user-login-name))
@@ -1275,8 +1230,7 @@ add your name with a \"-U\" prefix (such as \"-Umark\") to the list."
1275 server) 1230 server)
1276 "List of login parameters needed to connect to Postgres." 1231 "List of login parameters needed to connect to Postgres."
1277 :type 'sql-login-params 1232 :type 'sql-login-params
1278 :version "26.1" 1233 :version "26.1")
1279 :group 'SQL)
1280 1234
1281(defun sql-postgres-list-databases () 1235(defun sql-postgres-list-databases ()
1282 "Return a list of available PostgreSQL databases." 1236 "Return a list of available PostgreSQL databases."
@@ -1297,20 +1251,17 @@ add your name with a \"-U\" prefix (such as \"-Umark\") to the list."
1297 "Command to start isql by Interbase. 1251 "Command to start isql by Interbase.
1298 1252
1299Starts `sql-interactive-mode' after doing some setup." 1253Starts `sql-interactive-mode' after doing some setup."
1300 :type 'file 1254 :type 'file)
1301 :group 'SQL)
1302 1255
1303(defcustom sql-interbase-options nil 1256(defcustom sql-interbase-options nil
1304 "List of additional options for `sql-interbase-program'." 1257 "List of additional options for `sql-interbase-program'."
1305 :type '(repeat string) 1258 :type '(repeat string)
1306 :version "20.8" 1259 :version "20.8")
1307 :group 'SQL)
1308 1260
1309(defcustom sql-interbase-login-params '(user password database) 1261(defcustom sql-interbase-login-params '(user password database)
1310 "List of login parameters needed to connect to Interbase." 1262 "List of login parameters needed to connect to Interbase."
1311 :type 'sql-login-params 1263 :type 'sql-login-params
1312 :version "24.1" 1264 :version "24.1")
1313 :group 'SQL)
1314 1265
1315;; Customization for DB2 1266;; Customization for DB2
1316 1267
@@ -1318,20 +1269,17 @@ Starts `sql-interactive-mode' after doing some setup."
1318 "Command to start db2 by IBM. 1269 "Command to start db2 by IBM.
1319 1270
1320Starts `sql-interactive-mode' after doing some setup." 1271Starts `sql-interactive-mode' after doing some setup."
1321 :type 'file 1272 :type 'file)
1322 :group 'SQL)
1323 1273
1324(defcustom sql-db2-options nil 1274(defcustom sql-db2-options nil
1325 "List of additional options for `sql-db2-program'." 1275 "List of additional options for `sql-db2-program'."
1326 :type '(repeat string) 1276 :type '(repeat string)
1327 :version "20.8" 1277 :version "20.8")
1328 :group 'SQL)
1329 1278
1330(defcustom sql-db2-login-params nil 1279(defcustom sql-db2-login-params nil
1331 "List of login parameters needed to connect to DB2." 1280 "List of login parameters needed to connect to DB2."
1332 :type 'sql-login-params 1281 :type 'sql-login-params
1333 :version "24.1" 1282 :version "24.1")
1334 :group 'SQL)
1335 1283
1336;; Customization for Linter 1284;; Customization for Linter
1337 1285
@@ -1339,20 +1287,17 @@ Starts `sql-interactive-mode' after doing some setup."
1339 "Command to start inl by RELEX. 1287 "Command to start inl by RELEX.
1340 1288
1341Starts `sql-interactive-mode' after doing some setup." 1289Starts `sql-interactive-mode' after doing some setup."
1342 :type 'file 1290 :type 'file)
1343 :group 'SQL)
1344 1291
1345(defcustom sql-linter-options nil 1292(defcustom sql-linter-options nil
1346 "List of additional options for `sql-linter-program'." 1293 "List of additional options for `sql-linter-program'."
1347 :type '(repeat string) 1294 :type '(repeat string)
1348 :version "21.3" 1295 :version "21.3")
1349 :group 'SQL)
1350 1296
1351(defcustom sql-linter-login-params '(user password database server) 1297(defcustom sql-linter-login-params '(user password database server)
1352 "Login parameters to needed to connect to Linter." 1298 "Login parameters to needed to connect to Linter."
1353 :type 'sql-login-params 1299 :type 'sql-login-params
1354 :version "24.1" 1300 :version "24.1")
1355 :group 'SQL)
1356 1301
1357 1302
1358 1303
@@ -1436,10 +1381,7 @@ specified, it's `sql-product' or `sql-connection' must match."
1436 1381
1437(defvar sql-interactive-mode-map 1382(defvar sql-interactive-mode-map
1438 (let ((map (make-sparse-keymap))) 1383 (let ((map (make-sparse-keymap)))
1439 (if (fboundp 'set-keymap-parent) 1384 (set-keymap-parent map comint-mode-map)
1440 (set-keymap-parent map comint-mode-map); Emacs
1441 (if (fboundp 'set-keymap-parents)
1442 (set-keymap-parents map (list comint-mode-map)))); XEmacs
1443 (if (fboundp 'set-keymap-name) 1385 (if (fboundp 'set-keymap-name)
1444 (set-keymap-name map 'sql-interactive-mode-map)); XEmacs 1386 (set-keymap-name map 'sql-interactive-mode-map)); XEmacs
1445 (define-key map (kbd "C-j") 'sql-accumulate-and-indent) 1387 (define-key map (kbd "C-j") 'sql-accumulate-and-indent)
@@ -2374,7 +2316,8 @@ function `regexp-opt'.")
2374"ansi_warnings" "forceplan" "showplan_all" "showplan_text" 2316"ansi_warnings" "forceplan" "showplan_all" "showplan_text"
2375"statistics" "implicit_transactions" "remote_proc_transactions" 2317"statistics" "implicit_transactions" "remote_proc_transactions"
2376"transaction" "xact_abort" 2318"transaction" "xact_abort"
2377) t) 2319)
2320 t)
2378 "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$") 2321 "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")
2379 'font-lock-doc-face) 2322 'font-lock-doc-face)
2380 2323
@@ -2856,7 +2799,7 @@ See `sql-product-alist' for a list of products and supported features."
2856 (member feature sql-indirect-features) 2799 (member feature sql-indirect-features)
2857 (not not-indirect) 2800 (not not-indirect)
2858 (symbolp v)) 2801 (symbolp v))
2859 (eval v) 2802 (symbol-value v)
2860 v)) 2803 v))
2861 (error "`%s' is not a known product; use `sql-add-product' to add it first." product) 2804 (error "`%s' is not a known product; use `sql-add-product' to add it first." product)
2862 nil))) 2805 nil)))
@@ -4245,7 +4188,6 @@ must tell Emacs. Here's how to do that in your init file:
4245\(add-hook \\='sql-mode-hook 4188\(add-hook \\='sql-mode-hook
4246 (lambda () 4189 (lambda ()
4247 (modify-syntax-entry ?\\\\ \".\" sql-mode-syntax-table)))" 4190 (modify-syntax-entry ?\\\\ \".\" sql-mode-syntax-table)))"
4248 :group 'SQL
4249 :abbrev-table sql-mode-abbrev-table 4191 :abbrev-table sql-mode-abbrev-table
4250 4192
4251 (if sql-mode-menu 4193 (if sql-mode-menu
@@ -4280,7 +4222,7 @@ must tell Emacs. Here's how to do that in your init file:
4280(put 'sql-interactive-mode 'mode-class 'special) 4222(put 'sql-interactive-mode 'mode-class 'special)
4281(put 'sql-interactive-mode 'custom-mode-group 'SQL) 4223(put 'sql-interactive-mode 'custom-mode-group 'SQL)
4282;; FIXME: Why not use `define-derived-mode'? 4224;; FIXME: Why not use `define-derived-mode'?
4283(defun sql-interactive-mode () 4225(define-derived-mode sql-interactive-mode comint-mode "SQLi[?]"
4284 "Major mode to use a SQL interpreter interactively. 4226 "Major mode to use a SQL interpreter interactively.
4285 4227
4286Do not call this function by yourself. The environment must be 4228Do not call this function by yourself. The environment must be
@@ -4348,9 +4290,10 @@ you entered, right above the output it created.
4348 4290
4349\(setq comint-output-filter-functions 4291\(setq comint-output-filter-functions
4350 (function (lambda (STR) (comint-show-output))))" 4292 (function (lambda (STR) (comint-show-output))))"
4293 :syntax-table sql-mode-syntax-table
4351 ;; FIXME: The doc above uses `setq' on `comint-output-filter-functions', 4294 ;; FIXME: The doc above uses `setq' on `comint-output-filter-functions',
4352 ;; whereas hooks should be manipulated with things like `add/remove-hook'. 4295 ;; whereas hooks should be manipulated with things like `add/remove-hook'.
4353 (delay-mode-hooks (comint-mode)) 4296 :after-hook (sql--adjust-interactive-setup)
4354 4297
4355 ;; Get the `sql-product' for this interactive session. 4298 ;; Get the `sql-product' for this interactive session.
4356 (set (make-local-variable 'sql-product) 4299 (set (make-local-variable 'sql-product)
@@ -4358,14 +4301,11 @@ you entered, right above the output it created.
4358 sql-product)) 4301 sql-product))
4359 4302
4360 ;; Setup the mode. 4303 ;; Setup the mode.
4361 (setq major-mode 'sql-interactive-mode)
4362 (setq mode-name 4304 (setq mode-name
4363 (concat "SQLi[" (or (sql-get-product-feature sql-product :name) 4305 (concat "SQLi[" (or (sql-get-product-feature sql-product :name)
4364 (symbol-name sql-product)) "]")) 4306 (symbol-name sql-product)) "]"))
4365 (use-local-map sql-interactive-mode-map)
4366 (if sql-interactive-mode-menu 4307 (if sql-interactive-mode-menu
4367 (easy-menu-add sql-interactive-mode-menu)) ; XEmacs 4308 (easy-menu-add sql-interactive-mode-menu)) ; XEmacs
4368 (set-syntax-table sql-mode-syntax-table)
4369 4309
4370 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try 4310 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try
4371 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column 4311 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column
@@ -4409,9 +4349,10 @@ you entered, right above the output it created.
4409 (add-hook 'comint-preoutput-filter-functions 4349 (add-hook 'comint-preoutput-filter-functions
4410 #'sql-interactive-remove-continuation-prompt nil t) 4350 #'sql-interactive-remove-continuation-prompt nil t)
4411 (make-local-variable 'sql-input-ring-separator) 4351 (make-local-variable 'sql-input-ring-separator)
4412 (make-local-variable 'sql-input-ring-file-name) 4352 (make-local-variable 'sql-input-ring-file-name))
4413 ;; Run the mode hook (along with comint's hooks). 4353
4414 (run-mode-hooks 'sql-interactive-mode-hook) 4354(defun sql--adjust-interactive-setup ()
4355 "Finish the mode's setup after running the mode hook."
4415 ;; Set comint based on user overrides. 4356 ;; Set comint based on user overrides.
4416 (setq comint-prompt-regexp 4357 (setq comint-prompt-regexp
4417 (if sql-prompt-cont-regexp 4358 (if sql-prompt-cont-regexp
@@ -4490,7 +4431,7 @@ is specified in the connection settings."
4490 (dolist (vv connect-set) 4431 (dolist (vv connect-set)
4491 (let ((var (car vv)) 4432 (let ((var (car vv))
4492 (val (cadr vv))) 4433 (val (cadr vv)))
4493 (set-default var (eval val)))) 4434 (set-default var (eval val)))) ;FIXME: Why `eval'?
4494 (setq-default sql-connection connection) 4435 (setq-default sql-connection connection)
4495 4436
4496 ;; :sqli-login params variable 4437 ;; :sqli-login params variable
@@ -4521,10 +4462,10 @@ is specified in the connection settings."
4521 (if vals (cons var vals) var))))) 4462 (if vals (cons var vals) var)))))
4522 4463
4523 ;; Start the SQLi session with revised list of login parameters 4464 ;; Start the SQLi session with revised list of login parameters
4524 (eval `(let ((,param-var ',rem-vars)) 4465 (cl-progv (list param-var) (list rem-vars)
4525 (sql-product-interactive 4466 (sql-product-interactive
4526 ',sql-product 4467 sql-product
4527 ',(or buf-name (format "<%s>" connection)))))) 4468 (or buf-name (format "<%s>" connection)))))
4528 4469
4529 (user-error "SQL Connection <%s> does not exist" connection) 4470 (user-error "SQL Connection <%s> does not exist" connection)
4530 nil))) 4471 nil)))
@@ -4595,7 +4536,10 @@ optionally is saved to the user's init file."
4595 (format "Connection <%s>\t%s" (car conn) 4536 (format "Connection <%s>\t%s" (car conn)
4596 (let ((sql-user "") (sql-database "") 4537 (let ((sql-user "") (sql-database "")
4597 (sql-server "") (sql-port 0)) 4538 (sql-server "") (sql-port 0))
4598 (eval `(let ,(cdr conn) (sql-make-alternate-buffer-name))))) 4539 (cl-progv
4540 (mapcar #'car (cdr conn))
4541 (mapcar #'cadr (cdr conn))
4542 (sql-make-alternate-buffer-name))))
4599 (list 'sql-connect (car conn)) 4543 (list 'sql-connect (car conn))
4600 t)) 4544 t))
4601 sql-connection-alist) 4545 sql-connection-alist)
@@ -4977,8 +4921,7 @@ The default comes from `process-coding-system-alist' and
4977 4921
4978See the distinct values in ALL_OBJECTS.OBJECT_TYPE for possible values." 4922See the distinct values in ALL_OBJECTS.OBJECT_TYPE for possible values."
4979 :version "24.1" 4923 :version "24.1"
4980 :type '(repeat string) 4924 :type '(repeat string))
4981 :group 'SQL)
4982 4925
4983(defun sql-oracle-completion-object (sqlbuf schema) 4926(defun sql-oracle-completion-object (sqlbuf schema)
4984 (sql-redirect-value 4927 (sql-redirect-value
@@ -5624,21 +5567,18 @@ buffer.
5624(defcustom sql-vertica-program "vsql" 5567(defcustom sql-vertica-program "vsql"
5625 "Command to start the Vertica client." 5568 "Command to start the Vertica client."
5626 :version "25.1" 5569 :version "25.1"
5627 :type 'file 5570 :type 'file)
5628 :group 'SQL)
5629 5571
5630(defcustom sql-vertica-options '("-P" "pager=off") 5572(defcustom sql-vertica-options '("-P" "pager=off")
5631 "List of additional options for `sql-vertica-program'. 5573 "List of additional options for `sql-vertica-program'.
5632The default value disables the internal pager." 5574The default value disables the internal pager."
5633 :version "25.1" 5575 :version "25.1"
5634 :type '(repeat string) 5576 :type '(repeat string))
5635 :group 'SQL)
5636 5577
5637(defcustom sql-vertica-login-params '(user password database server) 5578(defcustom sql-vertica-login-params '(user password database server)
5638 "List of login parameters needed to connect to Vertica." 5579 "List of login parameters needed to connect to Vertica."
5639 :version "25.1" 5580 :version "25.1"
5640 :type 'sql-login-params 5581 :type 'sql-login-params)
5641 :group 'SQL)
5642 5582
5643(defun sql-comint-vertica (product options &optional buf-name) 5583(defun sql-comint-vertica (product options &optional buf-name)
5644 "Create comint buffer and connect to Vertica." 5584 "Create comint buffer and connect to Vertica."