diff options
| author | Juanma Barranquero | 2003-07-14 20:39:39 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-07-14 20:39:39 +0000 |
| commit | b4dd5c9ca599e6d54056f0116cada2780becaf98 (patch) | |
| tree | b82576632f21438557664091c3ed02afab33b618 | |
| parent | 71c884868f720517cfc3d7bb86f9fc456c9a6763 (diff) | |
| download | emacs-b4dd5c9ca599e6d54056f0116cada2780becaf98.tar.gz emacs-b4dd5c9ca599e6d54056f0116cada2780becaf98.zip | |
Revert last change.
| -rw-r--r-- | lisp/progmodes/sql.el | 1026 |
1 files changed, 156 insertions, 870 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 420f4d41613..4be9ec903f6 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | ;;; sql.el --- specialized comint.el for SQL interpreters | 1 | ;;; sql.el --- specialized comint.el for SQL interpreters |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | 5 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 6 | ;; Maintainer: Alex Schroeder <alex@gnu.org> | 6 | ;; Maintainer: Alex Schroeder <alex@gnu.org> |
| 7 | ;; Version: 1.8.0 | 7 | ;; Version: 1.7.0 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode | 9 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
| 10 | 10 | ||
| @@ -78,114 +78,24 @@ | |||
| 78 | 78 | ||
| 79 | ;;; Bugs: | 79 | ;;; Bugs: |
| 80 | 80 | ||
| 81 | ;; sql-ms now uses osql instead of isql. Osql flushes its error | 81 | ;; Using sql-ms (isql by Microsoft): When commands with syntax errors |
| 82 | ;; stream more frequently than isql so that error messages are | 82 | ;; or execution errors are executed, there is no server feedback. |
| 83 | ;; available. There is no prompt and some output still is buffered. | 83 | ;; This happens in stored procedures for example. The server messages |
| 84 | ;; This improves the interaction under Emacs but it still is somewhat | 84 | ;; only appear after the process is exited. This makes things |
| 85 | ;; awkward. | 85 | ;; somewhat unreliable. |
| 86 | |||
| 87 | ;; Quoted identifiers are not supported for hilighting. Most | ||
| 88 | ;; databases support the use of double quoted strings in place of | ||
| 89 | ;; identifiers; ms (Microsoft SQLServer) also supports identifiers | ||
| 90 | ;; enclosed within brackets []. | ||
| 91 | 86 | ||
| 92 | ;; ChangeLog available on request. | 87 | ;; ChangeLog available on request. |
| 93 | 88 | ||
| 94 | ;;; Product Support: | 89 | ;;; To Do: |
| 95 | 90 | ||
| 96 | ;; Set the variable `sql-product' to the product you usually use. If | 91 | ;; Add better hilight support for other brands; there is a bias towards |
| 97 | ;; you occasionally use another product, for certain files, add a | 92 | ;; Oracle because that's what I use at work. Anybody else just send in |
| 98 | ;; comment on the first line of the file saying | 93 | ;; your lists of reserved words, keywords and builtin functions! As |
| 99 | ;; -*- sql-product: mysql -*- | 94 | ;; long as I don't receive any feedback, everything is hilighted with |
| 100 | ;; See section "File Variables" in the Emacs manual for more info. | 95 | ;; ANSI keywords only. I received the list of ANSI keywords from a |
| 101 | 96 | ;; user; if you know of any changes, let me know. | |
| 102 | ;;; Adding another product: | 97 | |
| 103 | 98 | ;; Add different hilighting levels. | |
| 104 | ;; To add support for additional SQL products the following steps | ||
| 105 | ;; must be followed ("xyz" is the name of the product in the examples | ||
| 106 | ;; below): | ||
| 107 | |||
| 108 | ;; 1) Add the product to `sql-product' choice list. | ||
| 109 | |||
| 110 | ;; (const :tag "XyzDB" xyz) | ||
| 111 | |||
| 112 | ;; 2) Add an entry to the `sql-product-support' list. | ||
| 113 | |||
| 114 | ;; (xyz | ||
| 115 | ;; :font-lock sql-mode-xyz-font-lock-keywords | ||
| 116 | ;; :sqli-login (user password server database) | ||
| 117 | ;; :sqli-connect sql-connect-xyz | ||
| 118 | ;; :sqli-prompt-regexp "^xyzdb> " | ||
| 119 | ;; :sqli-prompt-length 7 | ||
| 120 | ;; :sqli-input-sender nil | ||
| 121 | ;; :syntax-alist ((?# . "w"))) | ||
| 122 | |||
| 123 | ;; 3) Add customizable values for the product interpreter and options. | ||
| 124 | |||
| 125 | ;; ;; Customization for XyzDB | ||
| 126 | ;; | ||
| 127 | ;; (defcustom sql-xyz-program "ixyz" | ||
| 128 | ;; "*Command to start ixyz by XyzDB." | ||
| 129 | ;; :type 'file | ||
| 130 | ;; :group 'SQL) | ||
| 131 | ;; | ||
| 132 | ;; (defcustom sql-xyz-options '("-X" "-Y" "-Z") | ||
| 133 | ;; "*List of additional options for `sql-xyz-program'." | ||
| 134 | ;; :type '(repeat string) | ||
| 135 | ;; :group 'SQL) | ||
| 136 | |||
| 137 | ;; 4) Add an entry to SQL->Product submenu. | ||
| 138 | |||
| 139 | ;; ["XyzDB" sql-highlight-xyz-keywords | ||
| 140 | ;; :style radio | ||
| 141 | ;; :selected (eq sql-product 'xyz)] | ||
| 142 | |||
| 143 | ;; 5) Add the font-lock specifications. At a minimum, default to | ||
| 144 | ;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for | ||
| 145 | ;; a more complex example. | ||
| 146 | |||
| 147 | ;; (defvar sql-mode-xyz-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 148 | ;; "XyzDB SQL keywords used by font-lock.") | ||
| 149 | |||
| 150 | ;; 6) Add a product highlighting function. | ||
| 151 | |||
| 152 | ;; (defun sql-highlight-xyz-keywords () | ||
| 153 | ;; "Highlight XyzDB keywords." | ||
| 154 | ;; (interactive) | ||
| 155 | ;; (sql-set-product 'xyz)) | ||
| 156 | |||
| 157 | ;; 7) Add an autoloaded SQLi function. | ||
| 158 | |||
| 159 | ;; ;;;###autoload | ||
| 160 | ;; (defun sql-xyz () | ||
| 161 | ;; "Run ixyz by XyzDB as an inferior process." | ||
| 162 | ;; (interactive) | ||
| 163 | ;; (sql-product-interactive 'xyz)) | ||
| 164 | |||
| 165 | ;; 8) Add a connect function which formats the command line arguments | ||
| 166 | ;; and starts the product interpreter in a comint buffer. See the | ||
| 167 | ;; existing connect functions for examples of the types of | ||
| 168 | ;; processing available. | ||
| 169 | |||
| 170 | ;; (defun sql-connect-xyz () | ||
| 171 | ;; "Create comint buffer and connect to XyzDB using the login | ||
| 172 | ;; parameters and command options." | ||
| 173 | ;; | ||
| 174 | ;; ;; Do something with `sql-user', `sql-password', | ||
| 175 | ;; ;; `sql-database', and `sql-server'. | ||
| 176 | ;; (let ((params sql-xyz-options)) | ||
| 177 | ;; (if (not (string= "" sql-server)) | ||
| 178 | ;; (setq params (append (list "-S" sql-server) params))) | ||
| 179 | ;; (if (not (string= "" sql-database)) | ||
| 180 | ;; (setq params (append (list "-D" sql-database) params))) | ||
| 181 | ;; (if (not (string= "" sql-password)) | ||
| 182 | ;; (setq params (append (list "-P" sql-password) params))) | ||
| 183 | ;; (if (not (string= "" sql-user)) | ||
| 184 | ;; (setq params (append (list "-U" sql-user) params))) | ||
| 185 | ;; (set-buffer (apply 'make-comint "SQL" sql-xyz-program | ||
| 186 | ;; nil params)))) | ||
| 187 | |||
| 188 | ;; 9) Save and compile sql.el. | ||
| 189 | 99 | ||
| 190 | ;;; Thanks to all the people who helped me out: | 100 | ;;; Thanks to all the people who helped me out: |
| 191 | 101 | ||
| @@ -195,7 +105,6 @@ | |||
| 195 | ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> | 105 | ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> |
| 196 | ;; nino <nino@inform.dk> | 106 | ;; nino <nino@inform.dk> |
| 197 | ;; Berend de Boer <berend@pobox.com> | 107 | ;; Berend de Boer <berend@pobox.com> |
| 198 | ;; Michael Mauger <mmaug@yahoo.com> | ||
| 199 | 108 | ||
| 200 | 109 | ||
| 201 | 110 | ||
| @@ -203,8 +112,7 @@ | |||
| 203 | 112 | ||
| 204 | (require 'comint) | 113 | (require 'comint) |
| 205 | ;; Need the following to allow GNU Emacs 19 to compile the file. | 114 | ;; Need the following to allow GNU Emacs 19 to compile the file. |
| 206 | (eval-when-compile | 115 | (require 'regexp-opt) |
| 207 | (require 'regexp-opt)) | ||
| 208 | (require 'custom) | 116 | (require 'custom) |
| 209 | 117 | ||
| 210 | ;;; Allow customization | 118 | ;;; Allow customization |
| @@ -214,7 +122,7 @@ | |||
| 214 | :version "20.4" | 122 | :version "20.4" |
| 215 | :group 'processes) | 123 | :group 'processes) |
| 216 | 124 | ||
| 217 | ;; These four variables will be used as defaults, if set. | 125 | ;; These three variables will be used as defaults, if set. |
| 218 | 126 | ||
| 219 | (defcustom sql-user "" | 127 | (defcustom sql-user "" |
| 220 | "*Default username." | 128 | "*Default username." |
| @@ -239,145 +147,6 @@ Customizing your password will store it in your ~/.emacs file." | |||
| 239 | :type 'string | 147 | :type 'string |
| 240 | :group 'SQL) | 148 | :group 'SQL) |
| 241 | 149 | ||
| 242 | ;; SQL Product support | ||
| 243 | (defcustom sql-product 'ansi | ||
| 244 | "*Select the SQL database product used so that buffers can be | ||
| 245 | highlighted properly when you open them." | ||
| 246 | :type '(choice (const :tag "ANSI" ansi) | ||
| 247 | (const :tag "DB2" db2) | ||
| 248 | (const :tag "Informix" informix) | ||
| 249 | (const :tag "Ingres" ingres) | ||
| 250 | (const :tag "Interbase" interbase) | ||
| 251 | (const :tag "Linter" linter) | ||
| 252 | (const :tag "Microsoft" ms) | ||
| 253 | (const :tag "MySQL" mysql) | ||
| 254 | (const :tag "Oracle" oracle) | ||
| 255 | (const :tag "PostGres" postgres) | ||
| 256 | (const :tag "Solid" solid) | ||
| 257 | (const :tag "SQLite" sqlite) | ||
| 258 | (const :tag "Sybase" sybase)) | ||
| 259 | :group 'SQL) | ||
| 260 | |||
| 261 | (defvar sql-interactive-product nil | ||
| 262 | "Product under `sql-interactive-mode'.") | ||
| 263 | |||
| 264 | (defvar sql-product-support | ||
| 265 | '((ansi | ||
| 266 | :font-lock sql-mode-ansi-font-lock-keywords) | ||
| 267 | (db2 | ||
| 268 | :font-lock sql-mode-db2-font-lock-keywords | ||
| 269 | :sqli-login nil | ||
| 270 | :sqli-connect sql-connect-db2 | ||
| 271 | :sqli-prompt-regexp "^db2 => " | ||
| 272 | :sqli-prompt-length 7) | ||
| 273 | (informix | ||
| 274 | :font-lock sql-mode-informix-font-lock-keywords | ||
| 275 | :sqli-login (database) | ||
| 276 | :sqli-connect sql-connect-informix | ||
| 277 | :sqli-prompt-regexp "^SQL> " | ||
| 278 | :sqli-prompt-length 5) | ||
| 279 | (ingres | ||
| 280 | :font-lock sql-mode-ingres-font-lock-keywords | ||
| 281 | :sqli-login (database) | ||
| 282 | :sqli-connect sql-connect-ingres | ||
| 283 | :sqli-prompt-regexp "^\* " | ||
| 284 | :sqli-prompt-length 2) | ||
| 285 | (interbase | ||
| 286 | :font-lock sql-mode-interbase-font-lock-keywords | ||
| 287 | :sqli-login (user password database) | ||
| 288 | :sqli-connect sql-connect-interbase | ||
| 289 | :sqli-prompt-regexp "^SQL> " | ||
| 290 | :sqli-prompt-length 5) | ||
| 291 | (linter | ||
| 292 | :font-lock sql-mode-linter-font-lock-keywords | ||
| 293 | :sqli-login (user password database server) | ||
| 294 | :sqli-connect sql-connect-linter | ||
| 295 | :sqli-prompt-regexp "^SQL>" | ||
| 296 | :sqli-prompt-length 4) | ||
| 297 | (ms | ||
| 298 | :font-lock sql-mode-ms-font-lock-keywords | ||
| 299 | :sqli-login (user password server database) | ||
| 300 | :sqli-connect sql-connect-ms | ||
| 301 | :sqli-prompt-regexp "^[0-9]*>" | ||
| 302 | :sqli-prompt-length 5 | ||
| 303 | :syntax-alist ((?@ . "w"))) | ||
| 304 | (mysql | ||
| 305 | :font-lock sql-mode-mysql-font-lock-keywords | ||
| 306 | :sqli-login (user password database server) | ||
| 307 | :sqli-connect sql-connect-mysql | ||
| 308 | :sqli-prompt-regexp "^mysql> " | ||
| 309 | :sqli-prompt-length 6) | ||
| 310 | (oracle | ||
| 311 | :font-lock sql-mode-oracle-font-lock-keywords | ||
| 312 | :sqli-login (user password database) | ||
| 313 | :sqli-connect sql-connect-oracle | ||
| 314 | :sqli-prompt-regexp "^SQL> " | ||
| 315 | :sqli-prompt-length 5 | ||
| 316 | :syntax-alist ((?$ . "w") (?# . "w"))) | ||
| 317 | (postgres | ||
| 318 | :font-lock sql-mode-postgres-font-lock-keywords | ||
| 319 | :sqli-login (database server) | ||
| 320 | :sqli-connect sql-connect-postgres | ||
| 321 | :sqli-prompt-regexp "^.*> *" | ||
| 322 | :sqli-prompt-length 5) | ||
| 323 | (solid | ||
| 324 | :font-lock sql-mode-solid-font-lock-keywords | ||
| 325 | :sqli-login (user password server) | ||
| 326 | :sqli-connect sql-connect-solid | ||
| 327 | :sqli-prompt-regexp "^" | ||
| 328 | :sqli-prompt-length 0) | ||
| 329 | (sqlite | ||
| 330 | :font-lock sql-mode-sqlite-font-lock-keywords | ||
| 331 | :sqli-login (user password server database) | ||
| 332 | :sqli-connect sql-connect-sqlite | ||
| 333 | :sqli-prompt-regexp "^sqlite> " | ||
| 334 | :sqli-prompt-length 8) | ||
| 335 | (sybase | ||
| 336 | :font-lock sql-mode-sybase-font-lock-keywords | ||
| 337 | :sqli-login (server user password database) | ||
| 338 | :sqli-connect sql-connect-sybase | ||
| 339 | :sqli-prompt-regexp "^SQL> " | ||
| 340 | :sqli-prompt-length 5 | ||
| 341 | :syntax-alist ((?@ . "w"))) | ||
| 342 | ) | ||
| 343 | "This variable contains a list of product features for each of the | ||
| 344 | SQL products handled by `sql-mode'. Without an entry in this list a | ||
| 345 | product will not be properly highlighted and will not support | ||
| 346 | `sql-interactive-mode'. | ||
| 347 | |||
| 348 | Each element in the list is in the following format: | ||
| 349 | |||
| 350 | \(PRODUCT FEATURE VALUE ...) | ||
| 351 | |||
| 352 | where PRODUCT is the appropriate value of `sql-product'. The product | ||
| 353 | name is then followed by FEATURE-VALUE pairs. If a FEATURE is not | ||
| 354 | specified, its VALUE is treated as nil. FEATURE must be one of the | ||
| 355 | following: | ||
| 356 | |||
| 357 | :font-lock name of the variable containing the product | ||
| 358 | specific font lock highlighting patterns. | ||
| 359 | |||
| 360 | :sqli-login a list of login parameters (i.e., user, | ||
| 361 | password, database and server) needed to | ||
| 362 | connect to the database. | ||
| 363 | |||
| 364 | :sqli-connect the name of a function which accepts no | ||
| 365 | parameters that will use the values of | ||
| 366 | `sql-user', `sql-password', | ||
| 367 | `sql-database' and `sql-server' to open a | ||
| 368 | comint buffer and connect to the | ||
| 369 | database. Do product specific | ||
| 370 | configuration of comint in this function. | ||
| 371 | |||
| 372 | :sqli-prompt-regexp a regular expression string that matches the | ||
| 373 | prompt issued by the product interpreter. | ||
| 374 | |||
| 375 | :sqli-prompt-length the length of the prompt on the line. | ||
| 376 | |||
| 377 | :syntax-alist an alist of syntax table entries to enable | ||
| 378 | special character treatment by font-lock and | ||
| 379 | imenu. ") | ||
| 380 | |||
| 381 | ;; misc customization of sql.el behaviour | 150 | ;; misc customization of sql.el behaviour |
| 382 | 151 | ||
| 383 | (defcustom sql-electric-stuff nil | 152 | (defcustom sql-electric-stuff nil |
| @@ -408,15 +177,8 @@ buffer is shown using `display-buffer'." | |||
| 408 | ;; imenu support for sql-mode. | 177 | ;; imenu support for sql-mode. |
| 409 | 178 | ||
| 410 | (defvar sql-imenu-generic-expression | 179 | (defvar sql-imenu-generic-expression |
| 411 | ;; Items are in reverse order because they are rendered in reverse. | 180 | '(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1) |
| 412 | '(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2) | 181 | ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)) |
| 413 | ("Sequences" "^\\s-*create\\s-+sequence\\s-+\\(\\w+\\)" 1) | ||
| 414 | ("Triggers" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?trigger\\s-+\\(\\w+\\)" 3) | ||
| 415 | ("Functions" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?function\\s-+\\(\\w+\\)" 3) | ||
| 416 | ("Procedures" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) | ||
| 417 | ("Packages" "^\\s-*create\\s-+\\(or\\s-+replace\\s-+\\)?package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) | ||
| 418 | ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1) | ||
| 419 | ("Tables/Views" "^\\s-*create\\s-+\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\)\\s-+\\(\\w+\\)" 4)) | ||
| 420 | "Define interesting points in the SQL buffer for `imenu'. | 182 | "Define interesting points in the SQL buffer for `imenu'. |
| 421 | 183 | ||
| 422 | This is used to set `imenu-generic-expression' when SQL mode is | 184 | This is used to set `imenu-generic-expression' when SQL mode is |
| @@ -512,7 +274,7 @@ The program can also specify a TCP connection. See `make-comint'." | |||
| 512 | :group 'SQL) | 274 | :group 'SQL) |
| 513 | 275 | ||
| 514 | (defcustom sql-sqlite-options nil | 276 | (defcustom sql-sqlite-options nil |
| 515 | "*List of additional options for `sql-sqlite-program'. | 277 | "*List of additional options for `sql-mysql-program'. |
| 516 | The following list of options is reported to make things work | 278 | The following list of options is reported to make things work |
| 517 | on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." | 279 | on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." |
| 518 | :type '(repeat string) | 280 | :type '(repeat string) |
| @@ -591,8 +353,8 @@ The program can also specify a TCP connection. See `make-comint'." | |||
| 591 | 353 | ||
| 592 | ;; Customization for Microsoft | 354 | ;; Customization for Microsoft |
| 593 | 355 | ||
| 594 | (defcustom sql-ms-program "osql" | 356 | (defcustom sql-ms-program "isql" |
| 595 | "*Command to start osql by Microsoft. | 357 | "*Command to start isql by Microsoft. |
| 596 | 358 | ||
| 597 | Starts `sql-interactive-mode' after doing some setup. | 359 | Starts `sql-interactive-mode' after doing some setup. |
| 598 | 360 | ||
| @@ -706,12 +468,12 @@ the local value of `sql-buffer' using \\[sql-set-sqli-buffer].") | |||
| 706 | (defvar sql-prompt-regexp nil | 468 | (defvar sql-prompt-regexp nil |
| 707 | "Prompt used to initialize `comint-prompt-regexp'. | 469 | "Prompt used to initialize `comint-prompt-regexp'. |
| 708 | 470 | ||
| 709 | You can change `sql-prompt-regexp' on `sql-interactive-mode-hook'.") | 471 | You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.") |
| 710 | 472 | ||
| 711 | (defvar sql-prompt-length 0 | 473 | (defvar sql-prompt-length 0 |
| 712 | "Prompt used to set `left-margin' in `sql-interactive-mode'. | 474 | "Prompt used to set `left-margin' in `sql-interactive-mode'. |
| 713 | 475 | ||
| 714 | You can change `sql-prompt-length' on `sql-interactive-mode-hook'.") | 476 | You can change it on `sql-interactive-mode-hook'.") |
| 715 | 477 | ||
| 716 | (defvar sql-alternate-buffer-name nil | 478 | (defvar sql-alternate-buffer-name nil |
| 717 | "Buffer-local string used to possibly rename the SQLi buffer. | 479 | "Buffer-local string used to possibly rename the SQLi buffer. |
| @@ -756,60 +518,22 @@ Based on `comint-mode-map'.") | |||
| 756 | (get-buffer-process sql-buffer))] | 518 | (get-buffer-process sql-buffer))] |
| 757 | ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs | 519 | ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
| 758 | mark-active) | 520 | mark-active) |
| 759 | (mark t)); XEmacs | 521 | (mark)); XEmacs |
| 760 | (buffer-live-p sql-buffer) | 522 | (buffer-live-p sql-buffer) |
| 761 | (get-buffer-process sql-buffer))] | 523 | (get-buffer-process sql-buffer))] |
| 762 | ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) | 524 | ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
| 763 | (get-buffer-process sql-buffer))] | 525 | (get-buffer-process sql-buffer))] |
| 764 | ["--" nil nil] | ||
| 765 | ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)] | ||
| 766 | ["Show SQLi buffer" sql-show-sqli-buffer t] | 526 | ["Show SQLi buffer" sql-show-sqli-buffer t] |
| 767 | ["Set SQLi buffer" sql-set-sqli-buffer t] | 527 | ["Set SQLi buffer" sql-set-sqli-buffer t] |
| 768 | ["Pop to SQLi buffer after send" | 528 | ["Pop to SQLi buffer after send" |
| 769 | sql-toggle-pop-to-buffer-after-send-region | 529 | sql-toggle-pop-to-buffer-after-send-region |
| 770 | :style toggle | 530 | :style toggle |
| 771 | :selected sql-pop-to-buffer-after-send-region] | 531 | :selected sql-pop-to-buffer-after-send-region] |
| 772 | ["--" nil nil] | 532 | ("Highlighting" |
| 773 | ("Product" | 533 | ["ANSI SQL keywords" sql-highlight-ansi-keywords t] |
| 774 | ["ANSI" sql-highlight-ansi-keywords | 534 | ["Oracle keywords" sql-highlight-oracle-keywords t] |
| 775 | :style radio | 535 | ["Postgres keywords" sql-highlight-postgres-keywords t] |
| 776 | :selected (eq sql-product 'ansi)] | 536 | ["Linter keywords" sql-highlight-linter-keywords t] |
| 777 | ["DB2" sql-highlight-db2-keywords | ||
| 778 | :style radio | ||
| 779 | :selected (eq sql-product 'db2)] | ||
| 780 | ["Informix" sql-highlight-informix-keywords | ||
| 781 | :style radio | ||
| 782 | :selected (eq sql-product 'informix)] | ||
| 783 | ["Ingres" sql-highlight-ingres-keywords | ||
| 784 | :style radio | ||
| 785 | :selected (eq sql-product 'ingres)] | ||
| 786 | ["Interbase" sql-highlight-interbase-keywords | ||
| 787 | :style radio | ||
| 788 | :selected (eq sql-product 'interbase)] | ||
| 789 | ["Linter" sql-highlight-linter-keywords | ||
| 790 | :style radio | ||
| 791 | :selected (eq sql-product 'linter)] | ||
| 792 | ["Microsoft" sql-highlight-ms-keywords | ||
| 793 | :style radio | ||
| 794 | :selected (eq sql-product 'ms)] | ||
| 795 | ["MySQL" sql-highlight-mysql-keywords | ||
| 796 | :style radio | ||
| 797 | :selected (eq sql-product 'mysql)] | ||
| 798 | ["Oracle" sql-highlight-oracle-keywords | ||
| 799 | :style radio | ||
| 800 | :selected (eq sql-product 'oracle)] | ||
| 801 | ["Postgres" sql-highlight-postgres-keywords | ||
| 802 | :style radio | ||
| 803 | :selected (eq sql-product 'postgres)] | ||
| 804 | ["Solid" sql-highlight-solid-keywords | ||
| 805 | :style radio | ||
| 806 | :selected (eq sql-product 'solid)] | ||
| 807 | ["SQLite" sql-highlight-sqlite-keywords | ||
| 808 | :style radio | ||
| 809 | :selected (eq sql-product 'sqlite)] | ||
| 810 | ["Sybase" sql-highlight-sybase-keywords | ||
| 811 | :style radio | ||
| 812 | :selected (eq sql-product 'sybase)] | ||
| 813 | ))) | 537 | ))) |
| 814 | 538 | ||
| 815 | ;; easy menu for sql-interactive-mode. | 539 | ;; easy menu for sql-interactive-mode. |
| @@ -827,22 +551,12 @@ Based on `comint-mode-map'.") | |||
| 827 | "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") | 551 | "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") |
| 828 | (if sql-mode-abbrev-table | 552 | (if sql-mode-abbrev-table |
| 829 | () | 553 | () |
| 830 | (let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev)))) | 554 | (let ((wrapper)) |
| 831 | d-a) | 555 | (define-abbrev-table 'sql-mode-abbrev-table ()) |
| 832 | ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. | 556 | (define-abbrev sql-mode-abbrev-table "ins" "insert") |
| 833 | (setq d-a | 557 | (define-abbrev sql-mode-abbrev-table "upd" "update") |
| 834 | (if (>= nargs 6) | 558 | (define-abbrev sql-mode-abbrev-table "del" "delete") |
| 835 | '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)) | 559 | (define-abbrev sql-mode-abbrev-table "sel" "select"))) |
| 836 | '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion)))) | ||
| 837 | |||
| 838 | (define-abbrev-table 'sql-mode-abbrev-table nil) | ||
| 839 | (funcall d-a "ins" "insert") | ||
| 840 | (funcall d-a "upd" "update") | ||
| 841 | (funcall d-a "del" "delete") | ||
| 842 | (funcall d-a "sel" "select") | ||
| 843 | (funcall d-a "proc" "procedure") | ||
| 844 | (funcall d-a "func" "function") | ||
| 845 | (funcall d-a "cr" "create"))) | ||
| 846 | 560 | ||
| 847 | ;; Syntax Table | 561 | ;; Syntax Table |
| 848 | 562 | ||
| @@ -867,253 +581,146 @@ Based on `comint-mode-map'.") | |||
| 867 | 581 | ||
| 868 | ;; Font lock support | 582 | ;; Font lock support |
| 869 | 583 | ||
| 870 | (defvar sql-mode-font-lock-object-name | 584 | (defvar sql-mode-ansi-font-lock-keywords nil |
| 871 | (list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+" | 585 | "ANSI SQL keywords used by font-lock. |
| 872 | "\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\|package\\(\\s-+body\\)?\\|" | ||
| 873 | "proc\\(edure\\)?\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+\\(\\w+\\)") | ||
| 874 | 8 'font-lock-function-name-face) | ||
| 875 | |||
| 876 | "Pattern to match the names of top-level objects in a CREATE, | ||
| 877 | DROP or ALTER statement. | ||
| 878 | |||
| 879 | The format of variable should be a valid `font-lock-keywords' | ||
| 880 | entry.") | ||
| 881 | 586 | ||
| 882 | (defvar sql-mode-ansi-font-lock-keywords | 587 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| 588 | regular expressions are created during compilation by calling the | ||
| 589 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 590 | you define your own sql-mode-ansi-font-lock-keywords. You may want to | ||
| 591 | add functions and PL/SQL keywords.") | ||
| 592 | (if sql-mode-ansi-font-lock-keywords | ||
| 593 | () | ||
| 883 | (let ((ansi-keywords (eval-when-compile | 594 | (let ((ansi-keywords (eval-when-compile |
| 884 | (concat "\\b" | 595 | (concat "\\b" |
| 885 | (regexp-opt '( | 596 | (regexp-opt '( |
| 886 | |||
| 887 | "authorization" "avg" "begin" "close" "cobol" "commit" | 597 | "authorization" "avg" "begin" "close" "cobol" "commit" |
| 888 | "continue" "count" "declare" "double" "end" "escape" | 598 | "continue" "count" "declare" "double" "end" "escape" |
| 889 | "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | 599 | "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
| 890 | "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | 600 | "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
| 891 | "precision" "primary" "procedure" "references" "rollback" | 601 | "precision" "primary" "procedure" "references" "rollback" |
| 892 | "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" | 602 | "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b"))) |
| 893 | |||
| 894 | ) t) "\\b"))) | ||
| 895 | (ansi-reserved-words (eval-when-compile | 603 | (ansi-reserved-words (eval-when-compile |
| 896 | (concat "\\b" | 604 | (concat "\\b" |
| 897 | (regexp-opt '( | 605 | (regexp-opt '( |
| 898 | |||
| 899 | "all" "and" "any" "as" "asc" "between" "by" "check" "create" | 606 | "all" "and" "any" "as" "asc" "between" "by" "check" "create" |
| 900 | "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | 607 | "current" "default" "delete" "desc" "distinct" "exists" "float" "for" |
| 901 | "from" "grant" "group" "having" "in" "insert" "into" "is" | 608 | "from" "grant" "group" "having" "in" "insert" "into" "is" |
| 902 | "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | 609 | "like" "not" "null" "of" "on" "option" "or" "order" "privileges" |
| 903 | "public" "select" "set" "table" "to" "union" "unique" | 610 | "public" "select" "set" "table" "to" "union" "unique" |
| 904 | "update" "user" "values" "view" "where" "with" | 611 | "update" "user" "values" "view" "where" "with") t) "\\b"))) |
| 905 | |||
| 906 | ) t) "\\b"))) | ||
| 907 | (ansi-types (eval-when-compile | 612 | (ansi-types (eval-when-compile |
| 908 | (concat "\\b" | 613 | (concat "\\b" |
| 909 | (regexp-opt '( | 614 | (regexp-opt '( |
| 910 | |||
| 911 | ;; ANSI Keywords that look like types | 615 | ;; ANSI Keywords that look like types |
| 912 | "character" "cursor" "dec" "int" "real" | 616 | "character" "cursor" "dec" "int" "real" |
| 913 | ;; ANSI Reserved Word that look like types | 617 | ;; ANSI Reserved Word that look like types |
| 914 | "char" "integer" "smallint" | 618 | "char" "integer" "smallint" ) t) "\\b")))) |
| 915 | 619 | (setq sql-mode-ansi-font-lock-keywords | |
| 916 | ) t) "\\b")))) | 620 | (list (cons ansi-keywords 'font-lock-function-name-face) |
| 917 | (list (cons ansi-keywords 'font-lock-keyword-face) | ||
| 918 | (cons ansi-reserved-words 'font-lock-keyword-face) | 621 | (cons ansi-reserved-words 'font-lock-keyword-face) |
| 919 | (cons ansi-types 'font-lock-type-face))) | 622 | (cons ansi-types 'font-lock-type-face))))) |
| 920 | 623 | ||
| 921 | "ANSI SQL keywords used by font-lock. | 624 | (defvar sql-mode-oracle-font-lock-keywords nil |
| 625 | "Oracle SQL keywords used by font-lock. | ||
| 922 | 626 | ||
| 923 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 627 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| 924 | regular expressions are created during compilation by calling the | 628 | regular expressions are created during compilation by calling the |
| 925 | function `regexp-opt'. Therefore, take a look at the source before | 629 | function `regexp-opt'. Therefore, take a look at the source before |
| 926 | you define your own sql-mode-ansi-font-lock-keywords. You may want to | 630 | you define your own sql-mode-oracle-font-lock-keywords. You may want |
| 927 | add functions and PL/SQL keywords.") | 631 | to add functions and PL/SQL keywords.") |
| 928 | 632 | (if sql-mode-oracle-font-lock-keywords | |
| 929 | (defvar sql-mode-oracle-font-lock-keywords | 633 | () |
| 930 | (let ((oracle-keywords (eval-when-compile | 634 | (let ((oracle-keywords (eval-when-compile |
| 931 | (concat "\\b" | 635 | (concat "\\b" |
| 932 | (regexp-opt '( | 636 | (regexp-opt '( |
| 933 | ;; Oracle (+ANSI) SQL keywords | 637 | "admin" "after" "allocate" "analyze" "archive" "archivelog" "backup" |
| 934 | 638 | "become" "before" "block" "body" "cache" "cancel" "cascade" "change" | |
| 935 | ; ANSI keywords | 639 | "checkpoint" "compile" "constraint" "constraints" "contents" |
| 936 | "authorization" "avg" "begin" "close" "cobol" "commit" | 640 | "controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount" |
| 937 | "continue" "count" "declare" "double" "end" "escape" | 641 | "dump" "each" "else" "elsif" "enable" "events" "except" "exceptions" |
| 938 | "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | 642 | "execute" "exit" "explain" "extent" "externally" "false" "flush" "force" |
| 939 | "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | 643 | "freelist" "freelists" "function" "groups" "if" "including" "initrans" |
| 940 | "precision" "primary" "procedure" "references" "rollback" | 644 | "instance" "layer" "link" "lists" "logfile" "loop" "manage" "manual" |
| 941 | "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" | 645 | "maxdatafiles" "maxinistances" "maxlogfiles" "maxloghistory" |
| 942 | 646 | "maxlogmembers" "maxtrans" "maxvalue" "minextents" "minvalue" "mount" | |
| 943 | ; ANSI reserved words | 647 | "new" "next" "noarchivelog" "nocache" "nocycle" "nomaxvalue" |
| 944 | "all" "and" "any" "as" "asc" "between" "by" "check" "create" | 648 | "nominvalue" "none" "noorder" "noresetlogs" "normal" "nosort" "off" |
| 945 | "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | 649 | "old" "only" "optimal" "others" "out" "own" "package" "parallel" |
| 946 | "from" "grant" "group" "having" "in" "insert" "into" "is" | 650 | "pctincrease" "pctused" "plan" "pragma" "private" "profile" "quota" |
| 947 | "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | 651 | "raise" "read" "recover" "referencing" "resetlogs" "restrict_references" |
| 948 | "public" "select" "set" "table" "to" "union" "unique" | 652 | "restricted" "return" "returning" "reuse" "rnds" "rnps" "role" "roles" |
| 949 | "update" "user" "values" "view" "where" "with" | 653 | "savepoint" "scn" "segment" "sequence" "shared" "snapshot" "sort" |
| 950 | 654 | "statement_id" "statistics" "stop" "storage" "subtype" "switch" "system" | |
| 951 | "access" "add" "admin" "after" "allocate" "alter" "analyze" "archive" | 655 | "tables" "tablespace" "temporary" "thread" "time" "tracing" |
| 952 | "archivelog" "audit" "authid" "backup" "become" "before" "block" | 656 | "transaction" "triggers" "true" "truncate" "type" "under" "unlimited" |
| 953 | "body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster" | 657 | "until" "use" "using" "when" "while" "wnds" "wnps" "write") t) "\\b"))) |
| 954 | "comment" "compile" "compress" "compute" "connect" "constraint" | ||
| 955 | "constraints" "contents" "controlfile" "cross" "currval" "cycle" | ||
| 956 | "database" "datafile" "dba" "deterministic" "disable" "dismount" | ||
| 957 | "drop" "dump" "each" "else" "else" "elsif" "enable" "events" "except" | ||
| 958 | "exceptions" "exclusive" "execute" "exit" "explain" "extent" | ||
| 959 | "externally" "false" "file" "flush" "force" "freelist" "freelists" | ||
| 960 | "full" "function" "global" "grant" "groups" "identified" "if" | ||
| 961 | "immediate" "including" "increment" "index" "initial" "initrans" | ||
| 962 | "inner" "instance" "intersect" "join" "layer" "left" "level" "link" | ||
| 963 | "lists" "lock" "logfile" "long" "loop" "manage" "manual" | ||
| 964 | "maxdatafiles" "maxextents" "maxinistances" "maxlogfiles" | ||
| 965 | "maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" "merge" | ||
| 966 | "minextents" "minus" "minvalue" "mode" "modify" "mount" "natural" | ||
| 967 | "new" "next" "nextval" "noarchivelog" "noaudit" "nocache" "nocompress" | ||
| 968 | "nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs" | ||
| 969 | "normal" "nosort" "nowait" "off" "offline" "old" "online" "only" | ||
| 970 | "optimal" "others" "out" "outer" "over" "own" "package" "parallel" | ||
| 971 | "parallel_enable" "pctfree" "pctincrease" "pctused" "plan" "pragma" | ||
| 972 | "preserve" "prior" "private" "profile" "quota" "raise" "raw" "read" | ||
| 973 | "recover" "referencing" "rename" "replace" "resetlogs" "resource" | ||
| 974 | "restrict_references" "restricted" "return" "returning" "reuse" | ||
| 975 | "revoke" "right" "rnds" "rnps" "role" "roles" "row" "rowlabel" | ||
| 976 | "rownum" "rows" "savepoint" "scn" "segment" "sequence" "session" | ||
| 977 | "share" "shared" "size" "snapshot" "sort" "statement_id" "statistics" | ||
| 978 | "stop" "storage" "subtype" "successful" "switch" "synonym" "sysdate" | ||
| 979 | "system" "tables" "tablespace" "temporary" "then" "thread" "tracing" | ||
| 980 | "transaction" "trigger" "triggers" "true" "truncate" "type" "uid" | ||
| 981 | "under" "unlimited" "until" "use" "using" "validate" "when" "while" | ||
| 982 | "wnds" "wnps" "write" | ||
| 983 | |||
| 984 | ) t) "\\b"))) | ||
| 985 | (oracle-warning-words (eval-when-compile | 658 | (oracle-warning-words (eval-when-compile |
| 986 | (concat "\\b" | 659 | (concat "\\b" |
| 987 | (regexp-opt '( | 660 | (regexp-opt '( |
| 988 | ;; PLSQL defined exceptions | 661 | "cursor_already_open" "dup_val_on_index" "exception" "invalid_cursor" |
| 989 | |||
| 990 | "access_into_null" "case_not_found" "collection_is_null" | ||
| 991 | "cursor_already_open" "dup_val_on_index" "invalid_cursor" | ||
| 992 | "invalid_number" "login_denied" "no_data_found" "not_logged_on" | 662 | "invalid_number" "login_denied" "no_data_found" "not_logged_on" |
| 993 | "program_error" "rowtype_mismatch" "self_is_null" "storage_error" | 663 | "notfound" "others" "pragma" "program_error" "storage_error" |
| 994 | "subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" | 664 | "timeout_on_resource" "too_many_rows" "transaction_backed_out" |
| 995 | "timeout_on_resource" "too_many_rows" "value_error" "zero_divide" | 665 | "value_error" "zero_divide") t) "\\b"))) |
| 996 | "exception" "notfound" | 666 | (oracle-reserved-words (eval-when-compile |
| 997 | 667 | (concat "\\b" | |
| 998 | ) t) "\\b"))) | ||
| 999 | |||
| 1000 | (oracle-sqlplus-commands | ||
| 1001 | (eval-when-compile | ||
| 1002 | (concat "^\\(\\(" | ||
| 1003 | (regexp-opt '( | 668 | (regexp-opt '( |
| 1004 | ;; SQL*Plus commands | 669 | "access" "add" "alter" "audit" "cluster" "column" "comment" "compress" |
| 1005 | 670 | "connect" "drop" "else" "exclusive" "file" "grant" | |
| 1006 | "@" "@@" "accept" "append" "archive" "attribute" "break" | 671 | "identified" "immediate" "increment" "index" "initial" "intersect" |
| 1007 | "btitle" "change" "clear" "column" "connect" "copy" "define" | 672 | "level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit" |
| 1008 | "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" | 673 | "nocompress" "nowait" "number" "offline" "online" "pctfree" "prior" |
| 1009 | "host" "input" "list" "password" "pause" "print" "prompt" "recover" | 674 | "raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum" |
| 1010 | "remark" "repfooter" "repheader" "run" "save" "show" "shutdown" | 675 | "rows" "session" "share" "size" "start" "successful" "synonym" "sysdate" |
| 1011 | "spool" "start" "startup" "store" "timing" "ttitle" "undefine" | 676 | "then" "trigger" "uid" "validate" "whenever") t) "\\b"))) |
| 1012 | "variable" "whenever" | 677 | (oracle-types (eval-when-compile |
| 1013 | |||
| 1014 | ) t) | ||
| 1015 | |||
| 1016 | "\\)\\|" | ||
| 1017 | "\\(compute\\s-+\\(avg\\|cou\\|min\\|max\\|num\\|sum\\|std\\|var\\)\\)\\|" | ||
| 1018 | "\\(set\\s-+\\(appi\\(nfo\\)?\\|array\\(size\\)?\\|" | ||
| 1019 | "auto\\(commit\\)?\\|autop\\(rint\\)?\\|autorecovery\\|" | ||
| 1020 | "autot\\(race\\)?\\|blo\\(ckterminator\\)?\\|cmds\\(ep\\)?\\|" | ||
| 1021 | "colsep\\|com\\(patibility\\)?\\|con\\(cat\\)?\\|" | ||
| 1022 | "copyc\\(ommit\\)?\\|copytypecheck\\|def\\(ine\\)?\\|" | ||
| 1023 | "describe\\|echo\\|editf\\(ile\\)?\\|emb\\(edded\\)?\\|" | ||
| 1024 | "esc\\(ape\\)?\\|feed\\(back\\)?\\|flagger\\|" | ||
| 1025 | "flu\\(sh\\)?\\|hea\\(ding\\)?\\|heads\\(ep\\)?\\|" | ||
| 1026 | "instance\\|lin\\(esize\\)?\\|lobof\\(fset\\)?\\|" | ||
| 1027 | "logsource\\|long\\|longc\\(hunksize\\)?\\|mark\\(up\\)?\\|" | ||
| 1028 | "newp\\(age\\)?\\|null\\|numf\\(ormat\\)?\\|" | ||
| 1029 | "num\\(width\\)?\\|pages\\(ize\\)?\\|pau\\(se\\)?\\|" | ||
| 1030 | "recsep\\|recsepchar\\|serverout\\(put\\)?\\|" | ||
| 1031 | "shift\\(inout\\)?\\|show\\(mode\\)?\\|" | ||
| 1032 | "sqlbl\\(anklines\\)?\\|sqlc\\(ase\\)?\\|" | ||
| 1033 | "sqlco\\(ntinue\\)?\\|sqln\\(umber\\)?\\|" | ||
| 1034 | "sqlpluscompat\\(ibility\\)?\\|sqlpre\\(fix\\)?\\|" | ||
| 1035 | "sqlp\\(rompt\\)?\\|sqlt\\(erminator\\)?\\|" | ||
| 1036 | "suf\\(fix\\)?\\|tab\\|term\\(out\\)?\\|ti\\(me\\)?\\|" | ||
| 1037 | "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|" | ||
| 1038 | "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)" | ||
| 1039 | "\\b.*$" | ||
| 1040 | ))) | ||
| 1041 | |||
| 1042 | (oracle-types | ||
| 1043 | (eval-when-compile | ||
| 1044 | (concat "\\b" | 678 | (concat "\\b" |
| 1045 | (regexp-opt '( | 679 | (regexp-opt '( |
| 1046 | ;; Oracle Keywords that look like types | 680 | ;; Oracle Keywords that look like types |
| 1047 | ;; Oracle Reserved Words that look like types | 681 | ;; Oracle Reserved Words that look like types |
| 1048 | 682 | "binary_integer" "blob" "boolean" "constant" "date" "decimal" "rowid" | |
| 1049 | "bfile" "binary_integer" "blob" "boolean" "byte" "char" "character" | 683 | "varchar" "varchar2") t) "\\b"))) |
| 1050 | "clob" "date" "day" "dec" "decimal" "double" "float" "int" "integer" | ||
| 1051 | "interval" "local" "long" "month" "natural" "naturaln" "nchar" "nclob" | ||
| 1052 | "number" "numeric" "nvarchar2" "pls_integer" "positive" "positiven" | ||
| 1053 | "precision" "raw" "real" "rowid" "second" "signtype" "smallint" | ||
| 1054 | "string" "time" "timestamp" "urowid" "varchar" "varchar2" "year" | ||
| 1055 | "zone" | ||
| 1056 | |||
| 1057 | ) t) "\\b"))) | ||
| 1058 | (oracle-builtin-functions (eval-when-compile | 684 | (oracle-builtin-functions (eval-when-compile |
| 1059 | (concat "\\b" | 685 | (concat "\\b" |
| 1060 | (regexp-opt '( | 686 | (regexp-opt '( |
| 1061 | ;; Misc Oracle builtin functions | 687 | ;; Misc Oracle builtin functions |
| 1062 | 688 | "abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat" | |
| 1063 | "abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2" | 689 | "convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor" |
| 1064 | "avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil" | 690 | "glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb" |
| 1065 | "chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr" | 691 | "last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower" |
| 1066 | "cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist" | 692 | "lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time" |
| 1067 | "current_date" "current_timestamp" "current_user" "dbtimezone" | 693 | "next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort" |
| 1068 | "decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob" | 694 | "nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad" |
| 1069 | "empty_clob" "existsnode" "exp" "extract" "extractvalue" "first" | 695 | "rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt" |
| 1070 | "first_value" "floor" "from_tz" "greatest" "group_id" "grouping" | 696 | "stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char" |
| 1071 | "grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day" | 697 | "to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte" |
| 1072 | "last_value" "lead" "least" "length" "ln" "localtimestamp" "log" | 698 | "translate" "trim" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b")))) |
| 1073 | "lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between" | 699 | (setq sql-mode-oracle-font-lock-keywords |
| 1074 | "nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id" | 700 | (append sql-mode-ansi-font-lock-keywords |
| 1075 | "nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper" | 701 | (list (cons oracle-keywords 'font-lock-function-name-face) |
| 1076 | "ntile" "nullif" "numtodsinterval" "numtoyminterval" "nvl" "nvl2" | ||
| 1077 | "path" "percent_rank" "percentile_cont" "percentile_disc" "power" | ||
| 1078 | "rank" "ratio_to_report" "rawtohex" "rawtonhex" "ref" "reftohex" | ||
| 1079 | "regr_slope" "regr_intercept" "regr_count" "regr_r2" "regr_avgx" | ||
| 1080 | "regr_avgy" "regr_sxx" "regr_syy" "regr_sxy" "round" | ||
| 1081 | "row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim" | ||
| 1082 | "sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev" | ||
| 1083 | "stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path" | ||
| 1084 | "sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid" | ||
| 1085 | "sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh" | ||
| 1086 | "to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte" | ||
| 1087 | "to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp" | ||
| 1088 | "to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc" | ||
| 1089 | "tz_offset" "uid" "unistr" "updatexml" "upper" "user" "userenv" | ||
| 1090 | "value" "var_pop" "var_samp" "variance" "vsize" "width_bucket" | ||
| 1091 | "xmlagg" "xmlcolattval" "xmlconcat" "xmlelement" "xmlforest" | ||
| 1092 | "xmlsequence" "xmltransform" | ||
| 1093 | |||
| 1094 | ) t) "\\b")))) | ||
| 1095 | (list (cons oracle-sqlplus-commands 'font-lock-doc-face) | ||
| 1096 | (cons oracle-keywords 'font-lock-keyword-face) | ||
| 1097 | (cons oracle-warning-words 'font-lock-warning-face) | 702 | (cons oracle-warning-words 'font-lock-warning-face) |
| 703 | (cons oracle-reserved-words 'font-lock-keyword-face) | ||
| 1098 | ;; XEmacs doesn't have font-lock-builtin-face | 704 | ;; XEmacs doesn't have font-lock-builtin-face |
| 1099 | (if (string-match "XEmacs\\|Lucid" emacs-version) | 705 | (if (string-match "XEmacs\\|Lucid" emacs-version) |
| 1100 | (cons oracle-builtin-functions 'font-lock-preprocessor-face) | 706 | (cons oracle-builtin-functions 'font-lock-preprocessor-face) |
| 1101 | ;; GNU Emacs 19 doesn't have it either | 707 | ;; GNU Emacs 19 doesn't have it either |
| 1102 | (if (string-match "GNU Emacs 19" emacs-version) | 708 | (if (string-match "GNU Emacs 19" emacs-version) |
| 1103 | (cons oracle-builtin-functions 'font-lock-keyword-face) | 709 | (cons oracle-builtin-functions 'font-lock-function-name-face) |
| 1104 | ;; Emacs | 710 | ;; Emacs |
| 1105 | (cons oracle-builtin-functions 'font-lock-builtin-face))) | 711 | (cons oracle-builtin-functions 'font-lock-builtin-face))) |
| 1106 | (cons oracle-types 'font-lock-type-face))) | 712 | (cons oracle-types 'font-lock-type-face)))))) |
| 1107 | 713 | ||
| 1108 | "Oracle SQL keywords used by font-lock. | 714 | (defvar sql-mode-postgres-font-lock-keywords nil |
| 715 | "Postgres SQL keywords used by font-lock. | ||
| 1109 | 716 | ||
| 1110 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 717 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| 1111 | regular expressions are created during compilation by calling the | 718 | regular expressions are created during compilation by calling the |
| 1112 | function `regexp-opt'. Therefore, take a look at the source before | 719 | function `regexp-opt'. Therefore, take a look at the source before |
| 1113 | you define your own sql-mode-oracle-font-lock-keywords. You may want | 720 | you define your own sql-mode-postgres-font-lock-keywords.") |
| 1114 | to add functions and PL/SQL keywords.") | ||
| 1115 | 721 | ||
| 1116 | (defvar sql-mode-postgres-font-lock-keywords | 722 | (if sql-mode-postgres-font-lock-keywords |
| 723 | () | ||
| 1117 | (let ((postgres-reserved-words (eval-when-compile | 724 | (let ((postgres-reserved-words (eval-when-compile |
| 1118 | (concat "\\b" | 725 | (concat "\\b" |
| 1119 | (regexp-opt '( | 726 | (regexp-opt '( |
| @@ -1122,17 +729,14 @@ to add functions and PL/SQL keywords.") | |||
| 1122 | (postgres-types (eval-when-compile | 729 | (postgres-types (eval-when-compile |
| 1123 | (concat "\\b" | 730 | (concat "\\b" |
| 1124 | (regexp-opt '( | 731 | (regexp-opt '( |
| 1125 | |||
| 1126 | "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" | 732 | "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
| 1127 | "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" | 733 | "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
| 1128 | "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" | 734 | "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
| 1129 | |||
| 1130 | ) t)"\\b"))) | 735 | ) t)"\\b"))) |
| 1131 | (postgres-builtin-functions (eval-when-compile | 736 | (postgres-builtin-functions (eval-when-compile |
| 1132 | (concat "\\b" | 737 | (concat "\\b" |
| 1133 | (regexp-opt '( | 738 | (regexp-opt '( |
| 1134 | ;; Misc Postgres builtin functions | 739 | ;; Misc Postgres builtin functions |
| 1135 | |||
| 1136 | "abstime" "age" "area" "box" "center" "date_part" "date_trunc" | 740 | "abstime" "age" "area" "box" "center" "date_part" "date_trunc" |
| 1137 | "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" | 741 | "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" |
| 1138 | "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" | 742 | "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" |
| @@ -1140,8 +744,8 @@ to add functions and PL/SQL keywords.") | |||
| 1140 | "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" | 744 | "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" |
| 1141 | "substring" "text" "timespan" "translate" "trim" "upgradepath" | 745 | "substring" "text" "timespan" "translate" "trim" "upgradepath" |
| 1142 | "upgradepoly" "upper" "varchar" "width" | 746 | "upgradepoly" "upper" "varchar" "width" |
| 1143 | |||
| 1144 | ) t) "\\b")))) | 747 | ) t) "\\b")))) |
| 748 | (setq sql-mode-postgres-font-lock-keywords | ||
| 1145 | (append sql-mode-ansi-font-lock-keywords | 749 | (append sql-mode-ansi-font-lock-keywords |
| 1146 | (list (cons postgres-reserved-words 'font-lock-keyword-face) | 750 | (list (cons postgres-reserved-words 'font-lock-keyword-face) |
| 1147 | ;; XEmacs doesn't have 'font-lock-builtin-face | 751 | ;; XEmacs doesn't have 'font-lock-builtin-face |
| @@ -1149,20 +753,21 @@ to add functions and PL/SQL keywords.") | |||
| 1149 | (cons postgres-builtin-functions 'font-lock-preprocessor-face) | 753 | (cons postgres-builtin-functions 'font-lock-preprocessor-face) |
| 1150 | ;; Emacs | 754 | ;; Emacs |
| 1151 | (cons postgres-builtin-functions 'font-lock-builtin-face)) | 755 | (cons postgres-builtin-functions 'font-lock-builtin-face)) |
| 1152 | (cons postgres-types 'font-lock-type-face)))) | 756 | (cons postgres-types 'font-lock-type-face)))))) |
| 1153 | 757 | ||
| 1154 | "Postgres SQL keywords used by font-lock. | 758 | |
| 759 | (defvar sql-mode-linter-font-lock-keywords nil | ||
| 760 | "Linter SQL keywords used by font-lock. | ||
| 1155 | 761 | ||
| 1156 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 762 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| 1157 | regular expressions are created during compilation by calling the | 763 | regular expressions are created during compilation by calling the |
| 1158 | function `regexp-opt'. Therefore, take a look at the source before | 764 | function `regexp-opt'.") |
| 1159 | you define your own sql-mode-postgres-font-lock-keywords.") | ||
| 1160 | 765 | ||
| 1161 | (defvar sql-mode-linter-font-lock-keywords | 766 | (if sql-mode-linter-font-lock-keywords |
| 767 | () | ||
| 1162 | (let ((linter-keywords (eval-when-compile | 768 | (let ((linter-keywords (eval-when-compile |
| 1163 | (concat "\\b" | 769 | (concat "\\b" |
| 1164 | (regexp-opt '( | 770 | (regexp-opt '( |
| 1165 | |||
| 1166 | "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" | 771 | "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" |
| 1167 | "committed" "count" "countblob" "cross" "current" "data" "database" | 772 | "committed" "count" "countblob" "cross" "current" "data" "database" |
| 1168 | "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" | 773 | "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" |
| @@ -1187,12 +792,10 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1187 | "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" | 792 | "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" |
| 1188 | "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" | 793 | "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" |
| 1189 | "wait" "windows_code" "workspace" "write" "xml" | 794 | "wait" "windows_code" "workspace" "write" "xml" |
| 1190 | |||
| 1191 | ) t) "\\b"))) | 795 | ) t) "\\b"))) |
| 1192 | (linter-reserved-words (eval-when-compile | 796 | (linter-reserved-words (eval-when-compile |
| 1193 | (concat "\\b" | 797 | (concat "\\b" |
| 1194 | (regexp-opt '( | 798 | (regexp-opt '( |
| 1195 | |||
| 1196 | "access" "action" "add" "address" "after" "all" "alter" "always" "and" | 799 | "access" "action" "add" "address" "after" "all" "alter" "always" "and" |
| 1197 | "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" | 800 | "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" |
| 1198 | "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" | 801 | "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" |
| @@ -1210,22 +813,18 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1210 | "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" | 813 | "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" |
| 1211 | "to" "union" "unique" "unlock" "until" "update" "using" "values" | 814 | "to" "union" "unique" "unlock" "until" "update" "using" "values" |
| 1212 | "view" "when" "where" "with" "without" | 815 | "view" "when" "where" "with" "without" |
| 1213 | |||
| 1214 | ) t) "\\b"))) | 816 | ) t) "\\b"))) |
| 1215 | (linter-types (eval-when-compile | 817 | (linter-types (eval-when-compile |
| 1216 | (concat "\\b" | 818 | (concat "\\b" |
| 1217 | (regexp-opt '( | 819 | (regexp-opt '( |
| 1218 | |||
| 1219 | "bigint" "bitmap" "blob" "boolean" "char" "character" "date" | 820 | "bigint" "bitmap" "blob" "boolean" "char" "character" "date" |
| 1220 | "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" | 821 | "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" |
| 1221 | "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" | 822 | "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" |
| 1222 | "cursor" "long" | 823 | "cursor" "long" |
| 1223 | |||
| 1224 | ) t) "\\b"))) | 824 | ) t) "\\b"))) |
| 1225 | (linter-builtin-functions (eval-when-compile | 825 | (linter-builtin-functions (eval-when-compile |
| 1226 | (concat "\\b" | 826 | (concat "\\b" |
| 1227 | (regexp-opt '( | 827 | (regexp-opt '( |
| 1228 | |||
| 1229 | "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" | 828 | "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" |
| 1230 | "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" | 829 | "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" |
| 1231 | "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" | 830 | "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" |
| @@ -1236,367 +835,59 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1236 | "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" | 835 | "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" |
| 1237 | "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" | 836 | "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" |
| 1238 | "instr" "least" "multime" "replace" "width" | 837 | "instr" "least" "multime" "replace" "width" |
| 1239 | |||
| 1240 | ) t) "\\b")))) | 838 | ) t) "\\b")))) |
| 839 | (setq sql-mode-linter-font-lock-keywords | ||
| 1241 | (append sql-mode-ansi-font-lock-keywords | 840 | (append sql-mode-ansi-font-lock-keywords |
| 1242 | (list (cons linter-keywords 'font-lock-keywords-face) | 841 | (list (cons linter-keywords 'font-lock-function-name-face) |
| 1243 | (cons linter-reserved-words 'font-lock-keyword-face) | 842 | (cons linter-reserved-words 'font-lock-keyword-face) |
| 1244 | ;; XEmacs doesn't have font-lock-builtin-face | 843 | ;; XEmacs doesn't have font-lock-builtin-face |
| 1245 | (if (string-match "XEmacs\\|Lucid" emacs-version) | 844 | (if (string-match "XEmacs\\|Lucid" emacs-version) |
| 1246 | (cons linter-builtin-functions 'font-lock-preprocessor-face) | 845 | (cons linter-builtin-functions 'font-lock-preprocessor-face) |
| 1247 | ;; GNU Emacs 19 doesn't have it either | 846 | ;; GNU Emacs 19 doesn't have it either |
| 1248 | (if (string-match "GNU Emacs 19" emacs-version) | 847 | (if (string-match "GNU Emacs 19" emacs-version) |
| 1249 | (cons linter-builtin-functions 'font-lock-keywords-face) | 848 | (cons linter-builtin-functions 'font-lock-function-name-face) |
| 1250 | ;; Emacs | 849 | ;; Emacs |
| 1251 | (cons linter-builtin-functions 'font-lock-builtin-face))) | 850 | (cons linter-builtin-functions 'font-lock-builtin-face))) |
| 1252 | (cons linter-types 'font-lock-type-face)))) | 851 | (cons linter-types 'font-lock-type-face)))))) |
| 1253 | |||
| 1254 | "Linter SQL keywords used by font-lock. | ||
| 1255 | |||
| 1256 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1257 | regular expressions are created during compilation by calling the | ||
| 1258 | function `regexp-opt'.") | ||
| 1259 | |||
| 1260 | (defvar sql-mode-ms-font-lock-keywords | ||
| 1261 | (let ((ms-reserved-words (eval-when-compile | ||
| 1262 | (concat "\\b" | ||
| 1263 | (regexp-opt '( | ||
| 1264 | |||
| 1265 | "absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization" | ||
| 1266 | "avg" "backup" "begin" "between" "break" "browse" "bulk" "by" | ||
| 1267 | "cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce" | ||
| 1268 | "column" "commit" "committed" "compute" "confirm" "constraint" | ||
| 1269 | "contains" "containstable" "continue" "controlrow" "convert" "count" | ||
| 1270 | "create" "cross" "current" "current_date" "current_time" | ||
| 1271 | "current_timestamp" "current_user" "database" "deallocate" | ||
| 1272 | "declare" "default" "delete" "deny" "desc" "disk" "distinct" | ||
| 1273 | "distributed" "double" "drop" "dummy" "dump" "else" "end" "errlvl" | ||
| 1274 | "errorexit" "escape" "except" "exec" "execute" "exists" "exit" "fetch" | ||
| 1275 | "file" "fillfactor" "first" "floppy" "for" "foreign" "freetext" | ||
| 1276 | "freetexttable" "from" "full" "goto" "grant" "group" "having" | ||
| 1277 | "holdlock" "identity" "identity_insert" "identitycol" "if" "in" | ||
| 1278 | "index" "inner" "insert" "intersect" "into" "is" "isolation" "join" | ||
| 1279 | "key" "kill" "last" "left" "level" "like" "lineno" "load" "max" "min" | ||
| 1280 | "mirrorexit" "national" "next" "nocheck" "nolock" "nonclustered" "not" | ||
| 1281 | "null" "nullif" "of" "off" "offsets" "on" "once" "only" "open" | ||
| 1282 | "opendatasource" "openquery" "openrowset" "option" "or" "order" | ||
| 1283 | "outer" "output" "over" "paglock" "percent" "perm" "permanent" "pipe" | ||
| 1284 | "plan" "precision" "prepare" "primary" "print" "prior" "privileges" | ||
| 1285 | "proc" "procedure" "processexit" "public" "raiserror" "read" | ||
| 1286 | "readcommitted" "readpast" "readtext" "readuncommitted" "reconfigure" | ||
| 1287 | "references" "relative" "repeatable" "repeatableread" "replication" | ||
| 1288 | "restore" "restrict" "return" "revoke" "right" "rollback" "rowcount" | ||
| 1289 | "rowguidcol" "rowlock" "rule" "save" "schema" "select" "serializable" | ||
| 1290 | "session_user" "set" "shutdown" "some" "statistics" "sum" | ||
| 1291 | "system_user" "table" "tablock" "tablockx" "tape" "temp" "temporary" | ||
| 1292 | "textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate" | ||
| 1293 | "tsequal" "uncommitted" "union" "unique" "update" "updatetext" | ||
| 1294 | "updlock" "use" "user" "values" "view" "waitfor" "when" "where" | ||
| 1295 | "while" "with" "work" "writetext" | ||
| 1296 | "collate" "function" "openxml" "returns" | ||
| 1297 | |||
| 1298 | ) t) "\\b"))) | ||
| 1299 | (ms-types (eval-when-compile | ||
| 1300 | (concat "\\b" | ||
| 1301 | (regexp-opt '( | ||
| 1302 | |||
| 1303 | "binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal" | ||
| 1304 | "double" "float" "image" "int" "integer" "money" "national" "nchar" | ||
| 1305 | "ntext" "numeric" "numeric" "nvarchar" "precision" "real" | ||
| 1306 | "smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint" | ||
| 1307 | "uniqueidentifier" "varbinary" "varchar" "varying" | ||
| 1308 | |||
| 1309 | ) t) "\\b"))) | ||
| 1310 | |||
| 1311 | (ms-vars "\\b@[a-zA-Z0-9_]*\\b") | ||
| 1312 | |||
| 1313 | (ms-builtin-functions (eval-when-compile | ||
| 1314 | (concat "\\b" | ||
| 1315 | (regexp-opt '( | ||
| 1316 | ;; Misc MS builtin functions | ||
| 1317 | |||
| 1318 | "@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts" | ||
| 1319 | "@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy" | ||
| 1320 | "@@langid" "@@language" "@@lock_timeout" "@@max_connections" | ||
| 1321 | "@@max_precision" "@@nestlevel" "@@options" "@@pack_received" | ||
| 1322 | "@@pack_sent" "@@packet_errors" "@@procid" "@@remserver" "@@rowcount" | ||
| 1323 | "@@servername" "@@servicename" "@@spid" "@@textsize" "@@timeticks" | ||
| 1324 | "@@total_errors" "@@total_read" "@@total_write" "@@trancount" | ||
| 1325 | "@@version" "abs" "acos" "and" "app_name" "ascii" "asin" "atan" "atn2" | ||
| 1326 | "avg" "case" "cast" "ceiling" "char" "charindex" "coalesce" | ||
| 1327 | "col_length" "col_name" "columnproperty" "containstable" "convert" | ||
| 1328 | "cos" "cot" "count" "current_timestamp" "current_user" "cursor_status" | ||
| 1329 | "databaseproperty" "datalength" "dateadd" "datediff" "datename" | ||
| 1330 | "datepart" "day" "db_id" "db_name" "degrees" "difference" "exp" | ||
| 1331 | "file_id" "file_name" "filegroup_id" "filegroup_name" | ||
| 1332 | "filegroupproperty" "fileproperty" "floor" "formatmessage" | ||
| 1333 | "freetexttable" "fulltextcatalogproperty" "fulltextserviceproperty" | ||
| 1334 | "getansinull" "getdate" "grouping" "host_id" "host_name" "ident_incr" | ||
| 1335 | "ident_seed" "identity" "index_col" "indexproperty" "is_member" | ||
| 1336 | "is_srvrolemember" "isdate" "isnull" "isnumeric" "left" "len" "log" | ||
| 1337 | "log10" "lower" "ltrim" "max" "min" "month" "nchar" "newid" "nullif" | ||
| 1338 | "object_id" "object_name" "objectproperty" "openquery" "openrowset" | ||
| 1339 | "parsename" "patindex" "patindex" "permissions" "pi" "power" | ||
| 1340 | "quotename" "radians" "rand" "replace" "replicate" "reverse" "right" | ||
| 1341 | "round" "rtrim" "session_user" "sign" "sin" "soundex" "space" "sqrt" | ||
| 1342 | "square" "stats_date" "stdev" "stdevp" "str" "stuff" "substring" "sum" | ||
| 1343 | "suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan" | ||
| 1344 | "textptr" "textvalid" "typeproperty" "unicode" "upper" "user" | ||
| 1345 | "user_id" "user_name" "var" "varp" "year" | ||
| 1346 | |||
| 1347 | ) t) "\\b"))) | ||
| 1348 | |||
| 1349 | (ms-config-commands | ||
| 1350 | (eval-when-compile | ||
| 1351 | (concat "^\\(\\(set\\s-+\\(" | ||
| 1352 | (regexp-opt '( | ||
| 1353 | |||
| 1354 | "datefirst" "dateformat" "deadlock_priority" "lock_timeout" | ||
| 1355 | "concat_null_yields_null" "cursor_close_on_commit" | ||
| 1356 | "disable_def_cnst_chk" "fips_flagger" "identity_insert" "language" | ||
| 1357 | "offsets" "quoted_identifier" "arithabort" "arithignore" "fmtonly" | ||
| 1358 | "nocount" "noexec" "numeric_roundabort" "parseonly" | ||
| 1359 | "query_governor_cost_limit" "rowcount" "textsize" "ansi_defaults" | ||
| 1360 | "ansi_null_dflt_off" "ansi_null_dflt_on" "ansi_nulls" "ansi_padding" | ||
| 1361 | "ansi_warnings" "forceplan" "showplan_all" "showplan_text" | ||
| 1362 | "statistics" "implicit_transactions" "remote_proc_transactions" | ||
| 1363 | "transaction" "xact_abort" | ||
| 1364 | |||
| 1365 | ) t) | ||
| 1366 | "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")))) | ||
| 1367 | |||
| 1368 | (list (cons ms-config-commands 'font-lock-doc-face) | ||
| 1369 | (cons ms-reserved-words 'font-lock-keyword-face) | ||
| 1370 | ;; XEmacs doesn't have 'font-lock-builtin-face | ||
| 1371 | (if (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 1372 | (cons ms-builtin-functions 'font-lock-preprocessor-face) | ||
| 1373 | ;; Emacs | ||
| 1374 | (cons ms-builtin-functions 'font-lock-builtin-face)) | ||
| 1375 | (cons ms-vars 'font-lock-variable-name-face) | ||
| 1376 | (cons ms-types 'font-lock-type-face))) | ||
| 1377 | |||
| 1378 | "Microsoft SQLServer SQL keywords used by font-lock. | ||
| 1379 | |||
| 1380 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1381 | regular expressions are created during compilation by calling the | ||
| 1382 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1383 | you define your own sql-mode-ms-font-lock-keywords.") | ||
| 1384 | |||
| 1385 | (defvar sql-mode-sybase-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1386 | "Sybase SQL keywords used by font-lock. | ||
| 1387 | |||
| 1388 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1389 | regular expressions are created during compilation by calling the | ||
| 1390 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1391 | you define your own sql-mode-sybase-font-lock-keywords.") | ||
| 1392 | |||
| 1393 | (defvar sql-mode-informix-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1394 | "Informix SQL keywords used by font-lock. | ||
| 1395 | |||
| 1396 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1397 | regular expressions are created during compilation by calling the | ||
| 1398 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1399 | you define your own sql-mode-informix-font-lock-keywords.") | ||
| 1400 | |||
| 1401 | (defvar sql-mode-interbase-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1402 | "Interbase SQL keywords used by font-lock. | ||
| 1403 | |||
| 1404 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1405 | regular expressions are created during compilation by calling the | ||
| 1406 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1407 | you define your own sql-mode-interbase-font-lock-keywords.") | ||
| 1408 | |||
| 1409 | (defvar sql-mode-ingres-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1410 | "Ingres SQL keywords used by font-lock. | ||
| 1411 | |||
| 1412 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1413 | regular expressions are created during compilation by calling the | ||
| 1414 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1415 | you define your own sql-mode-interbase-font-lock-keywords.") | ||
| 1416 | |||
| 1417 | (defvar sql-mode-solid-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1418 | "Solid SQL keywords used by font-lock. | ||
| 1419 | |||
| 1420 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1421 | regular expressions are created during compilation by calling the | ||
| 1422 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1423 | you define your own sql-mode-solid-font-lock-keywords.") | ||
| 1424 | |||
| 1425 | (defvar sql-mode-mysql-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1426 | "MySQL SQL keywords used by font-lock. | ||
| 1427 | |||
| 1428 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1429 | regular expressions are created during compilation by calling the | ||
| 1430 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1431 | you define your own sql-mode-mysql-font-lock-keywords.") | ||
| 1432 | |||
| 1433 | (defvar sql-mode-sqlite-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1434 | "SQLite SQL keywords used by font-lock. | ||
| 1435 | |||
| 1436 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 1437 | regular expressions are created during compilation by calling the | ||
| 1438 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1439 | you define your own sql-mode-sqlite-font-lock-keywords.") | ||
| 1440 | |||
| 1441 | (defvar sql-mode-db2-font-lock-keywords sql-mode-ansi-font-lock-keywords | ||
| 1442 | "DB2 SQL keywords used by font-lock. | ||
| 1443 | 852 | ||
| 1444 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 853 | (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords |
| 1445 | regular expressions are created during compilation by calling the | ||
| 1446 | function `regexp-opt'. Therefore, take a look at the source before | ||
| 1447 | you define your own sql-mode-db2-font-lock-keywords.") | ||
| 1448 | |||
| 1449 | (defvar sql-mode-font-lock-keywords nil | ||
| 1450 | "SQL keywords used by font-lock. | 854 | "SQL keywords used by font-lock. |
| 1451 | 855 | ||
| 1452 | Setting this variable directly no longer has any affect. Use | 856 | This variable defaults to `sql-mode-ansi-font-lock-keywords'. This is |
| 1453 | `sql-product' and `sql-add-product-keywords' to control the | 857 | used for the default `font-lock-defaults' value in `sql-mode'. This |
| 1454 | highlighting rules in sql-mode.") | 858 | can be changed by some entry functions to provide more hilighting.") |
| 1455 | |||
| 1456 | |||
| 1457 | |||
| 1458 | ;;; SQL Product support functions | ||
| 1459 | |||
| 1460 | (defun sql-product-feature (feature &optional product) | ||
| 1461 | "Lookup `feature' needed to support the current SQL product. | ||
| 1462 | |||
| 1463 | See \[sql-product-support] for a list of products and supported features." | ||
| 1464 | (cadr | ||
| 1465 | (memq feature | ||
| 1466 | (assoc (or product sql-product) | ||
| 1467 | sql-product-support)))) | ||
| 1468 | |||
| 1469 | (defun sql-product-font-lock (keywords-only imenu) | ||
| 1470 | "Sets `font-lock-defaults' and `font-lock-keywords' based on | ||
| 1471 | the product-specific keywords and syntax-alists defined in | ||
| 1472 | `sql-product-support'." | ||
| 1473 | (let | ||
| 1474 | ;; Get the product-specific syntax-alist. | ||
| 1475 | ((syntax-alist | ||
| 1476 | (append | ||
| 1477 | (sql-product-feature :syntax-alist) | ||
| 1478 | '((?_ . "w") (?. . "w"))))) | ||
| 1479 | |||
| 1480 | ;; Get the product-specific keywords. | ||
| 1481 | (setq sql-mode-font-lock-keywords | ||
| 1482 | (append | ||
| 1483 | (eval (sql-product-feature :font-lock)) | ||
| 1484 | (list sql-mode-font-lock-object-name))) | ||
| 1485 | |||
| 1486 | ;; Setup font-lock. (What is the minimum we should have to do | ||
| 1487 | ;; here?) | ||
| 1488 | (setq font-lock-set-defaults nil | ||
| 1489 | font-lock-keywords sql-mode-font-lock-keywords | ||
| 1490 | font-lock-defaults (list 'sql-mode-font-lock-keywords | ||
| 1491 | keywords-only t syntax-alist)) | ||
| 1492 | |||
| 1493 | ;; Setup imenu; it needs the same syntax-alist. | ||
| 1494 | (when imenu | ||
| 1495 | (setq imenu-syntax-alist syntax-alist)))) | ||
| 1496 | |||
| 1497 | ;;;###autoload | ||
| 1498 | (defun sql-add-product-keywords (product keywords) | ||
| 1499 | "Append a `font-lock-keywords' entry to the existing entries defined | ||
| 1500 | for the specified `product'." | ||
| 1501 | |||
| 1502 | (let ((font-lock (sql-product-feature :font-lock product))) | ||
| 1503 | (set font-lock (append (eval font-lock) (list keywords))))) | ||
| 1504 | 859 | ||
| 1505 | 860 | ||
| 1506 | 861 | ||
| 1507 | ;;; Functions to switch highlighting | 862 | ;;; Functions to switch highlighting |
| 1508 | 863 | ||
| 1509 | (defun sql-highlight-product () | ||
| 1510 | "Turns on the appropriate font highlighting for the SQL product | ||
| 1511 | selected." | ||
| 1512 | |||
| 1513 | (when (eq major-mode 'sql-mode) | ||
| 1514 | ;; Setup font-lock | ||
| 1515 | (sql-product-font-lock nil t) | ||
| 1516 | |||
| 1517 | ;; Force fontification, if its enabled. | ||
| 1518 | (if font-lock-mode | ||
| 1519 | (font-lock-fontify-buffer)) | ||
| 1520 | |||
| 1521 | ;; Set the mode name to include the product. | ||
| 1522 | (setq mode-name (concat "SQL[" (prin1-to-string sql-product) "]")))) | ||
| 1523 | |||
| 1524 | (defun sql-set-product (product) | ||
| 1525 | "Set `sql-product' to product and enable appropriate | ||
| 1526 | highlighting." | ||
| 1527 | (interactive "SEnter SQL product: ") | ||
| 1528 | (when (not (assoc product sql-product-support)) | ||
| 1529 | (error "SQL product %s is not supported; treated as ANSI" product) | ||
| 1530 | (setq product 'ansi)) | ||
| 1531 | |||
| 1532 | ;; Save product setting and fontify. | ||
| 1533 | (setq sql-product product) | ||
| 1534 | (sql-highlight-product)) | ||
| 1535 | |||
| 1536 | (defun sql-highlight-oracle-keywords () | 864 | (defun sql-highlight-oracle-keywords () |
| 1537 | "Highlight Oracle keywords." | 865 | "Highlight Oracle keywords. |
| 866 | Basically, this just sets `font-lock-keywords' appropriately." | ||
| 1538 | (interactive) | 867 | (interactive) |
| 1539 | (sql-set-product 'oracle)) | 868 | (setq font-lock-keywords sql-mode-oracle-font-lock-keywords) |
| 869 | (font-lock-fontify-buffer)) | ||
| 1540 | 870 | ||
| 1541 | (defun sql-highlight-postgres-keywords () | 871 | (defun sql-highlight-postgres-keywords () |
| 1542 | "Highlight Postgres keywords." | 872 | "Highlight Postgres keywords. |
| 873 | Basically, this just sets `font-lock-keywords' appropriately." | ||
| 1543 | (interactive) | 874 | (interactive) |
| 1544 | (sql-set-product 'postgres)) | 875 | (setq font-lock-keywords sql-mode-postgres-font-lock-keywords) |
| 876 | (font-lock-fontify-buffer)) | ||
| 1545 | 877 | ||
| 1546 | (defun sql-highlight-linter-keywords () | 878 | (defun sql-highlight-linter-keywords () |
| 1547 | "Highlight LINTER keywords." | 879 | "Highlight LINTER keywords. |
| 1548 | (interactive) | 880 | Basically, this just sets `font-lock-keywords' appropriately." |
| 1549 | (sql-set-product 'linter)) | ||
| 1550 | |||
| 1551 | (defun sql-highlight-ms-keywords () | ||
| 1552 | "Highlight Microsoft SQLServer keywords." | ||
| 1553 | (interactive) | 881 | (interactive) |
| 1554 | (sql-set-product 'ms)) | 882 | (setq font-lock-keywords sql-mode-linter-font-lock-keywords) |
| 883 | (font-lock-fontify-buffer)) | ||
| 1555 | 884 | ||
| 1556 | (defun sql-highlight-ansi-keywords () | 885 | (defun sql-highlight-ansi-keywords () |
| 1557 | "Highlight ANSI SQL keywords." | 886 | "Highlight ANSI SQL keywords. |
| 1558 | (interactive) | 887 | Basically, this just sets `font-lock-keywords' appropriately." |
| 1559 | (sql-set-product 'ansi)) | ||
| 1560 | |||
| 1561 | (defun sql-highlight-sybase-keywords () | ||
| 1562 | "Highlight Sybase SQL keywords." | ||
| 1563 | (interactive) | ||
| 1564 | (sql-set-product 'sybase)) | ||
| 1565 | |||
| 1566 | (defun sql-highlight-informix-keywords () | ||
| 1567 | "Highlight Informix SQL keywords." | ||
| 1568 | (interactive) | ||
| 1569 | (sql-set-product 'informix)) | ||
| 1570 | |||
| 1571 | (defun sql-highlight-interbase-keywords () | ||
| 1572 | "Highlight Interbase SQL keywords." | ||
| 1573 | (interactive) | ||
| 1574 | (sql-set-product 'interbase)) | ||
| 1575 | |||
| 1576 | (defun sql-highlight-ingres-keywords () | ||
| 1577 | "Highlight Ingres SQL keywords." | ||
| 1578 | (interactive) | ||
| 1579 | (sql-set-product 'ingres)) | ||
| 1580 | |||
| 1581 | (defun sql-highlight-solid-keywords () | ||
| 1582 | "Highlight Solid SQL keywords." | ||
| 1583 | (interactive) | ||
| 1584 | (sql-set-product 'solid)) | ||
| 1585 | |||
| 1586 | (defun sql-highlight-mysql-keywords () | ||
| 1587 | "Highlight MySQL SQL keywords." | ||
| 1588 | (interactive) | ||
| 1589 | (sql-set-product 'mysql)) | ||
| 1590 | |||
| 1591 | (defun sql-highlight-sqlite-keywords () | ||
| 1592 | "Highlight SQLite SQL keywords." | ||
| 1593 | (interactive) | ||
| 1594 | (sql-set-product 'sqlite)) | ||
| 1595 | |||
| 1596 | (defun sql-highlight-db2-keywords () | ||
| 1597 | "Highlight DB2 SQL keywords." | ||
| 1598 | (interactive) | 888 | (interactive) |
| 1599 | (sql-set-product 'db2)) | 889 | (setq font-lock-keywords sql-mode-ansi-font-lock-keywords) |
| 890 | (font-lock-fontify-buffer)) | ||
| 1600 | 891 | ||
| 1601 | 892 | ||
| 1602 | 893 | ||
| @@ -1662,7 +953,6 @@ Other non-free SQL implementations are also supported: | |||
| 1662 | Sybase: \\[sql-sybase] | 953 | Sybase: \\[sql-sybase] |
| 1663 | Ingres: \\[sql-ingres] | 954 | Ingres: \\[sql-ingres] |
| 1664 | Microsoft: \\[sql-ms] | 955 | Microsoft: \\[sql-ms] |
| 1665 | DB2: \\[sql-db2] | ||
| 1666 | Interbase: \\[sql-interbase] | 956 | Interbase: \\[sql-interbase] |
| 1667 | Linter: \\[sql-linter] | 957 | Linter: \\[sql-linter] |
| 1668 | 958 | ||
| @@ -1709,30 +999,26 @@ Parameter WHAT is a list of the arguments passed to this function. | |||
| 1709 | The function asks for the username if WHAT contains symbol `user', for | 999 | The function asks for the username if WHAT contains symbol `user', for |
| 1710 | the password if it contains symbol `password', for the server if it | 1000 | the password if it contains symbol `password', for the server if it |
| 1711 | contains symbol `server', and for the database if it contains symbol | 1001 | contains symbol `server', and for the database if it contains symbol |
| 1712 | `database'. The members of WHAT are processed in the order in which | 1002 | `database'. |
| 1713 | they are provided. | ||
| 1714 | 1003 | ||
| 1715 | In order to ask the user for username, password and database, call the | 1004 | In order to ask the user for username, password and database, call the |
| 1716 | function like this: (sql-get-login 'user 'password 'database)." | 1005 | function like this: (sql-get-login 'user 'password 'database)." |
| 1717 | (interactive) | 1006 | (interactive) |
| 1718 | (while what | 1007 | (if (memq 'user what) |
| 1719 | (cond | ||
| 1720 | ((eq (car what) 'user) ; user | ||
| 1721 | (setq sql-user | 1008 | (setq sql-user |
| 1722 | (read-from-minibuffer "User: " sql-user nil nil | 1009 | (read-from-minibuffer "User: " sql-user nil nil |
| 1723 | sql-user-history))) | 1010 | sql-user-history))) |
| 1724 | ((eq (car what) 'password) ; password | 1011 | (if (memq 'password what) |
| 1725 | (setq sql-password | 1012 | (setq sql-password |
| 1726 | (sql-read-passwd "Password: " sql-password))) | 1013 | (sql-read-passwd "Password: " sql-password))) |
| 1727 | ((eq (car what) 'server) ; server | 1014 | (if (memq 'server what) |
| 1728 | (setq sql-server | 1015 | (setq sql-server |
| 1729 | (read-from-minibuffer "Server: " sql-server nil nil | 1016 | (read-from-minibuffer "Server: " sql-server nil nil |
| 1730 | sql-server-history))) | 1017 | sql-server-history))) |
| 1731 | ((eq (car what) 'database) ; database | 1018 | (if (memq 'database what) |
| 1732 | (setq sql-database | 1019 | (setq sql-database |
| 1733 | (read-from-minibuffer "Database: " sql-database nil nil | 1020 | (read-from-minibuffer "Database: " sql-database nil nil |
| 1734 | sql-database-history)))) | 1021 | sql-database-history)))) |
| 1735 | (setq what (cdr what)))) | ||
| 1736 | 1022 | ||
| 1737 | (defun sql-find-sqli-buffer () | 1023 | (defun sql-find-sqli-buffer () |
| 1738 | "Return the current default SQLi buffer or nil. | 1024 | "Return the current default SQLi buffer or nil. |