annotate lisp/progmodes/sql.el @ 25672:68068da11161

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