diff options
| author | Stefan Monnier | 2004-04-29 21:55:28 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-04-29 21:55:28 +0000 |
| commit | 9fd8cb3673c562ce002add1c8a1ed14a571a9b22 (patch) | |
| tree | d4b527bcf797e661334bbc866e9bb5df4c7d7df7 | |
| parent | 56e6d6feccdaeed52524238d2e159a3a26ac9ce6 (diff) | |
| download | emacs-9fd8cb3673c562ce002add1c8a1ed14a571a9b22.tar.gz emacs-9fd8cb3673c562ce002add1c8a1ed14a571a9b22.zip | |
(sql-product-alist): Rename variable `sql-product-support'.
Add Postgres login parameters.
(sql-set-product, sql-product-feature): Update with renamed variable.
(sql-connect-postgres): Add username prompt.
(sql-imenu-generic-expression, sql-mode-font-lock-object-name):
Make patterns less product specific.
(sql-xemacs-p, sql-emacs19-p): Add flags for emacs variants.
(sql-mode-abbrev-table): Modify initialization.
(sql-builtin-face): Add variable.
(sql-keywords-re): Add macro.
(sql-mode-ansi-font-lock-keywords): Update for ANSI-92.
(sql-mode-oracle-font-lock-keywords): Update for Oracle 9i.
(sql-mode-postgres-font-lock-keywords): Update for Postgres 7.3.
(sql-mode-mysql-font-lock-keywords): Update for MySql 4.0.
(sql-mode-linter-font-lock-keywords)
(sql-mode-ms-font-lock-keywords): Use `sql-keywords-re' macro.
(sql-mode-sybase-font-lock-keywords, sql-mode-informix-font-lock-keywords)
(sql-mode-interbase-font-lock-keywords, sql-mode-ingres-font-lock-keywords)
(sql-mode-solid-font-lock-keywords, sql-mode-sqlite-font-lock-keywords)
(sql-mode-db2-font-lock-keywords): Default to nil.
(sql-product-font-lock): Always highlight ANSI keywords.
(sql-add-product-keywords): Made similar to `font-lock-add-keywords'.
(sql-send-string): Add function.
| -rw-r--r-- | lisp/progmodes/sql.el | 933 |
1 files changed, 588 insertions, 345 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 1a9251599ce..420b5f226b0 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -1,11 +1,12 @@ | |||
| 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,99,2000,01,02,03,04 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | 5 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 6 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> | 6 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> |
| 7 | ;; Version: 1.8.0 | 7 | ;; Version: 2.0.0 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/progmodes/sql.el | ||
| 9 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode | 10 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
| 10 | 11 | ||
| 11 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| @@ -101,7 +102,7 @@ | |||
| 101 | 102 | ||
| 102 | ;; (const :tag "XyzDB" xyz) | 103 | ;; (const :tag "XyzDB" xyz) |
| 103 | 104 | ||
| 104 | ;; 2) Add an entry to the `sql-product-support' list. | 105 | ;; 2) Add an entry to the `sql-product-alist' list. |
| 105 | 106 | ||
| 106 | ;; (xyz | 107 | ;; (xyz |
| 107 | ;; :font-lock sql-mode-xyz-font-lock-keywords | 108 | ;; :font-lock sql-mode-xyz-font-lock-keywords |
| @@ -136,7 +137,7 @@ | |||
| 136 | ;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for | 137 | ;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for |
| 137 | ;; a more complex example. | 138 | ;; a more complex example. |
| 138 | 139 | ||
| 139 | ;; (defvar sql-mode-xyz-font-lock-keywords sql-mode-ansi-font-lock-keywords | 140 | ;; (defvar sql-mode-xyz-font-lock-keywords nil |
| 140 | ;; "XyzDB SQL keywords used by font-lock.") | 141 | ;; "XyzDB SQL keywords used by font-lock.") |
| 141 | 142 | ||
| 142 | ;; 6) Add a product highlighting function. | 143 | ;; 6) Add a product highlighting function. |
| @@ -192,6 +193,7 @@ | |||
| 192 | 193 | ||
| 193 | ;;; Thanks to all the people who helped me out: | 194 | ;;; Thanks to all the people who helped me out: |
| 194 | 195 | ||
| 196 | ;; Alex Schroeder <alex@gnu.org> | ||
| 195 | ;; Kai Blauberg <kai.blauberg@metla.fi> | 197 | ;; Kai Blauberg <kai.blauberg@metla.fi> |
| 196 | ;; <ibalaban@dalet.com> | 198 | ;; <ibalaban@dalet.com> |
| 197 | ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> | 199 | ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> |
| @@ -199,6 +201,7 @@ | |||
| 199 | ;; nino <nino@inform.dk> | 201 | ;; nino <nino@inform.dk> |
| 200 | ;; Berend de Boer <berend@pobox.com> | 202 | ;; Berend de Boer <berend@pobox.com> |
| 201 | ;; Michael Mauger <mmaug@yahoo.com> | 203 | ;; Michael Mauger <mmaug@yahoo.com> |
| 204 | ;; Adam Jenkins <adam@thejenkins.org> | ||
| 202 | 205 | ||
| 203 | 206 | ||
| 204 | 207 | ||
| @@ -209,6 +212,8 @@ | |||
| 209 | (eval-when-compile | 212 | (eval-when-compile |
| 210 | (require 'regexp-opt)) | 213 | (require 'regexp-opt)) |
| 211 | (require 'custom) | 214 | (require 'custom) |
| 215 | (eval-when-compile ;; needed in Emacs 19, 20 | ||
| 216 | (setq max-specpdl-size 2000)) | ||
| 212 | 217 | ||
| 213 | ;;; Allow customization | 218 | ;;; Allow customization |
| 214 | 219 | ||
| @@ -264,7 +269,7 @@ highlighted properly when you open them." | |||
| 264 | (defvar sql-interactive-product nil | 269 | (defvar sql-interactive-product nil |
| 265 | "Product under `sql-interactive-mode'.") | 270 | "Product under `sql-interactive-mode'.") |
| 266 | 271 | ||
| 267 | (defvar sql-product-support | 272 | (defvar sql-product-alist |
| 268 | '((ansi | 273 | '((ansi |
| 269 | :font-lock sql-mode-ansi-font-lock-keywords) | 274 | :font-lock sql-mode-ansi-font-lock-keywords) |
| 270 | (db2 | 275 | (db2 |
| @@ -319,9 +324,9 @@ highlighted properly when you open them." | |||
| 319 | :syntax-alist ((?$ . "w") (?# . "w"))) | 324 | :syntax-alist ((?$ . "w") (?# . "w"))) |
| 320 | (postgres | 325 | (postgres |
| 321 | :font-lock sql-mode-postgres-font-lock-keywords | 326 | :font-lock sql-mode-postgres-font-lock-keywords |
| 322 | :sqli-login (database server) | 327 | :sqli-login (user database server) |
| 323 | :sqli-connect sql-connect-postgres | 328 | :sqli-connect sql-connect-postgres |
| 324 | :sqli-prompt-regexp "^.*> *" | 329 | :sqli-prompt-regexp "^.*[#>] *" |
| 325 | :sqli-prompt-length 5) | 330 | :sqli-prompt-length 5) |
| 326 | (solid | 331 | (solid |
| 327 | :font-lock sql-mode-solid-font-lock-keywords | 332 | :font-lock sql-mode-solid-font-lock-keywords |
| @@ -372,10 +377,12 @@ following: | |||
| 372 | database. Do product specific | 377 | database. Do product specific |
| 373 | configuration of comint in this function. | 378 | configuration of comint in this function. |
| 374 | 379 | ||
| 375 | :sqli-prompt-regexp a regular expression string that matches the | 380 | :sqli-prompt-regexp a regular expression string that matches |
| 376 | prompt issued by the product interpreter. | 381 | the prompt issued by the product |
| 382 | interpreter. (Not needed in 21.3+) | ||
| 377 | 383 | ||
| 378 | :sqli-prompt-length the length of the prompt on the line. | 384 | :sqli-prompt-length the length of the prompt on the line.(Not |
| 385 | needed in 21.3+) | ||
| 379 | 386 | ||
| 380 | :syntax-alist an alist of syntax table entries to enable | 387 | :syntax-alist an alist of syntax table entries to enable |
| 381 | special character treatment by font-lock and | 388 | special character treatment by font-lock and |
| @@ -412,14 +419,14 @@ buffer is shown using `display-buffer'." | |||
| 412 | 419 | ||
| 413 | (defvar sql-imenu-generic-expression | 420 | (defvar sql-imenu-generic-expression |
| 414 | ;; Items are in reverse order because they are rendered in reverse. | 421 | ;; Items are in reverse order because they are rendered in reverse. |
| 415 | '(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2) | 422 | '(("Rules/Defaults" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(rule\\|default\\)\\s-+\\(\\w+\\)" 3) |
| 416 | ("Sequences" "^\\s-*create\\s-+sequence\\s-+\\(\\w+\\)" 1) | 423 | ("Sequences" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*sequence\\s-+\\(\\w+\\)" 2) |
| 417 | ("Triggers" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?trigger\\s-+\\(\\w+\\)" 3) | 424 | ("Triggers" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*trigger\\s-+\\(\\w+\\)" 2) |
| 418 | ("Functions" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?function\\s-+\\(\\w+\\)" 3) | 425 | ("Functions" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?function\\s-+\\(\\w+\\)" 3) |
| 419 | ("Procedures" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) | 426 | ("Procedures" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) |
| 420 | ("Packages" "^\\s-*create\\s-+\\(or\\s-+replace\\s-+\\)?package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) | 427 | ("Packages" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) |
| 421 | ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1) | 428 | ("Indexes" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*index\\s-+\\(\\w+\\)" 2) |
| 422 | ("Tables/Views" "^\\s-*create\\s-+\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\)\\s-+\\(\\w+\\)" 4)) | 429 | ("Tables/Views" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(table\\|view\\)\\s-+\\(\\w+\\)" 3)) |
| 423 | "Define interesting points in the SQL buffer for `imenu'. | 430 | "Define interesting points in the SQL buffer for `imenu'. |
| 424 | 431 | ||
| 425 | This is used to set `imenu-generic-expression' when SQL mode is | 432 | This is used to set `imenu-generic-expression' when SQL mode is |
| @@ -686,6 +693,18 @@ Starts `sql-interactive-mode' after doing some setup." | |||
| 686 | 693 | ||
| 687 | ;;; Variables which do not need customization | 694 | ;;; Variables which do not need customization |
| 688 | 695 | ||
| 696 | (defvar sql-xemacs-p | ||
| 697 | (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 698 | "Is this a non-GNU Emacs?") | ||
| 699 | |||
| 700 | (defvar sql-emacs19-p | ||
| 701 | (string-match "GNU Emacs 19" emacs-version) | ||
| 702 | "Is this a GNU Emacs 19?") | ||
| 703 | |||
| 704 | (defvar sql-emacs20-p | ||
| 705 | (string-match "20" emacs-version) | ||
| 706 | "Is this a GNU Emacs 20?") | ||
| 707 | |||
| 689 | (defvar sql-user-history nil | 708 | (defvar sql-user-history nil |
| 690 | "History of usernames used.") | 709 | "History of usernames used.") |
| 691 | 710 | ||
| @@ -745,6 +764,7 @@ Based on `comint-mode-map'.") | |||
| 745 | (let ((map (make-sparse-keymap))) | 764 | (let ((map (make-sparse-keymap))) |
| 746 | (define-key map (kbd "C-c C-c") 'sql-send-paragraph) | 765 | (define-key map (kbd "C-c C-c") 'sql-send-paragraph) |
| 747 | (define-key map (kbd "C-c C-r") 'sql-send-region) | 766 | (define-key map (kbd "C-c C-r") 'sql-send-region) |
| 767 | (define-key map (kbd "C-c C-s") 'sql-send-string) | ||
| 748 | (define-key map (kbd "C-c C-b") 'sql-send-buffer) | 768 | (define-key map (kbd "C-c C-b") 'sql-send-buffer) |
| 749 | map) | 769 | map) |
| 750 | "Mode map used for `sql-mode'.") | 770 | "Mode map used for `sql-mode'.") |
| @@ -764,6 +784,7 @@ Based on `comint-mode-map'.") | |||
| 764 | (get-buffer-process sql-buffer))] | 784 | (get-buffer-process sql-buffer))] |
| 765 | ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) | 785 | ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
| 766 | (get-buffer-process sql-buffer))] | 786 | (get-buffer-process sql-buffer))] |
| 787 | ["Send String" sql-send-string t] | ||
| 767 | ["--" nil nil] | 788 | ["--" nil nil] |
| 768 | ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)] | 789 | ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)] |
| 769 | ["Show SQLi buffer" sql-show-sqli-buffer t] | 790 | ["Show SQLi buffer" sql-show-sqli-buffer t] |
| @@ -792,7 +813,7 @@ Based on `comint-mode-map'.") | |||
| 792 | ["Linter" sql-highlight-linter-keywords | 813 | ["Linter" sql-highlight-linter-keywords |
| 793 | :style radio | 814 | :style radio |
| 794 | :selected (eq sql-product 'linter)] | 815 | :selected (eq sql-product 'linter)] |
| 795 | ["Microsoft" sql-highlight-ms-keywords | 816 | ["MS SQLServer" sql-highlight-ms-keywords |
| 796 | :style radio | 817 | :style radio |
| 797 | :selected (eq sql-product 'ms)] | 818 | :selected (eq sql-product 'ms)] |
| 798 | ["MySQL" sql-highlight-mysql-keywords | 819 | ["MySQL" sql-highlight-mysql-keywords |
| @@ -828,24 +849,24 @@ Based on `comint-mode-map'.") | |||
| 828 | 849 | ||
| 829 | (defvar sql-mode-abbrev-table nil | 850 | (defvar sql-mode-abbrev-table nil |
| 830 | "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") | 851 | "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") |
| 831 | (if sql-mode-abbrev-table | 852 | (unless sql-mode-abbrev-table |
| 832 | () | 853 | (define-abbrev-table 'sql-mode-abbrev-table nil) |
| 833 | (let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev)))) | 854 | (mapcar |
| 834 | d-a) | ||
| 835 | ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. | 855 | ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. |
| 836 | (setq d-a | 856 | '(lambda (abbrev) |
| 837 | (if (>= nargs 6) | 857 | (let ((name (car abbrev)) |
| 838 | '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)) | 858 | (expansion (cdr abbrev))) |
| 839 | '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion)))) | 859 | (condition-case nil |
| 840 | 860 | (define-abbrev sql-mode-abbrev-table name expansion nil 0 t) | |
| 841 | (define-abbrev-table 'sql-mode-abbrev-table nil) | 861 | (error |
| 842 | (funcall d-a "ins" "insert") | 862 | (define-abbrev sql-mode-abbrev-table name expansion))))) |
| 843 | (funcall d-a "upd" "update") | 863 | '(("ins" "insert") |
| 844 | (funcall d-a "del" "delete") | 864 | ("upd" "update") |
| 845 | (funcall d-a "sel" "select") | 865 | ("del" "delete") |
| 846 | (funcall d-a "proc" "procedure") | 866 | ("sel" "select") |
| 847 | (funcall d-a "func" "function") | 867 | ("proc" "procedure") |
| 848 | (funcall d-a "cr" "create"))) | 868 | ("func" "function") |
| 869 | ("cr" "create")))) | ||
| 849 | 870 | ||
| 850 | ;; Syntax Table | 871 | ;; Syntax Table |
| 851 | 872 | ||
| @@ -855,7 +876,7 @@ Based on `comint-mode-map'.") | |||
| 855 | (modify-syntax-entry ?/ ". 14" table) | 876 | (modify-syntax-entry ?/ ". 14" table) |
| 856 | (modify-syntax-entry ?* ". 23" table) | 877 | (modify-syntax-entry ?* ". 23" table) |
| 857 | ;; double-dash starts comment | 878 | ;; double-dash starts comment |
| 858 | (if (string-match "XEmacs\\|Lucid" emacs-version) | 879 | (if sql-xemacs-p |
| 859 | (modify-syntax-entry ?- ". 56" table) | 880 | (modify-syntax-entry ?- ". 56" table) |
| 860 | (modify-syntax-entry ?- ". 12b" table)) | 881 | (modify-syntax-entry ?- ". 12b" table)) |
| 861 | ;; newline and formfeed end coments | 882 | ;; newline and formfeed end coments |
| @@ -871,55 +892,136 @@ Based on `comint-mode-map'.") | |||
| 871 | ;; Font lock support | 892 | ;; Font lock support |
| 872 | 893 | ||
| 873 | (defvar sql-mode-font-lock-object-name | 894 | (defvar sql-mode-font-lock-object-name |
| 874 | (list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+" | 895 | (list (concat "^\\s-*\\(create\\|drop\\|alter\\)\\s-+" ;; lead off with CREATE, DROP or ALTER |
| 875 | "\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\|package\\(\\s-+body\\)?\\|" | 896 | "\\(\\w+\\s-+\\)*" ;; optional intervening keywords |
| 876 | "proc\\(edure\\)?\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+\\(\\w+\\)") | 897 | "\\(table\\|view\\|package\\(\\s-+body\\)?\\|proc\\(edure\\)?" |
| 877 | 8 'font-lock-function-name-face) | 898 | "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+" |
| 878 | 899 | "\\(\\w+\\)") | |
| 879 | "Pattern to match the names of top-level objects in a CREATE, | 900 | 6 'font-lock-function-name-face) |
| 880 | DROP or ALTER statement. | 901 | |
| 881 | 902 | "Pattern to match the names of top-level objects. | |
| 882 | The format of variable should be a valid `font-lock-keywords' | 903 | |
| 883 | entry.") | 904 | The pattern matches the name in a CREATE, DROP or ALTER |
| 905 | statement. The format of variable should be a valid | ||
| 906 | `font-lock-keywords' entry.") | ||
| 907 | |||
| 908 | (defvar sql-builtin-face | ||
| 909 | (if sql-xemacs-p | ||
| 910 | ;; XEmacs doesn't have the builtin face | ||
| 911 | 'font-lock-preprocessor-face | ||
| 912 | ;; GNU Emacs 19 doesn't either | ||
| 913 | (if sql-emacs19-p | ||
| 914 | 'font-lock-keyword-face | ||
| 915 | ;; Emacs 2x | ||
| 916 | 'font-lock-builtin-face)) | ||
| 917 | "Builtin face for font-lock in SQL mode.") | ||
| 918 | |||
| 919 | (defvar sql-doc-face | ||
| 920 | (if (or sql-xemacs-p | ||
| 921 | sql-emacs19-p | ||
| 922 | sql-emacs20-p) | ||
| 923 | 'font-lock-string-face | ||
| 924 | 'font-lock-doc-face) | ||
| 925 | "Documentation face for font-lock in SQL mode.") | ||
| 926 | |||
| 927 | (defmacro sql-keywords-re (&rest keywords) | ||
| 928 | "Compile-time generation of regexp matching any one of KEYWORDS." | ||
| 929 | `(eval-when-compile | ||
| 930 | (concat "\\b" | ||
| 931 | (regexp-opt ',keywords t) | ||
| 932 | "\\b"))) | ||
| 884 | 933 | ||
| 885 | (defvar sql-mode-ansi-font-lock-keywords | 934 | (defvar sql-mode-ansi-font-lock-keywords |
| 886 | (let ((ansi-keywords (eval-when-compile | 935 | (let ((ansi-funcs (sql-keywords-re |
| 887 | (concat "\\b" | 936 | "abs" "avg" "bit_length" "cardinality" "cast" "char_length" |
| 888 | (regexp-opt '( | 937 | "character_length" "coalesce" "convert" "count" "current_date" |
| 889 | 938 | "current_path" "current_role" "current_time" "current_timestamp" | |
| 890 | "authorization" "avg" "begin" "close" "cobol" "commit" | 939 | "current_user" "extract" "localtime" "localtimestamp" "lower" "max" |
| 891 | "continue" "count" "declare" "double" "end" "escape" | 940 | "min" "mod" "nullif" "octet_length" "overlay" "placing" "session_user" |
| 892 | "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | 941 | "substring" "sum" "system_user" "translate" "treat" "trim" "upper" |
| 893 | "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | 942 | "user" |
| 894 | "precision" "primary" "procedure" "references" "rollback" | 943 | )) |
| 895 | "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" | 944 | |
| 896 | 945 | (ansi-non-reserved (sql-keywords-re | |
| 897 | ) t) "\\b"))) | 946 | "ada" "asensitive" "assignment" "asymmetric" "atomic" "between" |
| 898 | (ansi-reserved-words (eval-when-compile | 947 | "bitvar" "called" "catalog_name" "chain" "character_set_catalog" |
| 899 | (concat "\\b" | 948 | "character_set_name" "character_set_schema" "checked" "class_origin" |
| 900 | (regexp-opt '( | 949 | "cobol" "collation_catalog" "collation_name" "collation_schema" |
| 901 | 950 | "column_name" "command_function" "command_function_code" "committed" | |
| 902 | "all" "and" "any" "as" "asc" "between" "by" "check" "create" | 951 | "condition_number" "connection_name" "constraint_catalog" |
| 903 | "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | 952 | "constraint_name" "constraint_schema" "contains" "cursor_name" |
| 904 | "from" "grant" "group" "having" "in" "insert" "into" "is" | 953 | "datetime_interval_code" "datetime_interval_precision" "defined" |
| 905 | "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | 954 | "definer" "dispatch" "dynamic_function" "dynamic_function_code" |
| 906 | "public" "select" "set" "table" "to" "union" "unique" | 955 | "existing" "exists" "final" "fortran" "generated" "granted" |
| 907 | "update" "user" "values" "view" "where" "with" | 956 | "hierarchy" "hold" "implementation" "infix" "insensitive" "instance" |
| 908 | 957 | "instantiable" "invoker" "key_member" "key_type" "length" "m" | |
| 909 | ) t) "\\b"))) | 958 | "message_length" "message_octet_length" "message_text" "method" "more" |
| 910 | (ansi-types (eval-when-compile | 959 | "mumps" "name" "nullable" "number" "options" "overlaps" "overriding" |
| 911 | (concat "\\b" | 960 | "parameter_mode" "parameter_name" "parameter_ordinal_position" |
| 912 | (regexp-opt '( | 961 | "parameter_specific_catalog" "parameter_specific_name" |
| 913 | 962 | "parameter_specific_schema" "pascal" "pli" "position" "repeatable" | |
| 914 | ;; ANSI Keywords that look like types | 963 | "returned_length" "returned_octet_length" "returned_sqlstate" |
| 915 | "character" "cursor" "dec" "int" "real" | 964 | "routine_catalog" "routine_name" "routine_schema" "row_count" "scale" |
| 916 | ;; ANSI Reserved Word that look like types | 965 | "schema_name" "security" "self" "sensitive" "serializable" |
| 917 | "char" "integer" "smallint" | 966 | "server_name" "similar" "simple" "source" "specific_name" "style" |
| 918 | 967 | "subclass_origin" "sublist" "symmetric" "system" "table_name" | |
| 919 | ) t) "\\b")))) | 968 | "transaction_active" "transactions_committed" |
| 920 | (list (cons ansi-keywords 'font-lock-keyword-face) | 969 | "transactions_rolled_back" "transform" "transforms" "trigger_catalog" |
| 921 | (cons ansi-reserved-words 'font-lock-keyword-face) | 970 | "trigger_name" "trigger_schema" "type" "uncommitted" "unnamed" |
| 922 | (cons ansi-types 'font-lock-type-face))) | 971 | "user_defined_type_catalog" "user_defined_type_name" |
| 972 | "user_defined_type_schema" | ||
| 973 | )) | ||
| 974 | |||
| 975 | (ansi-reserved (sql-keywords-re | ||
| 976 | "absolute" "action" "add" "admin" "after" "aggregate" "alias" "all" | ||
| 977 | "allocate" "alter" "and" "any" "are" "as" "asc" "assertion" "at" | ||
| 978 | "authorization" "before" "begin" "both" "breadth" "by" "call" | ||
| 979 | "cascade" "cascaded" "case" "catalog" "check" "class" "close" | ||
| 980 | "collate" "collation" "column" "commit" "completion" "connect" | ||
| 981 | "connection" "constraint" "constraints" "constructor" "continue" | ||
| 982 | "corresponding" "create" "cross" "cube" "current" "cursor" "cycle" | ||
| 983 | "data" "day" "deallocate" "declare" "default" "deferrable" "deferred" | ||
| 984 | "delete" "depth" "deref" "desc" "describe" "descriptor" "destroy" | ||
| 985 | "destructor" "deterministic" "diagnostics" "dictionary" "disconnect" | ||
| 986 | "distinct" "domain" "drop" "dynamic" "each" "else" "end" "equals" | ||
| 987 | "escape" "every" "except" "exception" "exec" "execute" "external" | ||
| 988 | "false" "fetch" "first" "for" "foreign" "found" "free" "from" "full" | ||
| 989 | "function" "general" "get" "global" "go" "goto" "grant" "group" | ||
| 990 | "grouping" "having" "host" "hour" "identity" "ignore" "immediate" "in" | ||
| 991 | "indicator" "initialize" "initially" "inner" "inout" "input" "insert" | ||
| 992 | "intersect" "into" "is" "isolation" "iterate" "join" "key" "language" | ||
| 993 | "last" "lateral" "leading" "left" "less" "level" "like" "limit" | ||
| 994 | "local" "locator" "map" "match" "minute" "modifies" "modify" "module" | ||
| 995 | "month" "names" "natural" "new" "next" "no" "none" "not" "null" "of" | ||
| 996 | "off" "old" "on" "only" "open" "operation" "option" "or" "order" | ||
| 997 | "ordinality" "out" "outer" "output" "pad" "parameter" "parameters" | ||
| 998 | "partial" "path" "postfix" "prefix" "preorder" "prepare" "preserve" | ||
| 999 | "primary" "prior" "privileges" "procedure" "public" "read" "reads" | ||
| 1000 | "recursive" "references" "referencing" "relative" "restrict" "result" | ||
| 1001 | "return" "returns" "revoke" "right" "role" "rollback" "rollup" | ||
| 1002 | "routine" "rows" "savepoint" "schema" "scroll" "search" "second" | ||
| 1003 | "section" "select" "sequence" "session" "set" "sets" "size" "some" | ||
| 1004 | "space" "specific" "specifictype" "sql" "sqlexception" "sqlstate" | ||
| 1005 | "sqlwarning" "start" "state" "statement" "static" "structure" "table" | ||
| 1006 | "temporary" "terminate" "than" "then" "timezone_hour" | ||
| 1007 | "timezone_minute" "to" "trailing" "transaction" "translation" | ||
| 1008 | "trigger" "true" "under" "union" "unique" "unknown" "unnest" "update" | ||
| 1009 | "usage" "using" "value" "values" "variable" "view" "when" "whenever" | ||
| 1010 | "where" "with" "without" "work" "write" "year" | ||
| 1011 | )) | ||
| 1012 | |||
| 1013 | (ansi-types (sql-keywords-re | ||
| 1014 | "array" "binary" "bit" "blob" "boolean" "char" "character" "clob" | ||
| 1015 | "date" "dec" "decimal" "double" "float" "int" "integer" "interval" | ||
| 1016 | "large" "national" "nchar" "nclob" "numeric" "object" "precision" | ||
| 1017 | "real" "ref" "row" "scope" "smallint" "time" "timestamp" "varchar" | ||
| 1018 | "varying" "zone" | ||
| 1019 | ))) | ||
| 1020 | |||
| 1021 | `((,ansi-non-reserved . font-lock-keyword-face) | ||
| 1022 | (,ansi-reserved . font-lock-keyword-face) | ||
| 1023 | (,ansi-funcs . ,sql-builtin-face) | ||
| 1024 | (,ansi-types . font-lock-type-face))) | ||
| 923 | 1025 | ||
| 924 | "ANSI SQL keywords used by font-lock. | 1026 | "ANSI SQL keywords used by font-lock. |
| 925 | 1027 | ||
| @@ -930,66 +1032,156 @@ you define your own sql-mode-ansi-font-lock-keywords. You may want to | |||
| 930 | add functions and PL/SQL keywords.") | 1032 | add functions and PL/SQL keywords.") |
| 931 | 1033 | ||
| 932 | (defvar sql-mode-oracle-font-lock-keywords | 1034 | (defvar sql-mode-oracle-font-lock-keywords |
| 933 | (let ((oracle-keywords (eval-when-compile | 1035 | (let ((oracle-functions (sql-keywords-re |
| 934 | (concat "\\b" | 1036 | "abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2" |
| 935 | (regexp-opt '( | 1037 | "avg" "bfilename" "bin_to_num" "bitand" "cast" "ceil" "chartorowid" |
| 936 | ;; Oracle (+ANSI) SQL keywords | 1038 | "chr" "coalesce" "compose" "concat" "convert" "corr" "cos" "cosh" |
| 937 | 1039 | "count" "covar_pop" "covar_samp" "cume_dist" "current_date" | |
| 938 | ; ANSI keywords | 1040 | "current_timestamp" "current_user" "dbtimezone" "decode" "decompose" |
| 939 | "authorization" "avg" "begin" "close" "cobol" "commit" | 1041 | "dense_rank" "depth" "deref" "dump" "empty_clob" "existsnode" "exp" |
| 940 | "continue" "count" "declare" "double" "end" "escape" | 1042 | "extract" "extractvalue" "first" "first_value" "floor" "following" |
| 941 | "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | 1043 | "from_tz" "greatest" "group_id" "grouping_id" "hextoraw" "initcap" |
| 942 | "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | 1044 | "instr" "lag" "last" "last_day" "last_value" "lead" "least" "length" |
| 943 | "precision" "primary" "procedure" "references" "rollback" | 1045 | "ln" "localtimestamp" "lower" "lpad" "ltrim" "make_ref" "max" "min" |
| 944 | "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" | 1046 | "mod" "months_between" "new_time" "next_day" "nls_charset_decl_len" |
| 945 | 1047 | "nls_charset_id" "nls_charset_name" "nls_initcap" "nls_lower" | |
| 946 | ; ANSI reserved words | 1048 | "nls_upper" "nlssort" "ntile" "nullif" "numtodsinterval" |
| 947 | "all" "and" "any" "as" "asc" "between" "by" "check" "create" | 1049 | "numtoyminterval" "nvl" "nvl2" "over" "path" "percent_rank" |
| 948 | "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | 1050 | "percentile_cont" "percentile_disc" "power" "preceding" "rank" |
| 949 | "from" "grant" "group" "having" "in" "insert" "into" "is" | 1051 | "ratio_to_report" "rawtohex" "rawtonhex" "reftohex" "regr_" |
| 950 | "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | 1052 | "regr_avgx" "regr_avgy" "regr_count" "regr_intercept" "regr_r2" |
| 951 | "public" "select" "set" "table" "to" "union" "unique" | 1053 | "regr_slope" "regr_sxx" "regr_sxy" "regr_syy" "replace" "round" |
| 952 | "update" "user" "values" "view" "where" "with" | 1054 | "row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim" |
| 953 | 1055 | "sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev" | |
| 954 | "access" "add" "admin" "after" "allocate" "alter" "analyze" "archive" | 1056 | "stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path" |
| 955 | "archivelog" "audit" "authid" "backup" "become" "before" "block" | 1057 | "sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid" |
| 956 | "body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster" | 1058 | "sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh" |
| 957 | "comment" "compile" "compress" "compute" "connect" "constraint" | 1059 | "to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte" |
| 958 | "constraints" "contents" "controlfile" "cross" "currval" "cycle" | 1060 | "to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp" |
| 959 | "database" "datafile" "dba" "deterministic" "disable" "dismount" | 1061 | "to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc" |
| 960 | "drop" "dump" "each" "else" "else" "elsif" "enable" "events" "except" | 1062 | "tz_offset" "uid" "unbounded" "unistr" "updatexml" "upper" "user" |
| 961 | "exceptions" "exclusive" "execute" "exit" "explain" "extent" | 1063 | "userenv" "var_pop" "var_samp" "variance" "vsize" "width_bucket" "xml" |
| 962 | "externally" "false" "file" "flush" "force" "freelist" "freelists" | 1064 | "xmlagg" "xmlattribute" "xmlcolattval" "xmlconcat" "xmlelement" |
| 963 | "full" "function" "global" "grant" "groups" "identified" "if" | 1065 | "xmlforest" "xmlsequence" "xmltransform" |
| 964 | "immediate" "including" "increment" "index" "initial" "initrans" | 1066 | )) |
| 965 | "inner" "instance" "intersect" "join" "layer" "left" "level" "link" | 1067 | |
| 966 | "lists" "lock" "logfile" "long" "loop" "manage" "manual" | 1068 | (oracle-keywords (sql-keywords-re |
| 967 | "maxdatafiles" "maxextents" "maxinistances" "maxlogfiles" | 1069 | "abort" "access" "accessed" "account" "activate" "add" "admin" |
| 968 | "maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" "merge" | 1070 | "advise" "after" "agent" "aggregate" "all" "allocate" "allow" "alter" |
| 969 | "minextents" "minus" "minvalue" "mode" "modify" "mount" "natural" | 1071 | "always" "analyze" "ancillary" "and" "any" "apply" "archive" |
| 970 | "new" "next" "nextval" "noarchivelog" "noaudit" "nocache" "nocompress" | 1072 | "archivelog" "array" "as" "asc" "associate" "at" "attribute" |
| 971 | "nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs" | 1073 | "attributes" "audit" "authenticated" "authid" "authorization" "auto" |
| 972 | "normal" "nosort" "nowait" "off" "offline" "old" "online" "only" | 1074 | "autoallocate" "automatic" "availability" "backup" "before" "begin" |
| 973 | "optimal" "others" "out" "outer" "over" "own" "package" "parallel" | 1075 | "behalf" "between" "binding" "bitmap" "block" "blocksize" "body" |
| 974 | "parallel_enable" "pctfree" "pctincrease" "pctused" "plan" "pragma" | 1076 | "both" "buffer_pool" "build" "by" "cache" "call" "cancel" |
| 975 | "preserve" "prior" "private" "profile" "quota" "raise" "raw" "read" | 1077 | "cascade" "case" "category" "certificate" "chained" "change" "check" |
| 976 | "recover" "referencing" "rename" "replace" "resetlogs" "resource" | 1078 | "checkpoint" "child" "chunk" "class" "clear" "clone" "close" "cluster" |
| 977 | "restrict_references" "restricted" "return" "returning" "reuse" | 1079 | "column" "column_value" "columns" "comment" "commit" "committed" |
| 978 | "revoke" "right" "rnds" "rnps" "role" "roles" "row" "rowlabel" | 1080 | "compatibility" "compile" "complete" "composite_limit" "compress" |
| 979 | "rownum" "rows" "savepoint" "scn" "segment" "sequence" "session" | 1081 | "compute" "connect" "connect_time" "consider" "consistent" |
| 980 | "share" "shared" "size" "snapshot" "sort" "statement_id" "statistics" | 1082 | "constraint" "constraints" "constructor" "contents" "context" |
| 981 | "stop" "storage" "subtype" "successful" "switch" "synonym" "sysdate" | 1083 | "continue" "controlfile" "corruption" "cost" "cpu_per_call" |
| 982 | "system" "tables" "tablespace" "temporary" "then" "thread" "tracing" | 1084 | "cpu_per_session" "create" "cross" "cube" "current" "currval" "cycle" |
| 983 | "transaction" "trigger" "triggers" "true" "truncate" "type" "uid" | 1085 | "dangling" "data" "database" "datafile" "datafiles" "day" "ddl" |
| 984 | "under" "unlimited" "until" "use" "using" "validate" "when" "while" | 1086 | "deallocate" "debug" "default" "deferrable" "deferred" "definer" |
| 985 | "wnds" "wnps" "write" | 1087 | "delay" "delete" "demand" "desc" "determines" "deterministic" |
| 986 | 1088 | "dictionary" "dimension" "directory" "disable" "disassociate" | |
| 987 | ) t) "\\b"))) | 1089 | "disconnect" "distinct" "distinguished" "distributed" "dml" "drop" |
| 988 | (oracle-warning-words (eval-when-compile | 1090 | "each" "element" "else" "enable" "end" "equals_path" "escape" |
| 989 | (concat "\\b" | 1091 | "estimate" "except" "exceptions" "exchange" "excluding" "exists" |
| 990 | (regexp-opt '( | 1092 | "expire" "explain" "extent" "external" "externally" |
| 991 | ;; PLSQL defined exceptions | 1093 | "failed_login_attempts" "fast" "file" "final" "finish" "flush" "for" |
| 992 | 1094 | "force" "foreign" "freelist" "freelists" "freepools" "fresh" "from" | |
| 1095 | "full" "function" "functions" "generated" "global" "global_name" | ||
| 1096 | "globally" "grant" "group" "grouping" "groups" "guard" "hash" | ||
| 1097 | "hashkeys" "having" "heap" "hierarchy" "id" "identified" "identifier" | ||
| 1098 | "idle_time" "immediate" "in" "including" "increment" "index" "indexed" | ||
| 1099 | "indexes" "indextype" "indextypes" "indicator" "initial" "initialized" | ||
| 1100 | "initially" "initrans" "inner" "insert" "instance" "instantiable" | ||
| 1101 | "instead" "intersect" "into" "invalidate" "is" "isolation" "java" | ||
| 1102 | "join" "keep" "key" "kill" "language" "left" "less" "level" | ||
| 1103 | "levels" "library" "like" "like2" "like4" "likec" "limit" "link" | ||
| 1104 | "list" "lob" "local" "location" "locator" "lock" "log" "logfile" | ||
| 1105 | "logging" "logical" "logical_reads_per_call" | ||
| 1106 | "logical_reads_per_session" "managed" "management" "manual" "map" | ||
| 1107 | "mapping" "master" "matched" "materialized" "maxdatafiles" | ||
| 1108 | "maxextents" "maximize" "maxinstances" "maxlogfiles" "maxloghistory" | ||
| 1109 | "maxlogmembers" "maxsize" "maxtrans" "maxvalue" "member" "memory" | ||
| 1110 | "merge" "migrate" "minextents" "minimize" "minimum" "minus" "minvalue" | ||
| 1111 | "mode" "modify" "monitoring" "month" "mount" "move" "movement" "name" | ||
| 1112 | "named" "natural" "nested" "never" "new" "next" "nextval" "no" | ||
| 1113 | "noarchivelog" "noaudit" "nocache" "nocompress" "nocopy" "nocycle" | ||
| 1114 | "nodelay" "noforce" "nologging" "nomapping" "nomaxvalue" "nominimize" | ||
| 1115 | "nominvalue" "nomonitoring" "none" "noorder" "noparallel" "norely" | ||
| 1116 | "noresetlogs" "noreverse" "normal" "norowdependencies" "nosort" | ||
| 1117 | "noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null" | ||
| 1118 | "nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online" | ||
| 1119 | "only" "open" "operator" "optimal" "option" "or" "order" | ||
| 1120 | "organization" "out" "outer" "outline" "overflow" "overriding" | ||
| 1121 | "package" "packages" "parallel" "parallel_enable" "parameters" | ||
| 1122 | "parent" "partition" "partitions" "password" "password_grace_time" | ||
| 1123 | "password_life_time" "password_lock_time" "password_reuse_max" | ||
| 1124 | "password_reuse_time" "password_verify_function" "pctfree" | ||
| 1125 | "pctincrease" "pctthreshold" "pctused" "pctversion" "percent" | ||
| 1126 | "performance" "permanent" "pfile" "physical" "pipelined" "plan" | ||
| 1127 | "post_transaction" "pragma" "prebuilt" "preserve" "primary" "private" | ||
| 1128 | "private_sga" "privileges" "procedure" "profile" "protection" "public" | ||
| 1129 | "purge" "query" "quiesce" "quota" "range" "read" "reads" "rebuild" | ||
| 1130 | "records_per_block" "recover" "recovery" "recycle" "reduced" "ref" | ||
| 1131 | "references" "referencing" "refresh" "register" "reject" "relational" | ||
| 1132 | "rely" "rename" "reset" "resetlogs" "resize" "resolve" "resolver" | ||
| 1133 | "resource" "restrict" "restrict_references" "restricted" "result" | ||
| 1134 | "resumable" "resume" "retention" "return" "returning" "reuse" | ||
| 1135 | "reverse" "revoke" "rewrite" "right" "rnds" "rnps" "role" "roles" | ||
| 1136 | "rollback" "rollup" "row" "rowdependencies" "rownum" "rows" "sample" | ||
| 1137 | "savepoint" "scan" "schema" "scn" "scope" "segment" "select" | ||
| 1138 | "selectivity" "self" "sequence" "serializable" "session" | ||
| 1139 | "sessions_per_user" "set" "sets" "settings" "shared" "shared_pool" | ||
| 1140 | "shrink" "shutdown" "siblings" "sid" "single" "size" "skip" "some" | ||
| 1141 | "sort" "source" "space" "specification" "spfile" "split" "standby" | ||
| 1142 | "start" "statement_id" "static" "statistics" "stop" "storage" "store" | ||
| 1143 | "structure" "subpartition" "subpartitions" "substitutable" | ||
| 1144 | "successful" "supplemental" "suspend" "switch" "switchover" "synonym" | ||
| 1145 | "sys" "system" "table" "tables" "tablespace" "tempfile" "template" | ||
| 1146 | "temporary" "test" "than" "then" "thread" "through" "time_zone" | ||
| 1147 | "timeout" "to" "trace" "transaction" "trigger" "triggers" "truncate" | ||
| 1148 | "trust" "type" "types" "unarchived" "under" "under_path" "undo" | ||
| 1149 | "uniform" "union" "unique" "unlimited" "unlock" "unquiesce" | ||
| 1150 | "unrecoverable" "until" "unusable" "unused" "update" "upgrade" "usage" | ||
| 1151 | "use" "using" "validate" "validation" "value" "values" "variable" | ||
| 1152 | "varray" "version" "view" "wait" "when" "whenever" "where" "with" | ||
| 1153 | "without" "wnds" "wnps" "work" "write" "xmldata" "xmlschema" "xmltype" | ||
| 1154 | )) | ||
| 1155 | |||
| 1156 | (oracle-types (sql-keywords-re | ||
| 1157 | "bfile" "blob" "byte" "char" "character" "clob" "date" "dec" "decimal" | ||
| 1158 | "double" "float" "int" "integer" "interval" "long" "national" "nchar" | ||
| 1159 | "nclob" "number" "numeric" "nvarchar2" "precision" "raw" "real" | ||
| 1160 | "rowid" "second" "smallint" "time" "timestamp" "urowid" "varchar" | ||
| 1161 | "varchar2" "varying" "year" "zone" | ||
| 1162 | )) | ||
| 1163 | |||
| 1164 | (plsql-functions (sql-keywords-re | ||
| 1165 | "%bulk_rowcount" "%found" "%isopen" "%notfound" "%rowcount" "%rowtype" | ||
| 1166 | "%type" "extend" "prior" | ||
| 1167 | )) | ||
| 1168 | |||
| 1169 | (plsql-keywords (sql-keywords-re | ||
| 1170 | "autonomous_transaction" "bulk" "char_base" "collect" "constant" | ||
| 1171 | "cursor" "declare" "do" "elsif" "exception_init" "execute" "exit" | ||
| 1172 | "extends" "false" "fetch" "forall" "goto" "hour" "if" "interface" | ||
| 1173 | "loop" "minute" "number_base" "ocirowid" "opaque" "others" "rowtype" | ||
| 1174 | "separate" "serially_reusable" "sql" "sqlcode" "sqlerrm" "subtype" | ||
| 1175 | "the" "timezone_abbr" "timezone_hour" "timezone_minute" | ||
| 1176 | "timezone_region" "true" "varrying" "while" | ||
| 1177 | )) | ||
| 1178 | |||
| 1179 | (plsql-type (sql-keywords-re | ||
| 1180 | "binary_integer" "boolean" "naturaln" "pls_integer" "positive" | ||
| 1181 | "positiven" "record" "signtype" "string" | ||
| 1182 | )) | ||
| 1183 | |||
| 1184 | (plsql-warning (sql-keywords-re | ||
| 993 | "access_into_null" "case_not_found" "collection_is_null" | 1185 | "access_into_null" "case_not_found" "collection_is_null" |
| 994 | "cursor_already_open" "dup_val_on_index" "invalid_cursor" | 1186 | "cursor_already_open" "dup_val_on_index" "invalid_cursor" |
| 995 | "invalid_number" "login_denied" "no_data_found" "not_logged_on" | 1187 | "invalid_number" "login_denied" "no_data_found" "not_logged_on" |
| @@ -997,15 +1189,11 @@ add functions and PL/SQL keywords.") | |||
| 997 | "subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" | 1189 | "subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" |
| 998 | "timeout_on_resource" "too_many_rows" "value_error" "zero_divide" | 1190 | "timeout_on_resource" "too_many_rows" "value_error" "zero_divide" |
| 999 | "exception" "notfound" | 1191 | "exception" "notfound" |
| 1192 | )) | ||
| 1000 | 1193 | ||
| 1001 | ) t) "\\b"))) | 1194 | (sqlplus-commands |
| 1002 | 1195 | (eval-when-compile (concat "^\\(\\(" | |
| 1003 | (oracle-sqlplus-commands | 1196 | (regexp-opt '( |
| 1004 | (eval-when-compile | ||
| 1005 | (concat "^\\(\\(" | ||
| 1006 | (regexp-opt '( | ||
| 1007 | ;; SQL*Plus commands | ||
| 1008 | |||
| 1009 | "@" "@@" "accept" "append" "archive" "attribute" "break" | 1197 | "@" "@@" "accept" "append" "archive" "attribute" "break" |
| 1010 | "btitle" "change" "clear" "column" "connect" "copy" "define" | 1198 | "btitle" "change" "clear" "column" "connect" "copy" "define" |
| 1011 | "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" | 1199 | "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" |
| @@ -1040,73 +1228,16 @@ add functions and PL/SQL keywords.") | |||
| 1040 | "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|" | 1228 | "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|" |
| 1041 | "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)" | 1229 | "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)" |
| 1042 | "\\b.*$" | 1230 | "\\b.*$" |
| 1043 | ))) | 1231 | )))) |
| 1044 | 1232 | ||
| 1045 | (oracle-types | 1233 | `((,sqlplus-commands . ,sql-doc-face) |
| 1046 | (eval-when-compile | 1234 | (,oracle-functions . ,sql-builtin-face) |
| 1047 | (concat "\\b" | 1235 | (,oracle-keywords . font-lock-keyword-face) |
| 1048 | (regexp-opt '( | 1236 | (,oracle-types . font-lock-type-face) |
| 1049 | ;; Oracle Keywords that look like types | 1237 | (,plsql-functions . ,sql-builtin-face) |
| 1050 | ;; Oracle Reserved Words that look like types | 1238 | (,plsql-keywords . font-lock-keyword-face) |
| 1051 | 1239 | (,plsql-type . font-lock-type-face) | |
| 1052 | "bfile" "binary_integer" "blob" "boolean" "byte" "char" "character" | 1240 | (,plsql-warning . font-lock-warning-face))) |
| 1053 | "clob" "date" "day" "dec" "decimal" "double" "float" "int" "integer" | ||
| 1054 | "interval" "local" "long" "month" "natural" "naturaln" "nchar" "nclob" | ||
| 1055 | "number" "numeric" "nvarchar2" "pls_integer" "positive" "positiven" | ||
| 1056 | "precision" "raw" "real" "rowid" "second" "signtype" "smallint" | ||
| 1057 | "string" "time" "timestamp" "urowid" "varchar" "varchar2" "year" | ||
| 1058 | "zone" | ||
| 1059 | |||
| 1060 | ) t) "\\b"))) | ||
| 1061 | (oracle-builtin-functions (eval-when-compile | ||
| 1062 | (concat "\\b" | ||
| 1063 | (regexp-opt '( | ||
| 1064 | ;; Misc Oracle builtin functions | ||
| 1065 | |||
| 1066 | "abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2" | ||
| 1067 | "avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil" | ||
| 1068 | "chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr" | ||
| 1069 | "cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist" | ||
| 1070 | "current_date" "current_timestamp" "current_user" "dbtimezone" | ||
| 1071 | "decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob" | ||
| 1072 | "empty_clob" "existsnode" "exp" "extract" "extractvalue" "first" | ||
| 1073 | "first_value" "floor" "from_tz" "greatest" "group_id" "grouping" | ||
| 1074 | "grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day" | ||
| 1075 | "last_value" "lead" "least" "length" "ln" "localtimestamp" "log" | ||
| 1076 | "lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between" | ||
| 1077 | "nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id" | ||
| 1078 | "nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper" | ||
| 1079 | "ntile" "nullif" "numtodsinterval" "numtoyminterval" "nvl" "nvl2" | ||
| 1080 | "path" "percent_rank" "percentile_cont" "percentile_disc" "power" | ||
| 1081 | "rank" "ratio_to_report" "rawtohex" "rawtonhex" "ref" "reftohex" | ||
| 1082 | "regr_slope" "regr_intercept" "regr_count" "regr_r2" "regr_avgx" | ||
| 1083 | "regr_avgy" "regr_sxx" "regr_syy" "regr_sxy" "round" | ||
| 1084 | "row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim" | ||
| 1085 | "sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev" | ||
| 1086 | "stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path" | ||
| 1087 | "sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid" | ||
| 1088 | "sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh" | ||
| 1089 | "to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte" | ||
| 1090 | "to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp" | ||
| 1091 | "to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc" | ||
| 1092 | "tz_offset" "uid" "unistr" "updatexml" "upper" "user" "userenv" | ||
| 1093 | "value" "var_pop" "var_samp" "variance" "vsize" "width_bucket" | ||
| 1094 | "xmlagg" "xmlcolattval" "xmlconcat" "xmlelement" "xmlforest" | ||
| 1095 | "xmlsequence" "xmltransform" | ||
| 1096 | |||
| 1097 | ) t) "\\b")))) | ||
| 1098 | (list (cons oracle-sqlplus-commands 'font-lock-doc-face) | ||
| 1099 | (cons oracle-keywords 'font-lock-keyword-face) | ||
| 1100 | (cons oracle-warning-words 'font-lock-warning-face) | ||
| 1101 | ;; XEmacs doesn't have font-lock-builtin-face | ||
| 1102 | (if (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 1103 | (cons oracle-builtin-functions 'font-lock-preprocessor-face) | ||
| 1104 | ;; GNU Emacs 19 doesn't have it either | ||
| 1105 | (if (string-match "GNU Emacs 19" emacs-version) | ||
| 1106 | (cons oracle-builtin-functions 'font-lock-keyword-face) | ||
| 1107 | ;; Emacs | ||
| 1108 | (cons oracle-builtin-functions 'font-lock-builtin-face))) | ||
| 1109 | (cons oracle-types 'font-lock-type-face))) | ||
| 1110 | 1241 | ||
| 1111 | "Oracle SQL keywords used by font-lock. | 1242 | "Oracle SQL keywords used by font-lock. |
| 1112 | 1243 | ||
| @@ -1117,42 +1248,84 @@ you define your own sql-mode-oracle-font-lock-keywords. You may want | |||
| 1117 | to add functions and PL/SQL keywords.") | 1248 | to add functions and PL/SQL keywords.") |
| 1118 | 1249 | ||
| 1119 | (defvar sql-mode-postgres-font-lock-keywords | 1250 | (defvar sql-mode-postgres-font-lock-keywords |
| 1120 | (let ((postgres-reserved-words (eval-when-compile | 1251 | (let ((pg-funcs (sql-keywords-re |
| 1121 | (concat "\\b" | 1252 | "abbrev" "abs" "acos" "age" "area" "ascii" "asin" "atab2" "atan" |
| 1122 | (regexp-opt '( | 1253 | "atan2" "avg" "bit_length" "both" "broadcast" "btrim" "cbrt" "ceil" |
| 1123 | "language" | 1254 | "center" "char_length" "chr" "coalesce" "col_description" "convert" |
| 1124 | ) t) "\\b"))) | 1255 | "cos" "cot" "count" "current_database" "current_date" "current_schema" |
| 1125 | (postgres-types (eval-when-compile | 1256 | "current_schemas" "current_setting" "current_time" "current_timestamp" |
| 1126 | (concat "\\b" | 1257 | "current_user" "currval" "date_part" "date_trunc" "decode" "degrees" |
| 1127 | (regexp-opt '( | 1258 | "diameter" "encode" "exp" "extract" "floor" "get_bit" "get_byte" |
| 1128 | 1259 | "has_database_privilege" "has_function_privilege" | |
| 1129 | "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" | 1260 | "has_language_privilege" "has_schema_privilege" "has_table_privilege" |
| 1130 | "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" | 1261 | "height" "host" "initcap" "isclosed" "isfinite" "isopen" "leading" |
| 1131 | "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" | 1262 | "length" "ln" "localtime" "localtimestamp" "log" "lower" "lpad" |
| 1132 | 1263 | "ltrim" "masklen" "max" "min" "mod" "netmask" "network" "nextval" | |
| 1133 | ) t)"\\b"))) | 1264 | "now" "npoints" "nullif" "obj_description" "octet_length" "overlay" |
| 1134 | (postgres-builtin-functions (eval-when-compile | 1265 | "pclose" "pg_client_encoding" "pg_function_is_visible" |
| 1135 | (concat "\\b" | 1266 | "pg_get_constraintdef" "pg_get_indexdef" "pg_get_ruledef" |
| 1136 | (regexp-opt '( | 1267 | "pg_get_userbyid" "pg_get_viewdef" "pg_opclass_is_visible" |
| 1137 | ;; Misc Postgres builtin functions | 1268 | "pg_operator_is_visible" "pg_table_is_visible" "pg_type_is_visible" |
| 1138 | 1269 | "pi" "popen" "position" "pow" "quote_ident" "quote_literal" "radians" | |
| 1139 | "abstime" "age" "area" "box" "center" "date_part" "date_trunc" | 1270 | "radius" "random" "repeat" "replace" "round" "rpad" "rtrim" |
| 1140 | "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" | 1271 | "session_user" "set_bit" "set_byte" "set_config" "set_masklen" |
| 1141 | "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" | 1272 | "setval" "sign" "sin" "split_part" "sqrt" "stddev" "strpos" "substr" |
| 1142 | "length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" | 1273 | "substring" "sum" "tan" "timeofday" "to_ascii" "to_char" "to_date" |
| 1143 | "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" | 1274 | "to_hex" "to_number" "to_timestamp" "trailing" "translate" "trim" |
| 1144 | "substring" "text" "timespan" "translate" "trim" "upgradepath" | 1275 | "trunc" "upper" "variance" "version" "width" |
| 1145 | "upgradepoly" "upper" "varchar" "width" | 1276 | )) |
| 1146 | 1277 | ||
| 1147 | ) t) "\\b")))) | 1278 | (pg-reserved (sql-keywords-re |
| 1148 | (append sql-mode-ansi-font-lock-keywords | 1279 | "abort" "access" "add" "after" "aggregate" "alignment" "all" "alter" |
| 1149 | (list (cons postgres-reserved-words 'font-lock-keyword-face) | 1280 | "analyze" "and" "any" "as" "asc" "assignment" "authorization" |
| 1150 | ;; XEmacs doesn't have 'font-lock-builtin-face | 1281 | "backward" "basetype" "before" "begin" "between" "binary" "by" "cache" |
| 1151 | (if (string-match "XEmacs\\|Lucid" emacs-version) | 1282 | "called" "cascade" "case" "cast" "characteristics" "check" |
| 1152 | (cons postgres-builtin-functions 'font-lock-preprocessor-face) | 1283 | "checkpoint" "class" "close" "cluster" "column" "comment" "commit" |
| 1153 | ;; Emacs | 1284 | "committed" "commutator" "constraint" "constraints" "conversion" |
| 1154 | (cons postgres-builtin-functions 'font-lock-builtin-face)) | 1285 | "copy" "create" "createdb" "createuser" "cursor" "cycle" "database" |
| 1155 | (cons postgres-types 'font-lock-type-face)))) | 1286 | "deallocate" "declare" "default" "deferrable" "deferred" "definer" |
| 1287 | "delete" "delimiter" "desc" "distinct" "do" "domain" "drop" "each" | ||
| 1288 | "element" "else" "encoding" "encrypted" "end" "escape" "except" | ||
| 1289 | "exclusive" "execute" "exists" "explain" "extended" "external" "false" | ||
| 1290 | "fetch" "finalfunc" "for" "force" "foreign" "forward" "freeze" "from" | ||
| 1291 | "full" "function" "grant" "group" "gtcmp" "handler" "hashes" "having" | ||
| 1292 | "immediate" "immutable" "implicit" "in" "increment" "index" "inherits" | ||
| 1293 | "initcond" "initially" "input" "insensitive" "insert" "instead" | ||
| 1294 | "internallength" "intersect" "into" "invoker" "is" "isnull" | ||
| 1295 | "isolation" "join" "key" "language" "leftarg" "level" "like" "limit" | ||
| 1296 | "listen" "load" "local" "location" "lock" "ltcmp" "main" "match" | ||
| 1297 | "maxvalue" "merges" "minvalue" "mode" "move" "natural" "negator" | ||
| 1298 | "next" "nocreatedb" "nocreateuser" "none" "not" "nothing" "notify" | ||
| 1299 | "notnull" "null" "of" "offset" "oids" "on" "only" "operator" "or" | ||
| 1300 | "order" "output" "owner" "partial" "passedbyvalue" "password" "plain" | ||
| 1301 | "prepare" "primary" "prior" "privileges" "procedural" "procedure" | ||
| 1302 | "public" "read" "recheck" "references" "reindex" "relative" "rename" | ||
| 1303 | "reset" "restrict" "returns" "revoke" "rightarg" "rollback" "row" | ||
| 1304 | "rule" "schema" "scroll" "security" "select" "sequence" "serializable" | ||
| 1305 | "session" "set" "sfunc" "share" "show" "similar" "some" "sort1" | ||
| 1306 | "sort2" "stable" "start" "statement" "statistics" "storage" "strict" | ||
| 1307 | "stype" "sysid" "table" "temp" "template" "temporary" "then" "to" | ||
| 1308 | "transaction" "trigger" "true" "truncate" "trusted" "type" | ||
| 1309 | "unencrypted" "union" "unique" "unknown" "unlisten" "until" "update" | ||
| 1310 | "usage" "user" "using" "vacuum" "valid" "validator" "values" | ||
| 1311 | "variable" "verbose" "view" "volatile" "when" "where" "with" "without" | ||
| 1312 | "work" | ||
| 1313 | )) | ||
| 1314 | |||
| 1315 | (pg-types (sql-keywords-re | ||
| 1316 | "anyarray" "bigint" "bigserial" "bit" "boolean" "box" "bytea" "char" | ||
| 1317 | "character" "cidr" "circle" "cstring" "date" "decimal" "double" | ||
| 1318 | "float4" "float8" "inet" "int2" "int4" "int8" "integer" "internal" | ||
| 1319 | "interval" "language_handler" "line" "lseg" "macaddr" "money" | ||
| 1320 | "numeric" "oid" "opaque" "path" "point" "polygon" "precision" "real" | ||
| 1321 | "record" "regclass" "regoper" "regoperator" "regproc" "regprocedure" | ||
| 1322 | "regtype" "serial" "serial4" "serial8" "smallint" "text" "time" | ||
| 1323 | "timestamp" "varchar" "varying" "void" "zone" | ||
| 1324 | ))) | ||
| 1325 | |||
| 1326 | `((,pg-funcs . ,sql-builtin-face) | ||
| 1327 | (,pg-reserved . font-lock-keyword-face) | ||
| 1328 | (,pg-types . font-lock-type-face))) | ||
| 1156 | 1329 | ||
| 1157 | "Postgres SQL keywords used by font-lock. | 1330 | "Postgres SQL keywords used by font-lock. |
| 1158 | 1331 | ||
| @@ -1162,10 +1335,7 @@ function `regexp-opt'. Therefore, take a look at the source before | |||
| 1162 | you define your own sql-mode-postgres-font-lock-keywords.") | 1335 | you define your own sql-mode-postgres-font-lock-keywords.") |
| 1163 | 1336 | ||
| 1164 | (defvar sql-mode-linter-font-lock-keywords | 1337 | (defvar sql-mode-linter-font-lock-keywords |
| 1165 | (let ((linter-keywords (eval-when-compile | 1338 | (let ((linter-keywords (sql-keywords-re |
| 1166 | (concat "\\b" | ||
| 1167 | (regexp-opt '( | ||
| 1168 | |||
| 1169 | "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" | 1339 | "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" |
| 1170 | "committed" "count" "countblob" "cross" "current" "data" "database" | 1340 | "committed" "count" "countblob" "cross" "current" "data" "database" |
| 1171 | "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" | 1341 | "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" |
| @@ -1190,12 +1360,9 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1190 | "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" | 1360 | "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" |
| 1191 | "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" | 1361 | "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" |
| 1192 | "wait" "windows_code" "workspace" "write" "xml" | 1362 | "wait" "windows_code" "workspace" "write" "xml" |
| 1363 | )) | ||
| 1193 | 1364 | ||
| 1194 | ) t) "\\b"))) | 1365 | (linter-reserved (sql-keywords-re |
| 1195 | (linter-reserved-words (eval-when-compile | ||
| 1196 | (concat "\\b" | ||
| 1197 | (regexp-opt '( | ||
| 1198 | |||
| 1199 | "access" "action" "add" "address" "after" "all" "alter" "always" "and" | 1366 | "access" "action" "add" "address" "after" "all" "alter" "always" "and" |
| 1200 | "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" | 1367 | "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" |
| 1201 | "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" | 1368 | "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" |
| @@ -1213,22 +1380,16 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1213 | "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" | 1380 | "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" |
| 1214 | "to" "union" "unique" "unlock" "until" "update" "using" "values" | 1381 | "to" "union" "unique" "unlock" "until" "update" "using" "values" |
| 1215 | "view" "when" "where" "with" "without" | 1382 | "view" "when" "where" "with" "without" |
| 1383 | )) | ||
| 1216 | 1384 | ||
| 1217 | ) t) "\\b"))) | 1385 | (linter-types (sql-keywords-re |
| 1218 | (linter-types (eval-when-compile | ||
| 1219 | (concat "\\b" | ||
| 1220 | (regexp-opt '( | ||
| 1221 | |||
| 1222 | "bigint" "bitmap" "blob" "boolean" "char" "character" "date" | 1386 | "bigint" "bitmap" "blob" "boolean" "char" "character" "date" |
| 1223 | "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" | 1387 | "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" |
| 1224 | "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" | 1388 | "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" |
| 1225 | "cursor" "long" | 1389 | "cursor" "long" |
| 1390 | )) | ||
| 1226 | 1391 | ||
| 1227 | ) t) "\\b"))) | 1392 | (linter-functions (sql-keywords-re |
| 1228 | (linter-builtin-functions (eval-when-compile | ||
| 1229 | (concat "\\b" | ||
| 1230 | (regexp-opt '( | ||
| 1231 | |||
| 1232 | "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" | 1393 | "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" |
| 1233 | "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" | 1394 | "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" |
| 1234 | "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" | 1395 | "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" |
| @@ -1239,20 +1400,12 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 1239 | "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" | 1400 | "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" |
| 1240 | "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" | 1401 | "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" |
| 1241 | "instr" "least" "multime" "replace" "width" | 1402 | "instr" "least" "multime" "replace" "width" |
| 1403 | ))) | ||
| 1242 | 1404 | ||
| 1243 | ) t) "\\b")))) | 1405 | `((,linter-keywords . font-lock-keyword-face) |
| 1244 | (append sql-mode-ansi-font-lock-keywords | 1406 | (,linter-reserved . font-lock-keyword-face) |
| 1245 | (list (cons linter-keywords 'font-lock-keywords-face) | 1407 | (,linter-functions . ,sql-builtin-face) |
| 1246 | (cons linter-reserved-words 'font-lock-keyword-face) | 1408 | (,linter-types . font-lock-type-face))) |
| 1247 | ;; XEmacs doesn't have font-lock-builtin-face | ||
| 1248 | (if (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 1249 | (cons linter-builtin-functions 'font-lock-preprocessor-face) | ||
| 1250 | ;; GNU Emacs 19 doesn't have it either | ||
| 1251 | (if (string-match "GNU Emacs 19" emacs-version) | ||
| 1252 | (cons linter-builtin-functions 'font-lock-keywords-face) | ||
| 1253 | ;; Emacs | ||
| 1254 | (cons linter-builtin-functions 'font-lock-builtin-face))) | ||
| 1255 | (cons linter-types 'font-lock-type-face)))) | ||
| 1256 | 1409 | ||
| 1257 | "Linter SQL keywords used by font-lock. | 1410 | "Linter SQL keywords used by font-lock. |
| 1258 | 1411 | ||
| @@ -1261,21 +1414,18 @@ regular expressions are created during compilation by calling the | |||
| 1261 | function `regexp-opt'.") | 1414 | function `regexp-opt'.") |
| 1262 | 1415 | ||
| 1263 | (defvar sql-mode-ms-font-lock-keywords | 1416 | (defvar sql-mode-ms-font-lock-keywords |
| 1264 | (let ((ms-reserved-words (eval-when-compile | 1417 | (let ((ms-reserved (sql-keywords-re |
| 1265 | (concat "\\b" | ||
| 1266 | (regexp-opt '( | ||
| 1267 | |||
| 1268 | "absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization" | 1418 | "absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization" |
| 1269 | "avg" "backup" "begin" "between" "break" "browse" "bulk" "by" | 1419 | "avg" "backup" "begin" "between" "break" "browse" "bulk" "by" |
| 1270 | "cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce" | 1420 | "cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce" |
| 1271 | "column" "commit" "committed" "compute" "confirm" "constraint" | 1421 | "column" "commit" "committed" "compute" "confirm" "constraint" |
| 1272 | "contains" "containstable" "continue" "controlrow" "convert" "count" | 1422 | "contains" "containstable" "continue" "controlrow" "convert" "count" |
| 1273 | "create" "cross" "current" "current_date" "current_time" | 1423 | "create" "cross" "current" "current_date" "current_time" |
| 1274 | "current_timestamp" "current_user" "database" "deallocate" | 1424 | "current_timestamp" "current_user" "database" "deallocate" "declare" |
| 1275 | "declare" "default" "delete" "deny" "desc" "disk" "distinct" | 1425 | "default" "delete" "deny" "desc" "disk" "distinct" "distributed" |
| 1276 | "distributed" "double" "drop" "dummy" "dump" "else" "end" "errlvl" | 1426 | "double" "drop" "dummy" "dump" "else" "end" "errlvl" "errorexit" |
| 1277 | "errorexit" "escape" "except" "exec" "execute" "exists" "exit" "fetch" | 1427 | "escape" "except" "exec" "execute" "exists" "exit" "fetch" "file" |
| 1278 | "file" "fillfactor" "first" "floppy" "for" "foreign" "freetext" | 1428 | "fillfactor" "first" "floppy" "for" "foreign" "freetext" |
| 1279 | "freetexttable" "from" "full" "goto" "grant" "group" "having" | 1429 | "freetexttable" "from" "full" "goto" "grant" "group" "having" |
| 1280 | "holdlock" "identity" "identity_insert" "identitycol" "if" "in" | 1430 | "holdlock" "identity" "identity_insert" "identitycol" "if" "in" |
| 1281 | "index" "inner" "insert" "intersect" "into" "is" "isolation" "join" | 1431 | "index" "inner" "insert" "intersect" "into" "is" "isolation" "join" |
| @@ -1295,29 +1445,21 @@ function `regexp-opt'.") | |||
| 1295 | "textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate" | 1445 | "textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate" |
| 1296 | "tsequal" "uncommitted" "union" "unique" "update" "updatetext" | 1446 | "tsequal" "uncommitted" "union" "unique" "update" "updatetext" |
| 1297 | "updlock" "use" "user" "values" "view" "waitfor" "when" "where" | 1447 | "updlock" "use" "user" "values" "view" "waitfor" "when" "where" |
| 1298 | "while" "with" "work" "writetext" | 1448 | "while" "with" "work" "writetext" "collate" "function" "openxml" |
| 1299 | "collate" "function" "openxml" "returns" | 1449 | "returns" |
| 1300 | 1450 | )) | |
| 1301 | ) t) "\\b"))) | ||
| 1302 | (ms-types (eval-when-compile | ||
| 1303 | (concat "\\b" | ||
| 1304 | (regexp-opt '( | ||
| 1305 | 1451 | ||
| 1452 | (ms-types (sql-keywords-re | ||
| 1306 | "binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal" | 1453 | "binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal" |
| 1307 | "double" "float" "image" "int" "integer" "money" "national" "nchar" | 1454 | "double" "float" "image" "int" "integer" "money" "national" "nchar" |
| 1308 | "ntext" "numeric" "numeric" "nvarchar" "precision" "real" | 1455 | "ntext" "numeric" "numeric" "nvarchar" "precision" "real" |
| 1309 | "smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint" | 1456 | "smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint" |
| 1310 | "uniqueidentifier" "varbinary" "varchar" "varying" | 1457 | "uniqueidentifier" "varbinary" "varchar" "varying" |
| 1311 | 1458 | )) | |
| 1312 | ) t) "\\b"))) | ||
| 1313 | 1459 | ||
| 1314 | (ms-vars "\\b@[a-zA-Z0-9_]*\\b") | 1460 | (ms-vars "\\b@[a-zA-Z0-9_]*\\b") |
| 1315 | 1461 | ||
| 1316 | (ms-builtin-functions (eval-when-compile | 1462 | (ms-functions (sql-keywords-re |
| 1317 | (concat "\\b" | ||
| 1318 | (regexp-opt '( | ||
| 1319 | ;; Misc MS builtin functions | ||
| 1320 | |||
| 1321 | "@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts" | 1463 | "@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts" |
| 1322 | "@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy" | 1464 | "@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy" |
| 1323 | "@@langid" "@@language" "@@lock_timeout" "@@max_connections" | 1465 | "@@langid" "@@language" "@@lock_timeout" "@@max_connections" |
| @@ -1346,14 +1488,12 @@ function `regexp-opt'.") | |||
| 1346 | "suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan" | 1488 | "suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan" |
| 1347 | "textptr" "textvalid" "typeproperty" "unicode" "upper" "user" | 1489 | "textptr" "textvalid" "typeproperty" "unicode" "upper" "user" |
| 1348 | "user_id" "user_name" "var" "varp" "year" | 1490 | "user_id" "user_name" "var" "varp" "year" |
| 1491 | )) | ||
| 1349 | 1492 | ||
| 1350 | ) t) "\\b"))) | 1493 | (ms-commands |
| 1351 | |||
| 1352 | (ms-config-commands | ||
| 1353 | (eval-when-compile | 1494 | (eval-when-compile |
| 1354 | (concat "^\\(\\(set\\s-+\\(" | 1495 | (concat "^\\(\\(set\\s-+\\(" |
| 1355 | (regexp-opt '( | 1496 | (regexp-opt '( |
| 1356 | |||
| 1357 | "datefirst" "dateformat" "deadlock_priority" "lock_timeout" | 1497 | "datefirst" "dateformat" "deadlock_priority" "lock_timeout" |
| 1358 | "concat_null_yields_null" "cursor_close_on_commit" | 1498 | "concat_null_yields_null" "cursor_close_on_commit" |
| 1359 | "disable_def_cnst_chk" "fips_flagger" "identity_insert" "language" | 1499 | "disable_def_cnst_chk" "fips_flagger" "identity_insert" "language" |
| @@ -1364,19 +1504,14 @@ function `regexp-opt'.") | |||
| 1364 | "ansi_warnings" "forceplan" "showplan_all" "showplan_text" | 1504 | "ansi_warnings" "forceplan" "showplan_all" "showplan_text" |
| 1365 | "statistics" "implicit_transactions" "remote_proc_transactions" | 1505 | "statistics" "implicit_transactions" "remote_proc_transactions" |
| 1366 | "transaction" "xact_abort" | 1506 | "transaction" "xact_abort" |
| 1367 | |||
| 1368 | ) t) | 1507 | ) t) |
| 1369 | "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")))) | 1508 | "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")))) |
| 1370 | 1509 | ||
| 1371 | (list (cons ms-config-commands 'font-lock-doc-face) | 1510 | `((,ms-commands . ,sql-doc-face) |
| 1372 | (cons ms-reserved-words 'font-lock-keyword-face) | 1511 | (,ms-reserved . font-lock-keyword-face) |
| 1373 | ;; XEmacs doesn't have 'font-lock-builtin-face | 1512 | (,ms-functions . ,sql-builtin-face) |
| 1374 | (if (string-match "XEmacs\\|Lucid" emacs-version) | 1513 | (,ms-vars . font-lock-variable-name-face) |
| 1375 | (cons ms-builtin-functions 'font-lock-preprocessor-face) | 1514 | (,ms-types . font-lock-type-face))) |
| 1376 | ;; Emacs | ||
| 1377 | (cons ms-builtin-functions 'font-lock-builtin-face)) | ||
| 1378 | (cons ms-vars 'font-lock-variable-name-face) | ||
| 1379 | (cons ms-types 'font-lock-type-face))) | ||
| 1380 | 1515 | ||
| 1381 | "Microsoft SQLServer SQL keywords used by font-lock. | 1516 | "Microsoft SQLServer SQL keywords used by font-lock. |
| 1382 | 1517 | ||
| @@ -1385,7 +1520,7 @@ regular expressions are created during compilation by calling the | |||
| 1385 | function `regexp-opt'. Therefore, take a look at the source before | 1520 | function `regexp-opt'. Therefore, take a look at the source before |
| 1386 | you define your own sql-mode-ms-font-lock-keywords.") | 1521 | you define your own sql-mode-ms-font-lock-keywords.") |
| 1387 | 1522 | ||
| 1388 | (defvar sql-mode-sybase-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1523 | (defvar sql-mode-sybase-font-lock-keywords nil |
| 1389 | "Sybase SQL keywords used by font-lock. | 1524 | "Sybase SQL keywords used by font-lock. |
| 1390 | 1525 | ||
| 1391 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1526 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1393,7 +1528,7 @@ regular expressions are created during compilation by calling the | |||
| 1393 | function `regexp-opt'. Therefore, take a look at the source before | 1528 | function `regexp-opt'. Therefore, take a look at the source before |
| 1394 | you define your own sql-mode-sybase-font-lock-keywords.") | 1529 | you define your own sql-mode-sybase-font-lock-keywords.") |
| 1395 | 1530 | ||
| 1396 | (defvar sql-mode-informix-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1531 | (defvar sql-mode-informix-font-lock-keywords nil |
| 1397 | "Informix SQL keywords used by font-lock. | 1532 | "Informix SQL keywords used by font-lock. |
| 1398 | 1533 | ||
| 1399 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1534 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1401,7 +1536,7 @@ regular expressions are created during compilation by calling the | |||
| 1401 | function `regexp-opt'. Therefore, take a look at the source before | 1536 | function `regexp-opt'. Therefore, take a look at the source before |
| 1402 | you define your own sql-mode-informix-font-lock-keywords.") | 1537 | you define your own sql-mode-informix-font-lock-keywords.") |
| 1403 | 1538 | ||
| 1404 | (defvar sql-mode-interbase-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1539 | (defvar sql-mode-interbase-font-lock-keywords nil |
| 1405 | "Interbase SQL keywords used by font-lock. | 1540 | "Interbase SQL keywords used by font-lock. |
| 1406 | 1541 | ||
| 1407 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1542 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1409,7 +1544,7 @@ regular expressions are created during compilation by calling the | |||
| 1409 | function `regexp-opt'. Therefore, take a look at the source before | 1544 | function `regexp-opt'. Therefore, take a look at the source before |
| 1410 | you define your own sql-mode-interbase-font-lock-keywords.") | 1545 | you define your own sql-mode-interbase-font-lock-keywords.") |
| 1411 | 1546 | ||
| 1412 | (defvar sql-mode-ingres-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1547 | (defvar sql-mode-ingres-font-lock-keywords nil |
| 1413 | "Ingres SQL keywords used by font-lock. | 1548 | "Ingres SQL keywords used by font-lock. |
| 1414 | 1549 | ||
| 1415 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1550 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1417,7 +1552,7 @@ regular expressions are created during compilation by calling the | |||
| 1417 | function `regexp-opt'. Therefore, take a look at the source before | 1552 | function `regexp-opt'. Therefore, take a look at the source before |
| 1418 | you define your own sql-mode-interbase-font-lock-keywords.") | 1553 | you define your own sql-mode-interbase-font-lock-keywords.") |
| 1419 | 1554 | ||
| 1420 | (defvar sql-mode-solid-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1555 | (defvar sql-mode-solid-font-lock-keywords nil |
| 1421 | "Solid SQL keywords used by font-lock. | 1556 | "Solid SQL keywords used by font-lock. |
| 1422 | 1557 | ||
| 1423 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1558 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1425,7 +1560,76 @@ regular expressions are created during compilation by calling the | |||
| 1425 | function `regexp-opt'. Therefore, take a look at the source before | 1560 | function `regexp-opt'. Therefore, take a look at the source before |
| 1426 | you define your own sql-mode-solid-font-lock-keywords.") | 1561 | you define your own sql-mode-solid-font-lock-keywords.") |
| 1427 | 1562 | ||
| 1428 | (defvar sql-mode-mysql-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1563 | (defvar sql-mode-mysql-font-lock-keywords |
| 1564 | (let ((mysql-funcs (sql-keywords-re | ||
| 1565 | "ascii" "avg" "bdmpolyfromtext" "bdmpolyfromwkb" "bdpolyfromtext" | ||
| 1566 | "bdpolyfromwkb" "benchmark" "bin" "bit_and" "bit_length" "bit_or" | ||
| 1567 | "bit_xor" "both" "cast" "char_length" "character_length" "coalesce" | ||
| 1568 | "concat" "concat_ws" "connection_id" "conv" "convert" "count" | ||
| 1569 | "curdate" "current_date" "current_time" "current_timestamp" "curtime" | ||
| 1570 | "elt" "encrypt" "export_set" "field" "find_in_set" "found_rows" "from" | ||
| 1571 | "geomcollfromtext" "geomcollfromwkb" "geometrycollectionfromtext" | ||
| 1572 | "geometrycollectionfromwkb" "geometryfromtext" "geometryfromwkb" | ||
| 1573 | "geomfromtext" "geomfromwkb" "get_lock" "group_concat" "hex" "ifnull" | ||
| 1574 | "instr" "interval" "isnull" "last_insert_id" "lcase" "leading" | ||
| 1575 | "length" "linefromtext" "linefromwkb" "linestringfromtext" | ||
| 1576 | "linestringfromwkb" "load_file" "locate" "lower" "lpad" "ltrim" | ||
| 1577 | "make_set" "master_pos_wait" "max" "mid" "min" "mlinefromtext" | ||
| 1578 | "mlinefromwkb" "mpointfromtext" "mpointfromwkb" "mpolyfromtext" | ||
| 1579 | "mpolyfromwkb" "multilinestringfromtext" "multilinestringfromwkb" | ||
| 1580 | "multipointfromtext" "multipointfromwkb" "multipolygonfromtext" | ||
| 1581 | "multipolygonfromwkb" "now" "nullif" "oct" "octet_length" "ord" | ||
| 1582 | "pointfromtext" "pointfromwkb" "polyfromtext" "polyfromwkb" | ||
| 1583 | "polygonfromtext" "polygonfromwkb" "position" "quote" "rand" | ||
| 1584 | "release_lock" "repeat" "replace" "reverse" "rpad" "rtrim" "soundex" | ||
| 1585 | "space" "std" "stddev" "substring" "substring_index" "sum" "sysdate" | ||
| 1586 | "trailing" "trim" "ucase" "unix_timestamp" "upper" "user" "variance" | ||
| 1587 | )) | ||
| 1588 | |||
| 1589 | (mysql-keywords (sql-keywords-re | ||
| 1590 | "action" "add" "after" "against" "all" "alter" "and" "as" "asc" | ||
| 1591 | "auto_increment" "avg_row_length" "bdb" "between" "by" "cascade" | ||
| 1592 | "case" "change" "character" "check" "checksum" "close" "collate" | ||
| 1593 | "collation" "column" "columns" "comment" "committed" "concurrent" | ||
| 1594 | "constraint" "create" "cross" "data" "database" "default" | ||
| 1595 | "delay_key_write" "delayed" "delete" "desc" "directory" "disable" | ||
| 1596 | "distinct" "distinctrow" "do" "drop" "dumpfile" "duplicate" "else" | ||
| 1597 | "enable" "enclosed" "end" "escaped" "exists" "fields" "first" "for" | ||
| 1598 | "force" "foreign" "from" "full" "fulltext" "global" "group" "handler" | ||
| 1599 | "having" "heap" "high_priority" "if" "ignore" "in" "index" "infile" | ||
| 1600 | "inner" "insert" "insert_method" "into" "is" "isam" "isolation" "join" | ||
| 1601 | "key" "keys" "last" "left" "level" "like" "limit" "lines" "load" | ||
| 1602 | "local" "lock" "low_priority" "match" "max_rows" "merge" "min_rows" | ||
| 1603 | "mode" "modify" "mrg_myisam" "myisam" "natural" "next" "no" "not" | ||
| 1604 | "null" "offset" "oj" "on" "open" "optionally" "or" "order" "outer" | ||
| 1605 | "outfile" "pack_keys" "partial" "password" "prev" "primary" | ||
| 1606 | "procedure" "quick" "raid0" "raid_type" "read" "references" "rename" | ||
| 1607 | "repeatable" "restrict" "right" "rollback" "rollup" "row_format" | ||
| 1608 | "savepoint" "select" "separator" "serializable" "session" "set" | ||
| 1609 | "share" "show" "sql_big_result" "sql_buffer_result" "sql_cache" | ||
| 1610 | "sql_calc_found_rows" "sql_no_cache" "sql_small_result" "starting" | ||
| 1611 | "straight_join" "striped" "table" "tables" "temporary" "terminated" | ||
| 1612 | "then" "to" "transaction" "truncate" "type" "uncommitted" "union" | ||
| 1613 | "unique" "unlock" "update" "use" "using" "values" "when" "where" | ||
| 1614 | "with" "write" "xor" | ||
| 1615 | )) | ||
| 1616 | |||
| 1617 | (mysql-types (sql-keywords-re | ||
| 1618 | "bigint" "binary" "bit" "blob" "bool" "boolean" "char" "curve" "date" | ||
| 1619 | "datetime" "dec" "decimal" "double" "enum" "fixed" "float" "geometry" | ||
| 1620 | "geometrycollection" "int" "integer" "line" "linearring" "linestring" | ||
| 1621 | "longblob" "longtext" "mediumblob" "mediumint" "mediumtext" | ||
| 1622 | "multicurve" "multilinestring" "multipoint" "multipolygon" | ||
| 1623 | "multisurface" "national" "numeric" "point" "polygon" "precision" | ||
| 1624 | "real" "smallint" "surface" "text" "time" "timestamp" "tinyblob" | ||
| 1625 | "tinyint" "tinytext" "unsigned" "varchar" "year" "year2" "year4" | ||
| 1626 | "zerofill" | ||
| 1627 | ))) | ||
| 1628 | |||
| 1629 | `((,mysql-funcs . ,sql-builtin-face) | ||
| 1630 | (,mysql-keywords . font-lock-keyword-face) | ||
| 1631 | (,mysql-types . font-lock-type-face))) | ||
| 1632 | |||
| 1429 | "MySQL SQL keywords used by font-lock. | 1633 | "MySQL SQL keywords used by font-lock. |
| 1430 | 1634 | ||
| 1431 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1635 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1433,7 +1637,7 @@ regular expressions are created during compilation by calling the | |||
| 1433 | function `regexp-opt'. Therefore, take a look at the source before | 1637 | function `regexp-opt'. Therefore, take a look at the source before |
| 1434 | you define your own sql-mode-mysql-font-lock-keywords.") | 1638 | you define your own sql-mode-mysql-font-lock-keywords.") |
| 1435 | 1639 | ||
| 1436 | (defvar sql-mode-sqlite-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1640 | (defvar sql-mode-sqlite-font-lock-keywords nil |
| 1437 | "SQLite SQL keywords used by font-lock. | 1641 | "SQLite SQL keywords used by font-lock. |
| 1438 | 1642 | ||
| 1439 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1643 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1441,7 +1645,7 @@ regular expressions are created during compilation by calling the | |||
| 1441 | function `regexp-opt'. Therefore, take a look at the source before | 1645 | function `regexp-opt'. Therefore, take a look at the source before |
| 1442 | you define your own sql-mode-sqlite-font-lock-keywords.") | 1646 | you define your own sql-mode-sqlite-font-lock-keywords.") |
| 1443 | 1647 | ||
| 1444 | (defvar sql-mode-db2-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1648 | (defvar sql-mode-db2-font-lock-keywords nil |
| 1445 | "DB2 SQL keywords used by font-lock. | 1649 | "DB2 SQL keywords used by font-lock. |
| 1446 | 1650 | ||
| 1447 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1651 | This variable is used by `sql-mode' and `sql-interactive-mode'. The |
| @@ -1463,16 +1667,16 @@ highlighting rules in sql-mode.") | |||
| 1463 | (defun sql-product-feature (feature &optional product) | 1667 | (defun sql-product-feature (feature &optional product) |
| 1464 | "Lookup `feature' needed to support the current SQL product. | 1668 | "Lookup `feature' needed to support the current SQL product. |
| 1465 | 1669 | ||
| 1466 | See \[sql-product-support] for a list of products and supported features." | 1670 | See \[sql-product-alist] for a list of products and supported features." |
| 1467 | (cadr | 1671 | (plist-get |
| 1468 | (memq feature | 1672 | (cdr (assoc (or product sql-product) |
| 1469 | (assoc (or product sql-product) | 1673 | sql-product-alist)) |
| 1470 | sql-product-support)))) | 1674 | feature)) |
| 1471 | 1675 | ||
| 1472 | (defun sql-product-font-lock (keywords-only imenu) | 1676 | (defun sql-product-font-lock (keywords-only imenu) |
| 1473 | "Sets `font-lock-defaults' and `font-lock-keywords' based on | 1677 | "Sets `font-lock-defaults' and `font-lock-keywords' based on |
| 1474 | the product-specific keywords and syntax-alists defined in | 1678 | the product-specific keywords and syntax-alists defined in |
| 1475 | `sql-product-support'." | 1679 | `sql-product-alist'." |
| 1476 | (let | 1680 | (let |
| 1477 | ;; Get the product-specific syntax-alist. | 1681 | ;; Get the product-specific syntax-alist. |
| 1478 | ((syntax-alist | 1682 | ((syntax-alist |
| @@ -1484,6 +1688,7 @@ the product-specific keywords and syntax-alists defined in | |||
| 1484 | (setq sql-mode-font-lock-keywords | 1688 | (setq sql-mode-font-lock-keywords |
| 1485 | (append | 1689 | (append |
| 1486 | (eval (sql-product-feature :font-lock)) | 1690 | (eval (sql-product-feature :font-lock)) |
| 1691 | (eval (sql-product-feature :font-lock 'ansi)) | ||
| 1487 | (list sql-mode-font-lock-object-name))) | 1692 | (list sql-mode-font-lock-object-name))) |
| 1488 | 1693 | ||
| 1489 | ;; Setup font-lock. (What is the minimum we should have to do | 1694 | ;; Setup font-lock. (What is the minimum we should have to do |
| @@ -1498,12 +1703,34 @@ the product-specific keywords and syntax-alists defined in | |||
| 1498 | (setq imenu-syntax-alist syntax-alist)))) | 1703 | (setq imenu-syntax-alist syntax-alist)))) |
| 1499 | 1704 | ||
| 1500 | ;;;###autoload | 1705 | ;;;###autoload |
| 1501 | (defun sql-add-product-keywords (product keywords) | 1706 | (defun sql-add-product-keywords (product keywords &optional append) |
| 1502 | "Append a `font-lock-keywords' entry to the existing entries defined | 1707 | "Add highlighting KEYWORDS for SQL PRODUCT. |
| 1503 | for the specified `product'." | 1708 | |
| 1504 | 1709 | PRODUCT should be a symbol, the name of a sql product, such as | |
| 1505 | (let ((font-lock (sql-product-feature :font-lock product))) | 1710 | `oracle'. KEYWORDS should be a list; see the variable |
| 1506 | (set font-lock (append (eval font-lock) (list keywords))))) | 1711 | `font-lock-keywords'. By default they are added at the beginning |
| 1712 | of the current highlighting list. If optional argument APPEND is | ||
| 1713 | `set', they are used to replace the current highlighting list. | ||
| 1714 | If APPEND is any other non-nil value, they are added at the end | ||
| 1715 | of the current highlighting list. | ||
| 1716 | |||
| 1717 | For example: | ||
| 1718 | |||
| 1719 | (sql-add-product-keywords 'ms | ||
| 1720 | '((\"\\\\b\\\\w+_t\\\\b\" . font-lock-type-face))) | ||
| 1721 | |||
| 1722 | adds a fontification pattern to fontify identifiers ending in | ||
| 1723 | `_t' as data types." | ||
| 1724 | |||
| 1725 | (let ((font-lock (sql-product-feature :font-lock product)) | ||
| 1726 | old) | ||
| 1727 | (setq old (eval font-lock)) | ||
| 1728 | (set font-lock | ||
| 1729 | (if (eq append 'set) | ||
| 1730 | keywords | ||
| 1731 | (if append | ||
| 1732 | (append old keywords) | ||
| 1733 | (append keywords old)))))) | ||
| 1507 | 1734 | ||
| 1508 | 1735 | ||
| 1509 | 1736 | ||
| @@ -1518,7 +1745,8 @@ selected." | |||
| 1518 | (sql-product-font-lock nil t) | 1745 | (sql-product-font-lock nil t) |
| 1519 | 1746 | ||
| 1520 | ;; Force fontification, if its enabled. | 1747 | ;; Force fontification, if its enabled. |
| 1521 | (if font-lock-mode | 1748 | (if (and (boundp 'font-lock-mode) |
| 1749 | font-lock-mode) | ||
| 1522 | (font-lock-fontify-buffer)) | 1750 | (font-lock-fontify-buffer)) |
| 1523 | 1751 | ||
| 1524 | ;; Set the mode name to include the product. | 1752 | ;; Set the mode name to include the product. |
| @@ -1528,7 +1756,7 @@ selected." | |||
| 1528 | "Set `sql-product' to product and enable appropriate | 1756 | "Set `sql-product' to product and enable appropriate |
| 1529 | highlighting." | 1757 | highlighting." |
| 1530 | (interactive "SEnter SQL product: ") | 1758 | (interactive "SEnter SQL product: ") |
| 1531 | (when (not (assoc product sql-product-support)) | 1759 | (when (not (assoc product sql-product-alist)) |
| 1532 | (error "SQL product %s is not supported; treated as ANSI" product) | 1760 | (error "SQL product %s is not supported; treated as ANSI" product) |
| 1533 | (setq product 'ansi)) | 1761 | (setq product 'ansi)) |
| 1534 | 1762 | ||
| @@ -1952,6 +2180,19 @@ Every newline in STRING will be preceded with a space and a backslash." | |||
| 1952 | (interactive) | 2180 | (interactive) |
| 1953 | (sql-send-region (point-min) (point-max))) | 2181 | (sql-send-region (point-min) (point-max))) |
| 1954 | 2182 | ||
| 2183 | (defun sql-send-string (str) | ||
| 2184 | "Send a string to the SQL process." | ||
| 2185 | (interactive "sSQL Text: ") | ||
| 2186 | (if (buffer-live-p sql-buffer) | ||
| 2187 | (save-excursion | ||
| 2188 | (comint-send-string sql-buffer str) | ||
| 2189 | (comint-send-string sql-buffer "\n") | ||
| 2190 | (message "Sent string to buffer %s." (buffer-name sql-buffer)) | ||
| 2191 | (if sql-pop-to-buffer-after-send-region | ||
| 2192 | (pop-to-buffer sql-buffer) | ||
| 2193 | (display-buffer sql-buffer))) | ||
| 2194 | (message "No SQL process started."))) | ||
| 2195 | |||
| 1955 | (defun sql-toggle-pop-to-buffer-after-send-region (&optional value) | 2196 | (defun sql-toggle-pop-to-buffer-after-send-region (&optional value) |
| 1956 | "Toggle `sql-pop-to-buffer-after-send-region'. | 2197 | "Toggle `sql-pop-to-buffer-after-send-region'. |
| 1957 | 2198 | ||
| @@ -2611,6 +2852,8 @@ parameters and command options." | |||
| 2611 | (setq params (append params (list sql-database)))) | 2852 | (setq params (append params (list sql-database)))) |
| 2612 | (if (not (string= "" sql-server)) | 2853 | (if (not (string= "" sql-server)) |
| 2613 | (setq params (append (list "-h" sql-server) params))) | 2854 | (setq params (append (list "-h" sql-server) params))) |
| 2855 | (if (not (string= "" sql-user)) | ||
| 2856 | (setq params (append (list "-U" sql-user) params))) | ||
| 2614 | (set-buffer (apply 'make-comint "SQL" sql-postgres-program | 2857 | (set-buffer (apply 'make-comint "SQL" sql-postgres-program |
| 2615 | nil params)))) | 2858 | nil params)))) |
| 2616 | 2859 | ||