Mercurial > emacs
annotate lisp/progmodes/sql.el @ 26202:adecdf8bb61f
Makefile.in if leim is not used.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 26 Oct 1999 21:47:37 +0000 |
parents | e55139b50cb6 |
children | 0894b3c8dfd6 |
rev | line source |
---|---|
24050 | 1 ;;; sql.el --- specialized comint.el for SQL interpreters |
2 | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
3 ;; Copyright (C) 1998, 1999 Free Software Foundation, Inc. |
24050 | 4 |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
5 ;; Author: Alex Schroeder <alex@gnu.org> |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
6 ;; Maintainer: Alex Schroeder <alex@gnu.org> |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
7 ;; Version: 1.4.9 |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
8 ;; Keywords: comm languages processes |
24050 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
29 ;; Please send bug reports and bug fixes to the mailing list at |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
30 ;; sql.el@gnu.org. If you want to subscribe to the mailing list, send |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
31 ;; mail to sql.el-request@gnu.org with `subscribe sql.el FIRSTNAME |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
32 ;; LASTNAME' in the mail body. |
24050 | 33 |
34 ;; You can get the latest version of this file from my homepage | |
35 ;; <URL:http://www.geocities.com/TimesSquare/6120/emacs.html>. | |
36 | |
37 ;; This file provides a sql-mode and a sql-interactive-mode. My goals | |
38 ;; were two simple modes providing syntactic hilighting. The | |
39 ;; interactive mode had to provide a command-line history; the other | |
40 ;; mode had to provide "send region/buffer to SQL interpreter" | |
41 ;; functions. "simple" in this context means easy to use, easy to | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
42 ;; maintain and little or no bells and whistles. |
24050 | 43 |
44 ;; If anybody feels like extending this sql mode, take a look at the | |
45 ;; above mentioned modes and write a sqlx-mode on top of this one. If | |
46 ;; this proves to be difficult, please suggest changes that will | |
47 ;; facilitate your plans. | |
48 | |
49 ;; sql-interactive-mode is used to interact with a SQL interpreter | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
50 ;; process in a SQLi buffer (usually called `*SQL*'). The SQLi buffer |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
51 ;; is created by calling a SQL interpreter-specific entry function. Do |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
52 ;; *not* call sql-interactive-mode by itself. |
24050 | 53 |
54 ;; The list of currently supported interpreters and the corresponding | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
55 ;; entry function used to create the SQLi buffers is shown with |
24050 | 56 ;; `sql-help' (M-x sql-help). |
57 | |
58 ;; Since sql-interactive-mode is built on top of the general | |
59 ;; command-interpreter-in-a-buffer mode (comint mode), it shares a | |
60 ;; common base functionality, and a common set of bindings, with all | |
61 ;; modes derived from comint mode. This makes these modes easier to | |
62 ;; use. | |
63 | |
64 ;; sql-mode can be used to enable syntactic hilighting for SQL | |
65 ;; statements in another buffer. SQL statements can then be sent to | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
66 ;; the SQL process in the SQLi buffer. sql-mode has already been |
24050 | 67 ;; used as a template to a simple PL/SQL mode. |
68 | |
69 ;; For documentation on the functionality provided by comint mode, and | |
70 ;; the hooks available for customising it, see the file `comint.el'. | |
71 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
72 ;; Hint for newbies: take a look at `dabbrev-expand', `abbrev-mode', and |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
73 ;; `imenu-add-menubar-index'. |
24050 | 74 |
75 ;;; Requirements for Emacs 19.34: | |
76 | |
77 ;; If you are using Emacs 19.34, you will have to get and install | |
78 ;; the file regexp-opt.el | |
79 ;; <URL:ftp://ftp.ifi.uio.no/pub/emacs/emacs-20.3/lisp/emacs-lisp/regexp-opt.el> | |
80 ;; and the custom package | |
81 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>. | |
82 | |
83 ;;; Bugs: | |
84 | |
85 ;; Using sql-ms (isql by Microsoft): When commands with syntax errors | |
86 ;; or execution errors are executed, there is no server feedback. | |
87 ;; This happens in stored procedures for example. The server messages | |
88 ;; only appear after the process is exited. This makes things | |
89 ;; somewhat unreliable. | |
90 | |
91 ;;; To Do: | |
92 | |
93 ;; Add better hilight support for other brands; there is a bias towards | |
94 ;; Oracle because that's what I use at work. Anybody else just send in | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
95 ;; your lists of reserved words, keywords and builtin functions! As |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
96 ;; long as I don't receive any feedback, everything is hilighted with |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
97 ;; ANSI keywords only. I received the list of ANSI keywords from a |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
98 ;; user; if you know of any changes, let me know. |
24050 | 99 |
100 ;; Add different hilighting levels. | |
101 | |
102 ;;; Thanks to all the people who helped me out: | |
103 | |
104 ;; Kai Blauberg <kai.blauberg@metla.fi> | |
105 ;; <ibalaban@dalet.com> | |
106 ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> | |
107 ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
108 ;; nino <nino@inform.dk> |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
109 ;; Berend de Boer <berend@pobox.com> |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
110 |
24050 | 111 |
112 | |
113 ;;; Code: | |
114 | |
115 (require 'comint) | |
116 ;; Need the following to allow GNU Emacs 19 to compile the file. | |
117 (require 'regexp-opt) | |
118 (require 'custom) | |
119 | |
120 ;;; Allow customization | |
121 | |
122 (defgroup SQL nil | |
123 "Running a SQL interpreter from within Emacs buffers" | |
24556 | 124 :version "20.4" |
24050 | 125 :group 'processes) |
126 | |
127 ;; These three variables will be used as defaults, if set. | |
128 | |
129 (defcustom sql-user "" | |
130 "*Default username." | |
131 :type 'string | |
132 :group 'SQL) | |
133 | |
134 (defcustom sql-password "" | |
135 "*Default password. | |
136 | |
137 Storing your password in a textfile such as ~/.emacs could be dangerous. | |
138 Customizing your password will store it in your ~/.emacs file." | |
139 :type 'string | |
140 :group 'SQL) | |
141 | |
142 (defcustom sql-database "" | |
143 "*Default database." | |
144 :type 'string | |
145 :group 'SQL) | |
146 | |
147 (defcustom sql-server "" | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
148 "*Default server or host." |
24050 | 149 :type 'string |
150 :group 'SQL) | |
151 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
152 ;; misc customization of sql.el behaviour |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
153 |
24050 | 154 (defcustom sql-pop-to-buffer-after-send-region nil |
155 "*If t, pop to the buffer SQL statements are sent to. | |
156 | |
157 After a call to `sql-send-region' or `sql-send-buffer', | |
158 the window is split and the SQLi buffer is shown. If this | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
159 variable is not nil, that buffer's window will be selected |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
160 by calling `pop-to-buffer'. If this variable is nil, that |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
161 buffer is shown using `display-buffer'." |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
162 :type 'boolean |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
163 :group 'SQL) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
164 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
165 ;; imenu support for sql-mode. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
166 |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
167 (defvar sql-imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
168 '(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1) |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
169 ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)) |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
170 "Define interesting points in the SQL buffer for `imenu'. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
171 |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
172 This is used to rebind `imenu-generic-expression'.") |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
173 |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
174 ;; history file |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
175 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
176 (defcustom sql-input-ring-file-name nil |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
177 "*If non-nil, name of the file to read/write input history. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
178 |
24861
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
179 You have to set this variable if you want the history of your commands |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
180 saved from one Emacs session to the next. If this variable is set, |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
181 exiting the SQL interpreter in an SQLi buffer will write the input |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
182 history to the specified file. Starting a new process in a SQLi buffer |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
183 will read the input history from the specified file. |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
184 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
185 This is used to locally set `comint-input-ring-file-name' when reading |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
186 or writing the input history." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
187 :type '(choice (const :tag "none" nil) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
188 (file)) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
189 :group 'SQL) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
190 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
191 (defcustom sql-input-ring-separator "\n--\n" |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
192 "*Separator between commands in the history file. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
193 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
194 If set to \"\\n\", each line in the history file will be interpreted as |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
195 one command. Multi-line commands are split into several commands when |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
196 the input ring is initialized from a history file. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
197 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
198 This variable used to locally set `comint-input-ring-separator' when |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
199 reading or writing the history file. `comint-input-ring-separator' is |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
200 not yet part of Emacs; if your Emacs does not have it, setting |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
201 `sql-input-ring-separator' will have no effect. In that case multiline |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
202 commands will be split into several commands when the input history is |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
203 read, as if you had set `sql-input-ring-separator' to \"\\n\". |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
204 |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
205 The source code contains a link to a homepage that might have a patch |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
206 for comint.el to download." |
24050 | 207 :type 'string |
208 :group 'SQL) | |
209 | |
210 ;; The usual hooks | |
211 | |
212 (defcustom sql-interactive-mode-hook '() | |
213 "*Hook for customising `sql-interactive-mode'." | |
214 :type 'hook | |
215 :group 'SQL) | |
216 | |
217 (defcustom sql-mode-hook '() | |
218 "*Hook for customising `sql-mode'." | |
219 :type 'hook | |
220 :group 'SQL) | |
221 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
222 (defcustom sql-set-sqli-hook '() |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
223 "*Hook for reacting to changes of `sql-buffer'. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
224 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
225 This is called by `sql-set-sqli-buffer' when the value of `sql-buffer' |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
226 is changed." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
227 :type 'hook |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
228 :group 'SQL) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
229 |
24050 | 230 ;; Customisation for Oracle |
231 | |
232 (defcustom sql-oracle-program "sqlplus" | |
233 "*Command to start sqlplus by Oracle. | |
234 | |
235 Starts `sql-interactive-mode' after doing some setup. | |
236 | |
237 Under NT, \"sqlplus\" usually starts the sqlplus \"GUI\". In order to | |
238 start the sqlplus console, use \"plus33\" or something similar. You | |
239 will find the file in your Orant\\bin directory. | |
240 | |
241 The program can also specify a TCP connection. See `make-comint'." | |
242 :type 'file | |
243 :group 'SQL) | |
244 | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
245 ;; Customisation for MySql |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
246 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
247 (defcustom sql-mysql-program "mysql" |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
248 "*Command to start mysql by TcX. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
249 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
250 Starts `sql-interactive-mode' after doing some setup. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
251 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
252 The program can also specify a TCP connection. See `make-comint'." |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
253 :type 'file |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
254 :group 'SQL) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
255 |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
256 ;; Customisation for Solid |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
257 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
258 (defcustom sql-solid-program "solsql" |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
259 "*Command to start SOLID SQL Editor. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
260 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
261 Starts `sql-interactive-mode' after doing some setup. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
262 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
263 The program can also specify a TCP connection. See `make-comint'." |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
264 :type 'file |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
265 :group 'SQL) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
266 |
24050 | 267 ;; Customisation for SyBase |
268 | |
269 (defcustom sql-sybase-program "isql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
270 "*Command to start isql by SyBase. |
24050 | 271 |
272 Starts `sql-interactive-mode' after doing some setup. | |
273 | |
274 The program can also specify a TCP connection. See `make-comint'." | |
275 :type 'file | |
276 :group 'SQL) | |
277 | |
278 ;; Customisation for Informix | |
279 | |
280 (defcustom sql-informix-program "dbaccess" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
281 "*Command to start dbaccess by Informix. |
24050 | 282 |
283 Starts `sql-interactive-mode' after doing some setup. | |
284 | |
285 The program can also specify a TCP connection. See `make-comint'." | |
286 :type 'file | |
287 :group 'SQL) | |
288 | |
289 ;; Customisation for Ingres | |
290 | |
291 (defcustom sql-ingres-program "sql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
292 "*Command to start sql by Ingres. |
24050 | 293 |
294 Starts `sql-interactive-mode' after doing some setup. | |
295 | |
296 The program can also specify a TCP connection. See `make-comint'." | |
297 :type 'file | |
298 :group 'SQL) | |
299 | |
300 ;; Customisation for Microsoft | |
301 | |
302 (defcustom sql-ms-program "isql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
303 "*Command to start isql by Microsoft. |
24050 | 304 |
305 Starts `sql-interactive-mode' after doing some setup. | |
306 | |
307 The program can also specify a TCP connection. See `make-comint'." | |
308 :type 'file | |
309 :group 'SQL) | |
310 | |
311 ;; Customisation for Postgres | |
312 | |
313 (defcustom sql-postgres-program "psql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
314 "Command to start psql by Postgres. |
24050 | 315 |
316 Starts `sql-interactive-mode' after doing some setup. | |
317 | |
318 The program can also specify a TCP connection. See `make-comint'." | |
319 :type 'file | |
320 :group 'SQL) | |
321 | |
322 | |
323 | |
324 ;;; Variables which do not need customization | |
325 | |
326 (defvar sql-user-history nil | |
327 "History of usernames used.") | |
328 | |
329 (defvar sql-database-history nil | |
330 "History of databases used.") | |
331 | |
332 (defvar sql-server-history nil | |
333 "History of servers used.") | |
334 | |
335 ;; Passwords are not kept in a history. | |
336 | |
337 (defvar sql-buffer nil | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
338 "Current SQLi buffer. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
339 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
340 The global value of sql-buffer is the name of the latest SQLi buffer |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
341 created. Any SQL buffer created will make a local copy of this value. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
342 See `sql-interactive-mode' for more on multiple sessions. If you want |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
343 to change the SQLi buffer a SQL mode sends its SQL strings to, change |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
344 the local value of `sql-buffer' using \\[sql-set-sqli-buffer].") |
24050 | 345 |
346 (defvar sql-prompt-regexp nil | |
347 "Prompt used to initialize `comint-prompt-regexp'. | |
348 | |
349 You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.") | |
350 | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
351 (defvar sql-prompt-length 0 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
352 "Prompt used to set `left-margin' in `sql-interactive-mode'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
353 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
354 You can change it on `sql-interactive-mode-hook'.") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
355 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
356 (defvar sql-alternate-buffer-name nil |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
357 "Buffer-local string used to possibly rename the SQLi buffer. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
358 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
359 Used by `sql-rename-buffer'.") |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
360 |
24050 | 361 ;; Keymap for sql-interactive-mode, based on comint-mode-map. |
362 | |
363 (if (not (string-match "XEmacs\\|Lucid" emacs-version)) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
364 (defvar sql-interactive-mode-map |
24050 | 365 (let ((map (nconc (make-sparse-keymap) comint-mode-map))) |
366 (define-key map "\C-j" 'sql-accumulate-and-indent) | |
367 (define-key map "\C-c\C-w" 'sql-copy-column) | |
368 map) | |
369 "Mode map used for `sql-interactive-mode'.") | |
370 ;; XEmacs | |
371 (defvar sql-interactive-mode-map nil) | |
372 (if (not sql-interactive-mode-map) | |
373 (let ((map (make-keymap))) | |
374 (set-keymap-parents map (list comint-mode-map)) | |
375 (set-keymap-name map 'sql-interactive-mode-map) | |
376 (define-key map "\C-j" 'sql-accumulate-and-indent) | |
377 (define-key map "\C-c\C-w" 'sql-copy-column) | |
378 (setq sql-interactive-mode-map map)))) | |
379 | |
380 ;; Keymap for sql-mode. | |
381 | |
382 (defvar sql-mode-map | |
383 (let ((map (make-sparse-keymap))) | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
384 (define-key map "\C-c\C-c" 'sql-send-paragraph) |
24050 | 385 (define-key map "\C-c\C-r" 'sql-send-region) |
386 (define-key map "\C-c\C-b" 'sql-send-buffer) | |
387 (define-key map "\t" 'indent-relative) | |
388 map) | |
389 "Mode map used for `sql-mode'.") | |
390 | |
391 ;; easy menu for sql-mode. | |
392 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
393 (easy-menu-define |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
394 sql-mode-menu sql-mode-map |
24050 | 395 "Menu for `sql-mode'." |
396 '("SQL" | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
397 ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
398 (get-buffer-process sql-buffer))] |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
399 ["Send Region" sql-send-region (and mark-active |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
400 (buffer-live-p sql-buffer) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
401 (get-buffer-process sql-buffer))] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
402 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
403 (get-buffer-process sql-buffer))] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
404 ["Show SQLi buffer" sql-show-sqli-buffer t] |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
405 ["Set SQLi buffer" sql-set-sqli-buffer t] |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
406 ["Pop to SQLi buffer after send" |
24050 | 407 sql-toggle-pop-to-buffer-after-send-region |
408 :style toggle | |
409 :selected sql-pop-to-buffer-after-send-region])) | |
410 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
411 ;; easy menu for sql-interactive-mode. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
412 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
413 (easy-menu-define |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
414 sql-interactive-mode-menu sql-interactive-mode-map |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
415 "Menu for `sql-interactive-mode'." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
416 '("SQL" |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
417 ["Rename Buffer" sql-rename-buffer t])) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
418 |
24050 | 419 ;; Abbreviations -- if you want more of them, define them in your |
420 ;; ~/.emacs file. Abbrevs have to be enabled in your ~/.emacs, too. | |
421 | |
422 (defvar sql-mode-abbrev-table nil | |
423 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") | |
424 (if sql-mode-abbrev-table | |
425 () | |
426 (let ((wrapper)) | |
427 (define-abbrev-table 'sql-mode-abbrev-table ()) | |
428 (define-abbrev sql-mode-abbrev-table "ins" "insert" nil) | |
429 (define-abbrev sql-mode-abbrev-table "upd" "update" nil) | |
430 (define-abbrev sql-mode-abbrev-table "del" "delete" nil) | |
431 (define-abbrev sql-mode-abbrev-table "sel" "select" nil))) | |
432 | |
433 ;; Syntax Table | |
434 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
435 (defvar sql-mode-syntax-table |
24050 | 436 (let ((table (make-syntax-table))) |
437 ;; C-style comments /**/ (see elisp manual "Syntax Flags")) | |
438 (modify-syntax-entry ?/ ". 14" table) | |
439 (modify-syntax-entry ?* ". 23" table) | |
440 ;; double-dash starts comment | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
441 (if (string-match "XEmacs\\|Lucid" emacs-version) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
442 (modify-syntax-entry ?- ". 56" table) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
443 (modify-syntax-entry ?- ". 12b" table)) |
24050 | 444 ;; newline and formfeed end coments |
445 (modify-syntax-entry ?\n "> b" table) | |
446 (modify-syntax-entry ?\f "> b" table) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
447 ;; single quotes (') quotes delimit strings |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
448 (modify-syntax-entry ?' "\"" table) |
24050 | 449 table) |
450 "Syntax table used in `sql-mode' and `sql-interactive-mode'.") | |
451 | |
452 ;; Font lock support | |
453 | |
454 (defvar sql-mode-ansi-font-lock-keywords nil | |
455 "ANSI SQL keywords used by font-lock. | |
456 | |
457 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
458 regular expressions are created during compilation by calling the | |
459 function `regexp-opt'. Therefore, take a look at the source before | |
460 you define your own sql-mode-ansi-font-lock-keywords. You may want to | |
461 add functions and PL/SQL keywords.") | |
462 (if sql-mode-ansi-font-lock-keywords | |
463 () | |
464 (let ((ansi-keywords (eval-when-compile | |
465 (concat "\\b" | |
466 (regexp-opt '( | |
467 "authorization" "avg" "begin" "close" "cobol" "commit" | |
468 "continue" "count" "declare" "double" "end" "escape" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
469 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
24050 | 470 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
471 "precision" "primary" "procedure" "references" "rollback" | |
472 "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b"))) | |
473 (ansi-reserved-words (eval-when-compile | |
474 (concat "\\b" | |
475 (regexp-opt '( | |
476 "all" "and" "any" "as" "asc" "between" "by" "check" "create" | |
477 "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | |
478 "from" "grant" "group" "having" "in" "insert" "into" "is" | |
479 "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | |
480 "public" "select" "set" "table" "to" "union" "unique" | |
481 "update" "user" "values" "view" "where" "with") t) "\\b"))) | |
482 (ansi-types (eval-when-compile | |
483 (concat "\\b" | |
484 (regexp-opt '( | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
485 ;; ANSI Keywords that look like types |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
486 "character" "cursor" "dec" "int" "real" |
24050 | 487 ;; ANSI Reserved Word that look like types |
488 "char" "integer" "smallint" ) t) "\\b")))) | |
489 (setq sql-mode-ansi-font-lock-keywords | |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
490 (list (cons ansi-keywords 'font-lock-function-name-face) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
491 (cons ansi-reserved-words 'font-lock-keyword-face) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
492 (cons ansi-types 'font-lock-type-face))))) |
24050 | 493 |
494 (defvar sql-mode-oracle-font-lock-keywords nil | |
495 "Oracle SQL keywords used by font-lock. | |
496 | |
497 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
498 regular expressions are created during compilation by calling the | |
499 function `regexp-opt'. Therefore, take a look at the source before | |
500 you define your own sql-mode-oracle-font-lock-keywords. You may want | |
501 to add functions and PL/SQL keywords.") | |
502 (if sql-mode-oracle-font-lock-keywords | |
503 () | |
504 (let ((oracle-keywords (eval-when-compile | |
505 (concat "\\b" | |
506 (regexp-opt '( | |
507 "admin" "after" "allocate" "analyze" "archive" "archivelog" "backup" | |
508 "become" "before" "block" "body" "cache" "cancel" "cascade" "change" | |
509 "checkpoint" "compile" "constraint" "constraints" "contents" | |
510 "controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount" | |
511 "dump" "each" "enable" "events" "except" "exceptions" "execute" | |
512 "explain" "extent" "externally" "flush" "force" "freelist" "freelists" | |
513 "function" "groups" "including" "initrans" "instance" "layer" "link" | |
514 "lists" "logfile" "manage" "manual" "maxdatafiles" "maxinistances" | |
515 "maxlogfiles" "maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" | |
516 "minextents" "minvalue" "mount" "new" "next" "noarchivelog" "nocache" | |
517 "nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs" | |
518 "normal" "nosort" "off" "old" "only" "optimal" "own" "package" | |
519 "parallel" "pctincrease" "pctused" "plan" "private" "profile" "quota" | |
520 "read" "recover" "referencing" "resetlogs" "restricted" "reuse" "role" | |
521 "roles" "savepoint" "scn" "segment" "sequence" "shared" "snapshot" | |
522 "sort" "statement_id" "statistics" "stop" "storage" "switch" "system" | |
523 "tables" "tablespace" "temporary" "thread" "time" "tracing" | |
524 "transaction" "triggers" "truncate" "under" "unlimited" "until" "use" | |
525 "using" "when" "write") t) "\\b"))) | |
526 (oracle-reserved-words (eval-when-compile | |
527 (concat "\\b" | |
528 (regexp-opt '( | |
529 "access" "add" "alter" "audit" "cluster" "column" "comment" "compress" | |
530 "connect" "drop" "else" "exclusive" "file" "grant" | |
531 "identified" "immediate" "increment" "index" "initial" "intersect" | |
532 "level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit" | |
533 "nocompress" "nowait" "number" "offline" "online" "pctfree" "prior" | |
534 "raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum" | |
535 "rows" "session" "share" "size" "start" "successful" "synonym" "sysdate" | |
536 "then" "trigger" "uid" "validate" "whenever") t) "\\b"))) | |
537 (oracle-types (eval-when-compile | |
538 (concat "\\b" | |
539 (regexp-opt '( | |
540 ;; Oracle Keywords that look like types | |
541 ;; Oracle Reserved Words that look like types | |
542 "date" "decimal" "rowid" "varchar" "varchar2") t) "\\b"))) | |
543 (oracle-builtin-functions (eval-when-compile | |
544 (concat "\\b" | |
545 (regexp-opt '( | |
546 ;; Misc Oracle builtin functions | |
547 "abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat" | |
548 "convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor" | |
549 "glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb" | |
550 "last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower" | |
551 "lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time" | |
552 "next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort" | |
553 "nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad" | |
554 "rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt" | |
555 "stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char" | |
556 "to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte" | |
557 "translate" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b")))) | |
558 (setq sql-mode-oracle-font-lock-keywords | |
559 (append sql-mode-ansi-font-lock-keywords | |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
560 (list (cons oracle-keywords 'font-lock-function-name-face) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
561 (cons oracle-reserved-words 'font-lock-keyword-face) |
24050 | 562 ;; XEmacs doesn't have font-lock-builtin-face |
563 (if (string-match "XEmacs\\|Lucid" emacs-version) | |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
564 (cons oracle-builtin-functions 'font-lock-preprocessor-face) |
24050 | 565 ;; GNU Emacs 19 doesn't have it either |
566 (if (string-match "GNU Emacs 19" emacs-version) | |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
567 (cons oracle-builtin-functions 'font-lock-function-name-face) |
24050 | 568 ;; Emacs |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
569 (cons oracle-builtin-functions 'font-lock-builtin-face))) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
570 (cons oracle-types 'font-lock-type-face)))))) |
24050 | 571 |
572 (defvar sql-mode-postgres-font-lock-keywords nil | |
573 "Postgres SQL keywords used by font-lock. | |
574 | |
575 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
576 regular expressions are created during compilation by calling the | |
577 function `regexp-opt'. Therefore, take a look at the source before | |
578 you define your own sql-mode-postgres-font-lock-keywords.") | |
579 | |
580 (if sql-mode-postgres-font-lock-keywords | |
581 () | |
582 (let ((postgres-reserved-words (eval-when-compile | |
583 (concat "\\b" | |
584 (regexp-opt '( | |
585 "language" | |
586 ) t) "\\b"))) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
587 (postgres-types (eval-when-compile |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
588 (concat "\\b" |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
589 (regexp-opt '( |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
590 "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
591 "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
24050 | 592 "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
593 ) t)"\\b"))) | |
594 (postgres-builtin-functions (eval-when-compile | |
595 (concat "\\b" | |
596 (regexp-opt '( | |
597 ;; Misc Postgres builtin functions | |
598 "abstime" "age" "area" "box" "center" "date_part" "date_trunc" | |
599 "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" | |
600 "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" | |
601 "length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" | |
602 "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" | |
603 "substring" "text" "timespan" "translate" "trim" "upgradepath" | |
604 "upgradepoly" "upper" "varchar" "width" | |
605 ) t) "\\b")))) | |
606 (setq sql-mode-postgres-font-lock-keywords | |
607 (append sql-mode-ansi-font-lock-keywords | |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
608 (list (cons postgres-reserved-words 'font-lock-keyword-face) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
609 ;; XEmacs doesn't have 'font-lock-builtin-face |
24050 | 610 (if (string-match "XEmacs\\|Lucid" emacs-version) |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
611 (cons postgres-builtin-functions 'font-lock-preprocessor-face) |
24050 | 612 ;; Emacs |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
613 (cons postgres-builtin-functions 'font-lock-builtin-face)) |
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
614 (cons postgres-types 'font-lock-type-face)))))) |
24050 | 615 |
616 | |
617 (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
618 "SQL keywords used by font-lock. | |
619 | |
620 This variable defaults to `sql-mode-ansi-font-lock-keywords'. This is | |
621 used for the default `font-lock-defaults' value in `sql-mode'. This | |
622 can be changed by some entry functions to provide more hilighting.") | |
623 | |
624 | |
625 | |
626 ;;; Small functions | |
627 | |
628 (defun sql-accumulate-and-indent () | |
629 "Continue SQL statement on the next line." | |
630 (interactive) | |
25183
16937a774275
(sql-accumulate-and-indent): Instead of testing
Richard M. Stallman <rms@gnu.org>
parents:
24861
diff
changeset
|
631 (if (fboundp 'comint-accumulate) (comint-accumulate)) |
24050 | 632 (indent-according-to-mode)) |
633 | |
634 ;;;###autoload | |
635 (defun sql-help () | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
636 "Show short help for the SQL modes. |
24050 | 637 |
638 Use an entry function to open an interactive SQL buffer. This buffer is | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
639 usually named `*SQL*'. The name of the major mode is SQLi. |
24050 | 640 |
641 Use the following commands to start a specific SQL interpreter: | |
642 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
643 PostGres: \\[sql-postgres] |
24268 | 644 |
645 Other non-free SQL implementations are also supported: | |
646 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
647 MySQL: \\[sql-mysql] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
648 Solid: \\[sql-solid] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
649 Oracle: \\[sql-oracle] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
650 Informix: \\[sql-informix] |
24268 | 651 Sybase: \\[sql-sybase] |
652 Ingres: \\[sql-ingres] | |
653 Microsoft: \\[sql-ms] | |
654 | |
655 But we urge you to choose a free implementation instead of these. | |
24050 | 656 |
657 Once you have the SQLi buffer, you can enter SQL statements in the | |
658 buffer. The output generated is appended to the buffer and a new prompt | |
659 is generated. See the In/Out menu in the SQLi buffer for some functions | |
660 that help you navigate through the buffer, the input history, etc. | |
661 | |
662 Put a line with a call to autoload into your `~/.emacs' file for each | |
663 entry function you want to use regularly: | |
664 | |
665 \(autoload 'sql-postgres \"sql\" \"Interactive SQL mode.\" t) | |
666 | |
667 If you have a really complex SQL statement or if you are writing a | |
668 procedure, you can do this in a separate buffer. Put the new buffer in | |
669 `sql-mode' by calling \\[sql-mode]. The name of this buffer can be | |
670 anything. The name of the major mode is SQL. | |
671 | |
672 In this SQL buffer (SQL mode), you can send the region or the entire | |
673 buffer to the interactive SQL buffer (SQLi mode). The results are | |
674 appended to the SQLi buffer without disturbing your SQL buffer." | |
675 (interactive) | |
676 (describe-function 'sql-help)) | |
677 | |
678 (defun sql-read-passwd (prompt &optional default) | |
679 "Read a password using PROMPT. | |
680 Optional DEFAULT is password to start with. This function calls | |
681 `read-passwd' if it is available. If not, function | |
682 `ange-ftp-read-passwd' is called. This should always be available, | |
683 even in old versions of Emacs." | |
684 (if (fboundp 'read-passwd) | |
685 (read-passwd prompt nil default) | |
686 (unless (fboundp 'ange-ftp-read-passwd) | |
687 (autoload 'ange-ftp-read-passwd "ange-ftp")) | |
688 (ange-ftp-read-passwd prompt default))) | |
689 | |
690 (defun sql-get-login (&rest what) | |
691 "Get username, password and database from the user. | |
692 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
693 The variables `sql-user', `sql-password', `sql-server', and |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
694 `sql-database' can be customised. They are used as the default values. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
695 Usernames, servers and databases are stored in `sql-user-history', |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
696 `sql-server-history' and `database-history'. Passwords are not stored |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
697 in a history. |
24050 | 698 |
699 Parameter WHAT is a list of the arguments passed to this function. | |
700 The function asks for the username if WHAT contains symbol `user', for | |
701 the password if it contains symbol `password', for the server if it | |
702 contains symbol `server', and for the database if it contains symbol | |
703 `database'. | |
704 | |
705 In order to ask the user for username, password and database, call the | |
706 function like this: (sql-get-login 'user 'password 'database)." | |
707 (interactive) | |
708 (if (memq 'user what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
709 (setq sql-user |
24050 | 710 (read-from-minibuffer "User: " sql-user nil nil |
711 sql-user-history))) | |
712 (if (memq 'password what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
713 (setq sql-password |
24050 | 714 (sql-read-passwd "Password: " sql-password))) |
715 (if (memq 'server what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
716 (setq sql-server |
24050 | 717 (read-from-minibuffer "Server: " sql-server nil nil |
718 sql-server-history))) | |
719 (if (memq 'database what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
720 (setq sql-database |
24050 | 721 (read-from-minibuffer "Database: " sql-database nil nil |
722 sql-database-history)))) | |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
723 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
724 (defun sql-set-sqli-buffer () |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
725 "Set the SQLi buffer SQL strings are sent to. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
726 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
727 Call this function in a SQL buffer in order to set the SQLi buffer SQL |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
728 strings are sent to. Calling this function sets `sql-buffer' and runs |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
729 `sql-set-sqli-hook'. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
730 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
731 If you call it from a SQL buffer, this sets the local copy of |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
732 `sql-buffer'. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
733 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
734 If you call it from anywhere else, it sets the global copy of |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
735 `sql-buffer'." |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
736 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
737 (let ((new-buffer (get-buffer (read-buffer "New SQLi buffer: " nil t)))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
738 (if new-buffer |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
739 (progn |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
740 (setq sql-buffer new-buffer) |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
741 (run-hooks 'sql-set-sqli-hook))))) |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
742 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
743 (defun sql-show-sqli-buffer () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
744 "Show the name of current SQLi buffer. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
745 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
746 This is the buffer SQL strings are sent to. It is stored in the |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
747 variable `sql-buffer'. See `sql-help' on how to create such a buffer." |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
748 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
749 (if (null (buffer-live-p sql-buffer)) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
750 (message "%s has no SQLi buffer set." (buffer-name (current-buffer))) |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
751 (if (null (get-buffer-process sql-buffer)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
752 (message "Buffer %s has no process." (buffer-name sql-buffer)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
753 (message "Current SQLi buffer is %s." (buffer-name sql-buffer))))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
754 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
755 (defun sql-make-alternate-buffer-name () |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
756 "Return a string that can be used to rename a SQLi buffer. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
757 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
758 This is used to set `sql-alternate-buffer-name' within |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
759 `sql-interactive-mode'." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
760 (concat (if (string= "" sql-user) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
761 (if (string= "" user-login-name) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
762 () |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
763 (concat user-login-name "/")) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
764 (concat sql-user "/")) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
765 (if (string= "" sql-database) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
766 (if (string= "" sql-server) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
767 system-name |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
768 sql-server) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
769 sql-database))) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
770 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
771 (defun sql-rename-buffer () |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
772 "Renames a SQLi buffer." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
773 (interactive) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
774 (rename-buffer (format "*SQL: %s*" sql-alternate-buffer-name) t)) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
775 |
24050 | 776 (defun sql-copy-column () |
777 "Copy current column to the end of buffer. | |
778 Inserts SELECT or commas if appropriate." | |
779 (interactive) | |
780 (let ((column)) | |
781 (save-excursion | |
782 (setq column (buffer-substring | |
783 (progn (forward-char 1) (backward-sexp 1) (point)) | |
784 (progn (forward-sexp 1) (point)))) | |
785 (goto-char (point-max)) | |
786 (cond | |
787 ;; if empty command line, insert SELECT | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
788 ((save-excursion (beginning-of-line) |
24050 | 789 (looking-at (concat comint-prompt-regexp "$"))) |
790 (insert "SELECT ")) | |
791 ;; else if appending to SELECT or ORDER BY, insert a comma | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
792 ((save-excursion |
24050 | 793 (re-search-backward "\\b\\(select\\|order by\\) .+" |
794 (save-excursion (beginning-of-line) (point)) t)) | |
795 (insert ", ")) | |
796 ;; else insert a space | |
797 (t | |
798 (if (eq (preceding-char) ? ) | |
799 nil | |
800 (insert " ")))) | |
801 ;; in any case, insert the column | |
802 (insert column) | |
803 (message "%s" column)))) | |
804 | |
805 | |
806 | |
807 ;;; Sending the region to the SQLi buffer. | |
808 | |
809 (defun sql-send-region (start end) | |
810 "Send a region to the SQL process." | |
811 (interactive "r") | |
812 (if (buffer-live-p sql-buffer) | |
813 (save-excursion | |
814 (comint-send-region sql-buffer start end) | |
815 (if (string-match "\n$" (buffer-substring start end)) | |
816 () | |
817 (comint-send-string sql-buffer "\n")) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
818 (message "Sent string to buffer %s." (buffer-name sql-buffer)) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
819 (if sql-pop-to-buffer-after-send-region |
24050 | 820 (pop-to-buffer sql-buffer) |
821 (display-buffer sql-buffer))) | |
822 (message "No SQL process started."))) | |
823 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
824 (defun sql-send-paragraph () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
825 "Send the current paragraph to the SQL process." |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
826 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
827 (let ((start (save-excursion |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
828 (backward-paragraph) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
829 (point))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
830 (end (save-excursion |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
831 (forward-paragraph) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
832 (point)))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
833 (sql-send-region start end))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
834 |
24050 | 835 (defun sql-send-buffer () |
836 "Send the buffer contents to the SQL process." | |
837 (interactive) | |
838 (sql-send-region (point-min) (point-max))) | |
839 | |
840 (defun sql-toggle-pop-to-buffer-after-send-region (&optional value) | |
841 "Toggle `sql-pop-to-buffer-after-send-region'. | |
842 | |
843 If given the optional parameter VALUE, sets | |
844 sql-toggle-pop-to-buffer-after-send-region to VALUE." | |
845 (interactive "P") | |
846 (if value | |
847 (setq sql-pop-to-buffer-after-send-region value) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
848 (setq sql-pop-to-buffer-after-send-region |
24050 | 849 (null sql-pop-to-buffer-after-send-region )))) |
850 | |
851 | |
852 | |
853 ;;; SQL mode -- uses SQL interactive mode | |
854 | |
855 ;;;###autoload | |
856 (defun sql-mode () | |
857 "Major mode to edit SQL. | |
858 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
859 You can send SQL statements to the SQLi buffer using |
24050 | 860 \\[sql-send-region]. Such a buffer must exist before you can do this. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
861 See `sql-help' on how to create SQLi buffers. |
24050 | 862 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
863 \\{sql-mode-map} |
24050 | 864 Customization: Entry to this mode runs the `sql-mode-hook'. |
865 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
866 When you put a buffer in SQL mode, the buffer stores the last SQLi |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
867 buffer created as its destination in the variable `sql-buffer'. This |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
868 will be the buffer \\[sql-send-region] sends the region to. If this |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
869 SQLi buffer is killed, \\[sql-send-region] is no longer able to |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
870 determine where the strings should be sent to. You can set the |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
871 value of `sql-buffer' using \\[sql-set-sqli-buffer]. |
24050 | 872 |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
873 For information on how to create multiple SQLi buffers, see |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
874 `sql-interactive-mode'." |
24050 | 875 (interactive) |
876 (kill-all-local-variables) | |
877 (setq major-mode 'sql-mode) | |
878 (setq mode-name "SQL") | |
879 (use-local-map sql-mode-map) | |
880 (set-syntax-table sql-mode-syntax-table) | |
881 (make-local-variable 'font-lock-defaults) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
882 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
883 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
884 ;; will have just one quote. Therefore syntactic hilighting is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
885 ;; disabled for interactive buffers. `_' and `.' are considered part |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
886 ;; of words. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
887 (setq font-lock-defaults '(sql-mode-font-lock-keywords |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
888 nil t ((?_ . "w") (?. . "w")))) |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
889 (make-local-variable 'comment-start) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
890 (setq comment-start "--") |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
891 ;; Make each buffer in sql-mode remember the "current" SQLi buffer. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
892 (make-local-variable 'sql-buffer) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
893 ;; Add imenu support for sql-mode. Note that imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
894 ;; is buffer-local, so we don't need a local-variable for it. SQL is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
895 ;; case-insensitive, that's why we have to set imenu-case-fold-search. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
896 ;; imenu-syntax-alist makes sure that `_' is considered part of object |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
897 ;; names. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
898 (setq imenu-generic-expression sql-imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
899 imenu-case-fold-search t |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
900 imenu-syntax-alist '(("_" . "w"))) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
901 ;; Make `sql-send-paragraph' work on paragraphs that contain indented |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
902 ;; lines. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
903 (make-local-variable 'paragraph-separate) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
904 (make-local-variable 'paragraph-start) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
905 (setq paragraph-separate "[\f]*$" |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
906 paragraph-start "[\n\f]") |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
907 ;; Abbrevs |
24050 | 908 (setq local-abbrev-table sql-mode-abbrev-table) |
909 (setq abbrev-all-caps 1) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
910 ;; Run hook |
24050 | 911 (run-hooks 'sql-mode-hook)) |
912 | |
913 | |
914 | |
915 ;;; SQL interactive mode | |
916 | |
917 (put 'sql-interactive-mode 'mode-class 'special) | |
918 | |
919 (defun sql-interactive-mode () | |
920 "Major mode to use a SQL interpreter interactively. | |
921 | |
922 Do not call this function by yourself. The environment must be | |
923 initialized by an entry function specific for the SQL interpreter. See | |
924 `sql-help' for a list of available entry functions. | |
925 | |
926 \\[comint-send-input] after the end of the process' output sends the | |
927 text from the end of process to the end of the current line. | |
928 \\[comint-send-input] before end of process output copies the current | |
929 line minus the prompt to the end of the buffer and sends it. | |
930 \\[comint-copy-old-input] just copies the current line. | |
931 Use \\[sql-accumulate-and-indent] to enter multi-line statements. | |
932 | |
933 If you want to make multiple SQL buffers, rename the `*SQL*' buffer | |
934 using \\[rename-buffer] or \\[rename-uniquely] and start a new process. | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
935 See `sql-help' for a list of available entry functions. The last buffer |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
936 created by such an entry function is the current SQLi buffer. SQL |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
937 buffers will send strings to the SQLi buffer current at the time of |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
938 their creation. See `sql-mode' for details. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
939 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
940 Sample session using two connections: |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
941 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
942 1. Create first SQLi buffer by calling an entry function. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
943 2. Rename buffer \"*SQL*\" to \"*Connection 1*\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
944 3. Create a SQL buffer \"test1.sql\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
945 4. Create second SQLi buffer by calling an entry function. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
946 5. Rename buffer \"*SQL*\" to \"*Connection 2*\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
947 6. Create a SQL buffer \"test2.sql\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
948 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
949 Now \\[sql-send-region] in buffer \"test1.sql\" will send the region to |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
950 buffer \"*Connection 1*\", \\[sql-send-region] in buffer \"test2.sql\" |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
951 will send the region to buffer \"*Connection 2*\". |
24050 | 952 |
953 If you accidentally suspend your process, use \\[comint-continue-subjob] | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
954 to continue it. On some operating systems, this will not work because |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
955 the signals are not supported. |
24050 | 956 |
957 \\{sql-interactive-mode-map} | |
958 Customization: Entry to this mode runs the hooks on `comint-mode-hook' | |
959 and `sql-interactive-mode-hook' (in that order). Before each input, the | |
960 hooks on `comint-input-filter-functions' are run. After each SQL | |
961 interpreter output, the hooks on `comint-output-filter-functions' are | |
962 run. | |
963 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
964 Variable `sql-input-ring-file-name' controls the initialisation of the |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
965 input ring history. `comint-input-ring-file-name' is temporarily bound |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
966 to `sql-input-ring-file-name' when reading the input history. |
24050 | 967 |
968 Variables `comint-output-filter-functions', a hook, and | |
969 `comint-scroll-to-bottom-on-input' and | |
970 `comint-scroll-to-bottom-on-output' control whether input and output | |
971 cause the window to scroll to the end of the buffer. | |
972 | |
973 If you want to make SQL buffers limited in length, add the function | |
974 `comint-truncate-buffer' to `comint-output-filter-functions'. | |
975 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
976 Here is an example for your .emacs file. It keeps the SQLi buffer a |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
977 certain length. |
24050 | 978 |
979 \(add-hook 'sql-interactive-mode-hook | |
980 \(function (lambda () | |
981 \(setq comint-output-filter-functions 'comint-truncate-buffer)))) | |
982 | |
983 Here is another example. It will always put point back to the statement | |
984 you entered, right above the output it created. | |
985 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
986 \(setq comint-output-filter-functions |
24050 | 987 \(function (lambda (STR) (comint-show-output))))" |
988 (comint-mode) | |
989 (setq comint-prompt-regexp sql-prompt-regexp) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
990 (setq left-margin sql-prompt-length) |
24050 | 991 (setq major-mode 'sql-interactive-mode) |
992 (setq mode-name "SQLi") | |
993 (use-local-map sql-interactive-mode-map) | |
994 (set-syntax-table sql-mode-syntax-table) | |
995 (make-local-variable 'font-lock-defaults) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
996 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
997 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
998 ;; will have just one quote. Therefore syntactic hilighting is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
999 ;; disabled for interactive buffers. `_' and `.' are considered part |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1000 ;; of words. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1001 (setq font-lock-defaults '(sql-mode-font-lock-keywords |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1002 t t ((?_ . "w") (?. . "w")))) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1003 ;; Enable commenting and uncommenting of the region. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1004 (make-local-variable 'comment-start) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1005 (setq comment-start "--") |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1006 ;; Abbreviation table init and case-insensitive. It is not activatet |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1007 ;; by default. |
24050 | 1008 (setq local-abbrev-table sql-mode-abbrev-table) |
1009 (setq abbrev-all-caps 1) | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1010 ;; Exiting the process will call sql-stop. |
24050 | 1011 (set-process-sentinel (get-buffer-process sql-buffer) 'sql-stop) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1012 ;; Make input-ring stuff buffer local so that people who want a |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1013 ;; different history file for each buffer/process/client/whatever can |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1014 ;; change separator and file-name on the sql-interactive-mode-hook. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1015 (make-local-variable 'sql-input-ring-separator) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1016 (make-local-variable 'sql-input-ring-file-name) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1017 ;; Create a usefull name for renaming this buffer later. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1018 (make-local-variable 'sql-alternate-buffer-name) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1019 (setq sql-alternate-buffer-name (sql-make-alternate-buffer-name)) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1020 ;; User stuff. |
24050 | 1021 (run-hooks 'sql-interactive-mode-hook) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1022 ;; Calling the hook before calling comint-read-input-ring allows users |
24050 | 1023 ;; to set comint-input-ring-file-name in sql-interactive-mode-hook. |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1024 ;; While reading the history, file-name and history are rebound... |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1025 (let ((comint-input-ring-file-name sql-input-ring-file-name) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1026 (comint-input-ring-separator sql-input-ring-separator)) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1027 (comint-read-input-ring t))) |
24050 | 1028 |
1029 (defun sql-stop (process event) | |
1030 "Called when the SQL process is stopped. | |
1031 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1032 Writes the input history to a history file using |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1033 `comint-write-input-ring' and inserts a short message in the SQL buffer. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1034 `comint-comint-input-ring-file-name' is temporarily bound to |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1035 `sql-input-ring-file-name'. |
24050 | 1036 |
1037 This function is a sentinel watching the SQL interpreter process. | |
1038 Sentinels will always get the two parameters PROCESS and EVENT." | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1039 ;; Write history. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1040 ;; While reading the history, file-name and history are rebound... |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1041 (let ((comint-input-ring-file-name sql-input-ring-file-name) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1042 (comint-input-ring-separator sql-input-ring-separator)) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1043 (comint-write-input-ring)) |
24050 | 1044 (if (buffer-live-p sql-buffer) |
1045 (insert (format "\nProcess %s %s\n" process event)))) | |
1046 | |
1047 | |
1048 | |
1049 ;;; Entry functions for different SQL interpreters. | |
1050 | |
1051 (defun sql-oracle () | |
1052 "Run sqlplus by Oracle as an inferior process. | |
1053 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1054 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1055 If buffer exists and a process is running, just switch to buffer |
1056 `*SQL*'. | |
1057 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1058 Interpreter used comes from variable `sql-oracle-program'. Login uses |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1059 the variables `sql-user', `sql-password', and `sql-database' as |
24050 | 1060 defaults, if set. |
1061 | |
1062 The buffer is put in sql-interactive-mode, giving commands for sending | |
1063 input. See `sql-interactive-mode'. | |
1064 | |
1065 To specify a coding system for converting non-ASCII characters | |
1066 in the input and output to the process, use \\[universal-coding-system-argument] | |
1067 before \\[sql-oracle]. You can also specify this with \\[set-buffer-process-coding-system] | |
1068 in the SQL buffer, after you start the process. | |
1069 The default comes from `process-coding-system-alist' and | |
1070 `default-process-coding-system'. | |
1071 | |
1072 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1073 (interactive) | |
1074 (if (comint-check-proc "*SQL*") | |
1075 (pop-to-buffer "*SQL*") | |
1076 (sql-get-login 'user 'password 'database) | |
1077 (message "Login...") | |
1078 ;; Produce user/password@database construct. Password without user | |
1079 ;; is meaningless; database without user/password is meaningless, | |
1080 ;; because "@param" will ask sqlplus to interpret the script | |
1081 ;; "param". | |
1082 (let ((parameter nil)) | |
1083 (if (not (string= "" sql-user)) | |
1084 (if (not (string= "" sql-password)) | |
1085 (setq parameter (concat sql-user "/" sql-password)) | |
1086 (setq parameter sql-user))) | |
1087 (if (and parameter (not (string= "" sql-database))) | |
1088 (setq parameter (concat parameter "@" sql-database))) | |
1089 (if parameter | |
1090 (set-buffer (make-comint "SQL" sql-oracle-program nil parameter)) | |
1091 (set-buffer (make-comint "SQL" sql-oracle-program nil)))) | |
1092 (setq sql-prompt-regexp "^SQL> ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1093 (setq sql-prompt-length 5) |
24050 | 1094 (setq sql-buffer (current-buffer)) |
1095 ;; set sql-mode-font-lock-keywords to something different before | |
1096 ;; calling sql-interactive-mode. | |
1097 (setq sql-mode-font-lock-keywords sql-mode-oracle-font-lock-keywords) | |
1098 (sql-interactive-mode) | |
1099 (message "Login...done") | |
1100 (pop-to-buffer sql-buffer))) | |
1101 | |
1102 | |
1103 | |
1104 (defun sql-sybase () | |
1105 "Run isql by SyBase as an inferior process. | |
1106 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1107 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1108 If buffer exists and a process is running, just switch to buffer |
1109 `*SQL*'. | |
1110 | |
1111 Interpreter used comes from variable `sql-sybase-program'. Login uses | |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1112 the variables `sql-user', `sql-password', and `sql-server' as |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1113 defaults, if set. |
24050 | 1114 |
1115 The buffer is put in sql-interactive-mode, giving commands for sending | |
1116 input. See `sql-interactive-mode'. | |
1117 | |
1118 To specify a coding system for converting non-ASCII characters | |
1119 in the input and output to the process, use \\[universal-coding-system-argument] | |
1120 before \\[sql-sybase]. You can also specify this with \\[set-buffer-process-coding-system] | |
1121 in the SQL buffer, after you start the process. | |
1122 The default comes from `process-coding-system-alist' and | |
1123 `default-process-coding-system'. | |
1124 | |
1125 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1126 (interactive) | |
1127 (if (comint-check-proc "*SQL*") | |
1128 (pop-to-buffer "*SQL*") | |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1129 (sql-get-login 'user 'password 'server) |
24050 | 1130 (message "Login...") |
1131 ;; Put all parameters to the program (if defined) in a list and call | |
1132 ;; make-comint. | |
1133 (let ((params '("-w" "2048" "-n"))) | |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1134 ;; There is no way to specify the database via command line |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1135 ;; parameters. The -S option specifies the server. |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1136 (if (not (string= "" sql-server)) |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1137 (setq params (append (list "-S" sql-server) params))) |
24050 | 1138 (if (not (string= "" sql-password)) |
1139 (setq params (append (list "-P" sql-password) params))) | |
1140 (if (not (string= "" sql-user)) | |
1141 (setq params (append (list "-U" sql-user) params))) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1142 (set-buffer (apply 'make-comint "SQL" sql-sybase-program |
24050 | 1143 nil params))) |
1144 (setq sql-prompt-regexp "^SQL> ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1145 (setq sql-prompt-length 5) |
24050 | 1146 (setq sql-buffer (current-buffer)) |
1147 (sql-interactive-mode) | |
1148 (message "Login...done") | |
1149 (pop-to-buffer sql-buffer))) | |
1150 | |
1151 | |
1152 | |
1153 (defun sql-informix () | |
1154 "Run dbaccess by Informix as an inferior process. | |
1155 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1156 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1157 If buffer exists and a process is running, just switch to buffer |
1158 `*SQL*'. | |
1159 | |
1160 Interpreter used comes from variable `sql-informix-program'. Login uses | |
1161 the variable `sql-database' as default, if set. | |
1162 | |
1163 The buffer is put in sql-interactive-mode, giving commands for sending | |
1164 input. See `sql-interactive-mode'. | |
1165 | |
1166 To specify a coding system for converting non-ASCII characters | |
1167 in the input and output to the process, use \\[universal-coding-system-argument] | |
1168 before \\[sql-informix]. You can also specify this with \\[set-buffer-process-coding-system] | |
1169 in the SQL buffer, after you start the process. | |
1170 The default comes from `process-coding-system-alist' and | |
1171 `default-process-coding-system'. | |
1172 | |
1173 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1174 (interactive) | |
1175 (if (comint-check-proc "*SQL*") | |
1176 (pop-to-buffer "*SQL*") | |
1177 (sql-get-login 'database) | |
1178 (message "Login...") | |
1179 ;; username and password are ignored. | |
1180 (if (string= "" sql-database) | |
1181 (set-buffer (make-comint "SQL" sql-informix-program nil)) | |
1182 (set-buffer (make-comint "SQL" sql-informix-program nil sql-database))) | |
1183 (setq sql-prompt-regexp "^SQL> ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1184 (setq sql-prompt-length 5) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1185 (setq sql-buffer (current-buffer)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1186 (sql-interactive-mode) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1187 (message "Login...done") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1188 (pop-to-buffer sql-buffer))) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1189 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1190 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1191 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1192 (defun sql-mysql () |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1193 "Run mysql by TcX as an inferior process. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1194 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1195 Note that the widespread idea that mysql is free software is inaccurate; |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1196 its license is too restrictive. We urge you to use PostGres instead. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1197 |
24268 | 1198 If buffer `*SQL*' exists but no process is running, make a new process. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1199 If buffer exists and a process is running, just switch to buffer |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1200 `*SQL*'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1201 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1202 Interpreter used comes from variable `sql-mysql-program'. Login uses |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1203 the variables `sql-user', `sql-password', `sql-database', and |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1204 `sql-server' as defaults, if set. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1205 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1206 The buffer is put in sql-interactive-mode, giving commands for sending |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1207 input. See `sql-interactive-mode'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1208 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1209 To specify a coding system for converting non-ASCII characters |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1210 in the input and output to the process, use \\[universal-coding-system-argument] |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1211 before \\[sql-mysql]. You can also specify this with \\[set-buffer-process-coding-system] |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1212 in the SQL buffer, after you start the process. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1213 The default comes from `process-coding-system-alist' and |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1214 `default-process-coding-system'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1215 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1216 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1217 (interactive) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1218 (if (comint-check-proc "*SQL*") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1219 (pop-to-buffer "*SQL*") |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1220 (sql-get-login 'user 'password 'database 'server) |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1221 (message "Login...") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1222 ;; Put all parameters to the program (if defined) in a list and call |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1223 ;; make-comint. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1224 (let ((params)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1225 (if (not (string= "" sql-database)) |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1226 (setq params (append (list sql-database) params))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1227 (if (not (string= "" sql-server)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1228 (setq params (append (list (concat "--host=" sql-server)) params))) |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1229 (if (not (string= "" sql-password)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1230 (setq params (append (list (concat "--password=" sql-password)) params))) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1231 (if (not (string= "" sql-user)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1232 (setq params (append (list (concat "--user=" sql-user)) params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1233 (set-buffer (apply 'make-comint "SQL" sql-mysql-program |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1234 nil params))) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1235 (setq sql-prompt-regexp "^mysql>") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1236 (setq sql-prompt-length 6) |
24050 | 1237 (setq sql-buffer (current-buffer)) |
1238 (sql-interactive-mode) | |
1239 (message "Login...done") | |
1240 (pop-to-buffer sql-buffer))) | |
1241 | |
1242 | |
1243 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1244 (defun sql-solid () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1245 "Run solsql by Solid as an inferior process. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1246 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1247 If buffer `*SQL*' exists but no process is running, make a new process. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1248 If buffer exists and a process is running, just switch to buffer |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1249 `*SQL*'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1250 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1251 Interpreter used comes from variable `sql-solid-program'. Login uses |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1252 the variables `sql-user', `sql-password', and `sql-server' as |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1253 defaults, if set. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1254 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1255 The buffer is put in sql-interactive-mode, giving commands for sending |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1256 input. See `sql-interactive-mode'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1257 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1258 To specify a coding system for converting non-ASCII characters |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1259 in the input and output to the process, use \\[universal-coding-system-argument] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1260 before \\[sql-solid]. You can also specify this with \\[set-buffer-process-coding-system] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1261 in the SQL buffer, after you start the process. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1262 The default comes from `process-coding-system-alist' and |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1263 `default-process-coding-system'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1264 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1265 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1266 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1267 (if (comint-check-proc "*SQL*") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1268 (pop-to-buffer "*SQL*") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1269 (sql-get-login 'user 'password 'server) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1270 (message "Login...") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1271 ;; Put all parameters to the program (if defined) in a list and call |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1272 ;; make-comint. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1273 (let ((params)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1274 ;; It only makes sense if both username and password are there. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1275 (if (not (or (string= "" sql-user) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1276 (string= "" sql-password))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1277 (setq params (append (list sql-user sql-password) params))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1278 (if (not (string= "" sql-server)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1279 (setq params (append (list sql-server) params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1280 (set-buffer (apply 'make-comint "SQL" sql-solid-program |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1281 nil params))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1282 (setq sql-prompt-regexp "^") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1283 (setq sql-prompt-length 0) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1284 (setq sql-buffer (current-buffer)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1285 (sql-interactive-mode) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1286 (message "Login...done") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1287 (pop-to-buffer sql-buffer))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1288 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1289 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1290 |
24050 | 1291 (defun sql-ingres () |
1292 "Run sql by Ingres as an inferior process. | |
1293 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1294 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1295 If buffer exists and a process is running, just switch to buffer |
1296 `*SQL*'. | |
1297 | |
1298 Interpreter used comes from variable `sql-ingres-program'. Login uses | |
1299 the variable `sql-database' as default, if set. | |
1300 | |
1301 The buffer is put in sql-interactive-mode, giving commands for sending | |
1302 input. See `sql-interactive-mode'. | |
1303 | |
1304 To specify a coding system for converting non-ASCII characters | |
1305 in the input and output to the process, use \\[universal-coding-system-argument] | |
1306 before \\[sql-ingres]. You can also specify this with \\[set-buffer-process-coding-system] | |
1307 in the SQL buffer, after you start the process. | |
1308 The default comes from `process-coding-system-alist' and | |
1309 `default-process-coding-system'. | |
1310 | |
1311 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1312 (interactive) | |
1313 (if (comint-check-proc "*SQL*") | |
1314 (pop-to-buffer "*SQL*") | |
1315 (sql-get-login 'database) | |
1316 (message "Login...") | |
1317 ;; username and password are ignored. | |
1318 (if (string= "" sql-database) | |
1319 (set-buffer (make-comint "SQL" sql-ingres-program nil)) | |
1320 (set-buffer (make-comint "SQL" sql-ingres-program nil sql-database))) | |
1321 (setq sql-prompt-regexp "^\* ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1322 (setq sql-prompt-length 2) |
24050 | 1323 (setq sql-buffer (current-buffer)) |
1324 (sql-interactive-mode) | |
1325 (message "Login...done") | |
1326 (pop-to-buffer sql-buffer))) | |
1327 | |
1328 | |
1329 | |
1330 (defun sql-ms () | |
1331 "Run isql by Microsoft as an inferior process. | |
1332 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1333 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1334 If buffer exists and a process is running, just switch to buffer |
1335 `*SQL*'. | |
1336 | |
1337 Interpreter used comes from variable `sql-ms-program'. Login uses the | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1338 variables `sql-user', `sql-password', `sql-database', and `sql-server' |
24050 | 1339 as defaults, if set. |
1340 | |
1341 The buffer is put in sql-interactive-mode, giving commands for sending | |
1342 input. See `sql-interactive-mode'. | |
1343 | |
1344 To specify a coding system for converting non-ASCII characters | |
1345 in the input and output to the process, use \\[universal-coding-system-argument] | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1346 before \\[sql-ms]. You can also specify this with \\[set-buffer-process-coding-system] |
24050 | 1347 in the SQL buffer, after you start the process. |
1348 The default comes from `process-coding-system-alist' and | |
1349 `default-process-coding-system'. | |
1350 | |
1351 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1352 (interactive) | |
1353 (if (comint-check-proc "*SQL*") | |
1354 (pop-to-buffer "*SQL*") | |
1355 (sql-get-login 'user 'password 'database 'server) | |
1356 (message "Login...") | |
1357 ;; Put all parameters to the program (if defined) in a list and call | |
1358 ;; make-comint. | |
1359 (let ((params '("-w 300"))) | |
1360 (if (not (string= "" sql-server)) | |
1361 (setq params (append (list "-S" sql-server) params))) | |
1362 (if (not (string= "" sql-database)) | |
1363 (setq params (append (list "-d" sql-database) params))) | |
1364 (if (not (string= "" sql-user)) | |
1365 (setq params (append (list "-U" sql-user) params))) | |
1366 (if (not (string= "" sql-password)) | |
1367 (setq params (append (list "-P" sql-password) params)) | |
1368 ;; If -P is passed to ISQL as the last argument without a password, | |
1369 ;; it's considered null. | |
1370 (setq params (append params (list "-P")))) | |
1371 (set-buffer (apply 'make-comint "SQL" sql-ms-program | |
1372 nil params))) | |
1373 (setq sql-prompt-regexp "^[0-9]*>") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1374 (setq sql-prompt-length 5) |
24050 | 1375 (setq sql-buffer (current-buffer)) |
1376 (sql-interactive-mode) | |
1377 (message "Login...done") | |
1378 (pop-to-buffer sql-buffer))) | |
1379 | |
1380 | |
1381 | |
1382 | |
1383 ;;;###autoload | |
1384 (defun sql-postgres () | |
1385 "Run psql by Postgres as an inferior process. | |
1386 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1387 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1388 If buffer exists and a process is running, just switch to buffer |
1389 `*SQL*'. | |
1390 | |
1391 Interpreter used comes from variable `sql-postgres-program'. Login uses | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1392 the variables `sql-database' and `sql-server' as default, if set. |
24050 | 1393 |
1394 The buffer is put in sql-interactive-mode, giving commands for sending | |
1395 input. See `sql-interactive-mode'. | |
1396 | |
1397 To specify a coding system for converting non-ASCII characters | |
1398 in the input and output to the process, use \\[universal-coding-system-argument] | |
1399 before \\[sql-postgres]. You can also specify this with \\[set-buffer-process-coding-system] | |
1400 in the SQL buffer, after you start the process. | |
1401 The default comes from `process-coding-system-alist' and | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1402 `default-process-coding-system'. If your output lines end with ^M, |
24050 | 1403 your might try undecided-dos as a coding system. If this doesn't help, |
1404 Try to set `comint-output-filter-functions' like this: | |
1405 | |
1406 \(setq comint-output-filter-functions (append comint-output-filter-functions | |
1407 '(comint-strip-ctrl-m))) | |
1408 | |
1409 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1410 (interactive) | |
1411 (if (comint-check-proc "*SQL*") | |
1412 (pop-to-buffer "*SQL*") | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1413 (sql-get-login 'database 'server) |
24050 | 1414 (message "Login...") |
1415 ;; username and password are ignored. | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1416 (let ((params)) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1417 (if (not (string= "" sql-database)) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1418 (setq params (append (list sql-database) params))) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1419 (if (not (string= "" sql-server)) |
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1420 (setq params (append (list "-h" sql-server) params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1421 (set-buffer (apply 'make-comint "SQL" sql-postgres-program |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1422 nil params))) |
24050 | 1423 (setq sql-prompt-regexp "^.*> *") |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1424 (setq sql-prompt-length 5) |
24050 | 1425 ;; This is a lousy hack to prevent psql from truncating it's output |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1426 ;; and giving stupid warnings. If s.o. knows a way to prevent psql |
24050 | 1427 ;; from acting this way, then I would be very thankful to |
1428 ;; incorporate this (Gregor Zych <zych@pool.informatik.rwth-aachen.de>) | |
1429 (comint-send-string "*SQL*" "\\o \| cat\n") | |
1430 (setq sql-mode-font-lock-keywords sql-mode-postgres-font-lock-keywords) | |
1431 (setq sql-buffer (current-buffer)) | |
1432 (sql-interactive-mode) | |
1433 (message "Login...done") | |
1434 (pop-to-buffer sql-buffer))) | |
1435 | |
1436 (provide 'sql) | |
1437 | |
1438 ;;; sql.el ends here |