1 |
;;; sql.el --- specialized comint.el for SQL interpreters |
;;; sql.el --- specialized comint.el for SQL interpreters |
2 |
|
|
3 |
;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Alex Schroeder <alex@gnu.org> |
;; Author: Alex Schroeder <alex@gnu.org> |
6 |
;; Maintainer: Alex Schroeder <alex@gnu.org> |
;; Maintainer: Alex Schroeder <alex@gnu.org> |
7 |
;; Version: 1.7.0 |
;; Version: 1.8.0 |
8 |
;; Keywords: comm languages processes |
;; Keywords: comm languages processes |
9 |
;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
10 |
|
|
78 |
|
|
79 |
;;; Bugs: |
;;; Bugs: |
80 |
|
|
81 |
;; Using sql-ms (isql by Microsoft): When commands with syntax errors |
;; sql-ms now uses osql instead of isql. Osql flushes its error |
82 |
;; or execution errors are executed, there is no server feedback. |
;; stream more frequently than isql so that error messages are |
83 |
;; This happens in stored procedures for example. The server messages |
;; available. There is no prompt and some output still is buffered. |
84 |
;; only appear after the process is exited. This makes things |
;; This improves the interaction under Emacs but it still is somewhat |
85 |
;; somewhat unreliable. |
;; awkward. |
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 |
|
|
92 |
;; ChangeLog available on request. |
;; ChangeLog available on request. |
93 |
|
|
94 |
;;; To Do: |
;;; Product Support: |
95 |
|
|
96 |
;; Add better hilight support for other brands; there is a bias towards |
;; Set the variable `sql-product' to the product you usually use. If |
97 |
;; Oracle because that's what I use at work. Anybody else just send in |
;; you occasionally use another product, for certain files, add a |
98 |
;; your lists of reserved words, keywords and builtin functions! As |
;; comment on the first line of the file saying |
99 |
;; long as I don't receive any feedback, everything is hilighted with |
;; -*- sql-product: mysql -*- |
100 |
;; ANSI keywords only. I received the list of ANSI keywords from a |
;; See section "File Variables" in the Emacs manual for more info. |
101 |
;; user; if you know of any changes, let me know. |
|
102 |
|
;;; Adding another product: |
103 |
|
|
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 |
;; Add different hilighting levels. |
;; 9) Save and compile sql.el. |
189 |
|
|
190 |
;;; Thanks to all the people who helped me out: |
;;; Thanks to all the people who helped me out: |
191 |
|
|
195 |
;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> |
;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> |
196 |
;; nino <nino@inform.dk> |
;; nino <nino@inform.dk> |
197 |
;; Berend de Boer <berend@pobox.com> |
;; Berend de Boer <berend@pobox.com> |
198 |
|
;; Michael Mauger <mmaug@yahoo.com> |
199 |
|
|
200 |
|
|
201 |
|
|
203 |
|
|
204 |
(require 'comint) |
(require 'comint) |
205 |
;; Need the following to allow GNU Emacs 19 to compile the file. |
;; Need the following to allow GNU Emacs 19 to compile the file. |
206 |
(require 'regexp-opt) |
(eval-when-compile |
207 |
|
(require 'regexp-opt)) |
208 |
(require 'custom) |
(require 'custom) |
209 |
|
|
210 |
;;; Allow customization |
;;; Allow customization |
214 |
:version "20.4" |
:version "20.4" |
215 |
:group 'processes) |
:group 'processes) |
216 |
|
|
217 |
;; These three variables will be used as defaults, if set. |
;; These four variables will be used as defaults, if set. |
218 |
|
|
219 |
(defcustom sql-user "" |
(defcustom sql-user "" |
220 |
"*Default username." |
"*Default username." |
239 |
:type 'string |
:type 'string |
240 |
:group 'SQL) |
:group 'SQL) |
241 |
|
|
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 |
;; misc customization of sql.el behaviour |
382 |
|
|
383 |
(defcustom sql-electric-stuff nil |
(defcustom sql-electric-stuff nil |
408 |
;; imenu support for sql-mode. |
;; imenu support for sql-mode. |
409 |
|
|
410 |
(defvar sql-imenu-generic-expression |
(defvar sql-imenu-generic-expression |
411 |
'(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1) |
;; Items are in reverse order because they are rendered in reverse. |
412 |
("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)) |
'(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2) |
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'. |
"Define interesting points in the SQL buffer for `imenu'. |
421 |
|
|
422 |
This is used to set `imenu-generic-expression' when SQL mode is |
This is used to set `imenu-generic-expression' when SQL mode is |
512 |
:group 'SQL) |
:group 'SQL) |
513 |
|
|
514 |
(defcustom sql-sqlite-options nil |
(defcustom sql-sqlite-options nil |
515 |
"*List of additional options for `sql-mysql-program'. |
"*List of additional options for `sql-sqlite-program'. |
516 |
The following list of options is reported to make things work |
The following list of options is reported to make things work |
517 |
on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." |
on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." |
518 |
:type '(repeat string) |
:type '(repeat string) |
591 |
|
|
592 |
;; Customization for Microsoft |
;; Customization for Microsoft |
593 |
|
|
594 |
(defcustom sql-ms-program "isql" |
(defcustom sql-ms-program "osql" |
595 |
"*Command to start isql by Microsoft. |
"*Command to start osql by Microsoft. |
596 |
|
|
597 |
Starts `sql-interactive-mode' after doing some setup. |
Starts `sql-interactive-mode' after doing some setup. |
598 |
|
|
706 |
(defvar sql-prompt-regexp nil |
(defvar sql-prompt-regexp nil |
707 |
"Prompt used to initialize `comint-prompt-regexp'. |
"Prompt used to initialize `comint-prompt-regexp'. |
708 |
|
|
709 |
You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.") |
You can change `sql-prompt-regexp' on `sql-interactive-mode-hook'.") |
710 |
|
|
711 |
(defvar sql-prompt-length 0 |
(defvar sql-prompt-length 0 |
712 |
"Prompt used to set `left-margin' in `sql-interactive-mode'. |
"Prompt used to set `left-margin' in `sql-interactive-mode'. |
713 |
|
|
714 |
You can change it on `sql-interactive-mode-hook'.") |
You can change `sql-prompt-length' on `sql-interactive-mode-hook'.") |
715 |
|
|
716 |
(defvar sql-alternate-buffer-name nil |
(defvar sql-alternate-buffer-name nil |
717 |
"Buffer-local string used to possibly rename the SQLi buffer. |
"Buffer-local string used to possibly rename the SQLi buffer. |
756 |
(get-buffer-process sql-buffer))] |
(get-buffer-process sql-buffer))] |
757 |
["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
758 |
mark-active) |
mark-active) |
759 |
(mark)); XEmacs |
(mark t)); XEmacs |
760 |
(buffer-live-p sql-buffer) |
(buffer-live-p sql-buffer) |
761 |
(get-buffer-process sql-buffer))] |
(get-buffer-process sql-buffer))] |
762 |
["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
763 |
(get-buffer-process sql-buffer))] |
(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] |
["Show SQLi buffer" sql-show-sqli-buffer t] |
767 |
["Set SQLi buffer" sql-set-sqli-buffer t] |
["Set SQLi buffer" sql-set-sqli-buffer t] |
768 |
["Pop to SQLi buffer after send" |
["Pop to SQLi buffer after send" |
769 |
sql-toggle-pop-to-buffer-after-send-region |
sql-toggle-pop-to-buffer-after-send-region |
770 |
:style toggle |
:style toggle |
771 |
:selected sql-pop-to-buffer-after-send-region] |
:selected sql-pop-to-buffer-after-send-region] |
772 |
("Highlighting" |
["--" nil nil] |
773 |
["ANSI SQL keywords" sql-highlight-ansi-keywords t] |
("Product" |
774 |
["Oracle keywords" sql-highlight-oracle-keywords t] |
["ANSI" sql-highlight-ansi-keywords |
775 |
["Postgres keywords" sql-highlight-postgres-keywords t] |
:style radio |
776 |
["Linter keywords" sql-highlight-linter-keywords t] |
:selected (eq sql-product 'ansi)] |
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 |
))) |
))) |
814 |
|
|
815 |
;; easy menu for sql-interactive-mode. |
;; easy menu for sql-interactive-mode. |
827 |
"Abbrev table used in `sql-mode' and `sql-interactive-mode'.") |
"Abbrev table used in `sql-mode' and `sql-interactive-mode'.") |
828 |
(if sql-mode-abbrev-table |
(if sql-mode-abbrev-table |
829 |
() |
() |
830 |
(let ((wrapper)) |
(let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev)))) |
831 |
(define-abbrev-table 'sql-mode-abbrev-table ()) |
d-a) |
832 |
(define-abbrev sql-mode-abbrev-table "ins" "insert") |
;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. |
833 |
(define-abbrev sql-mode-abbrev-table "upd" "update") |
(setq d-a |
834 |
(define-abbrev sql-mode-abbrev-table "del" "delete") |
(if (>= nargs 6) |
835 |
(define-abbrev sql-mode-abbrev-table "sel" "select"))) |
'(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)) |
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 |
|
|
847 |
;; Syntax Table |
;; Syntax Table |
848 |
|
|
867 |
|
|
868 |
;; Font lock support |
;; Font lock support |
869 |
|
|
870 |
(defvar sql-mode-ansi-font-lock-keywords nil |
(defvar sql-mode-font-lock-object-name |
871 |
"ANSI SQL keywords used by font-lock. |
(list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+" |
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 |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
"Pattern to match the names of top-level objects in a CREATE, |
877 |
regular expressions are created during compilation by calling the |
DROP or ALTER statement. |
878 |
function `regexp-opt'. Therefore, take a look at the source before |
|
879 |
you define your own sql-mode-ansi-font-lock-keywords. You may want to |
The format of variable should be a valid `font-lock-keywords' |
880 |
add functions and PL/SQL keywords.") |
entry.") |
881 |
(if sql-mode-ansi-font-lock-keywords |
|
882 |
() |
(defvar sql-mode-ansi-font-lock-keywords |
883 |
(let ((ansi-keywords (eval-when-compile |
(let ((ansi-keywords (eval-when-compile |
884 |
(concat "\\b" |
(concat "\\b" |
885 |
(regexp-opt '( |
(regexp-opt '( |
886 |
|
|
887 |
"authorization" "avg" "begin" "close" "cobol" "commit" |
"authorization" "avg" "begin" "close" "cobol" "commit" |
888 |
"continue" "count" "declare" "double" "end" "escape" |
"continue" "count" "declare" "double" "end" "escape" |
889 |
"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
890 |
"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
891 |
"precision" "primary" "procedure" "references" "rollback" |
"precision" "primary" "procedure" "references" "rollback" |
892 |
"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b"))) |
"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" |
893 |
|
|
894 |
|
) t) "\\b"))) |
895 |
(ansi-reserved-words (eval-when-compile |
(ansi-reserved-words (eval-when-compile |
896 |
(concat "\\b" |
(concat "\\b" |
897 |
(regexp-opt '( |
(regexp-opt '( |
898 |
|
|
899 |
"all" "and" "any" "as" "asc" "between" "by" "check" "create" |
"all" "and" "any" "as" "asc" "between" "by" "check" "create" |
900 |
"current" "default" "delete" "desc" "distinct" "exists" "float" "for" |
"current" "default" "delete" "desc" "distinct" "exists" "float" "for" |
901 |
"from" "grant" "group" "having" "in" "insert" "into" "is" |
"from" "grant" "group" "having" "in" "insert" "into" "is" |
902 |
"like" "not" "null" "of" "on" "option" "or" "order" "privileges" |
"like" "not" "null" "of" "on" "option" "or" "order" "privileges" |
903 |
"public" "select" "set" "table" "to" "union" "unique" |
"public" "select" "set" "table" "to" "union" "unique" |
904 |
"update" "user" "values" "view" "where" "with") t) "\\b"))) |
"update" "user" "values" "view" "where" "with" |
905 |
|
|
906 |
|
) t) "\\b"))) |
907 |
(ansi-types (eval-when-compile |
(ansi-types (eval-when-compile |
908 |
(concat "\\b" |
(concat "\\b" |
909 |
(regexp-opt '( |
(regexp-opt '( |
910 |
|
|
911 |
;; ANSI Keywords that look like types |
;; ANSI Keywords that look like types |
912 |
"character" "cursor" "dec" "int" "real" |
"character" "cursor" "dec" "int" "real" |
913 |
;; ANSI Reserved Word that look like types |
;; ANSI Reserved Word that look like types |
914 |
"char" "integer" "smallint" ) t) "\\b")))) |
"char" "integer" "smallint" |
915 |
(setq sql-mode-ansi-font-lock-keywords |
|
916 |
(list (cons ansi-keywords 'font-lock-function-name-face) |
) t) "\\b")))) |
917 |
|
(list (cons ansi-keywords 'font-lock-keyword-face) |
918 |
(cons ansi-reserved-words 'font-lock-keyword-face) |
(cons ansi-reserved-words 'font-lock-keyword-face) |
919 |
(cons ansi-types 'font-lock-type-face))))) |
(cons ansi-types 'font-lock-type-face))) |
920 |
|
|
921 |
(defvar sql-mode-oracle-font-lock-keywords nil |
"ANSI SQL keywords used by font-lock. |
|
"Oracle SQL keywords used by font-lock. |
|
922 |
|
|
923 |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
924 |
regular expressions are created during compilation by calling the |
regular expressions are created during compilation by calling the |
925 |
function `regexp-opt'. Therefore, take a look at the source before |
function `regexp-opt'. Therefore, take a look at the source before |
926 |
you define your own sql-mode-oracle-font-lock-keywords. You may want |
you define your own sql-mode-ansi-font-lock-keywords. You may want to |
927 |
to add functions and PL/SQL keywords.") |
add functions and PL/SQL keywords.") |
928 |
(if sql-mode-oracle-font-lock-keywords |
|
929 |
() |
(defvar sql-mode-oracle-font-lock-keywords |
930 |
(let ((oracle-keywords (eval-when-compile |
(let ((oracle-keywords (eval-when-compile |
931 |
(concat "\\b" |
(concat "\\b" |
932 |
(regexp-opt '( |
(regexp-opt '( |
933 |
"admin" "after" "allocate" "analyze" "archive" "archivelog" "backup" |
;; Oracle (+ANSI) SQL keywords |
934 |
"become" "before" "block" "body" "cache" "cancel" "cascade" "change" |
|
935 |
"checkpoint" "compile" "constraint" "constraints" "contents" |
; ANSI keywords |
936 |
"controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount" |
"authorization" "avg" "begin" "close" "cobol" "commit" |
937 |
"dump" "each" "else" "elsif" "enable" "events" "except" "exceptions" |
"continue" "count" "declare" "double" "end" "escape" |
938 |
"execute" "exit" "explain" "extent" "externally" "false" "flush" "force" |
"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
939 |
"freelist" "freelists" "function" "groups" "if" "including" "initrans" |
"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
940 |
"instance" "layer" "link" "lists" "logfile" "loop" "manage" "manual" |
"precision" "primary" "procedure" "references" "rollback" |
941 |
"maxdatafiles" "maxinistances" "maxlogfiles" "maxloghistory" |
"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" |
942 |
"maxlogmembers" "maxtrans" "maxvalue" "minextents" "minvalue" "mount" |
|
943 |
"new" "next" "noarchivelog" "nocache" "nocycle" "nomaxvalue" |
; ANSI reserved words |
944 |
"nominvalue" "none" "noorder" "noresetlogs" "normal" "nosort" "off" |
"all" "and" "any" "as" "asc" "between" "by" "check" "create" |
945 |
"old" "only" "optimal" "others" "out" "own" "package" "parallel" |
"current" "default" "delete" "desc" "distinct" "exists" "float" "for" |
946 |
"pctincrease" "pctused" "plan" "pragma" "private" "profile" "quota" |
"from" "grant" "group" "having" "in" "insert" "into" "is" |
947 |
"raise" "read" "recover" "referencing" "resetlogs" "restrict_references" |
"like" "not" "null" "of" "on" "option" "or" "order" "privileges" |
948 |
"restricted" "return" "returning" "reuse" "rnds" "rnps" "role" "roles" |
"public" "select" "set" "table" "to" "union" "unique" |
949 |
"savepoint" "scn" "segment" "sequence" "shared" "snapshot" "sort" |
"update" "user" "values" "view" "where" "with" |
950 |
"statement_id" "statistics" "stop" "storage" "subtype" "switch" "system" |
|
951 |
"tables" "tablespace" "temporary" "thread" "time" "tracing" |
"access" "add" "admin" "after" "allocate" "alter" "analyze" "archive" |
952 |
"transaction" "triggers" "true" "truncate" "type" "under" "unlimited" |
"archivelog" "audit" "authid" "backup" "become" "before" "block" |
953 |
"until" "use" "using" "when" "while" "wnds" "wnps" "write") t) "\\b"))) |
"body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster" |
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 |
(oracle-warning-words (eval-when-compile |
986 |
(concat "\\b" |
(concat "\\b" |
987 |
(regexp-opt '( |
(regexp-opt '( |
988 |
"cursor_already_open" "dup_val_on_index" "exception" "invalid_cursor" |
;; PLSQL defined exceptions |
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" |
"invalid_number" "login_denied" "no_data_found" "not_logged_on" |
993 |
"notfound" "others" "pragma" "program_error" "storage_error" |
"program_error" "rowtype_mismatch" "self_is_null" "storage_error" |
994 |
"timeout_on_resource" "too_many_rows" "transaction_backed_out" |
"subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" |
995 |
"value_error" "zero_divide") t) "\\b"))) |
"timeout_on_resource" "too_many_rows" "value_error" "zero_divide" |
996 |
(oracle-reserved-words (eval-when-compile |
"exception" "notfound" |
997 |
(concat "\\b" |
|
998 |
|
) t) "\\b"))) |
999 |
|
|
1000 |
|
(oracle-sqlplus-commands |
1001 |
|
(eval-when-compile |
1002 |
|
(concat "^\\(\\(" |
1003 |
(regexp-opt '( |
(regexp-opt '( |
1004 |
"access" "add" "alter" "audit" "cluster" "column" "comment" "compress" |
;; SQL*Plus commands |
1005 |
"connect" "drop" "else" "exclusive" "file" "grant" |
|
1006 |
"identified" "immediate" "increment" "index" "initial" "intersect" |
"@" "@@" "accept" "append" "archive" "attribute" "break" |
1007 |
"level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit" |
"btitle" "change" "clear" "column" "connect" "copy" "define" |
1008 |
"nocompress" "nowait" "number" "offline" "online" "pctfree" "prior" |
"del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" |
1009 |
"raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum" |
"host" "input" "list" "password" "pause" "print" "prompt" "recover" |
1010 |
"rows" "session" "share" "size" "start" "successful" "synonym" "sysdate" |
"remark" "repfooter" "repheader" "run" "save" "show" "shutdown" |
1011 |
"then" "trigger" "uid" "validate" "whenever") t) "\\b"))) |
"spool" "start" "startup" "store" "timing" "ttitle" "undefine" |
1012 |
(oracle-types (eval-when-compile |
"variable" "whenever" |
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" |
(concat "\\b" |
1045 |
(regexp-opt '( |
(regexp-opt '( |
1046 |
;; Oracle Keywords that look like types |
;; Oracle Keywords that look like types |
1047 |
;; Oracle Reserved Words that look like types |
;; Oracle Reserved Words that look like types |
1048 |
"binary_integer" "blob" "boolean" "constant" "date" "decimal" "rowid" |
|
1049 |
"varchar" "varchar2") t) "\\b"))) |
"bfile" "binary_integer" "blob" "boolean" "byte" "char" "character" |
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 |
(oracle-builtin-functions (eval-when-compile |
1059 |
(concat "\\b" |
(concat "\\b" |
1060 |
(regexp-opt '( |
(regexp-opt '( |
1061 |
;; Misc Oracle builtin functions |
;; Misc Oracle builtin functions |
1062 |
"abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat" |
|
1063 |
"convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor" |
"abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2" |
1064 |
"glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb" |
"avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil" |
1065 |
"last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower" |
"chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr" |
1066 |
"lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time" |
"cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist" |
1067 |
"next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort" |
"current_date" "current_timestamp" "current_user" "dbtimezone" |
1068 |
"nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad" |
"decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob" |
1069 |
"rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt" |
"empty_clob" "existsnode" "exp" "extract" "extractvalue" "first" |
1070 |
"stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char" |
"first_value" "floor" "from_tz" "greatest" "group_id" "grouping" |
1071 |
"to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte" |
"grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day" |
1072 |
"translate" "trim" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b")))) |
"last_value" "lead" "least" "length" "ln" "localtimestamp" "log" |
1073 |
(setq sql-mode-oracle-font-lock-keywords |
"lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between" |
1074 |
(append sql-mode-ansi-font-lock-keywords |
"nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id" |
1075 |
(list (cons oracle-keywords 'font-lock-function-name-face) |
"nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper" |
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) |
(cons oracle-warning-words 'font-lock-warning-face) |
|
(cons oracle-reserved-words 'font-lock-keyword-face) |
|
1098 |
;; XEmacs doesn't have font-lock-builtin-face |
;; XEmacs doesn't have font-lock-builtin-face |
1099 |
(if (string-match "XEmacs\\|Lucid" emacs-version) |
(if (string-match "XEmacs\\|Lucid" emacs-version) |
1100 |
(cons oracle-builtin-functions 'font-lock-preprocessor-face) |
(cons oracle-builtin-functions 'font-lock-preprocessor-face) |
1101 |
;; GNU Emacs 19 doesn't have it either |
;; GNU Emacs 19 doesn't have it either |
1102 |
(if (string-match "GNU Emacs 19" emacs-version) |
(if (string-match "GNU Emacs 19" emacs-version) |
1103 |
(cons oracle-builtin-functions 'font-lock-function-name-face) |
(cons oracle-builtin-functions 'font-lock-keyword-face) |
1104 |
;; Emacs |
;; Emacs |
1105 |
(cons oracle-builtin-functions 'font-lock-builtin-face))) |
(cons oracle-builtin-functions 'font-lock-builtin-face))) |
1106 |
(cons oracle-types 'font-lock-type-face)))))) |
(cons oracle-types 'font-lock-type-face))) |
1107 |
|
|
1108 |
(defvar sql-mode-postgres-font-lock-keywords nil |
"Oracle SQL keywords used by font-lock. |
|
"Postgres SQL keywords used by font-lock. |
|
1109 |
|
|
1110 |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
1111 |
regular expressions are created during compilation by calling the |
regular expressions are created during compilation by calling the |
1112 |
function `regexp-opt'. Therefore, take a look at the source before |
function `regexp-opt'. Therefore, take a look at the source before |
1113 |
you define your own sql-mode-postgres-font-lock-keywords.") |
you define your own sql-mode-oracle-font-lock-keywords. You may want |
1114 |
|
to add functions and PL/SQL keywords.") |
1115 |
|
|
1116 |
(if sql-mode-postgres-font-lock-keywords |
(defvar sql-mode-postgres-font-lock-keywords |
|
() |
|
1117 |
(let ((postgres-reserved-words (eval-when-compile |
(let ((postgres-reserved-words (eval-when-compile |
1118 |
(concat "\\b" |
(concat "\\b" |
1119 |
(regexp-opt '( |
(regexp-opt '( |
1122 |
(postgres-types (eval-when-compile |
(postgres-types (eval-when-compile |
1123 |
(concat "\\b" |
(concat "\\b" |
1124 |
(regexp-opt '( |
(regexp-opt '( |
1125 |
|
|
1126 |
"bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
"bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
1127 |
"float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
"float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
1128 |
"point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
"point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
1129 |
|
|
1130 |
) t)"\\b"))) |
) t)"\\b"))) |
1131 |
(postgres-builtin-functions (eval-when-compile |
(postgres-builtin-functions (eval-when-compile |
1132 |
(concat "\\b" |
(concat "\\b" |
1133 |
(regexp-opt '( |
(regexp-opt '( |
1134 |
;; Misc Postgres builtin functions |
;; Misc Postgres builtin functions |
1135 |
|
|
1136 |
"abstime" "age" "area" "box" "center" "date_part" "date_trunc" |
"abstime" "age" "area" "box" "center" "date_part" "date_trunc" |
1137 |
"datetime" "dexp" "diameter" "dpow" "float" "float4" "height" |
"datetime" "dexp" "diameter" "dpow" "float" "float4" "height" |
1138 |
"initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" |
"initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" |
1140 |
"position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" |
"position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" |
1141 |
"substring" "text" "timespan" "translate" "trim" "upgradepath" |
"substring" "text" "timespan" "translate" "trim" "upgradepath" |
1142 |
"upgradepoly" "upper" "varchar" "width" |
"upgradepoly" "upper" "varchar" "width" |
1143 |
|
|
1144 |
) t) "\\b")))) |
) t) "\\b")))) |
|
(setq sql-mode-postgres-font-lock-keywords |
|
1145 |
(append sql-mode-ansi-font-lock-keywords |
(append sql-mode-ansi-font-lock-keywords |
1146 |
(list (cons postgres-reserved-words 'font-lock-keyword-face) |
(list (cons postgres-reserved-words 'font-lock-keyword-face) |
1147 |
;; XEmacs doesn't have 'font-lock-builtin-face |
;; XEmacs doesn't have 'font-lock-builtin-face |
1149 |
(cons postgres-builtin-functions 'font-lock-preprocessor-face) |
(cons postgres-builtin-functions 'font-lock-preprocessor-face) |
1150 |
;; Emacs |
;; Emacs |
1151 |
(cons postgres-builtin-functions 'font-lock-builtin-face)) |
(cons postgres-builtin-functions 'font-lock-builtin-face)) |
1152 |
(cons postgres-types 'font-lock-type-face)))))) |
(cons postgres-types 'font-lock-type-face)))) |
1153 |
|
|
1154 |
|
"Postgres SQL keywords used by font-lock. |
|
(defvar sql-mode-linter-font-lock-keywords nil |
|
|
"Linter SQL keywords used by font-lock. |
|
1155 |
|
|
1156 |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
1157 |
regular expressions are created during compilation by calling the |
regular expressions are created during compilation by calling the |
1158 |
function `regexp-opt'.") |
function `regexp-opt'. Therefore, take a look at the source before |
1159 |
|
you define your own sql-mode-postgres-font-lock-keywords.") |
1160 |
|
|
1161 |
(if sql-mode-linter-font-lock-keywords |
(defvar sql-mode-linter-font-lock-keywords |
|
() |
|
1162 |
(let ((linter-keywords (eval-when-compile |
(let ((linter-keywords (eval-when-compile |
1163 |
(concat "\\b" |
(concat "\\b" |
1164 |
(regexp-opt '( |
(regexp-opt '( |
1165 |
|
|
1166 |
"autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" |
"autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" |
1167 |
"committed" "count" "countblob" "cross" "current" "data" "database" |
"committed" "count" "countblob" "cross" "current" "data" "database" |
1168 |
"datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" |
"datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" |
1187 |
"trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" |
"trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" |
1188 |
"unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" |
"unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" |
1189 |
"wait" "windows_code" "workspace" "write" "xml" |
"wait" "windows_code" "workspace" "write" "xml" |
1190 |
|
|
1191 |
) t) "\\b"))) |
) t) "\\b"))) |
1192 |
(linter-reserved-words (eval-when-compile |
(linter-reserved-words (eval-when-compile |
1193 |
(concat "\\b" |
(concat "\\b" |
1194 |
(regexp-opt '( |
(regexp-opt '( |
1195 |
|
|
1196 |
"access" "action" "add" "address" "after" "all" "alter" "always" "and" |
"access" "action" "add" "address" "after" "all" "alter" "always" "and" |
1197 |
"any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" |
"any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" |
1198 |
"aud_obj_name_len" "backup" "base" "before" "between" "blobfile" |
"aud_obj_name_len" "backup" "base" "before" "between" "blobfile" |
1210 |
"start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" |
"start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" |
1211 |
"to" "union" "unique" "unlock" "until" "update" "using" "values" |
"to" "union" "unique" "unlock" "until" "update" "using" "values" |
1212 |
"view" "when" "where" "with" "without" |
"view" "when" "where" "with" "without" |
1213 |
|
|
1214 |
) t) "\\b"))) |
) t) "\\b"))) |
1215 |
(linter-types (eval-when-compile |
(linter-types (eval-when-compile |
1216 |
(concat "\\b" |
(concat "\\b" |
1217 |
(regexp-opt '( |
(regexp-opt '( |
1218 |
|
|
1219 |
"bigint" "bitmap" "blob" "boolean" "char" "character" "date" |
"bigint" "bitmap" "blob" "boolean" "char" "character" "date" |
1220 |
"datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" |
"datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" |
1221 |
"number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" |
"number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" |
1222 |
"cursor" "long" |
"cursor" "long" |
1223 |
|
|
1224 |
) t) "\\b"))) |
) t) "\\b"))) |
1225 |
(linter-builtin-functions (eval-when-compile |
(linter-builtin-functions (eval-when-compile |
1226 |
(concat "\\b" |
(concat "\\b" |
1227 |
(regexp-opt '( |
(regexp-opt '( |
1228 |
|
|
1229 |
"abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" |
"abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" |
1230 |
"exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" |
"exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" |
1231 |
"getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" |
"getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" |
1236 |
"to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" |
"to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" |
1237 |
"substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" |
"substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" |
1238 |
"instr" "least" "multime" "replace" "width" |
"instr" "least" "multime" "replace" "width" |
1239 |
|
|
1240 |
) t) "\\b")))) |
) t) "\\b")))) |
|
(setq sql-mode-linter-font-lock-keywords |
|
1241 |
(append sql-mode-ansi-font-lock-keywords |
(append sql-mode-ansi-font-lock-keywords |
1242 |
(list (cons linter-keywords 'font-lock-function-name-face) |
(list (cons linter-keywords 'font-lock-keywords-face) |
1243 |
(cons linter-reserved-words 'font-lock-keyword-face) |
(cons linter-reserved-words 'font-lock-keyword-face) |
1244 |
;; XEmacs doesn't have font-lock-builtin-face |
;; XEmacs doesn't have font-lock-builtin-face |
1245 |
(if (string-match "XEmacs\\|Lucid" emacs-version) |
(if (string-match "XEmacs\\|Lucid" emacs-version) |
1246 |
(cons linter-builtin-functions 'font-lock-preprocessor-face) |
(cons linter-builtin-functions 'font-lock-preprocessor-face) |
1247 |
;; GNU Emacs 19 doesn't have it either |
;; GNU Emacs 19 doesn't have it either |
1248 |
(if (string-match "GNU Emacs 19" emacs-version) |
(if (string-match "GNU Emacs 19" emacs-version) |
1249 |
(cons linter-builtin-functions 'font-lock-function-name-face) |
(cons linter-builtin-functions 'font-lock-keywords-face) |
1250 |
;; Emacs |
;; Emacs |
1251 |
(cons linter-builtin-functions 'font-lock-builtin-face))) |
(cons linter-builtin-functions 'font-lock-builtin-face))) |
1252 |
(cons linter-types 'font-lock-type-face)))))) |
(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-font-lock-keywords sql-mode-ansi-font-lock-keywords |
(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 |
|
|
1444 |
|
This variable is used by `sql-mode' and `sql-interactive-mode'. The |
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. |
"SQL keywords used by font-lock. |
1451 |
|
|
1452 |
This variable defaults to `sql-mode-ansi-font-lock-keywords'. This is |
Setting this variable directly no longer has any affect. Use |
1453 |
used for the default `font-lock-defaults' value in `sql-mode'. This |
`sql-product' and `sql-add-product-keywords' to control the |
1454 |
can be changed by some entry functions to provide more hilighting.") |
highlighting rules in sql-mode.") |
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 |
|
|
1505 |
|
|
1506 |
|
|
1507 |
;;; Functions to switch highlighting |
;;; Functions to switch highlighting |
1508 |
|
|
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 () |
(defun sql-highlight-oracle-keywords () |
1537 |
"Highlight Oracle keywords. |
"Highlight Oracle keywords." |
|
Basically, this just sets `font-lock-keywords' appropriately." |
|
1538 |
(interactive) |
(interactive) |
1539 |
(setq font-lock-keywords sql-mode-oracle-font-lock-keywords) |
(sql-set-product 'oracle)) |
|
(font-lock-fontify-buffer)) |
|
1540 |
|
|
1541 |
(defun sql-highlight-postgres-keywords () |
(defun sql-highlight-postgres-keywords () |
1542 |
"Highlight Postgres keywords. |
"Highlight Postgres keywords." |
|
Basically, this just sets `font-lock-keywords' appropriately." |
|
1543 |
(interactive) |
(interactive) |
1544 |
(setq font-lock-keywords sql-mode-postgres-font-lock-keywords) |
(sql-set-product 'postgres)) |
|
(font-lock-fontify-buffer)) |
|
1545 |
|
|
1546 |
(defun sql-highlight-linter-keywords () |
(defun sql-highlight-linter-keywords () |
1547 |
"Highlight LINTER keywords. |
"Highlight LINTER keywords." |
|
Basically, this just sets `font-lock-keywords' appropriately." |
|
1548 |
(interactive) |
(interactive) |
1549 |
(setq font-lock-keywords sql-mode-linter-font-lock-keywords) |
(sql-set-product 'linter)) |
1550 |
(font-lock-fontify-buffer)) |
|
1551 |
|
(defun sql-highlight-ms-keywords () |
1552 |
|
"Highlight Microsoft SQLServer keywords." |
1553 |
|
(interactive) |
1554 |
|
(sql-set-product 'ms)) |
1555 |
|
|
1556 |
(defun sql-highlight-ansi-keywords () |
(defun sql-highlight-ansi-keywords () |
1557 |
"Highlight ANSI SQL keywords. |
"Highlight ANSI SQL keywords." |
1558 |
Basically, this just sets `font-lock-keywords' appropriately." |
(interactive) |
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) |
(interactive) |
1599 |
(setq font-lock-keywords sql-mode-ansi-font-lock-keywords) |
(sql-set-product 'db2)) |
|
(font-lock-fontify-buffer)) |
|
1600 |
|
|
1601 |
|
|
1602 |
|
|
1662 |
Sybase: \\[sql-sybase] |
Sybase: \\[sql-sybase] |
1663 |
Ingres: \\[sql-ingres] |
Ingres: \\[sql-ingres] |
1664 |
Microsoft: \\[sql-ms] |
Microsoft: \\[sql-ms] |
1665 |
|
DB2: \\[sql-db2] |
1666 |
Interbase: \\[sql-interbase] |
Interbase: \\[sql-interbase] |
1667 |
Linter: \\[sql-linter] |
Linter: \\[sql-linter] |
1668 |
|
|
1709 |
The function asks for the username if WHAT contains symbol `user', for |
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 |
the password if it contains symbol `password', for the server if it |
1711 |
contains symbol `server', and for the database if it contains symbol |
contains symbol `server', and for the database if it contains symbol |
1712 |
`database'. |
`database'. The members of WHAT are processed in the order in which |
1713 |
|
they are provided. |
1714 |
|
|
1715 |
In order to ask the user for username, password and database, call the |
In order to ask the user for username, password and database, call the |
1716 |
function like this: (sql-get-login 'user 'password 'database)." |
function like this: (sql-get-login 'user 'password 'database)." |
1717 |
(interactive) |
(interactive) |
1718 |
(if (memq 'user what) |
(while what |
1719 |
|
(cond |
1720 |
|
((eq (car what) 'user) ; user |
1721 |
(setq sql-user |
(setq sql-user |
1722 |
(read-from-minibuffer "User: " sql-user nil nil |
(read-from-minibuffer "User: " sql-user nil nil |
1723 |
sql-user-history))) |
sql-user-history))) |
1724 |
(if (memq 'password what) |
((eq (car what) 'password) ; password |
1725 |
(setq sql-password |
(setq sql-password |
1726 |
(sql-read-passwd "Password: " sql-password))) |
(sql-read-passwd "Password: " sql-password))) |
1727 |
(if (memq 'server what) |
((eq (car what) 'server) ; server |
1728 |
(setq sql-server |
(setq sql-server |
1729 |
(read-from-minibuffer "Server: " sql-server nil nil |
(read-from-minibuffer "Server: " sql-server nil nil |
1730 |
sql-server-history))) |
sql-server-history))) |
1731 |
(if (memq 'database what) |
((eq (car what) 'database) ; database |
1732 |
(setq sql-database |
(setq sql-database |
1733 |
(read-from-minibuffer "Database: " sql-database nil nil |
(read-from-minibuffer "Database: " sql-database nil nil |
1734 |
sql-database-history)))) |
sql-database-history)))) |
1735 |
|
(setq what (cdr what)))) |
1736 |
|
|
1737 |
(defun sql-find-sqli-buffer () |
(defun sql-find-sqli-buffer () |
1738 |
"Return the current default SQLi buffer or nil. |
"Return the current default SQLi buffer or nil. |