Mercurial > emacs
comparison lisp/progmodes/sql.el @ 31392:1f97a090ba6d
(sql-postgres): Use sql-postgres-options.
(sql-postgres-options): New variable.
(sql-mode-menu): Work around missing variable mark-active
in XEmacs.
(sql-mode): Added call to easy-menu-add for XEmacs compatibility.
(sql-interactive-mode): Added call to easy-menu-add for XEmacs
compatibility.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 05 Sep 2000 10:44:21 +0000 |
parents | 2069c10bf952 |
children | 5aa8b2b669b7 |
comparison
equal
deleted
inserted
replaced
31391:0275fa841f55 | 31392:1f97a090ba6d |
---|---|
2 | 2 |
3 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 1999, 2000 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.19 | 7 ;; Version: 1.4.21 |
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 |
56 ;; command-interpreter-in-a-buffer mode (comint mode), it shares a | 56 ;; command-interpreter-in-a-buffer mode (comint mode), it shares a |
57 ;; common base functionality, and a common set of bindings, with all | 57 ;; common base functionality, and a common set of bindings, with all |
58 ;; modes derived from comint mode. This makes these modes easier to | 58 ;; modes derived from comint mode. This makes these modes easier to |
59 ;; use. | 59 ;; use. |
60 | 60 |
61 ;; sql-mode can be used to enable syntactic hilighting for SQL | 61 ;; sql-mode can be used to keep editing SQL statements. The SQL |
62 ;; statements in another buffer. SQL statements can then be sent to | 62 ;; statements can be sent to the SQL process in the SQLi buffer. |
63 ;; the SQL process in the SQLi buffer. sql-mode has already been | |
64 ;; used as a template to a simple PL/SQL mode. | |
65 | 63 |
66 ;; For documentation on the functionality provided by comint mode, and | 64 ;; For documentation on the functionality provided by comint mode, and |
67 ;; the hooks available for customising it, see the file `comint.el'. | 65 ;; the hooks available for customising it, see the file `comint.el'. |
68 | 66 |
69 ;; 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 |
336 | 334 |
337 Starts `sql-interactive-mode' after doing some setup. | 335 Starts `sql-interactive-mode' after doing some setup. |
338 | 336 |
339 The program can also specify a TCP connection. See `make-comint'." | 337 The program can also specify a TCP connection. See `make-comint'." |
340 :type 'file | 338 :type 'file |
339 :group 'SQL) | |
340 | |
341 (defcustom sql-postgres-options '("--pset" "pager=off") | |
342 "*List of additional options for `sql-postgres-program'. | |
343 The default setting includes the --pset option which breaks | |
344 older versions of the psql client (such as version 6.5.3). | |
345 If you want the psql to prompt you for a user name, add the | |
346 string \"-u\" to the list of options." | |
347 :type '(repeat string) | |
348 :version "20.8" | |
341 :group 'SQL) | 349 :group 'SQL) |
342 | 350 |
343 | 351 |
344 | 352 |
345 ;;; Variables which do not need customization | 353 ;;; Variables which do not need customization |
413 sql-mode-menu sql-mode-map | 421 sql-mode-menu sql-mode-map |
414 "Menu for `sql-mode'." | 422 "Menu for `sql-mode'." |
415 '("SQL" | 423 '("SQL" |
416 ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) | 424 ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) |
417 (get-buffer-process sql-buffer))] | 425 (get-buffer-process sql-buffer))] |
418 ["Send Region" sql-send-region (and mark-active | 426 ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
427 mark-active) | |
428 (mark)); XEmacs | |
419 (buffer-live-p sql-buffer) | 429 (buffer-live-p sql-buffer) |
420 (get-buffer-process sql-buffer))] | 430 (get-buffer-process sql-buffer))] |
421 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) | 431 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
422 (get-buffer-process sql-buffer))] | 432 (get-buffer-process sql-buffer))] |
423 ["Show SQLi buffer" sql-show-sqli-buffer t] | 433 ["Show SQLi buffer" sql-show-sqli-buffer t] |
1009 (interactive) | 1019 (interactive) |
1010 (kill-all-local-variables) | 1020 (kill-all-local-variables) |
1011 (setq major-mode 'sql-mode) | 1021 (setq major-mode 'sql-mode) |
1012 (setq mode-name "SQL") | 1022 (setq mode-name "SQL") |
1013 (use-local-map sql-mode-map) | 1023 (use-local-map sql-mode-map) |
1024 (if sql-mode-menu | |
1025 (easy-menu-add sql-mode-menu)); XEmacs | |
1014 (set-syntax-table sql-mode-syntax-table) | 1026 (set-syntax-table sql-mode-syntax-table) |
1015 (make-local-variable 'font-lock-defaults) | 1027 (make-local-variable 'font-lock-defaults) |
1016 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try | 1028 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
1017 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column | 1029 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
1018 ;; will have just one quote. Therefore syntactic hilighting is | 1030 ;; will have just one quote. Therefore syntactic hilighting is |
1122 (setq comint-prompt-regexp sql-prompt-regexp) | 1134 (setq comint-prompt-regexp sql-prompt-regexp) |
1123 (setq left-margin sql-prompt-length) | 1135 (setq left-margin sql-prompt-length) |
1124 (setq major-mode 'sql-interactive-mode) | 1136 (setq major-mode 'sql-interactive-mode) |
1125 (setq mode-name "SQLi") | 1137 (setq mode-name "SQLi") |
1126 (use-local-map sql-interactive-mode-map) | 1138 (use-local-map sql-interactive-mode-map) |
1139 (if sql-interactive-mode-menu | |
1140 (easy-menu-add sql-interactive-mode-menu)); XEmacs | |
1127 (set-syntax-table sql-mode-syntax-table) | 1141 (set-syntax-table sql-mode-syntax-table) |
1128 (make-local-variable 'font-lock-defaults) | 1142 (make-local-variable 'font-lock-defaults) |
1129 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try | 1143 ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try |
1130 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column | 1144 ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column |
1131 ;; will have just one quote. Therefore syntactic hilighting is | 1145 ;; will have just one quote. Therefore syntactic hilighting is |
1555 (pop-to-buffer "*SQL*") | 1569 (pop-to-buffer "*SQL*") |
1556 (sql-get-login 'database 'server) | 1570 (sql-get-login 'database 'server) |
1557 (message "Login...") | 1571 (message "Login...") |
1558 ;; username and password are ignored. Jason Beegan suggest using | 1572 ;; username and password are ignored. Jason Beegan suggest using |
1559 ;; --pset and pager=off instead of \\o|cat. The later was the | 1573 ;; --pset and pager=off instead of \\o|cat. The later was the |
1560 ;; solution by Gregor Zych. If you find that your postgres doesn't | 1574 ;; solution by Gregor Zych. Jason's suggestion is the default value |
1561 ;; like Jason Beegans's solution and prefers Gregor Zych's solution, | 1575 ;; for sql-postgres-options. |
1562 ;; then I'd love to hear from you. Send your comments to the | 1576 (let ((params sql-postgres-options)) |
1563 ;; mailing list. | |
1564 (let ((params (list "--pset" "pager=off"))) | |
1565 (if (not (string= "" sql-database)) | 1577 (if (not (string= "" sql-database)) |
1566 (setq params (append (list sql-database) params))) | 1578 (setq params (append (list sql-database) params))) |
1567 (if (not (string= "" sql-server)) | 1579 (if (not (string= "" sql-server)) |
1568 (setq params (append (list "-h" sql-server) params))) | 1580 (setq params (append (list "-h" sql-server) params))) |
1569 (set-buffer (apply 'make-comint "SQL" sql-postgres-program | 1581 (set-buffer (apply 'make-comint "SQL" sql-postgres-program |