comparison lisp/progmodes/sql.el @ 36571:54a8a84a22f6

(sql-interbase): New function. (sql-interbase-program): New option. (sql-interbase-options): New option. And some typos fixed: "customise" to "customize".
author Gerd Moellmann <gerd@gnu.org>
date Tue, 06 Mar 2001 12:24:17 +0000
parents e72a04113eac
children 9781f3a3c955
comparison
equal deleted inserted replaced
36570:4dc9c2de9141 36571:54a8a84a22f6
2 2
3 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 4
5 ;; Author: Alex Schroeder <alex@gnu.org> 5 ;; Author: Alex Schroeder <alex@gnu.org>
6 ;; Maintainer: Alex Schroeder <alex@gnu.org> 6 ;; Maintainer: Alex Schroeder <alex@gnu.org>
7 ;; Version: 1.4.25 7 ;; Version: 1.5.0
8 ;; Keywords: comm languages processes 8 ;; Keywords: comm languages processes
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
60 60
61 ;; sql-mode can be used to keep editing SQL statements. The SQL 61 ;; sql-mode can be used to keep editing SQL statements. The SQL
62 ;; statements can be sent to the SQL process in the SQLi buffer. 62 ;; statements can be sent to the SQL process in the SQLi buffer.
63 63
64 ;; For documentation on the functionality provided by comint mode, and 64 ;; For documentation on the functionality provided by comint mode, and
65 ;; the hooks available for customising it, see the file `comint.el'. 65 ;; the hooks available for customizing it, see the file `comint.el'.
66 66
67 ;; Hint for newbies: take a look at `dabbrev-expand', `abbrev-mode', and 67 ;; Hint for newbies: take a look at `dabbrev-expand', `abbrev-mode', and
68 ;; `imenu-add-menubar-index'. 68 ;; `imenu-add-menubar-index'.
69 69
70 ;;; Requirements for Emacs 19.34: 70 ;;; Requirements for Emacs 19.34:
221 :group 'SQL) 221 :group 'SQL)
222 222
223 ;; The usual hooks 223 ;; The usual hooks
224 224
225 (defcustom sql-interactive-mode-hook '() 225 (defcustom sql-interactive-mode-hook '()
226 "*Hook for customising `sql-interactive-mode'." 226 "*Hook for customizing `sql-interactive-mode'."
227 :type 'hook 227 :type 'hook
228 :group 'SQL) 228 :group 'SQL)
229 229
230 (defcustom sql-mode-hook '() 230 (defcustom sql-mode-hook '()
231 "*Hook for customising `sql-mode'." 231 "*Hook for customizing `sql-mode'."
232 :type 'hook 232 :type 'hook
233 :group 'SQL) 233 :group 'SQL)
234 234
235 (defcustom sql-set-sqli-hook '() 235 (defcustom sql-set-sqli-hook '()
236 "*Hook for reacting to changes of `sql-buffer'. 236 "*Hook for reacting to changes of `sql-buffer'.
238 This is called by `sql-set-sqli-buffer' when the value of `sql-buffer' 238 This is called by `sql-set-sqli-buffer' when the value of `sql-buffer'
239 is changed." 239 is changed."
240 :type 'hook 240 :type 'hook
241 :group 'SQL) 241 :group 'SQL)
242 242
243 ;; Customisation for Oracle 243 ;; Customization for Oracle
244 244
245 (defcustom sql-oracle-program "sqlplus" 245 (defcustom sql-oracle-program "sqlplus"
246 "*Command to start sqlplus by Oracle. 246 "*Command to start sqlplus by Oracle.
247 247
248 Starts `sql-interactive-mode' after doing some setup. 248 Starts `sql-interactive-mode' after doing some setup.
259 "*List of additional options for `sql-oracle-program'." 259 "*List of additional options for `sql-oracle-program'."
260 :type '(repeat string) 260 :type '(repeat string)
261 :version "20.8" 261 :version "20.8"
262 :group 'SQL) 262 :group 'SQL)
263 263
264 ;; Customisation for MySql 264 ;; Customization for MySql
265 265
266 (defcustom sql-mysql-program "mysql" 266 (defcustom sql-mysql-program "mysql"
267 "*Command to start mysql by TcX. 267 "*Command to start mysql by TcX.
268 268
269 Starts `sql-interactive-mode' after doing some setup. 269 Starts `sql-interactive-mode' after doing some setup.
278 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." 278 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
279 :type '(repeat string) 279 :type '(repeat string)
280 :version "20.8" 280 :version "20.8"
281 :group 'SQL) 281 :group 'SQL)
282 282
283 ;; Customisation for Solid 283 ;; Customization for Solid
284 284
285 (defcustom sql-solid-program "solsql" 285 (defcustom sql-solid-program "solsql"
286 "*Command to start SOLID SQL Editor. 286 "*Command to start SOLID SQL Editor.
287 287
288 Starts `sql-interactive-mode' after doing some setup. 288 Starts `sql-interactive-mode' after doing some setup.
289 289
290 The program can also specify a TCP connection. See `make-comint'." 290 The program can also specify a TCP connection. See `make-comint'."
291 :type 'file 291 :type 'file
292 :group 'SQL) 292 :group 'SQL)
293 293
294 ;; Customisation for SyBase 294 ;; Customization for SyBase
295 295
296 (defcustom sql-sybase-program "isql" 296 (defcustom sql-sybase-program "isql"
297 "*Command to start isql by SyBase. 297 "*Command to start isql by SyBase.
298 298
299 Starts `sql-interactive-mode' after doing some setup. 299 Starts `sql-interactive-mode' after doing some setup.
307 Some versions of isql might require the -n option in order to work." 307 Some versions of isql might require the -n option in order to work."
308 :type '(repeat string) 308 :type '(repeat string)
309 :version "20.8" 309 :version "20.8"
310 :group 'SQL) 310 :group 'SQL)
311 311
312 ;; Customisation for Informix 312 ;; Customization for Informix
313 313
314 (defcustom sql-informix-program "dbaccess" 314 (defcustom sql-informix-program "dbaccess"
315 "*Command to start dbaccess by Informix. 315 "*Command to start dbaccess by Informix.
316 316
317 Starts `sql-interactive-mode' after doing some setup. 317 Starts `sql-interactive-mode' after doing some setup.
318 318
319 The program can also specify a TCP connection. See `make-comint'." 319 The program can also specify a TCP connection. See `make-comint'."
320 :type 'file 320 :type 'file
321 :group 'SQL) 321 :group 'SQL)
322 322
323 ;; Customisation for Ingres 323 ;; Customization for Ingres
324 324
325 (defcustom sql-ingres-program "sql" 325 (defcustom sql-ingres-program "sql"
326 "*Command to start sql by Ingres. 326 "*Command to start sql by Ingres.
327 327
328 Starts `sql-interactive-mode' after doing some setup. 328 Starts `sql-interactive-mode' after doing some setup.
329 329
330 The program can also specify a TCP connection. See `make-comint'." 330 The program can also specify a TCP connection. See `make-comint'."
331 :type 'file 331 :type 'file
332 :group 'SQL) 332 :group 'SQL)
333 333
334 ;; Customisation for Microsoft 334 ;; Customization for Microsoft
335 335
336 (defcustom sql-ms-program "isql" 336 (defcustom sql-ms-program "isql"
337 "*Command to start isql by Microsoft. 337 "*Command to start isql by Microsoft.
338 338
339 Starts `sql-interactive-mode' after doing some setup. 339 Starts `sql-interactive-mode' after doing some setup.
340 340
341 The program can also specify a TCP connection. See `make-comint'." 341 The program can also specify a TCP connection. See `make-comint'."
342 :type 'file 342 :type 'file
343 :group 'SQL) 343 :group 'SQL)
344 344
345 ;; Customisation for Postgres 345 ;; Customization for Postgres
346 346
347 (defcustom sql-postgres-program "psql" 347 (defcustom sql-postgres-program "psql"
348 "Command to start psql by Postgres. 348 "Command to start psql by Postgres.
349 349
350 Starts `sql-interactive-mode' after doing some setup. 350 Starts `sql-interactive-mode' after doing some setup.
358 The default setting includes the -P option which breaks 358 The default setting includes the -P option which breaks
359 older versions of the psql client (such as version 6.5.3). 359 older versions of the psql client (such as version 6.5.3).
360 The -P option is equivalent to the --pset option. 360 The -P option is equivalent to the --pset option.
361 If you want the psql to prompt you for a user name, add the 361 If you want the psql to prompt you for a user name, add the
362 string \"-u\" to the list of options." 362 string \"-u\" to the list of options."
363 :type '(repeat string)
364 :version "20.8"
365 :group 'SQL)
366
367 ;; Customization for Interbase
368
369 (defcustom sql-interbase-program "isql"
370 "*Command to start isql by Interbase.
371
372 Starts `sql-interactive-mode' after doing some setup.
373
374 The program can also specify a TCP connection. See `make-comint'."
375 :type 'file
376 :group 'SQL)
377
378 (defcustom sql-interbase-options nil
379 "*List of additional options for `sql-interbase-program'."
363 :type '(repeat string) 380 :type '(repeat string)
364 :version "20.8" 381 :version "20.8"
365 :group 'SQL) 382 :group 'SQL)
366 383
367 384
774 791
775 (defun sql-get-login (&rest what) 792 (defun sql-get-login (&rest what)
776 "Get username, password and database from the user. 793 "Get username, password and database from the user.
777 794
778 The variables `sql-user', `sql-password', `sql-server', and 795 The variables `sql-user', `sql-password', `sql-server', and
779 `sql-database' can be customised. They are used as the default values. 796 `sql-database' can be customized. They are used as the default values.
780 Usernames, servers and databases are stored in `sql-user-history', 797 Usernames, servers and databases are stored in `sql-user-history',
781 `sql-server-history' and `database-history'. Passwords are not stored 798 `sql-server-history' and `database-history'. Passwords are not stored
782 in a history. 799 in a history.
783 800
784 Parameter WHAT is a list of the arguments passed to this function. 801 Parameter WHAT is a list of the arguments passed to this function.
1550 (setq sql-buffer (current-buffer)) 1567 (setq sql-buffer (current-buffer))
1551 (sql-interactive-mode) 1568 (sql-interactive-mode)
1552 (message "Login...done") 1569 (message "Login...done")
1553 (pop-to-buffer sql-buffer))) 1570 (pop-to-buffer sql-buffer)))
1554 1571
1555
1556 1572
1557 1573
1558 ;;;###autoload 1574 ;;;###autoload
1559 (defun sql-postgres () 1575 (defun sql-postgres ()
1560 "Run psql by Postgres as an inferior process. 1576 "Run psql by Postgres as an inferior process.
1611 (setq sql-buffer (current-buffer)) 1627 (setq sql-buffer (current-buffer))
1612 (sql-interactive-mode) 1628 (sql-interactive-mode)
1613 (message "Login...done") 1629 (message "Login...done")
1614 (pop-to-buffer sql-buffer))) 1630 (pop-to-buffer sql-buffer)))
1615 1631
1632
1633
1634 ;;;###autoload
1635 (defun sql-interbase ()
1636 "Run isql by Interbase as an inferior process.
1637
1638 If buffer `*SQL*' exists but no process is running, make a new process.
1639 If buffer exists and a process is running, just switch to buffer
1640 `*SQL*'.
1641
1642 Interpreter used comes from variable `sql-interbase-program'. Login
1643 uses the variables `sql-user', `sql-password', and `sql-database' as
1644 defaults, if set.
1645
1646 The buffer is put in sql-interactive-mode, giving commands for sending
1647 input. See `sql-interactive-mode'.
1648
1649 To specify a coding system for converting non-ASCII characters
1650 in the input and output to the process, use \\[universal-coding-system-argument]
1651 before \\[sql-interbase]. You can also specify this with \\[set-buffer-process-coding-system]
1652 in the SQL buffer, after you start the process.
1653 The default comes from `process-coding-system-alist' and
1654 `default-process-coding-system'.
1655
1656 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)"
1657 (interactive)
1658 (if (comint-check-proc "*SQL*")
1659 (pop-to-buffer "*SQL*")
1660 (sql-get-login 'user 'password 'database)
1661 (message "Login...")
1662 ;; Put all parameters to the program (if defined) in a list and call
1663 ;; make-comint.
1664 (let ((params sql-interbase-options))
1665 (if (not (string= "" sql-user))
1666 (setq params (append (list "-u" sql-user) params)))
1667 (if (not (string= "" sql-password))
1668 (setq params (append (list "-p" sql-password) params)))
1669 (if (not (string= "" sql-database))
1670 (setq params (cons sql-database params))); add to the front!
1671 (set-buffer (apply 'make-comint "SQL" sql-interbase-program
1672 nil params)))
1673 (setq sql-prompt-regexp "^SQL> ")
1674 (setq sql-prompt-length 5)
1675 (setq sql-buffer (current-buffer))
1676 (sql-interactive-mode)
1677 (message "Login...done")
1678 (pop-to-buffer sql-buffer)))
1679
1616 (provide 'sql) 1680 (provide 'sql)
1617 1681
1618 ;;; sql.el ends here 1682 ;;; sql.el ends here