diff options
| author | Juanma Barranquero | 2002-11-21 08:32:06 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2002-11-21 08:32:06 +0000 |
| commit | f4df536d0abea71ac9f816b13d745db05d6a0345 (patch) | |
| tree | 9d19731ee2ceff2df8aaaa7f6eb018329408191e | |
| parent | 1fb876f6651f07f164ebf4ad2e5413101ae68151 (diff) | |
| download | emacs-f4df536d0abea71ac9f816b13d745db05d6a0345.tar.gz emacs-f4df536d0abea71ac9f816b13d745db05d6a0345.zip | |
Added LINTER support.
(sql-linter-program): New variable.
(sql-linter-options): New variable.
(sql-mode-menu): Added Linter keywords.
(sql-mode-linter-font-lock-keywords): New variable.
(sql-highlight-linter-keywords): New function.
(sql-linter): New function.
(sql-ms-options): New variable.
(sql-ms): Use it.
| -rw-r--r-- | lisp/ChangeLog | 20 | ||||
| -rw-r--r-- | lisp/progmodes/sql.el | 203 |
2 files changed, 209 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3db6fd175c7..8ccff041624 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2002-11-21 Eugene Exarevsky <zheka@relex.ru> | ||
| 2 | |||
| 3 | * progmodes/sql.el: Added LINTER support. | ||
| 4 | (sql-linter-program): New variable. | ||
| 5 | (sql-linter-options): New variable. | ||
| 6 | (sql-mode-menu): Added Linter keywords. | ||
| 7 | (sql-mode-linter-font-lock-keywords): New variable. | ||
| 8 | (sql-highlight-linter-keywords): New function. | ||
| 9 | (sql-linter): New function. | ||
| 10 | (sql-ms-options): New variable. | ||
| 11 | (sql-ms): Use it. | ||
| 12 | |||
| 1 | 2002-11-21 John Paul Wallington <jpw@shootybangbang.com> | 13 | 2002-11-21 John Paul Wallington <jpw@shootybangbang.com> |
| 2 | 14 | ||
| 3 | * ibuffer.el (ibuffer-formats): Change default value; bump width | 15 | * ibuffer.el (ibuffer-formats): Change default value; bump width |
| @@ -18,7 +30,7 @@ | |||
| 18 | 30 | ||
| 19 | * subr.el (symbol-file): Remove unused variable `functions'. | 31 | * subr.el (symbol-file): Remove unused variable `functions'. |
| 20 | 32 | ||
| 21 | 2002-11-20 Markus Rost <rost@math.ohio-state.edu> | 33 | 2002-11-20 Markus Rost <rost@math.ohio-state.edu> |
| 22 | 34 | ||
| 23 | * Makefile.in (setwins_almost): Renamed from finder_setwins. | 35 | * Makefile.in (setwins_almost): Renamed from finder_setwins. |
| 24 | (custom-deps): Use it. | 36 | (custom-deps): Use it. |
| @@ -44,7 +56,7 @@ | |||
| 44 | 56 | ||
| 45 | * emacs-lisp/byte-opt.el (side-effect-free-fns): Several additions. | 57 | * emacs-lisp/byte-opt.el (side-effect-free-fns): Several additions. |
| 46 | 58 | ||
| 47 | 2002-11-19 Markus Rost <rost@math.ohio-state.edu> | 59 | 2002-11-19 Markus Rost <rost@math.ohio-state.edu> |
| 48 | 60 | ||
| 49 | * progmodes/vhdl-mode.el (defgroup vhdl-related): Declare the | 61 | * progmodes/vhdl-mode.el (defgroup vhdl-related): Declare the |
| 50 | members here rather than with custom-add-to-group. This is the | 62 | members here rather than with custom-add-to-group. This is the |
| @@ -175,7 +187,7 @@ | |||
| 175 | (calendar-mode): Set up font-lock mode. | 187 | (calendar-mode): Set up font-lock mode. |
| 176 | (generate-calendar-window): Fontify if font-lock-mode is on. | 188 | (generate-calendar-window): Fontify if font-lock-mode is on. |
| 177 | 189 | ||
| 178 | 2002-11-16 Ivan Zakharyaschev <imz@altlinux.org> (tiny change) | 190 | 2002-11-16 Ivan Zakharyaschev <imz@altlinux.org> (tiny change) |
| 179 | 191 | ||
| 180 | * international/codepage.el (cp866-decode-table): Fix the | 192 | * international/codepage.el (cp866-decode-table): Fix the |
| 181 | translation table. | 193 | translation table. |
| @@ -265,7 +277,7 @@ | |||
| 265 | paragraph with `fill-nobreak-invisible' let-bound to t. | 277 | paragraph with `fill-nobreak-invisible' let-bound to t. |
| 266 | Don't use `display' property; insert "see" directly in buffer. | 278 | Don't use `display' property; insert "see" directly in buffer. |
| 267 | 279 | ||
| 268 | 2002-11-14 Nick Roberts <nick@nick.uklinux.net> | 280 | 2002-11-14 Nick Roberts <nick@nick.uklinux.net> |
| 269 | 281 | ||
| 270 | * gdb-ui.el: New file, User Interface for running GDB | 282 | * gdb-ui.el: New file, User Interface for running GDB |
| 271 | 283 | ||
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index fb33db00681..00b779ba741 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | ;;; sql.el --- specialized comint.el for SQL interpreters | 1 | ;;; sql.el --- specialized comint.el for SQL interpreters |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998, 1999, 2000, 2001, 2002 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.6.5 | 7 | ;; Version: 1.7.0 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode | 9 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
| 10 | 10 | ||
| @@ -343,6 +343,13 @@ The program can also specify a TCP connection. See `make-comint'." | |||
| 343 | :type 'file | 343 | :type 'file |
| 344 | :group 'SQL) | 344 | :group 'SQL) |
| 345 | 345 | ||
| 346 | (defcustom sql-ms-options '("-w" "300" "-n") | ||
| 347 | ;; -w is the linesize | ||
| 348 | "*List of additional options for `sql-ms-program'." | ||
| 349 | :type '(repeat string) | ||
| 350 | :version "21.4" | ||
| 351 | :group 'SQL) | ||
| 352 | |||
| 346 | ;; Customization for Postgres | 353 | ;; Customization for Postgres |
| 347 | 354 | ||
| 348 | (defcustom sql-postgres-program "psql" | 355 | (defcustom sql-postgres-program "psql" |
| @@ -400,6 +407,21 @@ The program can also specify a TCP connection. See `make-comint'." | |||
| 400 | :version "20.8" | 407 | :version "20.8" |
| 401 | :group 'SQL) | 408 | :group 'SQL) |
| 402 | 409 | ||
| 410 | ;; Customization for Linter | ||
| 411 | |||
| 412 | (defcustom sql-linter-program "inl" | ||
| 413 | "*Command to start inl by RELEX. | ||
| 414 | |||
| 415 | Starts `sql-interactive-mode' after doing some setup." | ||
| 416 | :type 'file | ||
| 417 | :group 'SQL) | ||
| 418 | |||
| 419 | (defcustom sql-linter-options nil | ||
| 420 | "*List of additional options for `sql-linter-program'." | ||
| 421 | :type '(repeat string) | ||
| 422 | :version "21.3" | ||
| 423 | :group 'SQL) | ||
| 424 | |||
| 403 | 425 | ||
| 404 | 426 | ||
| 405 | ;;; Variables which do not need customization | 427 | ;;; Variables which do not need customization |
| @@ -441,7 +463,7 @@ Used by `sql-rename-buffer'.") | |||
| 441 | 463 | ||
| 442 | ;; Keymap for sql-interactive-mode. | 464 | ;; Keymap for sql-interactive-mode. |
| 443 | 465 | ||
| 444 | (defvar sql-interactive-mode-map | 466 | (defvar sql-interactive-mode-map |
| 445 | (let ((map (make-sparse-keymap))) | 467 | (let ((map (make-sparse-keymap))) |
| 446 | (if (functionp 'set-keymap-parent) | 468 | (if (functionp 'set-keymap-parent) |
| 447 | (set-keymap-parent map comint-mode-map); Emacs | 469 | (set-keymap-parent map comint-mode-map); Emacs |
| @@ -491,7 +513,9 @@ Based on `comint-mode-map'.") | |||
| 491 | ("Highlighting" | 513 | ("Highlighting" |
| 492 | ["ANSI SQL keywords" sql-highlight-ansi-keywords t] | 514 | ["ANSI SQL keywords" sql-highlight-ansi-keywords t] |
| 493 | ["Oracle keywords" sql-highlight-oracle-keywords t] | 515 | ["Oracle keywords" sql-highlight-oracle-keywords t] |
| 494 | ["Postgres keywords" sql-highlight-postgres-keywords t]))) | 516 | ["Postgres keywords" sql-highlight-postgres-keywords t] |
| 517 | ["Linter keywords" sql-highlight-linter-keywords t] | ||
| 518 | ))) | ||
| 495 | 519 | ||
| 496 | ;; easy menu for sql-interactive-mode. | 520 | ;; easy menu for sql-interactive-mode. |
| 497 | 521 | ||
| @@ -713,6 +737,100 @@ you define your own sql-mode-postgres-font-lock-keywords.") | |||
| 713 | (cons postgres-types 'font-lock-type-face)))))) | 737 | (cons postgres-types 'font-lock-type-face)))))) |
| 714 | 738 | ||
| 715 | 739 | ||
| 740 | (defvar sql-mode-linter-font-lock-keywords nil | ||
| 741 | "Linter SQL keywords used by font-lock. | ||
| 742 | |||
| 743 | This variable is used by `sql-mode' and `sql-interactive-mode'. The | ||
| 744 | regular expressions are created during compilation by calling the | ||
| 745 | function `regexp-opt'.") | ||
| 746 | |||
| 747 | (if sql-mode-linter-font-lock-keywords | ||
| 748 | () | ||
| 749 | (let ((linter-keywords (eval-when-compile | ||
| 750 | (concat "\\b" | ||
| 751 | (regexp-opt '( | ||
| 752 | "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" | ||
| 753 | "committed" "count" "countblob" "cross" "current" "data" "database" | ||
| 754 | "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" | ||
| 755 | "denied" "description" "device" "difference" "directory" "error" | ||
| 756 | "escape" "euc" "exclusive" "external" "extfile" "false" "file" | ||
| 757 | "filename" "filesize" "filetime" "filter" "findblob" "first" "foreign" | ||
| 758 | "full" "fuzzy" "global" "granted" "ignore" "immediate" "increment" | ||
| 759 | "indexes" "indexfile" "indexfiles" "indextime" "initial" "integrity" | ||
| 760 | "internal" "key" "last_autoinc" "last_rowid" "limit" "linter" | ||
| 761 | "linter_file_device" "linter_file_size" "linter_name_length" "ln" | ||
| 762 | "local" "login" "maxisn" "maxrow" "maxrowid" "maxvalue" "message" | ||
| 763 | "minvalue" "module" "names" "national" "natural" "new" "new_table" | ||
| 764 | "no" "node" "noneuc" "nulliferror" "numbers" "off" "old" "old_table" | ||
| 765 | "only" "operation" "optimistic" "option" "page" "partially" "password" | ||
| 766 | "phrase" "plan" "precision" "primary" "priority" "privileges" | ||
| 767 | "proc_info_size" "proc_par_name_len" "protocol" "quant" "range" "raw" | ||
| 768 | "read" "record" "records" "references" "remote" "rename" "replication" | ||
| 769 | "restart" "rewrite" "root" "row" "rule" "savepoint" "security" | ||
| 770 | "sensitive" "sequence" "serializable" "server" "since" "size" "some" | ||
| 771 | "startup" "statement" "station" "success" "sys_guid" "tables" "test" | ||
| 772 | "timeout" "trace" "transaction" "translation" "trigger" | ||
| 773 | "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" | ||
| 774 | "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" | ||
| 775 | "wait" "windows_code" "workspace" "write" "xml" | ||
| 776 | ) t) "\\b"))) | ||
| 777 | (linter-reserved-words (eval-when-compile | ||
| 778 | (concat "\\b" | ||
| 779 | (regexp-opt '( | ||
| 780 | "access" "action" "add" "address" "after" "all" "alter" "always" "and" | ||
| 781 | "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" | ||
| 782 | "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" | ||
| 783 | "blobfiles" "blobpct" "brief" "browse" "by" "case" "cast" "check" | ||
| 784 | "clear" "close" "column" "comment" "commit" "connect" "contains" | ||
| 785 | "correct" "create" "delete" "desc" "disable" "disconnect" "distinct" | ||
| 786 | "drop" "each" "ef" "else" "enable" "end" "event" "except" "exclude" | ||
| 787 | "execute" "exists" "extract" "fetch" "finish" "for" "from" "get" | ||
| 788 | "grant" "group" "having" "identified" "in" "index" "inner" "insert" | ||
| 789 | "instead" "intersect" "into" "is" "isolation" "join" "left" "level" | ||
| 790 | "like" "lock" "mode" "modify" "not" "nowait" "null" "of" "on" "open" | ||
| 791 | "or" "order" "outer" "owner" "press" "prior" "procedure" "public" | ||
| 792 | "purge" "rebuild" "resource" "restrict" "revoke" "right" "role" | ||
| 793 | "rollback" "rownum" "select" "session" "set" "share" "shutdown" | ||
| 794 | "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" | ||
| 795 | "to" "union" "unique" "unlock" "until" "update" "using" "values" | ||
| 796 | "view" "when" "where" "with" "without" | ||
| 797 | ) t) "\\b"))) | ||
| 798 | (linter-types (eval-when-compile | ||
| 799 | (concat "\\b" | ||
| 800 | (regexp-opt '( | ||
| 801 | "bigint" "bitmap" "blob" "boolean" "char" "character" "date" | ||
| 802 | "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" | ||
| 803 | "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" | ||
| 804 | "cursor" "long" | ||
| 805 | ) t) "\\b"))) | ||
| 806 | (linter-builtin-functions (eval-when-compile | ||
| 807 | (concat "\\b" | ||
| 808 | (regexp-opt '( | ||
| 809 | "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" | ||
| 810 | "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" | ||
| 811 | "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" | ||
| 812 | "lower" "lpad" "ltrim" "max" "min" "mod" "monthname" "nvl" | ||
| 813 | "octet_length" "power" "rand" "rawtohex" "repeat_string" | ||
| 814 | "right_substr" "round" "rpad" "rtrim" "sign" "sin" "sinh" "soundex" | ||
| 815 | "sqrt" "sum" "tan" "tanh" "timeint_to_days" "to_char" "to_date" | ||
| 816 | "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" | ||
| 817 | "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" | ||
| 818 | "instr" "least" "multime" "replace" "width" | ||
| 819 | ) t) "\\b")))) | ||
| 820 | (setq sql-mode-linter-font-lock-keywords | ||
| 821 | (append sql-mode-ansi-font-lock-keywords | ||
| 822 | (list (cons linter-keywords 'font-lock-function-name-face) | ||
| 823 | (cons linter-reserved-words 'font-lock-keyword-face) | ||
| 824 | ;; XEmacs doesn't have font-lock-builtin-face | ||
| 825 | (if (string-match "XEmacs\\|Lucid" emacs-version) | ||
| 826 | (cons linter-builtin-functions 'font-lock-preprocessor-face) | ||
| 827 | ;; GNU Emacs 19 doesn't have it either | ||
| 828 | (if (string-match "GNU Emacs 19" emacs-version) | ||
| 829 | (cons linter-builtin-functions 'font-lock-function-name-face) | ||
| 830 | ;; Emacs | ||
| 831 | (cons linter-builtin-functions 'font-lock-builtin-face))) | ||
| 832 | (cons linter-types 'font-lock-type-face)))))) | ||
| 833 | |||
| 716 | (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords | 834 | (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords |
| 717 | "SQL keywords used by font-lock. | 835 | "SQL keywords used by font-lock. |
| 718 | 836 | ||
| @@ -738,6 +856,13 @@ Basically, this just sets `font-lock-keywords' appropriately." | |||
| 738 | (setq font-lock-keywords sql-mode-postgres-font-lock-keywords) | 856 | (setq font-lock-keywords sql-mode-postgres-font-lock-keywords) |
| 739 | (font-lock-fontify-buffer)) | 857 | (font-lock-fontify-buffer)) |
| 740 | 858 | ||
| 859 | (defun sql-highlight-linter-keywords () | ||
| 860 | "Highlight LINTER keywords. | ||
| 861 | Basically, this just sets `font-lock-keywords' appropriately." | ||
| 862 | (interactive) | ||
| 863 | (setq font-lock-keywords sql-mode-linter-font-lock-keywords) | ||
| 864 | (font-lock-fontify-buffer)) | ||
| 865 | |||
| 741 | (defun sql-highlight-ansi-keywords () | 866 | (defun sql-highlight-ansi-keywords () |
| 742 | "Highlight ANSI SQL keywords. | 867 | "Highlight ANSI SQL keywords. |
| 743 | Basically, this just sets `font-lock-keywords' appropriately." | 868 | Basically, this just sets `font-lock-keywords' appropriately." |
| @@ -783,7 +908,7 @@ the regular expression `comint-prompt-regexp', a buffer local variable." | |||
| 783 | (defun sql-accumulate-and-indent () | 908 | (defun sql-accumulate-and-indent () |
| 784 | "Continue SQL statement on the next line." | 909 | "Continue SQL statement on the next line." |
| 785 | (interactive) | 910 | (interactive) |
| 786 | (if (fboundp 'comint-accumulate) | 911 | (if (fboundp 'comint-accumulate) |
| 787 | (comint-accumulate) | 912 | (comint-accumulate) |
| 788 | (newline)) | 913 | (newline)) |
| 789 | (indent-according-to-mode)) | 914 | (indent-according-to-mode)) |
| @@ -809,6 +934,7 @@ Other non-free SQL implementations are also supported: | |||
| 809 | Ingres: \\[sql-ingres] | 934 | Ingres: \\[sql-ingres] |
| 810 | Microsoft: \\[sql-ms] | 935 | Microsoft: \\[sql-ms] |
| 811 | Interbase: \\[sql-interbase] | 936 | Interbase: \\[sql-interbase] |
| 937 | Linter: \\[sql-linter] | ||
| 812 | 938 | ||
| 813 | But we urge you to choose a free implementation instead of these. | 939 | But we urge you to choose a free implementation instead of these. |
| 814 | 940 | ||
| @@ -896,7 +1022,7 @@ be in `sql-interactive-mode' and have a process." | |||
| 896 | found))))) | 1022 | found))))) |
| 897 | 1023 | ||
| 898 | (defun sql-set-sqli-buffer-generally () | 1024 | (defun sql-set-sqli-buffer-generally () |
| 899 | "Set SQLi buffer for all SQL buffers that have none. | 1025 | "Set SQLi buffer for all SQL buffers that have none. |
| 900 | This function checks all SQL buffers for their SQLi buffer. If their | 1026 | This function checks all SQL buffers for their SQLi buffer. If their |
| 901 | SQLi buffer is nonexistent or has no process, it is set to the current | 1027 | SQLi buffer is nonexistent or has no process, it is set to the current |
| 902 | default SQLi buffer. The current default SQLi buffer is determined | 1028 | default SQLi buffer. The current default SQLi buffer is determined |
| @@ -1022,7 +1148,7 @@ Inserts SELECT or commas if appropriate." | |||
| 1022 | Placeholders are words starting with and ampersand like &this. | 1148 | Placeholders are words starting with and ampersand like &this. |
| 1023 | This function is used for `comint-input-sender' if using `sql-oracle' on NT." | 1149 | This function is used for `comint-input-sender' if using `sql-oracle' on NT." |
| 1024 | (while (string-match "&\\(\\sw+\\)" string) | 1150 | (while (string-match "&\\(\\sw+\\)" string) |
| 1025 | (setq string (replace-match | 1151 | (setq string (replace-match |
| 1026 | (read-from-minibuffer | 1152 | (read-from-minibuffer |
| 1027 | (format "Enter value for %s: " (match-string 1 string)) | 1153 | (format "Enter value for %s: " (match-string 1 string)) |
| 1028 | nil nil nil sql-placeholder-history) | 1154 | nil nil nil sql-placeholder-history) |
| @@ -1348,7 +1474,7 @@ The default comes from `process-coding-system-alist' and | |||
| 1348 | (setq parameter (nconc (list parameter) sql-oracle-options)) | 1474 | (setq parameter (nconc (list parameter) sql-oracle-options)) |
| 1349 | (setq parameter sql-oracle-options)) | 1475 | (setq parameter sql-oracle-options)) |
| 1350 | (if parameter | 1476 | (if parameter |
| 1351 | (set-buffer (apply 'make-comint "SQL" sql-oracle-program nil | 1477 | (set-buffer (apply 'make-comint "SQL" sql-oracle-program nil |
| 1352 | parameter)) | 1478 | parameter)) |
| 1353 | (set-buffer (make-comint "SQL" sql-oracle-program nil)))) | 1479 | (set-buffer (make-comint "SQL" sql-oracle-program nil)))) |
| 1354 | (setq sql-prompt-regexp "^SQL> ") | 1480 | (setq sql-prompt-regexp "^SQL> ") |
| @@ -1612,7 +1738,8 @@ If buffer exists and a process is running, just switch to buffer | |||
| 1612 | 1738 | ||
| 1613 | Interpreter used comes from variable `sql-ms-program'. Login uses the | 1739 | Interpreter used comes from variable `sql-ms-program'. Login uses the |
| 1614 | variables `sql-user', `sql-password', `sql-database', and `sql-server' | 1740 | variables `sql-user', `sql-password', `sql-database', and `sql-server' |
| 1615 | as defaults, if set. | 1741 | as defaults, if set. Additional command line parameters can be stored |
| 1742 | in the list `sql-ms-options'. | ||
| 1616 | 1743 | ||
| 1617 | The buffer is put in sql-interactive-mode, giving commands for sending | 1744 | The buffer is put in sql-interactive-mode, giving commands for sending |
| 1618 | input. See `sql-interactive-mode'. | 1745 | input. See `sql-interactive-mode'. |
| @@ -1632,7 +1759,7 @@ The default comes from `process-coding-system-alist' and | |||
| 1632 | (message "Login...") | 1759 | (message "Login...") |
| 1633 | ;; Put all parameters to the program (if defined) in a list and call | 1760 | ;; Put all parameters to the program (if defined) in a list and call |
| 1634 | ;; make-comint. | 1761 | ;; make-comint. |
| 1635 | (let ((params '("-w 300"))) | 1762 | (let ((params sql-ms-options)) |
| 1636 | (if (not (string= "" sql-server)) | 1763 | (if (not (string= "" sql-server)) |
| 1637 | (setq params (append (list "-S" sql-server) params))) | 1764 | (setq params (append (list "-S" sql-server) params))) |
| 1638 | (if (not (string= "" sql-database)) | 1765 | (if (not (string= "" sql-database)) |
| @@ -1809,6 +1936,62 @@ The default comes from `process-coding-system-alist' and | |||
| 1809 | (message "Login...done") | 1936 | (message "Login...done") |
| 1810 | (pop-to-buffer sql-buffer))) | 1937 | (pop-to-buffer sql-buffer))) |
| 1811 | 1938 | ||
| 1939 | ;;;###autoload | ||
| 1940 | (defun sql-linter () | ||
| 1941 | "Run inl by RELEX as an inferior process. | ||
| 1942 | |||
| 1943 | If buffer `*SQL*' exists but no process is running, make a new process. | ||
| 1944 | If buffer exists and a process is running, just switch to buffer | ||
| 1945 | `*SQL*'. | ||
| 1946 | |||
| 1947 | Interpreter used comes from variable `sql-linter-program' - usually `inl'. | ||
| 1948 | Login uses the variables `sql-user', `sql-password', `sql-database' and | ||
| 1949 | `sql-server' as defaults, if set. Additional command line parameters | ||
| 1950 | can be stored in the list `sql-linter-options'. Run inl -h to get help on | ||
| 1951 | parameters. | ||
| 1952 | |||
| 1953 | `sql-database' is used to set the LINTER_MBX environment variable for | ||
| 1954 | local connections, `sql-server' refers to the server name from the | ||
| 1955 | `nodetab' file for the network connection (dbc_tcp or friends must run | ||
| 1956 | for this to work). If `sql-password' is an empty string, inl will use | ||
| 1957 | an empty password. | ||
| 1958 | |||
| 1959 | The buffer is put in sql-interactive-mode, giving commands for sending | ||
| 1960 | input. See `sql-interactive-mode'. | ||
| 1961 | |||
| 1962 | To use LINTER font locking by default, put this line into your .emacs : | ||
| 1963 | (setq sql-mode-font-lock-keywords sql-mode-linter-font-lock-keywords) | ||
| 1964 | |||
| 1965 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | ||
| 1966 | (interactive) | ||
| 1967 | (if (comint-check-proc "*SQL*") | ||
| 1968 | (pop-to-buffer "*SQL*") | ||
| 1969 | (sql-get-login 'user 'password 'database 'server) | ||
| 1970 | (message "Login...") | ||
| 1971 | ;; Put all parameters to the program (if defined) in a list and call | ||
| 1972 | ;; make-comint. | ||
| 1973 | (let ((params sql-linter-options) (login nil) (old-mbx (getenv "LINTER_MBX"))) | ||
| 1974 | (if (not (string= "" sql-user)) | ||
| 1975 | (setq login (concat sql-user "/" sql-password))) | ||
| 1976 | (setq params (append (list "-u" login) params)) | ||
| 1977 | (if (not (string= "" sql-server)) | ||
| 1978 | (setq params (append (list "-n" sql-server) params))) | ||
| 1979 | (if (string= "" sql-database) | ||
| 1980 | (setenv "LINTER_MBX" nil) | ||
| 1981 | (setenv "LINTER_MBX" sql-database)) | ||
| 1982 | (set-buffer (apply 'make-comint "SQL" sql-linter-program nil | ||
| 1983 | params)) | ||
| 1984 | (setenv "LINTER_MBX" old-mbx) | ||
| 1985 | ) | ||
| 1986 | (setq sql-prompt-regexp "^SQL>") | ||
| 1987 | (setq sql-prompt-length 4) | ||
| 1988 | (setq sql-buffer (current-buffer)) | ||
| 1989 | (sql-interactive-mode) | ||
| 1990 | (message "Login...done") | ||
| 1991 | (pop-to-buffer sql-buffer))) | ||
| 1992 | |||
| 1993 | |||
| 1994 | |||
| 1812 | (provide 'sql) | 1995 | (provide 'sql) |
| 1813 | 1996 | ||
| 1814 | ;;; sql.el ends here | 1997 | ;;; sql.el ends here |