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