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