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