Mercurial > emacs
annotate lisp/progmodes/sql.el @ 43645:feb21d2d94b4
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 03 Mar 2002 00:36:27 +0000 |
parents | 2f56e7fc793a |
children | 893d44670df9 |
rev | line source |
---|---|
24050 | 1 ;;; sql.el --- specialized comint.el for SQL interpreters |
2 | |
36523
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
24050 | 4 |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
5 ;; Author: Alex Schroeder <alex@gnu.org> |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
6 ;; Maintainer: Alex Schroeder <alex@gnu.org> |
40971
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
7 ;; Version: 1.6.5 |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
8 ;; Keywords: comm languages processes |
38872 | 9 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
24050 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Commentary: | |
29 | |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
30 ;; Please send bug reports and bug fixes to the mailing list at |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
31 ;; sql.el@gnu.org. If you want to subscribe to the mailing list, send |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
32 ;; mail to sql.el-request@gnu.org with `subscribe sql.el FIRSTNAME |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
33 ;; LASTNAME' in the mail body. |
24050 | 34 |
35 ;; This file provides a sql-mode and a sql-interactive-mode. My goals | |
36 ;; were two simple modes providing syntactic hilighting. The | |
37 ;; interactive mode had to provide a command-line history; the other | |
38 ;; mode had to provide "send region/buffer to SQL interpreter" | |
39 ;; functions. "simple" in this context means easy to use, easy to | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
40 ;; maintain and little or no bells and whistles. |
24050 | 41 |
42 ;; If anybody feels like extending this sql mode, take a look at the | |
43 ;; above mentioned modes and write a sqlx-mode on top of this one. If | |
44 ;; this proves to be difficult, please suggest changes that will | |
45 ;; facilitate your plans. | |
46 | |
47 ;; sql-interactive-mode is used to interact with a SQL interpreter | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
48 ;; process in a SQLi buffer (usually called `*SQL*'). The SQLi buffer |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
49 ;; is created by calling a SQL interpreter-specific entry function. Do |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
50 ;; *not* call sql-interactive-mode by itself. |
24050 | 51 |
52 ;; The list of currently supported interpreters and the corresponding | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
53 ;; entry function used to create the SQLi buffers is shown with |
24050 | 54 ;; `sql-help' (M-x sql-help). |
55 | |
56 ;; Since sql-interactive-mode is built on top of the general | |
57 ;; command-interpreter-in-a-buffer mode (comint mode), it shares a | |
58 ;; common base functionality, and a common set of bindings, with all | |
59 ;; modes derived from comint mode. This makes these modes easier to | |
60 ;; use. | |
61 | |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
62 ;; sql-mode can be used to keep editing SQL statements. The SQL |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
63 ;; statements can be sent to the SQL process in the SQLi buffer. |
24050 | 64 |
65 ;; For documentation on the functionality provided by comint mode, and | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
66 ;; the hooks available for customizing it, see the file `comint.el'. |
24050 | 67 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
68 ;; Hint for newbies: take a look at `dabbrev-expand', `abbrev-mode', and |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
69 ;; `imenu-add-menubar-index'. |
24050 | 70 |
71 ;;; Requirements for Emacs 19.34: | |
72 | |
73 ;; If you are using Emacs 19.34, you will have to get and install | |
74 ;; the file regexp-opt.el | |
75 ;; <URL:ftp://ftp.ifi.uio.no/pub/emacs/emacs-20.3/lisp/emacs-lisp/regexp-opt.el> | |
76 ;; and the custom package | |
77 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>. | |
78 | |
79 ;;; Bugs: | |
80 | |
81 ;; Using sql-ms (isql by Microsoft): When commands with syntax errors | |
82 ;; or execution errors are executed, there is no server feedback. | |
83 ;; This happens in stored procedures for example. The server messages | |
84 ;; only appear after the process is exited. This makes things | |
85 ;; somewhat unreliable. | |
86 | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
87 ;; ChangeLog available on request. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
88 |
24050 | 89 ;;; To Do: |
90 | |
91 ;; Add better hilight support for other brands; there is a bias towards | |
92 ;; 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
|
93 ;; 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
|
94 ;; 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
|
95 ;; 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
|
96 ;; user; if you know of any changes, let me know. |
24050 | 97 |
98 ;; Add different hilighting levels. | |
99 | |
100 ;;; Thanks to all the people who helped me out: | |
101 | |
102 ;; Kai Blauberg <kai.blauberg@metla.fi> | |
103 ;; <ibalaban@dalet.com> | |
104 ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> | |
105 ;; 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
|
106 ;; nino <nino@inform.dk> |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
107 ;; Berend de Boer <berend@pobox.com> |
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" | |
24556 | 122 :version "20.4" |
24050 | 123 :group 'processes) |
124 | |
125 ;; These three variables will be used as defaults, if set. | |
126 | |
127 (defcustom sql-user "" | |
128 "*Default username." | |
129 :type 'string | |
130 :group 'SQL) | |
131 | |
132 (defcustom sql-password "" | |
133 "*Default password. | |
134 | |
135 Storing your password in a textfile such as ~/.emacs could be dangerous. | |
136 Customizing your password will store it in your ~/.emacs file." | |
137 :type 'string | |
138 :group 'SQL) | |
139 | |
140 (defcustom sql-database "" | |
141 "*Default database." | |
142 :type 'string | |
143 :group 'SQL) | |
144 | |
145 (defcustom sql-server "" | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
146 "*Default server or host." |
24050 | 147 :type 'string |
148 :group 'SQL) | |
149 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
150 ;; misc customization of sql.el behaviour |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
151 |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
152 (defcustom sql-electric-stuff nil |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
153 "Treat some input as electric. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
154 If set to the symbol `semicolon', then hitting `;' will send current |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
155 input in the SQLi buffer to the process. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
156 If set to the symbol `go', then hitting `go' on a line by itself will |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
157 send current input in the SQLi buffer to the process. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
158 If set to nil, then you must use \\[comint-send-input] in order to send |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
159 current input in the SQLi buffer to the process." |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
160 :type '(choice (const :tag "Nothing" nil) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
161 (const :tag "The semikolon `;'" semicolon) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
162 (const :tag "The string `go' by itself" go)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
163 :version "20.8" |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
164 :group 'SQL) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
165 |
24050 | 166 (defcustom sql-pop-to-buffer-after-send-region nil |
167 "*If t, pop to the buffer SQL statements are sent to. | |
168 | |
169 After a call to `sql-send-region' or `sql-send-buffer', | |
170 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
|
171 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
|
172 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
|
173 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
|
174 :type 'boolean |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
175 :group 'SQL) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
176 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
177 ;; imenu support for sql-mode. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
178 |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
179 (defvar sql-imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
180 '(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1) |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
181 ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)) |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
182 "Define interesting points in the SQL buffer for `imenu'. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
183 |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
184 This is used to set `imenu-generic-expression' when SQL mode is |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
185 entered. Subsequent changes to sql-imenu-generic-expression will not |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
186 affect existing SQL buffers because imenu-generic-expression is a |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
187 local variable.") |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
188 |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
189 ;; history file |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
190 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
191 (defcustom sql-input-ring-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
|
192 "*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
|
193 |
24861
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
194 You have to set this variable if you want the history of your commands |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
195 saved from one Emacs session to the next. If this variable is set, |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
196 exiting the SQL interpreter in an SQLi buffer will write the input |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
197 history to the specified file. Starting a new process in a SQLi buffer |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
198 will read the input history from the specified file. |
0d593aa15c0f
(sql-input-ring-file-name): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24591
diff
changeset
|
199 |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
200 This is used to initialize `comint-input-ring-file-name'. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
201 |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
202 Note that the size of the input history is determined by the variable |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
203 `comint-input-ring-size'." |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
204 :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
|
205 (file)) |
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 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
208 (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
|
209 "*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
|
210 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
211 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
|
212 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
|
213 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
|
214 |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
215 This variable used to initialize `comint-input-ring-separator'. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
216 `comint-input-ring-separator' is part of Emacs 21; if your Emacs |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
217 does not have it, setting `sql-input-ring-separator' will have no |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
218 effect. In that case multiline commands will be split into several |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
219 commands when the input history is read, as if you had set |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
220 `sql-input-ring-separator' to \"\\n\"." |
24050 | 221 :type 'string |
222 :group 'SQL) | |
223 | |
224 ;; The usual hooks | |
225 | |
226 (defcustom sql-interactive-mode-hook '() | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
227 "*Hook for customizing `sql-interactive-mode'." |
24050 | 228 :type 'hook |
229 :group 'SQL) | |
230 | |
231 (defcustom sql-mode-hook '() | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
232 "*Hook for customizing `sql-mode'." |
24050 | 233 :type 'hook |
234 :group 'SQL) | |
235 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
236 (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
|
237 "*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
|
238 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
239 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
|
240 is changed." |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
241 :type 'hook |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
242 :group 'SQL) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
243 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
244 ;; Customization for Oracle |
24050 | 245 |
246 (defcustom sql-oracle-program "sqlplus" | |
247 "*Command to start sqlplus by Oracle. | |
248 | |
249 Starts `sql-interactive-mode' after doing some setup. | |
250 | |
251 Under NT, \"sqlplus\" usually starts the sqlplus \"GUI\". In order to | |
252 start the sqlplus console, use \"plus33\" or something similar. You | |
253 will find the file in your Orant\\bin directory. | |
254 | |
255 The program can also specify a TCP connection. See `make-comint'." | |
256 :type 'file | |
257 :group 'SQL) | |
258 | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
259 (defcustom sql-oracle-options nil |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
260 "*List of additional options for `sql-oracle-program'." |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
261 :type '(repeat string) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
262 :version "20.8" |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
263 :group 'SQL) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
264 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
265 ;; Customization for MySql |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
266 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
267 (defcustom sql-mysql-program "mysql" |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
268 "*Command to start mysql by TcX. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
269 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
270 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
|
271 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
272 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
|
273 :type 'file |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
274 :group 'SQL) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
275 |
32169
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
276 (defcustom sql-mysql-options nil |
34704
7cb3b80e66b8
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32621
diff
changeset
|
277 "*List of additional options for `sql-mysql-program'. |
7cb3b80e66b8
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32621
diff
changeset
|
278 The following list of options is reported to make things work |
7cb3b80e66b8
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32621
diff
changeset
|
279 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." |
32169
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
280 :type '(repeat string) |
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
281 :version "20.8" |
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
282 :group 'SQL) |
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
283 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
284 ;; Customization for Solid |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
285 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
286 (defcustom sql-solid-program "solsql" |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
287 "*Command to start SOLID SQL Editor. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
288 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
289 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
|
290 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
291 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
|
292 :type 'file |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
293 :group 'SQL) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
294 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
295 ;; Customization for SyBase |
24050 | 296 |
297 (defcustom sql-sybase-program "isql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
298 "*Command to start isql by SyBase. |
24050 | 299 |
300 Starts `sql-interactive-mode' after doing some setup. | |
301 | |
302 The program can also specify a TCP connection. See `make-comint'." | |
303 :type 'file | |
304 :group 'SQL) | |
305 | |
32621
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
306 (defcustom sql-sybase-options nil |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
307 "*List of additional options for `sql-sybase-program'. |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
308 Some versions of isql might require the -n option in order to work." |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
309 :type '(repeat string) |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
310 :version "20.8" |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
311 :group 'SQL) |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
312 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
313 ;; Customization for Informix |
24050 | 314 |
315 (defcustom sql-informix-program "dbaccess" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
316 "*Command to start dbaccess by Informix. |
24050 | 317 |
318 Starts `sql-interactive-mode' after doing some setup. | |
319 | |
320 The program can also specify a TCP connection. See `make-comint'." | |
321 :type 'file | |
322 :group 'SQL) | |
323 | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
324 ;; Customization for Ingres |
24050 | 325 |
326 (defcustom sql-ingres-program "sql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
327 "*Command to start sql by Ingres. |
24050 | 328 |
329 Starts `sql-interactive-mode' after doing some setup. | |
330 | |
331 The program can also specify a TCP connection. See `make-comint'." | |
332 :type 'file | |
333 :group 'SQL) | |
334 | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
335 ;; Customization for Microsoft |
24050 | 336 |
337 (defcustom sql-ms-program "isql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
338 "*Command to start isql by Microsoft. |
24050 | 339 |
340 Starts `sql-interactive-mode' after doing some setup. | |
341 | |
342 The program can also specify a TCP connection. See `make-comint'." | |
343 :type 'file | |
344 :group 'SQL) | |
345 | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
346 ;; Customization for Postgres |
24050 | 347 |
348 (defcustom sql-postgres-program "psql" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
349 "Command to start psql by Postgres. |
24050 | 350 |
351 Starts `sql-interactive-mode' after doing some setup. | |
352 | |
353 The program can also specify a TCP connection. See `make-comint'." | |
354 :type 'file | |
355 :group 'SQL) | |
356 | |
34704
7cb3b80e66b8
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32621
diff
changeset
|
357 (defcustom sql-postgres-options '("-P" "pager=off") |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
358 "*List of additional options for `sql-postgres-program'. |
38872 | 359 The default setting includes the -P option which breaks older versions |
360 of the psql client (such as version 6.5.3). The -P option is equivalent | |
361 to the --pset option. If you want the psql to prompt you for a user | |
362 name, add the string \"-u\" to the list of options. If you want to | |
363 provide a user name on the command line (newer versions such as 7.1), | |
364 add your name with a \"-U\" prefix (such as \"-Umark\") to the list." | |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
365 :type '(repeat string) |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
366 :version "20.8" |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
367 :group 'SQL) |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
368 |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
369 ;; Customization for Interbase |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
370 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
371 (defcustom sql-interbase-program "isql" |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
372 "*Command to start isql by Interbase. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
373 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
374 Starts `sql-interactive-mode' after doing some setup. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
375 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
376 The program can also specify a TCP connection. See `make-comint'." |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
377 :type 'file |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
378 :group 'SQL) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
379 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
380 (defcustom sql-interbase-options nil |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
381 "*List of additional options for `sql-interbase-program'." |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
382 :type '(repeat string) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
383 :version "20.8" |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
384 :group 'SQL) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
385 |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
386 ;; Customization for DB2 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
387 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
388 (defcustom sql-db2-program "db2" |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
389 "*Command to start db2 by IBM. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
390 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
391 Starts `sql-interactive-mode' after doing some setup. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
392 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
393 The program can also specify a TCP connection. See `make-comint'." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
394 :type 'file |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
395 :group 'SQL) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
396 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
397 (defcustom sql-db2-options nil |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
398 "*List of additional options for `sql-db2-program'." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
399 :type '(repeat string) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
400 :version "20.8" |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
401 :group 'SQL) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
402 |
24050 | 403 |
404 | |
405 ;;; Variables which do not need customization | |
406 | |
407 (defvar sql-user-history nil | |
408 "History of usernames used.") | |
409 | |
410 (defvar sql-database-history nil | |
411 "History of databases used.") | |
412 | |
413 (defvar sql-server-history nil | |
414 "History of servers used.") | |
415 | |
416 ;; Passwords are not kept in a history. | |
417 | |
418 (defvar sql-buffer nil | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
419 "Current SQLi buffer. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
420 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
421 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
|
422 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
|
423 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
|
424 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
|
425 the local value of `sql-buffer' using \\[sql-set-sqli-buffer].") |
24050 | 426 |
427 (defvar sql-prompt-regexp nil | |
428 "Prompt used to initialize `comint-prompt-regexp'. | |
429 | |
430 You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.") | |
431 | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
432 (defvar sql-prompt-length 0 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
433 "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
|
434 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
435 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
|
436 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
437 (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
|
438 "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
|
439 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
440 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
|
441 |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
442 ;; Keymap for sql-interactive-mode. |
24050 | 443 |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
444 (defvar sql-interactive-mode-map |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
445 (let ((map (make-sparse-keymap))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
446 (if (functionp 'set-keymap-parent) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
447 (set-keymap-parent map comint-mode-map); Emacs |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
448 (set-keymap-parents map (list comint-mode-map))); XEmacs |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
449 (if (functionp 'set-keymap-name) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
450 (set-keymap-name map 'sql-interactive-mode-map)); XEmacs |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
451 (define-key map (kbd "C-j") 'sql-accumulate-and-indent) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
452 (define-key map (kbd "C-c C-w") 'sql-copy-column) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
453 (define-key map (kbd "O") 'sql-magic-go) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
454 (define-key map (kbd "o") 'sql-magic-go) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
455 (define-key map (kbd ";") 'sql-magic-semicolon) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
456 map) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
457 "Mode map used for `sql-interactive-mode'. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
458 Based on `comint-mode-map'.") |
24050 | 459 |
460 ;; Keymap for sql-mode. | |
461 | |
462 (defvar sql-mode-map | |
463 (let ((map (make-sparse-keymap))) | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
464 (define-key map (kbd "C-c C-c") 'sql-send-paragraph) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
465 (define-key map (kbd "C-c C-r") 'sql-send-region) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
466 (define-key map (kbd "C-c C-b") 'sql-send-buffer) |
24050 | 467 map) |
468 "Mode map used for `sql-mode'.") | |
469 | |
470 ;; easy menu for sql-mode. | |
471 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
472 (easy-menu-define |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
473 sql-mode-menu sql-mode-map |
24050 | 474 "Menu for `sql-mode'." |
475 '("SQL" | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
476 ["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
|
477 (get-buffer-process sql-buffer))] |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
478 ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
479 mark-active) |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
480 (mark)); XEmacs |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
481 (buffer-live-p sql-buffer) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
482 (get-buffer-process sql-buffer))] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
483 ["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
|
484 (get-buffer-process sql-buffer))] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
485 ["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
|
486 ["Set SQLi buffer" sql-set-sqli-buffer t] |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
487 ["Pop to SQLi buffer after send" |
24050 | 488 sql-toggle-pop-to-buffer-after-send-region |
489 :style toggle | |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
490 :selected sql-pop-to-buffer-after-send-region] |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
491 ("Highlighting" |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
492 ["ANSI SQL keywords" sql-highlight-ansi-keywords t] |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
493 ["Oracle keywords" sql-highlight-oracle-keywords t] |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
494 ["Postgres keywords" sql-highlight-postgres-keywords t]))) |
24050 | 495 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
496 ;; 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
|
497 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
498 (easy-menu-define |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
499 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
|
500 "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
|
501 '("SQL" |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
502 ["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
|
503 |
24050 | 504 ;; Abbreviations -- if you want more of them, define them in your |
505 ;; ~/.emacs file. Abbrevs have to be enabled in your ~/.emacs, too. | |
506 | |
507 (defvar sql-mode-abbrev-table nil | |
508 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") | |
509 (if sql-mode-abbrev-table | |
510 () | |
511 (let ((wrapper)) | |
512 (define-abbrev-table 'sql-mode-abbrev-table ()) | |
42440
87ae537c4b14
(sql-mode-abbrev-table): Mark all the predefined abbrevs as "system"
Pavel Janík <Pavel@Janik.cz>
parents:
40971
diff
changeset
|
513 (define-abbrev sql-mode-abbrev-table "ins" "insert" nil 0 t) |
87ae537c4b14
(sql-mode-abbrev-table): Mark all the predefined abbrevs as "system"
Pavel Janík <Pavel@Janik.cz>
parents:
40971
diff
changeset
|
514 (define-abbrev sql-mode-abbrev-table "upd" "update" nil 0 t) |
87ae537c4b14
(sql-mode-abbrev-table): Mark all the predefined abbrevs as "system"
Pavel Janík <Pavel@Janik.cz>
parents:
40971
diff
changeset
|
515 (define-abbrev sql-mode-abbrev-table "del" "delete" nil 0 t) |
87ae537c4b14
(sql-mode-abbrev-table): Mark all the predefined abbrevs as "system"
Pavel Janík <Pavel@Janik.cz>
parents:
40971
diff
changeset
|
516 (define-abbrev sql-mode-abbrev-table "sel" "select" nil 0 t))) |
24050 | 517 |
518 ;; Syntax Table | |
519 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
520 (defvar sql-mode-syntax-table |
24050 | 521 (let ((table (make-syntax-table))) |
522 ;; C-style comments /**/ (see elisp manual "Syntax Flags")) | |
523 (modify-syntax-entry ?/ ". 14" table) | |
524 (modify-syntax-entry ?* ". 23" table) | |
525 ;; 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
|
526 (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
|
527 (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
|
528 (modify-syntax-entry ?- ". 12b" table)) |
24050 | 529 ;; newline and formfeed end coments |
530 (modify-syntax-entry ?\n "> b" table) | |
531 (modify-syntax-entry ?\f "> b" table) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
532 ;; single quotes (') quotes delimit strings |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
533 (modify-syntax-entry ?' "\"" table) |
40971
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
534 ;; backslash is no escape character |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
535 (modify-syntax-entry ?\\ "." table) |
24050 | 536 table) |
537 "Syntax table used in `sql-mode' and `sql-interactive-mode'.") | |
538 | |
539 ;; Font lock support | |
540 | |
541 (defvar sql-mode-ansi-font-lock-keywords nil | |
542 "ANSI SQL keywords used by font-lock. | |
543 | |
544 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
545 regular expressions are created during compilation by calling the | |
546 function `regexp-opt'. Therefore, take a look at the source before | |
547 you define your own sql-mode-ansi-font-lock-keywords. You may want to | |
548 add functions and PL/SQL keywords.") | |
549 (if sql-mode-ansi-font-lock-keywords | |
550 () | |
551 (let ((ansi-keywords (eval-when-compile | |
552 (concat "\\b" | |
553 (regexp-opt '( | |
554 "authorization" "avg" "begin" "close" "cobol" "commit" | |
555 "continue" "count" "declare" "double" "end" "escape" | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
556 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
24050 | 557 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
558 "precision" "primary" "procedure" "references" "rollback" | |
559 "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b"))) | |
560 (ansi-reserved-words (eval-when-compile | |
561 (concat "\\b" | |
562 (regexp-opt '( | |
563 "all" "and" "any" "as" "asc" "between" "by" "check" "create" | |
564 "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | |
565 "from" "grant" "group" "having" "in" "insert" "into" "is" | |
566 "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | |
567 "public" "select" "set" "table" "to" "union" "unique" | |
568 "update" "user" "values" "view" "where" "with") t) "\\b"))) | |
569 (ansi-types (eval-when-compile | |
570 (concat "\\b" | |
571 (regexp-opt '( | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
572 ;; ANSI Keywords that look like types |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
573 "character" "cursor" "dec" "int" "real" |
24050 | 574 ;; ANSI Reserved Word that look like types |
575 "char" "integer" "smallint" ) t) "\\b")))) | |
576 (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
|
577 (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
|
578 (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
|
579 (cons ansi-types 'font-lock-type-face))))) |
24050 | 580 |
581 (defvar sql-mode-oracle-font-lock-keywords nil | |
582 "Oracle SQL keywords used by font-lock. | |
583 | |
584 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
585 regular expressions are created during compilation by calling the | |
586 function `regexp-opt'. Therefore, take a look at the source before | |
587 you define your own sql-mode-oracle-font-lock-keywords. You may want | |
588 to add functions and PL/SQL keywords.") | |
589 (if sql-mode-oracle-font-lock-keywords | |
590 () | |
591 (let ((oracle-keywords (eval-when-compile | |
592 (concat "\\b" | |
593 (regexp-opt '( | |
594 "admin" "after" "allocate" "analyze" "archive" "archivelog" "backup" | |
595 "become" "before" "block" "body" "cache" "cancel" "cascade" "change" | |
596 "checkpoint" "compile" "constraint" "constraints" "contents" | |
597 "controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount" | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
598 "dump" "each" "else" "elsif" "enable" "events" "except" "exceptions" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
599 "execute" "exit" "explain" "extent" "externally" "false" "flush" "force" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
600 "freelist" "freelists" "function" "groups" "if" "including" "initrans" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
601 "instance" "layer" "link" "lists" "logfile" "loop" "manage" "manual" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
602 "maxdatafiles" "maxinistances" "maxlogfiles" "maxloghistory" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
603 "maxlogmembers" "maxtrans" "maxvalue" "minextents" "minvalue" "mount" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
604 "new" "next" "noarchivelog" "nocache" "nocycle" "nomaxvalue" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
605 "nominvalue" "none" "noorder" "noresetlogs" "normal" "nosort" "off" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
606 "old" "only" "optimal" "others" "out" "own" "package" "parallel" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
607 "pctincrease" "pctused" "plan" "pragma" "private" "profile" "quota" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
608 "raise" "read" "recover" "referencing" "resetlogs" "restrict_references" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
609 "restricted" "return" "returning" "reuse" "rnds" "rnps" "role" "roles" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
610 "savepoint" "scn" "segment" "sequence" "shared" "snapshot" "sort" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
611 "statement_id" "statistics" "stop" "storage" "subtype" "switch" "system" |
24050 | 612 "tables" "tablespace" "temporary" "thread" "time" "tracing" |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
613 "transaction" "triggers" "true" "truncate" "type" "under" "unlimited" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
614 "until" "use" "using" "when" "while" "wnds" "wnps" "write") t) "\\b"))) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
615 (oracle-warning-words (eval-when-compile |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
616 (concat "\\b" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
617 (regexp-opt '( |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
618 "cursor_already_open" "dup_val_on_index" "exception" "invalid_cursor" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
619 "invalid_number" "login_denied" "no_data_found" "not_logged_on" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
620 "notfound" "others" "pragma" "program_error" "storage_error" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
621 "timeout_on_resource" "too_many_rows" "transaction_backed_out" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
622 "value_error" "zero_divide") t) "\\b"))) |
24050 | 623 (oracle-reserved-words (eval-when-compile |
624 (concat "\\b" | |
625 (regexp-opt '( | |
626 "access" "add" "alter" "audit" "cluster" "column" "comment" "compress" | |
627 "connect" "drop" "else" "exclusive" "file" "grant" | |
628 "identified" "immediate" "increment" "index" "initial" "intersect" | |
629 "level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit" | |
630 "nocompress" "nowait" "number" "offline" "online" "pctfree" "prior" | |
631 "raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum" | |
632 "rows" "session" "share" "size" "start" "successful" "synonym" "sysdate" | |
633 "then" "trigger" "uid" "validate" "whenever") t) "\\b"))) | |
634 (oracle-types (eval-when-compile | |
635 (concat "\\b" | |
636 (regexp-opt '( | |
637 ;; Oracle Keywords that look like types | |
638 ;; Oracle Reserved Words that look like types | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
639 "binary_integer" "blob" "boolean" "constant" "date" "decimal" "rowid" |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
640 "varchar" "varchar2") t) "\\b"))) |
24050 | 641 (oracle-builtin-functions (eval-when-compile |
642 (concat "\\b" | |
643 (regexp-opt '( | |
644 ;; Misc Oracle builtin functions | |
645 "abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat" | |
646 "convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor" | |
647 "glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb" | |
648 "last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower" | |
649 "lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time" | |
650 "next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort" | |
651 "nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad" | |
652 "rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt" | |
653 "stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char" | |
654 "to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte" | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
655 "translate" "trim" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b")))) |
24050 | 656 (setq sql-mode-oracle-font-lock-keywords |
657 (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
|
658 (list (cons oracle-keywords 'font-lock-function-name-face) |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
659 (cons oracle-warning-words 'font-lock-warning-face) |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
660 (cons oracle-reserved-words 'font-lock-keyword-face) |
24050 | 661 ;; XEmacs doesn't have font-lock-builtin-face |
662 (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
|
663 (cons oracle-builtin-functions 'font-lock-preprocessor-face) |
24050 | 664 ;; GNU Emacs 19 doesn't have it either |
665 (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
|
666 (cons oracle-builtin-functions 'font-lock-function-name-face) |
24050 | 667 ;; Emacs |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
668 (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
|
669 (cons oracle-types 'font-lock-type-face)))))) |
24050 | 670 |
671 (defvar sql-mode-postgres-font-lock-keywords nil | |
672 "Postgres SQL keywords used by font-lock. | |
673 | |
674 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
675 regular expressions are created during compilation by calling the | |
676 function `regexp-opt'. Therefore, take a look at the source before | |
677 you define your own sql-mode-postgres-font-lock-keywords.") | |
678 | |
679 (if sql-mode-postgres-font-lock-keywords | |
680 () | |
681 (let ((postgres-reserved-words (eval-when-compile | |
682 (concat "\\b" | |
683 (regexp-opt '( | |
684 "language" | |
685 ) t) "\\b"))) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
686 (postgres-types (eval-when-compile |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
687 (concat "\\b" |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
688 (regexp-opt '( |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
689 "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
690 "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
24050 | 691 "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
692 ) t)"\\b"))) | |
693 (postgres-builtin-functions (eval-when-compile | |
694 (concat "\\b" | |
695 (regexp-opt '( | |
696 ;; Misc Postgres builtin functions | |
697 "abstime" "age" "area" "box" "center" "date_part" "date_trunc" | |
698 "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" | |
699 "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" | |
700 "length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" | |
701 "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" | |
702 "substring" "text" "timespan" "translate" "trim" "upgradepath" | |
703 "upgradepoly" "upper" "varchar" "width" | |
704 ) t) "\\b")))) | |
705 (setq sql-mode-postgres-font-lock-keywords | |
706 (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
|
707 (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
|
708 ;; XEmacs doesn't have 'font-lock-builtin-face |
24050 | 709 (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
|
710 (cons postgres-builtin-functions 'font-lock-preprocessor-face) |
24050 | 711 ;; Emacs |
24058
85622273d1e8
(sql-mode-ansi-font-lock-keywords): Quote font-lock
Karl Heuer <kwzh@gnu.org>
parents:
24050
diff
changeset
|
712 (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
|
713 (cons postgres-types 'font-lock-type-face)))))) |
24050 | 714 |
715 | |
716 (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
717 "SQL keywords used by font-lock. | |
718 | |
719 This variable defaults to `sql-mode-ansi-font-lock-keywords'. This is | |
720 used for the default `font-lock-defaults' value in `sql-mode'. This | |
721 can be changed by some entry functions to provide more hilighting.") | |
722 | |
723 | |
30905
2069c10bf952
(sql-magic-go): Use comint-bol.
Gerd Moellmann <gerd@gnu.org>
parents:
30838
diff
changeset
|
724 |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
725 ;;; Functions to switch highlighting |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
726 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
727 (defun sql-highlight-oracle-keywords () |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
728 "Highlight Oracle keywords. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
729 Basically, this just sets `font-lock-keywords' appropriately." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
730 (interactive) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
731 (setq font-lock-keywords sql-mode-oracle-font-lock-keywords) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
732 (font-lock-fontify-buffer)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
733 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
734 (defun sql-highlight-postgres-keywords () |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
735 "Highlight Postgres keywords. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
736 Basically, this just sets `font-lock-keywords' appropriately." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
737 (interactive) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
738 (setq font-lock-keywords sql-mode-postgres-font-lock-keywords) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
739 (font-lock-fontify-buffer)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
740 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
741 (defun sql-highlight-ansi-keywords () |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
742 "Highlight ANSI SQL keywords. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
743 Basically, this just sets `font-lock-keywords' appropriately." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
744 (interactive) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
745 (setq font-lock-keywords sql-mode-ansi-font-lock-keywords) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
746 (font-lock-fontify-buffer)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
747 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
748 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
749 |
30838
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
750 ;;; Compatibility functions |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
751 |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
752 (if (not (fboundp 'comint-line-beginning-position)) |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
753 ;; comint-line-beginning-position is defined in Emacs 21 |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
754 (defun comint-line-beginning-position () |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
755 "Returns the buffer position of the beginning of the line, after any prompt. |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
756 The prompt is assumed to be any text at the beginning of the line matching |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
757 the regular expression `comint-prompt-regexp', a buffer local variable." |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
758 (save-excursion (comint-bol nil) (point)))) |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
759 |
c9f793802722
Add compatibility definition of comint-line-beginning-position.
Miles Bader <miles@gnu.org>
parents:
30642
diff
changeset
|
760 |
24050 | 761 |
762 ;;; Small functions | |
763 | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
764 (defun sql-magic-go (arg) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
765 "Insert \"o\" and call `comint-send-input'. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
766 `sql-electric-stuff' must be the symbol `go'." |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
767 (interactive "P") |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
768 (self-insert-command (prefix-numeric-value arg)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
769 (if (and (equal sql-electric-stuff 'go) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
770 (save-excursion |
30642
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
771 (comint-bol nil) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
772 (looking-at "go\\b"))) |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
773 (comint-send-input))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
774 |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
775 (defun sql-magic-semicolon (arg) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
776 "Insert semicolon and call `comint-send-input'. |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
777 `sql-electric-stuff' must be the symbol `semicolon'." |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
778 (interactive "P") |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
779 (self-insert-command (prefix-numeric-value arg)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
780 (if (equal sql-electric-stuff 'semicolon) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
781 (comint-send-input))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
782 |
24050 | 783 (defun sql-accumulate-and-indent () |
784 "Continue SQL statement on the next line." | |
785 (interactive) | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
786 (if (fboundp 'comint-accumulate) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
787 (comint-accumulate) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
788 (newline)) |
24050 | 789 (indent-according-to-mode)) |
790 | |
791 ;;;###autoload | |
792 (defun sql-help () | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
793 "Show short help for the SQL modes. |
24050 | 794 |
795 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
|
796 usually named `*SQL*'. The name of the major mode is SQLi. |
24050 | 797 |
798 Use the following commands to start a specific SQL interpreter: | |
799 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
800 PostGres: \\[sql-postgres] |
40432
225bd38b0ce7
(sql-mysql): Doc change by RMS.
Gerd Moellmann <gerd@gnu.org>
parents:
38872
diff
changeset
|
801 MySQL: \\[sql-mysql] |
24268 | 802 |
803 Other non-free SQL implementations are also supported: | |
804 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
805 Solid: \\[sql-solid] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
806 Oracle: \\[sql-oracle] |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
807 Informix: \\[sql-informix] |
24268 | 808 Sybase: \\[sql-sybase] |
809 Ingres: \\[sql-ingres] | |
810 Microsoft: \\[sql-ms] | |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
811 Interbase: \\[sql-interbase] |
24268 | 812 |
813 But we urge you to choose a free implementation instead of these. | |
24050 | 814 |
815 Once you have the SQLi buffer, you can enter SQL statements in the | |
816 buffer. The output generated is appended to the buffer and a new prompt | |
817 is generated. See the In/Out menu in the SQLi buffer for some functions | |
818 that help you navigate through the buffer, the input history, etc. | |
819 | |
820 If you have a really complex SQL statement or if you are writing a | |
821 procedure, you can do this in a separate buffer. Put the new buffer in | |
822 `sql-mode' by calling \\[sql-mode]. The name of this buffer can be | |
823 anything. The name of the major mode is SQL. | |
824 | |
825 In this SQL buffer (SQL mode), you can send the region or the entire | |
826 buffer to the interactive SQL buffer (SQLi mode). The results are | |
827 appended to the SQLi buffer without disturbing your SQL buffer." | |
828 (interactive) | |
829 (describe-function 'sql-help)) | |
830 | |
831 (defun sql-read-passwd (prompt &optional default) | |
832 "Read a password using PROMPT. | |
833 Optional DEFAULT is password to start with. This function calls | |
834 `read-passwd' if it is available. If not, function | |
835 `ange-ftp-read-passwd' is called. This should always be available, | |
836 even in old versions of Emacs." | |
837 (if (fboundp 'read-passwd) | |
838 (read-passwd prompt nil default) | |
839 (unless (fboundp 'ange-ftp-read-passwd) | |
840 (autoload 'ange-ftp-read-passwd "ange-ftp")) | |
841 (ange-ftp-read-passwd prompt default))) | |
842 | |
843 (defun sql-get-login (&rest what) | |
844 "Get username, password and database from the user. | |
845 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
846 The variables `sql-user', `sql-password', `sql-server', and |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
847 `sql-database' can be customized. They are used as the default values. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
848 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
|
849 `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
|
850 in a history. |
24050 | 851 |
852 Parameter WHAT is a list of the arguments passed to this function. | |
853 The function asks for the username if WHAT contains symbol `user', for | |
854 the password if it contains symbol `password', for the server if it | |
855 contains symbol `server', and for the database if it contains symbol | |
856 `database'. | |
857 | |
858 In order to ask the user for username, password and database, call the | |
859 function like this: (sql-get-login 'user 'password 'database)." | |
860 (interactive) | |
861 (if (memq 'user what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
862 (setq sql-user |
24050 | 863 (read-from-minibuffer "User: " sql-user nil nil |
864 sql-user-history))) | |
865 (if (memq 'password what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
866 (setq sql-password |
24050 | 867 (sql-read-passwd "Password: " sql-password))) |
868 (if (memq 'server what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
869 (setq sql-server |
24050 | 870 (read-from-minibuffer "Server: " sql-server nil nil |
871 sql-server-history))) | |
872 (if (memq 'database what) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
873 (setq sql-database |
24050 | 874 (read-from-minibuffer "Database: " sql-database nil nil |
875 sql-database-history)))) | |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
876 |
26576
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
877 (defun sql-find-sqli-buffer () |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
878 "Return the current default SQLi buffer or nil. |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
879 In order to qualify, the SQLi buffer must be alive, |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
880 be in `sql-interactive-mode' and have a process." |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
881 (let ((default-buffer (default-value 'sql-buffer))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
882 (if (and (buffer-live-p default-buffer) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
883 (get-buffer-process default-buffer)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
884 default-buffer |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
885 (save-excursion |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
886 (let ((buflist (buffer-list)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
887 (found)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
888 (while (not (or (null buflist) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
889 found)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
890 (let ((candidate (car buflist))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
891 (set-buffer candidate) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
892 (if (and (equal major-mode 'sql-interactive-mode) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
893 (get-buffer-process candidate)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
894 (setq found candidate)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
895 (setq buflist (cdr buflist)))) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
896 found))))) |
26576
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
897 |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
898 (defun sql-set-sqli-buffer-generally () |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
899 "Set SQLi buffer for all SQL buffers that have none. |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
900 This function checks all SQL buffers for their SQLi buffer. If their |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
901 SQLi buffer is nonexistent or has no process, it is set to the current |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
902 default SQLi buffer. The current default SQLi buffer is determined |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
903 using `sql-find-sqli-buffer'. If `sql-buffer' is set, |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
904 `sql-set-sqli-hook' is run." |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
905 (interactive) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
906 (save-excursion |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
907 (let ((buflist (buffer-list)) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
908 (default-sqli-buffer (sql-find-sqli-buffer))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
909 (setq-default sql-buffer default-sqli-buffer) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
910 (while (not (null buflist)) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
911 (let ((candidate (car buflist))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
912 (set-buffer candidate) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
913 (if (and (equal major-mode 'sql-mode) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
914 (not (buffer-live-p sql-buffer))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
915 (progn |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
916 (setq sql-buffer default-sqli-buffer) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
917 (run-hooks 'sql-set-sqli-hook)))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
918 (setq buflist (cdr buflist)))))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
919 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
920 (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
|
921 "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
|
922 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
923 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
|
924 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
|
925 `sql-set-sqli-hook'. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
926 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
927 If you call it from a SQL buffer, this sets the local copy of |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
928 `sql-buffer'. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
929 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
930 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
|
931 `sql-buffer'." |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
932 (interactive) |
26576
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
933 (let ((default-buffer (sql-find-sqli-buffer))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
934 (if (null default-buffer) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
935 (error "There is no suitable SQLi buffer")) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
936 (let ((new-buffer |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
937 (get-buffer |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
938 (read-buffer "New SQLi buffer: " default-buffer t)))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
939 (if (null (get-buffer-process new-buffer)) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
940 (error "Buffer %s has no process" (buffer-name new-buffer))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
941 (if (null (save-excursion |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
942 (set-buffer new-buffer) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
943 (equal major-mode 'sql-interactive-mode))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
944 (error "Buffer %s is no SQLi buffer" (buffer-name new-buffer))) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
945 (if new-buffer |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
946 (progn |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
947 (setq sql-buffer new-buffer) |
0894b3c8dfd6
(sql-find-sqli-buffer): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
25826
diff
changeset
|
948 (run-hooks 'sql-set-sqli-hook)))))) |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
949 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
950 (defun sql-show-sqli-buffer () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
951 "Show the name of current SQLi buffer. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
952 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
953 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
|
954 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
|
955 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
956 (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
|
957 (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
|
958 (if (null (get-buffer-process sql-buffer)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
959 (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
|
960 (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
|
961 |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
962 (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
|
963 "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
|
964 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
965 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
|
966 `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
|
967 (concat (if (string= "" sql-user) |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
968 (if (string= "" (user-login-name)) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
969 () |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
970 (concat (user-login-name) "/")) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
971 (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
|
972 (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
|
973 (if (string= "" sql-server) |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
974 (system-name) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
975 sql-server) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
976 sql-database))) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
977 |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
978 (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
|
979 "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
|
980 (interactive) |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
981 (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
|
982 |
24050 | 983 (defun sql-copy-column () |
984 "Copy current column to the end of buffer. | |
985 Inserts SELECT or commas if appropriate." | |
986 (interactive) | |
987 (let ((column)) | |
988 (save-excursion | |
989 (setq column (buffer-substring | |
990 (progn (forward-char 1) (backward-sexp 1) (point)) | |
991 (progn (forward-sexp 1) (point)))) | |
992 (goto-char (point-max)) | |
30642
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
993 (let ((bol (comint-line-beginning-position))) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
994 (cond |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
995 ;; if empty command line, insert SELECT |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
996 ((= bol (point)) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
997 (insert "SELECT ")) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
998 ;; else if appending to INTO .* (, SELECT or ORDER BY, insert a comma |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
999 ((save-excursion |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1000 (re-search-backward "\\b\\(\\(into\\s-+\\S-+\\s-+(\\)\\|select\\|order by\\) .+" |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1001 bol t)) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1002 (insert ", ")) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1003 ;; else insert a space |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1004 (t |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1005 (if (eq (preceding-char) ? ) |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1006 nil |
ae938744b6b1
(sql-magic-go): Use comint-bol instead of explicitly matching
Miles Bader <miles@gnu.org>
parents:
30513
diff
changeset
|
1007 (insert " "))))) |
24050 | 1008 ;; in any case, insert the column |
1009 (insert column) | |
1010 (message "%s" column)))) | |
1011 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1012 ;; On NT, SQL*Plus for Oracle turns on full buffering for stdout if it |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1013 ;; is not attached to a character device; therefore placeholder |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1014 ;; replacement by SQL*Plus is fully buffered. The workaround lets |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1015 ;; Emacs query for the placeholders. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1016 |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1017 (defvar sql-placeholder-history nil |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1018 "History of placeholder values used.") |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1019 |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1020 (defun sql-query-placeholders-and-send (proc string) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1021 "Send to PROC input STRING, maybe replacing placeholders. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1022 Placeholders are words starting with and ampersand like &this. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1023 This function is used for `comint-input-sender' if using `sql-oracle' on NT." |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1024 (while (string-match "&\\(\\sw+\\)" string) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1025 (setq string (replace-match |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1026 (read-from-minibuffer |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1027 (format "Enter value for %s: " (match-string 1 string)) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1028 nil nil nil sql-placeholder-history) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1029 t t string))) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1030 (comint-send-string proc string) |
42694
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1031 (if comint-input-sender-no-newline |
42799
2f56e7fc793a
(sql-escape-newlines-and-send)
Richard M. Stallman <rms@gnu.org>
parents:
42694
diff
changeset
|
1032 (if (not (string-equal string "")) |
42694
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1033 (process-send-eof)) |
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1034 (comint-send-string proc "\n"))) |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1035 |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1036 ;; Using DB2 interactively, newlines must be escaped with " \". |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1037 ;; The space before the backslash is relevant. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1038 (defun sql-escape-newlines-and-send (proc string) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1039 "Send to PROC input STRING, escaping newlines if necessary. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1040 Every newline in STRING will be preceded with a space and a backslash." |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1041 (let ((result "") (start 0) mb me) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1042 (while (string-match "\n" string start) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1043 (setq mb (match-beginning 0) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1044 me (match-end 0)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1045 (if (and (> mb 1) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1046 (string-equal " \\" (substring string (- mb 2) mb))) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1047 (setq result (concat result (substring string start me))) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1048 (setq result (concat result (substring string start mb) " \\\n"))) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1049 (setq start me)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1050 (setq result (concat result (substring string start))) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1051 (comint-send-string proc result) |
42694
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1052 (if comint-input-sender-no-newline |
42799
2f56e7fc793a
(sql-escape-newlines-and-send)
Richard M. Stallman <rms@gnu.org>
parents:
42694
diff
changeset
|
1053 (if (not (string-equal string "")) |
42694
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1054 (process-send-eof)) |
4664fcfde396
(sql-query-placeholders-and-send): Handle
Richard M. Stallman <rms@gnu.org>
parents:
42440
diff
changeset
|
1055 (comint-send-string proc "\n")))) |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1056 |
24050 | 1057 |
1058 | |
1059 ;;; Sending the region to the SQLi buffer. | |
1060 | |
1061 (defun sql-send-region (start end) | |
1062 "Send a region to the SQL process." | |
1063 (interactive "r") | |
1064 (if (buffer-live-p sql-buffer) | |
1065 (save-excursion | |
1066 (comint-send-region sql-buffer start end) | |
1067 (if (string-match "\n$" (buffer-substring start end)) | |
1068 () | |
1069 (comint-send-string sql-buffer "\n")) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1070 (message "Sent string to buffer %s." (buffer-name sql-buffer)) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1071 (if sql-pop-to-buffer-after-send-region |
24050 | 1072 (pop-to-buffer sql-buffer) |
1073 (display-buffer sql-buffer))) | |
1074 (message "No SQL process started."))) | |
1075 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1076 (defun sql-send-paragraph () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1077 "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
|
1078 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1079 (let ((start (save-excursion |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1080 (backward-paragraph) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1081 (point))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1082 (end (save-excursion |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1083 (forward-paragraph) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1084 (point)))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1085 (sql-send-region start end))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1086 |
24050 | 1087 (defun sql-send-buffer () |
1088 "Send the buffer contents to the SQL process." | |
1089 (interactive) | |
1090 (sql-send-region (point-min) (point-max))) | |
1091 | |
1092 (defun sql-toggle-pop-to-buffer-after-send-region (&optional value) | |
1093 "Toggle `sql-pop-to-buffer-after-send-region'. | |
1094 | |
1095 If given the optional parameter VALUE, sets | |
1096 sql-toggle-pop-to-buffer-after-send-region to VALUE." | |
1097 (interactive "P") | |
1098 (if value | |
1099 (setq sql-pop-to-buffer-after-send-region value) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1100 (setq sql-pop-to-buffer-after-send-region |
24050 | 1101 (null sql-pop-to-buffer-after-send-region )))) |
1102 | |
1103 | |
1104 | |
1105 ;;; SQL mode -- uses SQL interactive mode | |
1106 | |
1107 ;;;###autoload | |
1108 (defun sql-mode () | |
1109 "Major mode to edit SQL. | |
1110 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1111 You can send SQL statements to the SQLi buffer using |
24050 | 1112 \\[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
|
1113 See `sql-help' on how to create SQLi buffers. |
24050 | 1114 |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1115 \\{sql-mode-map} |
24050 | 1116 Customization: Entry to this mode runs the `sql-mode-hook'. |
1117 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 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
|
1123 value of `sql-buffer' using \\[sql-set-sqli-buffer]. |
24050 | 1124 |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1125 For information on how to create multiple SQLi buffers, see |
40971
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1126 `sql-interactive-mode'. |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1127 |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1128 Note that SQL doesn't have an escape character unless you specify |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1129 one. If you specify backslash as escape character in SQL, |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1130 you must tell Emacs. Here's how to do that in your `~/.emacs' file: |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1131 |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1132 \(add-hook 'sql-mode-hook |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1133 (lambda () |
fa679d186a7d
(sql-mode): Doc change.
Richard M. Stallman <rms@gnu.org>
parents:
40432
diff
changeset
|
1134 (modify-syntax-entry ?\\\\ \".\" sql-mode-syntax-table)))" |
24050 | 1135 (interactive) |
1136 (kill-all-local-variables) | |
1137 (setq major-mode 'sql-mode) | |
1138 (setq mode-name "SQL") | |
1139 (use-local-map sql-mode-map) | |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
1140 (if sql-mode-menu |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
1141 (easy-menu-add sql-mode-menu)); XEmacs |
24050 | 1142 (set-syntax-table sql-mode-syntax-table) |
1143 (make-local-variable 'font-lock-defaults) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1144 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1145 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1146 ;; will have just one quote. Therefore syntactic hilighting is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1147 ;; disabled for interactive buffers. `_' and `.' are considered part |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1148 ;; of words. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1149 (setq font-lock-defaults '(sql-mode-font-lock-keywords |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1150 nil t ((?_ . "w") (?. . "w")))) |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1151 (make-local-variable 'comment-start) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1152 (setq comment-start "--") |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1153 ;; Make each buffer in sql-mode remember the "current" SQLi buffer. |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1154 (make-local-variable 'sql-buffer) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1155 ;; Add imenu support for sql-mode. Note that imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1156 ;; is buffer-local, so we don't need a local-variable for it. SQL is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1157 ;; case-insensitive, that's why we have to set imenu-case-fold-search. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1158 ;; imenu-syntax-alist makes sure that `_' is considered part of object |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1159 ;; names. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1160 (setq imenu-generic-expression sql-imenu-generic-expression |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1161 imenu-case-fold-search t |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1162 imenu-syntax-alist '(("_" . "w"))) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1163 ;; 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
|
1164 ;; lines. |
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1165 (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
|
1166 (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
|
1167 (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
|
1168 paragraph-start "[\n\f]") |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1169 ;; Abbrevs |
24050 | 1170 (setq local-abbrev-table sql-mode-abbrev-table) |
1171 (setq abbrev-all-caps 1) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1172 ;; Run hook |
24050 | 1173 (run-hooks 'sql-mode-hook)) |
1174 | |
1175 | |
1176 | |
1177 ;;; SQL interactive mode | |
1178 | |
1179 (put 'sql-interactive-mode 'mode-class 'special) | |
1180 | |
1181 (defun sql-interactive-mode () | |
1182 "Major mode to use a SQL interpreter interactively. | |
1183 | |
1184 Do not call this function by yourself. The environment must be | |
1185 initialized by an entry function specific for the SQL interpreter. See | |
1186 `sql-help' for a list of available entry functions. | |
1187 | |
1188 \\[comint-send-input] after the end of the process' output sends the | |
1189 text from the end of process to the end of the current line. | |
1190 \\[comint-send-input] before end of process output copies the current | |
1191 line minus the prompt to the end of the buffer and sends it. | |
1192 \\[comint-copy-old-input] just copies the current line. | |
1193 Use \\[sql-accumulate-and-indent] to enter multi-line statements. | |
1194 | |
1195 If you want to make multiple SQL buffers, rename the `*SQL*' buffer | |
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 their creation. See `sql-mode' for details. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1201 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1202 Sample session using two connections: |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1203 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1204 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
|
1205 2. Rename buffer \"*SQL*\" to \"*Connection 1*\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1206 3. Create a SQL buffer \"test1.sql\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1207 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
|
1208 5. Rename buffer \"*SQL*\" to \"*Connection 2*\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1209 6. Create a SQL buffer \"test2.sql\". |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1210 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1211 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
|
1212 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
|
1213 will send the region to buffer \"*Connection 2*\". |
24050 | 1214 |
1215 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
|
1216 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
|
1217 the signals are not supported. |
24050 | 1218 |
1219 \\{sql-interactive-mode-map} | |
1220 Customization: Entry to this mode runs the hooks on `comint-mode-hook' | |
1221 and `sql-interactive-mode-hook' (in that order). Before each input, the | |
1222 hooks on `comint-input-filter-functions' are run. After each SQL | |
1223 interpreter output, the hooks on `comint-output-filter-functions' are | |
1224 run. | |
1225 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1226 Variable `sql-input-ring-file-name' controls the initialisation of the |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1227 input ring history. |
24050 | 1228 |
1229 Variables `comint-output-filter-functions', a hook, and | |
1230 `comint-scroll-to-bottom-on-input' and | |
1231 `comint-scroll-to-bottom-on-output' control whether input and output | |
1232 cause the window to scroll to the end of the buffer. | |
1233 | |
1234 If you want to make SQL buffers limited in length, add the function | |
1235 `comint-truncate-buffer' to `comint-output-filter-functions'. | |
1236 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1237 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
|
1238 certain length. |
24050 | 1239 |
1240 \(add-hook 'sql-interactive-mode-hook | |
1241 \(function (lambda () | |
1242 \(setq comint-output-filter-functions 'comint-truncate-buffer)))) | |
1243 | |
1244 Here is another example. It will always put point back to the statement | |
1245 you entered, right above the output it created. | |
1246 | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1247 \(setq comint-output-filter-functions |
24050 | 1248 \(function (lambda (STR) (comint-show-output))))" |
1249 (comint-mode) | |
1250 (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
|
1251 (setq left-margin sql-prompt-length) |
24050 | 1252 (setq major-mode 'sql-interactive-mode) |
1253 (setq mode-name "SQLi") | |
1254 (use-local-map sql-interactive-mode-map) | |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
1255 (if sql-interactive-mode-menu |
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
1256 (easy-menu-add sql-interactive-mode-menu)); XEmacs |
24050 | 1257 (set-syntax-table sql-mode-syntax-table) |
1258 (make-local-variable 'font-lock-defaults) | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1259 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1260 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1261 ;; will have just one quote. Therefore syntactic hilighting is |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1262 ;; disabled for interactive buffers. `_' and `.' are considered part |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1263 ;; of words. |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1264 (setq font-lock-defaults '(sql-mode-font-lock-keywords |
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1265 t t ((?_ . "w") (?. . "w")))) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1266 ;; 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
|
1267 (make-local-variable 'comment-start) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1268 (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
|
1269 ;; 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
|
1270 ;; by default. |
24050 | 1271 (setq local-abbrev-table sql-mode-abbrev-table) |
1272 (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
|
1273 ;; Exiting the process will call sql-stop. |
24050 | 1274 (set-process-sentinel (get-buffer-process sql-buffer) 'sql-stop) |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1275 ;; People wanting a different history file for each |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1276 ;; buffer/process/client/whatever can change separator and file-name |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1277 ;; on the sql-interactive-mode-hook. |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1278 (setq comint-input-ring-separator sql-input-ring-separator |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1279 comint-input-ring-file-name sql-input-ring-file-name) |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1280 ;; 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
|
1281 (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
|
1282 (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
|
1283 ;; User stuff. |
24050 | 1284 (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
|
1285 ;; Calling the hook before calling comint-read-input-ring allows users |
24050 | 1286 ;; to set comint-input-ring-file-name in sql-interactive-mode-hook. |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1287 (comint-read-input-ring t)) |
24050 | 1288 |
1289 (defun sql-stop (process event) | |
1290 "Called when the SQL process is stopped. | |
1291 | |
24353
1ae2a12a85ee
(sql-set-sqli-hook): A hook run when sql-buffer is
Richard M. Stallman <rms@gnu.org>
parents:
24310
diff
changeset
|
1292 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
|
1293 `comint-write-input-ring' and inserts a short message in the SQL buffer. |
24050 | 1294 |
1295 This function is a sentinel watching the SQL interpreter process. | |
1296 Sentinels will always get the two parameters PROCESS and EVENT." | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1297 (comint-write-input-ring) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1298 (if (and (eq (current-buffer) sql-buffer) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1299 (not buffer-read-only)) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1300 (insert (format "\nProcess %s %s\n" process event)) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1301 (message "Process %s %s" process event))) |
24050 | 1302 |
1303 | |
1304 | |
1305 ;;; Entry functions for different SQL interpreters. | |
1306 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1307 ;;;###autoload |
24050 | 1308 (defun sql-oracle () |
1309 "Run sqlplus by Oracle as an inferior process. | |
1310 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1311 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1312 If buffer exists and a process is running, just switch to buffer |
1313 `*SQL*'. | |
1314 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1315 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
|
1316 the variables `sql-user', `sql-password', and `sql-database' as |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1317 defaults, if set. Additional command line parameters can be stored in |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1318 the list `sql-oracle-options'. |
24050 | 1319 |
1320 The buffer is put in sql-interactive-mode, giving commands for sending | |
1321 input. See `sql-interactive-mode'. | |
1322 | |
1323 To specify a coding system for converting non-ASCII characters | |
1324 in the input and output to the process, use \\[universal-coding-system-argument] | |
1325 before \\[sql-oracle]. You can also specify this with \\[set-buffer-process-coding-system] | |
1326 in the SQL buffer, after you start the process. | |
1327 The default comes from `process-coding-system-alist' and | |
1328 `default-process-coding-system'. | |
1329 | |
1330 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1331 (interactive) | |
1332 (if (comint-check-proc "*SQL*") | |
1333 (pop-to-buffer "*SQL*") | |
1334 (sql-get-login 'user 'password 'database) | |
1335 (message "Login...") | |
1336 ;; Produce user/password@database construct. Password without user | |
1337 ;; is meaningless; database without user/password is meaningless, | |
1338 ;; because "@param" will ask sqlplus to interpret the script | |
1339 ;; "param". | |
1340 (let ((parameter nil)) | |
1341 (if (not (string= "" sql-user)) | |
1342 (if (not (string= "" sql-password)) | |
1343 (setq parameter (concat sql-user "/" sql-password)) | |
1344 (setq parameter sql-user))) | |
1345 (if (and parameter (not (string= "" sql-database))) | |
1346 (setq parameter (concat parameter "@" sql-database))) | |
1347 (if parameter | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1348 (setq parameter (nconc (list parameter) sql-oracle-options)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1349 (setq parameter sql-oracle-options)) |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1350 (if parameter |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1351 (set-buffer (apply 'make-comint "SQL" sql-oracle-program nil |
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1352 parameter)) |
24050 | 1353 (set-buffer (make-comint "SQL" sql-oracle-program nil)))) |
1354 (setq sql-prompt-regexp "^SQL> ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1355 (setq sql-prompt-length 5) |
24050 | 1356 (setq sql-buffer (current-buffer)) |
1357 ;; set sql-mode-font-lock-keywords to something different before | |
1358 ;; calling sql-interactive-mode. | |
1359 (setq sql-mode-font-lock-keywords sql-mode-oracle-font-lock-keywords) | |
1360 (sql-interactive-mode) | |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1361 ;; If running on NT, make sure we do placeholder replacement |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1362 ;; ourselves. This must come after sql-interactive-mode because all |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1363 ;; local variables will be killed, there. |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1364 (if (eq window-system 'w32) |
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1365 (setq comint-input-sender 'sql-query-placeholders-and-send)) |
24050 | 1366 (message "Login...done") |
1367 (pop-to-buffer sql-buffer))) | |
1368 | |
1369 | |
1370 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1371 ;;;###autoload |
24050 | 1372 (defun sql-sybase () |
1373 "Run isql by SyBase as an inferior process. | |
1374 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1375 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1376 If buffer exists and a process is running, just switch to buffer |
1377 `*SQL*'. | |
1378 | |
1379 Interpreter used comes from variable `sql-sybase-program'. Login uses | |
32621
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
1380 the variables `sql-server', `sql-user', `sql-password', and |
36523
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1381 `sql-database' as defaults, if set. Additional command line parameters |
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1382 can be stored in the list `sql-sybase-options'. |
24050 | 1383 |
1384 The buffer is put in sql-interactive-mode, giving commands for sending | |
1385 input. See `sql-interactive-mode'. | |
1386 | |
1387 To specify a coding system for converting non-ASCII characters | |
1388 in the input and output to the process, use \\[universal-coding-system-argument] | |
1389 before \\[sql-sybase]. You can also specify this with \\[set-buffer-process-coding-system] | |
1390 in the SQL buffer, after you start the process. | |
1391 The default comes from `process-coding-system-alist' and | |
1392 `default-process-coding-system'. | |
1393 | |
1394 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1395 (interactive) | |
1396 (if (comint-check-proc "*SQL*") | |
1397 (pop-to-buffer "*SQL*") | |
36523
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1398 (sql-get-login 'server 'user 'password 'database) |
24050 | 1399 (message "Login...") |
1400 ;; Put all parameters to the program (if defined) in a list and call | |
1401 ;; make-comint. | |
32621
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
1402 (let ((params sql-sybase-options)) |
25381
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1403 (if (not (string= "" sql-server)) |
970b18c6803f
(sql-sybase): use sql-server instead of sql-database.
Alex Schroeder <alex@gnu.org>
parents:
25183
diff
changeset
|
1404 (setq params (append (list "-S" sql-server) params))) |
32621
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
1405 (if (not (string= "" sql-database)) |
50c28d51e0f2
(sql-sybase-options): New option.
Gerd Moellmann <gerd@gnu.org>
parents:
32169
diff
changeset
|
1406 (setq params (append (list "-D" sql-database) params))) |
24050 | 1407 (if (not (string= "" sql-password)) |
1408 (setq params (append (list "-P" sql-password) params))) | |
1409 (if (not (string= "" sql-user)) | |
1410 (setq params (append (list "-U" sql-user) params))) | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1411 (set-buffer (apply 'make-comint "SQL" sql-sybase-program |
24050 | 1412 nil params))) |
1413 (setq sql-prompt-regexp "^SQL> ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1414 (setq sql-prompt-length 5) |
24050 | 1415 (setq sql-buffer (current-buffer)) |
1416 (sql-interactive-mode) | |
1417 (message "Login...done") | |
1418 (pop-to-buffer sql-buffer))) | |
1419 | |
1420 | |
1421 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1422 ;;;###autoload |
24050 | 1423 (defun sql-informix () |
1424 "Run dbaccess by Informix as an inferior process. | |
1425 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1426 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1427 If buffer exists and a process is running, just switch to buffer |
1428 `*SQL*'. | |
1429 | |
1430 Interpreter used comes from variable `sql-informix-program'. Login uses | |
1431 the variable `sql-database' as default, if set. | |
1432 | |
1433 The buffer is put in sql-interactive-mode, giving commands for sending | |
1434 input. See `sql-interactive-mode'. | |
1435 | |
1436 To specify a coding system for converting non-ASCII characters | |
1437 in the input and output to the process, use \\[universal-coding-system-argument] | |
1438 before \\[sql-informix]. You can also specify this with \\[set-buffer-process-coding-system] | |
1439 in the SQL buffer, after you start the process. | |
1440 The default comes from `process-coding-system-alist' and | |
1441 `default-process-coding-system'. | |
1442 | |
1443 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1444 (interactive) | |
1445 (if (comint-check-proc "*SQL*") | |
1446 (pop-to-buffer "*SQL*") | |
1447 (sql-get-login 'database) | |
1448 (message "Login...") | |
1449 ;; username and password are ignored. | |
1450 (if (string= "" sql-database) | |
1451 (set-buffer (make-comint "SQL" sql-informix-program nil)) | |
29937
693c2c631d72
(sql-interactive-mode-map): Use `kbd' in calls to
Gerd Moellmann <gerd@gnu.org>
parents:
26576
diff
changeset
|
1452 (set-buffer (make-comint "SQL" sql-informix-program nil sql-database "-"))) |
24050 | 1453 (setq sql-prompt-regexp "^SQL> ") |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1454 (setq sql-prompt-length 5) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1455 (setq sql-buffer (current-buffer)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1456 (sql-interactive-mode) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1457 (message "Login...done") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1458 (pop-to-buffer sql-buffer))) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1459 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1460 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1461 |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1462 ;;;###autoload |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1463 (defun sql-mysql () |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1464 "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
|
1465 |
40432
225bd38b0ce7
(sql-mysql): Doc change by RMS.
Gerd Moellmann <gerd@gnu.org>
parents:
38872
diff
changeset
|
1466 Mysql versions 3.23 and up are free software. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1467 |
24268 | 1468 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
|
1469 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
|
1470 `*SQL*'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1471 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1472 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
|
1473 the variables `sql-user', `sql-password', `sql-database', and |
36523
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1474 `sql-server' as defaults, if set. Additional command line parameters |
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1475 can be stored in the list `sql-mysql-options'. |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1476 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1477 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
|
1478 input. See `sql-interactive-mode'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1479 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1480 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
|
1481 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
|
1482 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
|
1483 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
|
1484 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
|
1485 `default-process-coding-system'. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1486 |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1487 \(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
|
1488 (interactive) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1489 (if (comint-check-proc "*SQL*") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1490 (pop-to-buffer "*SQL*") |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1491 (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
|
1492 (message "Login...") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1493 ;; 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
|
1494 ;; make-comint. |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1495 (let ((params)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1496 (if (not (string= "" sql-database)) |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1497 (setq params (append (list sql-database) params))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1498 (if (not (string= "" sql-server)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1499 (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
|
1500 (if (not (string= "" sql-password)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1501 (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
|
1502 (if (not (string= "" sql-user)) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1503 (setq params (append (list (concat "--user=" sql-user)) params))) |
32169
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
1504 (if (not (null sql-mysql-options)) |
5aa8b2b669b7
(sql-mysql-options): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31392
diff
changeset
|
1505 (setq params (append sql-mysql-options params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1506 (set-buffer (apply 'make-comint "SQL" sql-mysql-program |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1507 nil params))) |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1508 (setq sql-prompt-regexp "^mysql>") |
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1509 (setq sql-prompt-length 6) |
24050 | 1510 (setq sql-buffer (current-buffer)) |
1511 (sql-interactive-mode) | |
1512 (message "Login...done") | |
1513 (pop-to-buffer sql-buffer))) | |
1514 | |
1515 | |
1516 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1517 ;;;###autoload |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1518 (defun sql-solid () |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1519 "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
|
1520 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1521 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
|
1522 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
|
1523 `*SQL*'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1524 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1525 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
|
1526 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
|
1527 defaults, if set. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1528 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1529 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
|
1530 input. See `sql-interactive-mode'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1531 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1532 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
|
1533 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
|
1534 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
|
1535 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
|
1536 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
|
1537 `default-process-coding-system'. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1538 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1539 \(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
|
1540 (interactive) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1541 (if (comint-check-proc "*SQL*") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1542 (pop-to-buffer "*SQL*") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1543 (sql-get-login 'user 'password 'server) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1544 (message "Login...") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1545 ;; 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
|
1546 ;; make-comint. |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1547 (let ((params)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1548 ;; 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
|
1549 (if (not (or (string= "" sql-user) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1550 (string= "" sql-password))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1551 (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
|
1552 (if (not (string= "" sql-server)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1553 (setq params (append (list sql-server) params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1554 (set-buffer (apply 'make-comint "SQL" sql-solid-program |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1555 nil params))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1556 (setq sql-prompt-regexp "^") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1557 (setq sql-prompt-length 0) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1558 (setq sql-buffer (current-buffer)) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1559 (sql-interactive-mode) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1560 (message "Login...done") |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1561 (pop-to-buffer sql-buffer))) |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1562 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1563 |
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1564 |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1565 ;;;###autoload |
24050 | 1566 (defun sql-ingres () |
1567 "Run sql by Ingres as an inferior process. | |
1568 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1569 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1570 If buffer exists and a process is running, just switch to buffer |
1571 `*SQL*'. | |
1572 | |
1573 Interpreter used comes from variable `sql-ingres-program'. Login uses | |
1574 the variable `sql-database' as default, if set. | |
1575 | |
1576 The buffer is put in sql-interactive-mode, giving commands for sending | |
1577 input. See `sql-interactive-mode'. | |
1578 | |
1579 To specify a coding system for converting non-ASCII characters | |
1580 in the input and output to the process, use \\[universal-coding-system-argument] | |
1581 before \\[sql-ingres]. You can also specify this with \\[set-buffer-process-coding-system] | |
1582 in the SQL buffer, after you start the process. | |
1583 The default comes from `process-coding-system-alist' and | |
1584 `default-process-coding-system'. | |
1585 | |
1586 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1587 (interactive) | |
1588 (if (comint-check-proc "*SQL*") | |
1589 (pop-to-buffer "*SQL*") | |
1590 (sql-get-login 'database) | |
1591 (message "Login...") | |
1592 ;; username and password are ignored. | |
1593 (if (string= "" sql-database) | |
1594 (set-buffer (make-comint "SQL" sql-ingres-program nil)) | |
1595 (set-buffer (make-comint "SQL" sql-ingres-program nil sql-database))) | |
1596 (setq sql-prompt-regexp "^\* ") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1597 (setq sql-prompt-length 2) |
24050 | 1598 (setq sql-buffer (current-buffer)) |
1599 (sql-interactive-mode) | |
1600 (message "Login...done") | |
1601 (pop-to-buffer sql-buffer))) | |
1602 | |
1603 | |
1604 | |
30513
12162d90d9e4
(sql-ms): Added autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
29937
diff
changeset
|
1605 ;;;###autoload |
24050 | 1606 (defun sql-ms () |
1607 "Run isql by Microsoft as an inferior process. | |
1608 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1609 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1610 If buffer exists and a process is running, just switch to buffer |
1611 `*SQL*'. | |
1612 | |
1613 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
|
1614 variables `sql-user', `sql-password', `sql-database', and `sql-server' |
24050 | 1615 as defaults, if set. |
1616 | |
1617 The buffer is put in sql-interactive-mode, giving commands for sending | |
1618 input. See `sql-interactive-mode'. | |
1619 | |
1620 To specify a coding system for converting non-ASCII characters | |
1621 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
|
1622 before \\[sql-ms]. You can also specify this with \\[set-buffer-process-coding-system] |
24050 | 1623 in the SQL buffer, after you start the process. |
1624 The default comes from `process-coding-system-alist' and | |
1625 `default-process-coding-system'. | |
1626 | |
1627 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1628 (interactive) | |
1629 (if (comint-check-proc "*SQL*") | |
1630 (pop-to-buffer "*SQL*") | |
1631 (sql-get-login 'user 'password 'database 'server) | |
1632 (message "Login...") | |
1633 ;; Put all parameters to the program (if defined) in a list and call | |
1634 ;; make-comint. | |
1635 (let ((params '("-w 300"))) | |
1636 (if (not (string= "" sql-server)) | |
1637 (setq params (append (list "-S" sql-server) params))) | |
1638 (if (not (string= "" sql-database)) | |
1639 (setq params (append (list "-d" sql-database) params))) | |
1640 (if (not (string= "" sql-user)) | |
1641 (setq params (append (list "-U" sql-user) params))) | |
1642 (if (not (string= "" sql-password)) | |
1643 (setq params (append (list "-P" sql-password) params)) | |
1644 ;; If -P is passed to ISQL as the last argument without a password, | |
1645 ;; it's considered null. | |
1646 (setq params (append params (list "-P")))) | |
1647 (set-buffer (apply 'make-comint "SQL" sql-ms-program | |
1648 nil params))) | |
1649 (setq sql-prompt-regexp "^[0-9]*>") | |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1650 (setq sql-prompt-length 5) |
24050 | 1651 (setq sql-buffer (current-buffer)) |
1652 (sql-interactive-mode) | |
1653 (message "Login...done") | |
1654 (pop-to-buffer sql-buffer))) | |
1655 | |
1656 | |
1657 | |
1658 ;;;###autoload | |
1659 (defun sql-postgres () | |
1660 "Run psql by Postgres as an inferior process. | |
1661 | |
24310
e76bade08723
Added keywords from `finder-by-keyword'.
Richard M. Stallman <rms@gnu.org>
parents:
24268
diff
changeset
|
1662 If buffer `*SQL*' exists but no process is running, make a new process. |
24050 | 1663 If buffer exists and a process is running, just switch to buffer |
1664 `*SQL*'. | |
1665 | |
1666 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
|
1667 the variables `sql-database' and `sql-server' as default, if set. |
36523
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1668 Additional command line parameters can be stored in the list |
e72a04113eac
(sql-sybase): Fix typo (was: query user about server two
Gerd Moellmann <gerd@gnu.org>
parents:
34704
diff
changeset
|
1669 `sql-postgres-options'. |
24050 | 1670 |
1671 The buffer is put in sql-interactive-mode, giving commands for sending | |
1672 input. See `sql-interactive-mode'. | |
1673 | |
1674 To specify a coding system for converting non-ASCII characters | |
1675 in the input and output to the process, use \\[universal-coding-system-argument] | |
1676 before \\[sql-postgres]. You can also specify this with \\[set-buffer-process-coding-system] | |
1677 in the SQL buffer, after you start the process. | |
1678 The default comes from `process-coding-system-alist' and | |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1679 `default-process-coding-system'. If your output lines end with ^M, |
24050 | 1680 your might try undecided-dos as a coding system. If this doesn't help, |
1681 Try to set `comint-output-filter-functions' like this: | |
1682 | |
1683 \(setq comint-output-filter-functions (append comint-output-filter-functions | |
1684 '(comint-strip-ctrl-m))) | |
1685 | |
1686 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | |
1687 (interactive) | |
1688 (if (comint-check-proc "*SQL*") | |
1689 (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
|
1690 (sql-get-login 'database 'server) |
24050 | 1691 (message "Login...") |
38872 | 1692 ;; username and password are ignored. Mark Stosberg suggest to add |
1693 ;; the database at the end. Jason Beegan suggest using --pset and | |
1694 ;; pager=off instead of \\o|cat. The later was the solution by | |
1695 ;; Gregor Zych. Jason's suggestion is the default value for | |
1696 ;; sql-postgres-options. | |
31392
1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
Gerd Moellmann <gerd@gnu.org>
parents:
30905
diff
changeset
|
1697 (let ((params sql-postgres-options)) |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1698 (if (not (string= "" sql-database)) |
38872 | 1699 (setq params (append params (list sql-database)))) |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1700 (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
|
1701 (setq params (append (list "-h" sql-server) params))) |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1702 (set-buffer (apply 'make-comint "SQL" sql-postgres-program |
24354
6a438ef0b573
Set version to 1.4.1. Changed mail address to
Richard M. Stallman <rms@gnu.org>
parents:
24353
diff
changeset
|
1703 nil params))) |
24050 | 1704 (setq sql-prompt-regexp "^.*> *") |
24267
f40837b25999
Changed version to 1.2.1.
Richard M. Stallman <rms@gnu.org>
parents:
24058
diff
changeset
|
1705 (setq sql-prompt-length 5) |
24050 | 1706 ;; This is a lousy hack to prevent psql from truncating it's output |
25826
e55139b50cb6
(sql-imenu-generic-expression): new, used to set
Alex Schroeder <alex@gnu.org>
parents:
25381
diff
changeset
|
1707 ;; and giving stupid warnings. If s.o. knows a way to prevent psql |
24050 | 1708 ;; from acting this way, then I would be very thankful to |
1709 ;; incorporate this (Gregor Zych <zych@pool.informatik.rwth-aachen.de>) | |
30905
2069c10bf952
(sql-magic-go): Use comint-bol.
Gerd Moellmann <gerd@gnu.org>
parents:
30838
diff
changeset
|
1710 ;; (comint-send-string "*SQL*" "\\o \| cat\n") |
24050 | 1711 (setq sql-mode-font-lock-keywords sql-mode-postgres-font-lock-keywords) |
1712 (setq sql-buffer (current-buffer)) | |
1713 (sql-interactive-mode) | |
1714 (message "Login...done") | |
1715 (pop-to-buffer sql-buffer))) | |
1716 | |
36571
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1717 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1718 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1719 ;;;###autoload |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1720 (defun sql-interbase () |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1721 "Run isql by Interbase as an inferior process. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1722 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1723 If buffer `*SQL*' exists but no process is running, make a new process. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1724 If buffer exists and a process is running, just switch to buffer |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1725 `*SQL*'. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1726 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1727 Interpreter used comes from variable `sql-interbase-program'. Login |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1728 uses the variables `sql-user', `sql-password', and `sql-database' as |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1729 defaults, if set. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1730 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1731 The buffer is put in sql-interactive-mode, giving commands for sending |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1732 input. See `sql-interactive-mode'. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1733 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1734 To specify a coding system for converting non-ASCII characters |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1735 in the input and output to the process, use \\[universal-coding-system-argument] |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1736 before \\[sql-interbase]. You can also specify this with \\[set-buffer-process-coding-system] |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1737 in the SQL buffer, after you start the process. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1738 The default comes from `process-coding-system-alist' and |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1739 `default-process-coding-system'. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1740 |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1741 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1742 (interactive) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1743 (if (comint-check-proc "*SQL*") |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1744 (pop-to-buffer "*SQL*") |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1745 (sql-get-login 'user 'password 'database) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1746 (message "Login...") |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1747 ;; Put all parameters to the program (if defined) in a list and call |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1748 ;; make-comint. |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1749 (let ((params sql-interbase-options)) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1750 (if (not (string= "" sql-user)) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1751 (setq params (append (list "-u" sql-user) params))) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1752 (if (not (string= "" sql-password)) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1753 (setq params (append (list "-p" sql-password) params))) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1754 (if (not (string= "" sql-database)) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1755 (setq params (cons sql-database params))); add to the front! |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1756 (set-buffer (apply 'make-comint "SQL" sql-interbase-program |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1757 nil params))) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1758 (setq sql-prompt-regexp "^SQL> ") |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1759 (setq sql-prompt-length 5) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1760 (setq sql-buffer (current-buffer)) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1761 (sql-interactive-mode) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1762 (message "Login...done") |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1763 (pop-to-buffer sql-buffer))) |
54a8a84a22f6
(sql-interbase): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36523
diff
changeset
|
1764 |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1765 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1766 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1767 ;;;###autoload |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1768 (defun sql-db2 () |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1769 "Run db2 by IBM as an inferior process. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1770 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1771 If buffer `*SQL*' exists but no process is running, make a new process. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1772 If buffer exists and a process is running, just switch to buffer |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1773 `*SQL*'. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1774 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1775 Interpreter used comes from variable `sql-db2-program'. There is not |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1776 automatic login. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1777 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1778 The buffer is put in sql-interactive-mode, giving commands for sending |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1779 input. See `sql-interactive-mode'. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1780 |
38872 | 1781 If you use \\[sql-accumulate-and-indent] to send multiline commands to |
1782 db2, newlines will be escaped if necessary. If you don't want that, set | |
1783 `comint-input-sender' back to `comint-simple-send' by writing an after | |
1784 advice. See the elisp manual for more information. | |
37409
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1785 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1786 To specify a coding system for converting non-ASCII characters |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1787 in the input and output to the process, use \\[universal-coding-system-argument] |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1788 before \\[sql-db2]. You can also specify this with \\[set-buffer-process-coding-system] |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1789 in the SQL buffer, after you start the process. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1790 The default comes from `process-coding-system-alist' and |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1791 `default-process-coding-system'. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1792 |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1793 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1794 (interactive) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1795 (if (comint-check-proc "*SQL*") |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1796 (pop-to-buffer "*SQL*") |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1797 (message "Login...") |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1798 ;; Put all parameters to the program (if defined) in a list and call |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1799 ;; make-comint. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1800 (set-buffer (apply 'make-comint "SQL" sql-db2-program |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1801 nil sql-db2-options)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1802 (setq sql-prompt-regexp "^db2 => ") |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1803 (setq sql-prompt-length 7) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1804 (setq sql-buffer (current-buffer)) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1805 (sql-interactive-mode) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1806 ;; Escape newlines. This must come after sql-interactive-mode |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1807 ;; because all local variables will be killed, there. |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1808 (setq comint-input-sender 'sql-escape-newlines-and-send) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1809 (message "Login...done") |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1810 (pop-to-buffer sql-buffer))) |
9781f3a3c955
(sql-escape-newlines-and-send): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
36571
diff
changeset
|
1811 |
24050 | 1812 (provide 'sql) |
1813 | |
1814 ;;; sql.el ends here |