annotate lisp/progmodes/sql.el @ 24058:85622273d1e8

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