diff options
| author | Michael Mauger | 2013-03-11 00:09:37 -0400 |
|---|---|---|
| committer | Michael Mauger | 2013-03-11 00:09:37 -0400 |
| commit | e18e61cf276880f658ab8cdf1f242a675b58cd71 (patch) | |
| tree | 1ed994ee4c6ed8f6342b11d41e2053071d4c1de1 /lisp/progmodes/sql.el | |
| parent | 307d0e95ee9da988333c9d373b9955300bbaa340 (diff) | |
| download | emacs-e18e61cf276880f658ab8cdf1f242a675b58cd71.tar.gz emacs-e18e61cf276880f658ab8cdf1f242a675b58cd71.zip | |
* progmodes/sql.el Version 3.2
Please note that my address changed to <michael@mauger.com>; the
<mmaug@yahoo.com> address remains active.
(sql-connection-alist): Updates documentation to fix bug#13715.
(sql-connect): Handle missing `sql-connection-alist' correctly.
(sql-mode-oracle-font-lock-keywords): Add missing keywords.
(sql-magic-go, sql-magic-semicolon): Mark with `delete-selection'
property.
(sql-default-value): New function.
(sql-get-login-ext, sql-get-login): Fixes bug where buffer-local
values were not used.
(sql-rename-buffer): Make sure alternate buffer name has no text
properties.
(sql-input-sender, sql-execute-feature): Fetch variable with
`buffer-local-value' rather than `with-current-buffer'.
(sql-*): Use #' function syntax consistently.
(sql-*): Use message/error/user-error consistently.
Diffstat (limited to 'lisp/progmodes/sql.el')
| -rw-r--r-- | lisp/progmodes/sql.el | 317 |
1 files changed, 165 insertions, 152 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 781aa241802..3cf6757d5ec 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | ;; Copyright (C) 1998-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | 5 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 6 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> | 6 | ;; Maintainer: Michael Mauger <michael@mauger.com> |
| 7 | ;; Version: 3.1 | 7 | ;; Version: 3.2 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ | 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ |
| 10 | 10 | ||
| @@ -209,7 +209,7 @@ | |||
| 209 | ;; nino <nino@inform.dk> | 209 | ;; nino <nino@inform.dk> |
| 210 | ;; Berend de Boer <berend@pobox.com> | 210 | ;; Berend de Boer <berend@pobox.com> |
| 211 | ;; Adam Jenkins <adam@thejenkins.org> | 211 | ;; Adam Jenkins <adam@thejenkins.org> |
| 212 | ;; Michael Mauger <mmaug@yahoo.com> -- improved product support | 212 | ;; Michael Mauger <michael@mauger.com> -- improved product support |
| 213 | ;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support | 213 | ;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support |
| 214 | ;; Harald Maier <maierh@myself.com> -- sql-send-string | 214 | ;; Harald Maier <maierh@myself.com> -- sql-send-string |
| 215 | ;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; | 215 | ;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; |
| @@ -218,6 +218,9 @@ | |||
| 218 | ;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug | 218 | ;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug |
| 219 | ;; Ian Bjorhovde <idbjorh@dataproxy.com> -- db2 escape newlines | 219 | ;; Ian Bjorhovde <idbjorh@dataproxy.com> -- db2 escape newlines |
| 220 | ;; incorrectly enabled by default | 220 | ;; incorrectly enabled by default |
| 221 | ;; Roman Scherer <roman.scherer@nugg.ad> -- Connection documentation | ||
| 222 | ;; Mark Wilkinson <wilkinsonmr@gmail.com> -- file-local variables ignored | ||
| 223 | ;; | ||
| 221 | 224 | ||
| 222 | 225 | ||
| 223 | 226 | ||
| @@ -605,11 +608,12 @@ Each element of the alist is as follows: | |||
| 605 | 608 | ||
| 606 | \(CONNECTION \(SQL-VARIABLE VALUE) ...) | 609 | \(CONNECTION \(SQL-VARIABLE VALUE) ...) |
| 607 | 610 | ||
| 608 | Where CONNECTION is a symbol identifying the connection, SQL-VARIABLE | 611 | Where CONNECTION is a case-insensitive string identifying the |
| 609 | is the symbol name of a SQL mode variable, and VALUE is the value to | 612 | connection, SQL-VARIABLE is the symbol name of a SQL mode |
| 610 | be assigned to the variable. The most common SQL-VARIABLE settings | 613 | variable, and VALUE is the value to be assigned to the variable. |
| 611 | associated with a connection are: `sql-product', `sql-user', | 614 | The most common SQL-VARIABLE settings associated with a |
| 612 | `sql-password', `sql-port', `sql-server', and `sql-database'. | 615 | connection are: `sql-product', `sql-user', `sql-password', |
| 616 | `sql-port', `sql-server', and `sql-database'. | ||
| 613 | 617 | ||
| 614 | If a SQL-VARIABLE is part of the connection, it will not be | 618 | If a SQL-VARIABLE is part of the connection, it will not be |
| 615 | prompted for during login. The command `sql-connect' starts a | 619 | prompted for during login. The command `sql-connect' starts a |
| @@ -1299,7 +1303,7 @@ Based on `comint-mode-map'.") | |||
| 1299 | ;; double quotes (") don't delimit strings | 1303 | ;; double quotes (") don't delimit strings |
| 1300 | (modify-syntax-entry ?\" "." table) | 1304 | (modify-syntax-entry ?\" "." table) |
| 1301 | ;; Make these all punctuation | 1305 | ;; Make these all punctuation |
| 1302 | (mapc (lambda (c) (modify-syntax-entry c "." table)) | 1306 | (mapc #'(lambda (c) (modify-syntax-entry c "." table)) |
| 1303 | (string-to-list "!#$%&+,.:;<=>?@\\|")) | 1307 | (string-to-list "!#$%&+,.:;<=>?@\\|")) |
| 1304 | table) | 1308 | table) |
| 1305 | "Syntax table used in `sql-mode' and `sql-interactive-mode'.") | 1309 | "Syntax table used in `sql-mode' and `sql-interactive-mode'.") |
| @@ -1509,7 +1513,7 @@ to add functions and PL/SQL keywords.") | |||
| 1509 | (not (derived-mode-p 'sql-interactive-mode))) | 1513 | (not (derived-mode-p 'sql-interactive-mode))) |
| 1510 | (not sql-buffer) | 1514 | (not sql-buffer) |
| 1511 | (not (eq sql-product 'oracle))) | 1515 | (not (eq sql-product 'oracle))) |
| 1512 | (error "Not an Oracle buffer") | 1516 | (user-error "Not an Oracle buffer") |
| 1513 | 1517 | ||
| 1514 | (let ((b "*RESERVED WORDS*")) | 1518 | (let ((b "*RESERVED WORDS*")) |
| 1515 | (sql-execute sql-buffer b | 1519 | (sql-execute sql-buffer b |
| @@ -1692,7 +1696,7 @@ to add functions and PL/SQL keywords.") | |||
| 1692 | "noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null" | 1696 | "noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null" |
| 1693 | "nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online" | 1697 | "nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online" |
| 1694 | "only" "open" "operator" "optimal" "option" "or" "order" | 1698 | "only" "open" "operator" "optimal" "option" "or" "order" |
| 1695 | "organization" "out" "outer" "outline" "overflow" "overriding" | 1699 | "organization" "out" "outer" "outline" "over" "overflow" "overriding" |
| 1696 | "package" "packages" "parallel" "parallel_enable" "parameters" | 1700 | "package" "packages" "parallel" "parallel_enable" "parameters" |
| 1697 | "parent" "partition" "partitions" "password" "password_grace_time" | 1701 | "parent" "partition" "partitions" "password" "password_grace_time" |
| 1698 | "password_life_time" "password_lock_time" "password_reuse_max" | 1702 | "password_life_time" "password_lock_time" "password_reuse_max" |
| @@ -1745,7 +1749,7 @@ to add functions and PL/SQL keywords.") | |||
| 1745 | ;; Oracle PL/SQL Functions | 1749 | ;; Oracle PL/SQL Functions |
| 1746 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil | 1750 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil |
| 1747 | "delete" "trim" "extend" "exists" "first" "last" "count" "limit" | 1751 | "delete" "trim" "extend" "exists" "first" "last" "count" "limit" |
| 1748 | "prior" "next" | 1752 | "prior" "next" "sqlcode" "sqlerrm" |
| 1749 | ) | 1753 | ) |
| 1750 | 1754 | ||
| 1751 | ;; Oracle PL/SQL Reserved words | 1755 | ;; Oracle PL/SQL Reserved words |
| @@ -2402,7 +2406,7 @@ highlighting rules in SQL mode.") | |||
| 2402 | (let ((init (or (and initial (symbol-name initial)) "ansi"))) | 2406 | (let ((init (or (and initial (symbol-name initial)) "ansi"))) |
| 2403 | (intern (completing-read | 2407 | (intern (completing-read |
| 2404 | prompt | 2408 | prompt |
| 2405 | (mapcar (lambda (info) (symbol-name (car info))) | 2409 | (mapcar #'(lambda (info) (symbol-name (car info))) |
| 2406 | sql-product-alist) | 2410 | sql-product-alist) |
| 2407 | nil 'require-match | 2411 | nil 'require-match |
| 2408 | init 'sql-product-history init)))) | 2412 | init 'sql-product-history init)))) |
| @@ -2418,7 +2422,7 @@ configuration." | |||
| 2418 | 2422 | ||
| 2419 | ;; Don't do anything if the product is already supported | 2423 | ;; Don't do anything if the product is already supported |
| 2420 | (if (assoc product sql-product-alist) | 2424 | (if (assoc product sql-product-alist) |
| 2421 | (message "Product `%s' is already defined" product) | 2425 | (user-error "Product `%s' is already defined" product) |
| 2422 | 2426 | ||
| 2423 | ;; Add product to the alist | 2427 | ;; Add product to the alist |
| 2424 | (add-to-list 'sql-product-alist `((,product :name ,display . ,plist))) | 2428 | (add-to-list 'sql-product-alist `((,product :name ,display . ,plist))) |
| @@ -2437,11 +2441,11 @@ configuration." | |||
| 2437 | ;; after this product's name. | 2441 | ;; after this product's name. |
| 2438 | (let ((next-item) | 2442 | (let ((next-item) |
| 2439 | (down-display (downcase display))) | 2443 | (down-display (downcase display))) |
| 2440 | (map-keymap (lambda (k b) | 2444 | (map-keymap #'(lambda (k b) |
| 2441 | (when (and (not next-item) | 2445 | (when (and (not next-item) |
| 2442 | (string-lessp down-display | 2446 | (string-lessp down-display |
| 2443 | (downcase (cadr b)))) | 2447 | (downcase (cadr b)))) |
| 2444 | (setq next-item k))) | 2448 | (setq next-item k))) |
| 2445 | (easy-menu-get-map sql-mode-menu '("Product"))) | 2449 | (easy-menu-get-map sql-mode-menu '("Product"))) |
| 2446 | next-item)) | 2450 | next-item)) |
| 2447 | product)) | 2451 | product)) |
| @@ -2472,7 +2476,7 @@ argument must be a plist keyword accepted by | |||
| 2472 | (symbolp v)) | 2476 | (symbolp v)) |
| 2473 | (set v newvalue) | 2477 | (set v newvalue) |
| 2474 | (setcdr p (plist-put (cdr p) feature newvalue))) | 2478 | (setcdr p (plist-put (cdr p) feature newvalue))) |
| 2475 | (message "`%s' is not a known product; use `sql-add-product' to add it first." product)))) | 2479 | (error "`%s' is not a known product; use `sql-add-product' to add it first." product)))) |
| 2476 | 2480 | ||
| 2477 | (defun sql-get-product-feature (product feature &optional fallback not-indirect) | 2481 | (defun sql-get-product-feature (product feature &optional fallback not-indirect) |
| 2478 | "Lookup FEATURE associated with a SQL PRODUCT. | 2482 | "Lookup FEATURE associated with a SQL PRODUCT. |
| @@ -2502,7 +2506,7 @@ See `sql-product-alist' for a list of products and supported features." | |||
| 2502 | (symbolp v)) | 2506 | (symbolp v)) |
| 2503 | (symbol-value v) | 2507 | (symbol-value v) |
| 2504 | v)) | 2508 | v)) |
| 2505 | (message "`%s' is not a known product; use `sql-add-product' to add it first." product) | 2509 | (error "`%s' is not a known product; use `sql-add-product' to add it first." product) |
| 2506 | nil))) | 2510 | nil))) |
| 2507 | 2511 | ||
| 2508 | (defun sql-product-font-lock (keywords-only imenu) | 2512 | (defun sql-product-font-lock (keywords-only imenu) |
| @@ -2543,13 +2547,13 @@ also be configured." | |||
| 2543 | (font-lock-mode-internal t)) | 2547 | (font-lock-mode-internal t)) |
| 2544 | 2548 | ||
| 2545 | (add-hook 'font-lock-mode-hook | 2549 | (add-hook 'font-lock-mode-hook |
| 2546 | (lambda () | 2550 | #'(lambda () |
| 2547 | ;; Provide defaults for new font-lock faces. | 2551 | ;; Provide defaults for new font-lock faces. |
| 2548 | (defvar font-lock-builtin-face | 2552 | (defvar font-lock-builtin-face |
| 2549 | (if (boundp 'font-lock-preprocessor-face) | 2553 | (if (boundp 'font-lock-preprocessor-face) |
| 2550 | font-lock-preprocessor-face | 2554 | font-lock-preprocessor-face |
| 2551 | font-lock-keyword-face)) | 2555 | font-lock-keyword-face)) |
| 2552 | (defvar font-lock-doc-face font-lock-string-face)) | 2556 | (defvar font-lock-doc-face font-lock-string-face)) |
| 2553 | nil t) | 2557 | nil t) |
| 2554 | 2558 | ||
| 2555 | ;; Setup imenu; it needs the same syntax-alist. | 2559 | ;; Setup imenu; it needs the same syntax-alist. |
| @@ -2592,10 +2596,10 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2592 | "Iterate through login parameters and return a list of results." | 2596 | "Iterate through login parameters and return a list of results." |
| 2593 | (delq nil | 2597 | (delq nil |
| 2594 | (mapcar | 2598 | (mapcar |
| 2595 | (lambda (param) | 2599 | #'(lambda (param) |
| 2596 | (let ((token (or (car-safe param) param)) | 2600 | (let ((token (or (car-safe param) param)) |
| 2597 | (plist (cdr-safe param))) | 2601 | (plist (cdr-safe param))) |
| 2598 | (funcall body token plist))) | 2602 | (funcall body token plist))) |
| 2599 | login-params))) | 2603 | login-params))) |
| 2600 | 2604 | ||
| 2601 | 2605 | ||
| @@ -2604,8 +2608,8 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2604 | 2608 | ||
| 2605 | (defun sql-product-syntax-table () | 2609 | (defun sql-product-syntax-table () |
| 2606 | (let ((table (copy-syntax-table sql-mode-syntax-table))) | 2610 | (let ((table (copy-syntax-table sql-mode-syntax-table))) |
| 2607 | (mapc (lambda (entry) | 2611 | (mapc #'(lambda (entry) |
| 2608 | (modify-syntax-entry (car entry) (cdr entry) table)) | 2612 | (modify-syntax-entry (car entry) (cdr entry) table)) |
| 2609 | (sql-get-product-feature sql-product :syntax-alist)) | 2613 | (sql-get-product-feature sql-product :syntax-alist)) |
| 2610 | table)) | 2614 | table)) |
| 2611 | 2615 | ||
| @@ -2613,10 +2617,10 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2613 | (append | 2617 | (append |
| 2614 | ;; Change all symbol character to word characters | 2618 | ;; Change all symbol character to word characters |
| 2615 | (mapcar | 2619 | (mapcar |
| 2616 | (lambda (entry) (if (string= (substring (cdr entry) 0 1) "_") | 2620 | #'(lambda (entry) (if (string= (substring (cdr entry) 0 1) "_") |
| 2617 | (cons (car entry) | 2621 | (cons (car entry) |
| 2618 | (concat "w" (substring (cdr entry) 1))) | 2622 | (concat "w" (substring (cdr entry) 1))) |
| 2619 | entry)) | 2623 | entry)) |
| 2620 | (sql-get-product-feature sql-product :syntax-alist)) | 2624 | (sql-get-product-feature sql-product :syntax-alist)) |
| 2621 | '((?_ . "w")))) | 2625 | '((?_ . "w")))) |
| 2622 | 2626 | ||
| @@ -2639,7 +2643,7 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2639 | (list (sql-read-product "SQL product: "))) | 2643 | (list (sql-read-product "SQL product: "))) |
| 2640 | (if (stringp product) (setq product (intern product))) | 2644 | (if (stringp product) (setq product (intern product))) |
| 2641 | (when (not (assoc product sql-product-alist)) | 2645 | (when (not (assoc product sql-product-alist)) |
| 2642 | (error "SQL product %s is not supported; treated as ANSI" product) | 2646 | (user-error "SQL product %s is not supported; treated as ANSI" product) |
| 2643 | (setq product 'ansi)) | 2647 | (setq product 'ansi)) |
| 2644 | 2648 | ||
| 2645 | ;; Save product setting and fontify. | 2649 | ;; Save product setting and fontify. |
| @@ -2765,6 +2769,7 @@ local variable." | |||
| 2765 | (comint-bol nil) | 2769 | (comint-bol nil) |
| 2766 | (looking-at "go\\b"))) | 2770 | (looking-at "go\\b"))) |
| 2767 | (comint-send-input))) | 2771 | (comint-send-input))) |
| 2772 | (put 'sql-magic-go 'delete-selection t) | ||
| 2768 | 2773 | ||
| 2769 | (defun sql-magic-semicolon (arg) | 2774 | (defun sql-magic-semicolon (arg) |
| 2770 | "Insert semicolon and call `comint-send-input'. | 2775 | "Insert semicolon and call `comint-send-input'. |
| @@ -2773,6 +2778,7 @@ local variable." | |||
| 2773 | (self-insert-command (prefix-numeric-value arg)) | 2778 | (self-insert-command (prefix-numeric-value arg)) |
| 2774 | (if (equal sql-electric-stuff 'semicolon) | 2779 | (if (equal sql-electric-stuff 'semicolon) |
| 2775 | (comint-send-input))) | 2780 | (comint-send-input))) |
| 2781 | (put 'sql-magic-semicolon 'delete-selection t) | ||
| 2776 | 2782 | ||
| 2777 | (defun sql-accumulate-and-indent () | 2783 | (defun sql-accumulate-and-indent () |
| 2778 | "Continue SQL statement on the next line." | 2784 | "Continue SQL statement on the next line." |
| @@ -2861,6 +2867,15 @@ appended to the SQLi buffer without disturbing your SQL buffer." | |||
| 2861 | t t doc 0))) | 2867 | t t doc 0))) |
| 2862 | doc) | 2868 | doc) |
| 2863 | 2869 | ||
| 2870 | (defun sql-default-value (var) | ||
| 2871 | "Fetch the value of a variable. | ||
| 2872 | |||
| 2873 | If the current buffer is in `sql-interactive-mode', then fetch | ||
| 2874 | the global value, otherwise use the buffer local value." | ||
| 2875 | (if (derived-mode-p 'sql-interactive-mode) | ||
| 2876 | (default-value var) | ||
| 2877 | (buffer-local-value var (current-buffer)))) | ||
| 2878 | |||
| 2864 | (defun sql-get-login-ext (symbol prompt history-var plist) | 2879 | (defun sql-get-login-ext (symbol prompt history-var plist) |
| 2865 | "Prompt user with extended login parameters. | 2880 | "Prompt user with extended login parameters. |
| 2866 | 2881 | ||
| @@ -2882,7 +2897,7 @@ value. (The property value is used as the PREDICATE argument to | |||
| 2882 | (set-default | 2897 | (set-default |
| 2883 | symbol | 2898 | symbol |
| 2884 | (let* ((default (plist-get plist :default)) | 2899 | (let* ((default (plist-get plist :default)) |
| 2885 | (last-value (default-value symbol)) | 2900 | (last-value (sql-default-value symbol)) |
| 2886 | (prompt-def | 2901 | (prompt-def |
| 2887 | (if default | 2902 | (if default |
| 2888 | (if (string-match "\\(\\):[ \t]*\\'" prompt) | 2903 | (if (string-match "\\(\\):[ \t]*\\'" prompt) |
| @@ -2950,7 +2965,7 @@ function like this: (sql-get-login 'user 'password 'database)." | |||
| 2950 | 2965 | ||
| 2951 | (`password | 2966 | (`password |
| 2952 | (setq-default sql-password | 2967 | (setq-default sql-password |
| 2953 | (read-passwd "Password: " nil sql-password))) | 2968 | (read-passwd "Password: " nil (sql-default-value 'sql-password)))) |
| 2954 | 2969 | ||
| 2955 | (`server | 2970 | (`server |
| 2956 | (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist)) | 2971 | (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist)) |
| @@ -2978,10 +2993,10 @@ In order to qualify, the SQLi buffer must be alive, be in | |||
| 2978 | (sql-buffer-live-p buf prod connection) | 2993 | (sql-buffer-live-p buf prod connection) |
| 2979 | buf) | 2994 | buf) |
| 2980 | ;; Look thru each buffer | 2995 | ;; Look thru each buffer |
| 2981 | (car (apply 'append | 2996 | (car (apply #'append |
| 2982 | (mapcar (lambda (b) | 2997 | (mapcar #'(lambda (b) |
| 2983 | (and (sql-buffer-live-p b prod connection) | 2998 | (and (sql-buffer-live-p b prod connection) |
| 2984 | (list (buffer-name b)))) | 2999 | (list (buffer-name b)))) |
| 2985 | (buffer-list))))))) | 3000 | (buffer-list))))))) |
| 2986 | 3001 | ||
| 2987 | (defun sql-set-sqli-buffer-generally () | 3002 | (defun sql-set-sqli-buffer-generally () |
| @@ -3022,10 +3037,10 @@ If you call it from anywhere else, it sets the global copy of | |||
| 3022 | (interactive) | 3037 | (interactive) |
| 3023 | (let ((default-buffer (sql-find-sqli-buffer))) | 3038 | (let ((default-buffer (sql-find-sqli-buffer))) |
| 3024 | (if (null default-buffer) | 3039 | (if (null default-buffer) |
| 3025 | (error "There is no suitable SQLi buffer") | 3040 | (user-error "There is no suitable SQLi buffer") |
| 3026 | (let ((new-buffer (read-buffer "New SQLi buffer: " default-buffer t))) | 3041 | (let ((new-buffer (read-buffer "New SQLi buffer: " default-buffer t))) |
| 3027 | (if (null (sql-buffer-live-p new-buffer)) | 3042 | (if (null (sql-buffer-live-p new-buffer)) |
| 3028 | (error "Buffer %s is not a working SQLi buffer" new-buffer) | 3043 | (user-error "Buffer %s is not a working SQLi buffer" new-buffer) |
| 3029 | (when new-buffer | 3044 | (when new-buffer |
| 3030 | (setq sql-buffer new-buffer) | 3045 | (setq sql-buffer new-buffer) |
| 3031 | (run-hooks 'sql-set-sqli-hook))))))) | 3046 | (run-hooks 'sql-set-sqli-hook))))))) |
| @@ -3038,10 +3053,10 @@ variable `sql-buffer'. See `sql-help' on how to create such a buffer." | |||
| 3038 | (interactive) | 3053 | (interactive) |
| 3039 | (if (or (null sql-buffer) | 3054 | (if (or (null sql-buffer) |
| 3040 | (null (buffer-live-p (get-buffer sql-buffer)))) | 3055 | (null (buffer-live-p (get-buffer sql-buffer)))) |
| 3041 | (message "%s has no SQLi buffer set." (buffer-name (current-buffer))) | 3056 | (user-error "%s has no SQLi buffer set" (buffer-name (current-buffer))) |
| 3042 | (if (null (get-buffer-process sql-buffer)) | 3057 | (if (null (get-buffer-process sql-buffer)) |
| 3043 | (message "Buffer %s has no process." sql-buffer) | 3058 | (user-error "Buffer %s has no process" sql-buffer) |
| 3044 | (message "Current SQLi buffer is %s." sql-buffer)))) | 3059 | (user-error "Current SQLi buffer is %s" sql-buffer)))) |
| 3045 | 3060 | ||
| 3046 | (defun sql-make-alternate-buffer-name () | 3061 | (defun sql-make-alternate-buffer-name () |
| 3047 | "Return a string that can be used to rename a SQLi buffer. | 3062 | "Return a string that can be used to rename a SQLi buffer. |
| @@ -3062,35 +3077,35 @@ server/database name." | |||
| 3062 | 3077 | ||
| 3063 | ;; Build a name using the :sqli-login setting | 3078 | ;; Build a name using the :sqli-login setting |
| 3064 | (setq name | 3079 | (setq name |
| 3065 | (apply 'concat | 3080 | (apply #'concat |
| 3066 | (cdr | 3081 | (cdr |
| 3067 | (apply 'append nil | 3082 | (apply #'append nil |
| 3068 | (sql-for-each-login | 3083 | (sql-for-each-login |
| 3069 | (sql-get-product-feature sql-product :sqli-login) | 3084 | (sql-get-product-feature sql-product :sqli-login) |
| 3070 | (lambda (token plist) | 3085 | #'(lambda (token plist) |
| 3071 | (pcase token | 3086 | (pcase token |
| 3072 | (`user | 3087 | (`user |
| 3073 | (unless (string= "" sql-user) | 3088 | (unless (string= "" sql-user) |
| 3074 | (list "/" sql-user))) | 3089 | (list "/" sql-user))) |
| 3075 | (`port | 3090 | (`port |
| 3076 | (unless (or (not (numberp sql-port)) | 3091 | (unless (or (not (numberp sql-port)) |
| 3077 | (= 0 sql-port)) | 3092 | (= 0 sql-port)) |
| 3078 | (list ":" (number-to-string sql-port)))) | 3093 | (list ":" (number-to-string sql-port)))) |
| 3079 | (`server | 3094 | (`server |
| 3080 | (unless (string= "" sql-server) | 3095 | (unless (string= "" sql-server) |
| 3081 | (list "." | 3096 | (list "." |
| 3082 | (if (plist-member plist :file) | 3097 | (if (plist-member plist :file) |
| 3083 | (file-name-nondirectory sql-server) | 3098 | (file-name-nondirectory sql-server) |
| 3084 | sql-server)))) | 3099 | sql-server)))) |
| 3085 | (`database | 3100 | (`database |
| 3086 | (unless (string= "" sql-database) | 3101 | (unless (string= "" sql-database) |
| 3087 | (list "@" | 3102 | (list "@" |
| 3088 | (if (plist-member plist :file) | 3103 | (if (plist-member plist :file) |
| 3089 | (file-name-nondirectory sql-database) | 3104 | (file-name-nondirectory sql-database) |
| 3090 | sql-database)))) | 3105 | sql-database)))) |
| 3091 | 3106 | ||
| 3092 | ;; (`password nil) | 3107 | ;; (`password nil) |
| 3093 | (_ nil)))))))) | 3108 | (_ nil)))))))) |
| 3094 | 3109 | ||
| 3095 | ;; If there's a connection, use it and the name thus far | 3110 | ;; If there's a connection, use it and the name thus far |
| 3096 | (if sql-connection | 3111 | (if sql-connection |
| @@ -3125,7 +3140,7 @@ NEW-NAME is empty, then the buffer name will be \"*SQL*\"." | |||
| 3125 | (interactive "P") | 3140 | (interactive "P") |
| 3126 | 3141 | ||
| 3127 | (if (not (derived-mode-p 'sql-interactive-mode)) | 3142 | (if (not (derived-mode-p 'sql-interactive-mode)) |
| 3128 | (message "Current buffer is not a SQL interactive buffer") | 3143 | (user-error "Current buffer is not a SQL interactive buffer") |
| 3129 | 3144 | ||
| 3130 | (setq sql-alternate-buffer-name | 3145 | (setq sql-alternate-buffer-name |
| 3131 | (cond | 3146 | (cond |
| @@ -3135,6 +3150,7 @@ NEW-NAME is empty, then the buffer name will be \"*SQL*\"." | |||
| 3135 | sql-alternate-buffer-name)) | 3150 | sql-alternate-buffer-name)) |
| 3136 | (t sql-alternate-buffer-name))) | 3151 | (t sql-alternate-buffer-name))) |
| 3137 | 3152 | ||
| 3153 | (setq sql-alternate-buffer-name (substring-no-properties sql-alternate-buffer-name)) | ||
| 3138 | (rename-buffer (if (string= "" sql-alternate-buffer-name) | 3154 | (rename-buffer (if (string= "" sql-alternate-buffer-name) |
| 3139 | "*SQL*" | 3155 | "*SQL*" |
| 3140 | (format "*SQL: %s*" sql-alternate-buffer-name)) | 3156 | (format "*SQL: %s*" sql-alternate-buffer-name)) |
| @@ -3222,7 +3238,7 @@ Allows the suppression of continuation prompts.") | |||
| 3222 | (defun sql-input-sender (proc string) | 3238 | (defun sql-input-sender (proc string) |
| 3223 | "Send STRING to PROC after applying filters." | 3239 | "Send STRING to PROC after applying filters." |
| 3224 | 3240 | ||
| 3225 | (let* ((product (with-current-buffer (process-buffer proc) sql-product)) | 3241 | (let* ((product (buffer-local-value 'sql-product (process-buffer proc))) |
| 3226 | (filter (sql-get-product-feature product :input-filter))) | 3242 | (filter (sql-get-product-feature product :input-filter))) |
| 3227 | 3243 | ||
| 3228 | ;; Apply filter(s) | 3244 | ;; Apply filter(s) |
| @@ -3232,15 +3248,13 @@ Allows the suppression of continuation prompts.") | |||
| 3232 | ((functionp filter) | 3248 | ((functionp filter) |
| 3233 | (setq string (funcall filter string))) | 3249 | (setq string (funcall filter string))) |
| 3234 | ((listp filter) | 3250 | ((listp filter) |
| 3235 | (mapc (lambda (f) (setq string (funcall f string))) filter)) | 3251 | (mapc #'(lambda (f) (setq string (funcall f string))) filter)) |
| 3236 | (t nil)) | 3252 | (t nil)) |
| 3237 | 3253 | ||
| 3238 | ;; Count how many newlines in the string | 3254 | ;; Count how many newlines in the string |
| 3239 | (setq sql-output-newline-count 0) | 3255 | (setq sql-output-newline-count |
| 3240 | (mapc (lambda (ch) | 3256 | (apply #'+ (mapcar #'(lambda (ch) |
| 3241 | (when (eq ch ?\n) | 3257 | (if (eq ch ?\n) 1 0)) string))) |
| 3242 | (setq sql-output-newline-count (1+ sql-output-newline-count)))) | ||
| 3243 | string) | ||
| 3244 | 3258 | ||
| 3245 | ;; Send the string | 3259 | ;; Send the string |
| 3246 | (comint-simple-send proc string))) | 3260 | (comint-simple-send proc string))) |
| @@ -3320,7 +3334,7 @@ to avoid deleting non-prompt output." | |||
| 3320 | (if sql-send-terminator | 3334 | (if sql-send-terminator |
| 3321 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) | 3335 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) |
| 3322 | 3336 | ||
| 3323 | (message "Sent string to buffer %s." sql-buffer))) | 3337 | (message "Sent string to buffer %s" sql-buffer))) |
| 3324 | 3338 | ||
| 3325 | ;; Display the sql buffer | 3339 | ;; Display the sql buffer |
| 3326 | (if sql-pop-to-buffer-after-send-region | 3340 | (if sql-pop-to-buffer-after-send-region |
| @@ -3328,7 +3342,7 @@ to avoid deleting non-prompt output." | |||
| 3328 | (display-buffer sql-buffer))) | 3342 | (display-buffer sql-buffer))) |
| 3329 | 3343 | ||
| 3330 | ;; We don't have no stinkin' sql | 3344 | ;; We don't have no stinkin' sql |
| 3331 | (message "No SQL process started.")))) | 3345 | (user-error "No SQL process started")))) |
| 3332 | 3346 | ||
| 3333 | (defun sql-send-region (start end) | 3347 | (defun sql-send-region (start end) |
| 3334 | "Send a region to the SQL process." | 3348 | "Send a region to the SQL process." |
| @@ -3421,7 +3435,7 @@ list of SQLi command strings." | |||
| 3421 | (when visible | 3435 | (when visible |
| 3422 | (message "Executing SQL command...")) | 3436 | (message "Executing SQL command...")) |
| 3423 | (if (consp command) | 3437 | (if (consp command) |
| 3424 | (mapc (lambda (c) (sql-redirect-one sqlbuf c outbuf save-prior)) | 3438 | (mapc #'(lambda (c) (sql-redirect-one sqlbuf c outbuf save-prior)) |
| 3425 | command) | 3439 | command) |
| 3426 | (sql-redirect-one sqlbuf command outbuf save-prior)) | 3440 | (sql-redirect-one sqlbuf command outbuf save-prior)) |
| 3427 | (when visible | 3441 | (when visible |
| @@ -3498,11 +3512,11 @@ for each match." | |||
| 3498 | (match-string regexp-groups)) | 3512 | (match-string regexp-groups)) |
| 3499 | ;; list of numbers; return the specified matches only | 3513 | ;; list of numbers; return the specified matches only |
| 3500 | ((consp regexp-groups) | 3514 | ((consp regexp-groups) |
| 3501 | (mapcar (lambda (c) | 3515 | (mapcar #'(lambda (c) |
| 3502 | (cond | 3516 | (cond |
| 3503 | ((numberp c) (match-string c)) | 3517 | ((numberp c) (match-string c)) |
| 3504 | ((stringp c) (match-substitute-replacement c)) | 3518 | ((stringp c) (match-substitute-replacement c)) |
| 3505 | (t (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" c)))) | 3519 | (t (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" c)))) |
| 3506 | regexp-groups)) | 3520 | regexp-groups)) |
| 3507 | ;; String is specified; return replacement string | 3521 | ;; String is specified; return replacement string |
| 3508 | ((stringp regexp-groups) | 3522 | ((stringp regexp-groups) |
| @@ -3528,15 +3542,15 @@ strings are formatted with ARG and executed. | |||
| 3528 | If the results are empty the OUTBUF is deleted, otherwise the | 3542 | If the results are empty the OUTBUF is deleted, otherwise the |
| 3529 | buffer is popped into a view window." | 3543 | buffer is popped into a view window." |
| 3530 | (mapc | 3544 | (mapc |
| 3531 | (lambda (c) | 3545 | #'(lambda (c) |
| 3532 | (cond | 3546 | (cond |
| 3533 | ((stringp c) | 3547 | ((stringp c) |
| 3534 | (sql-redirect sqlbuf (if arg (format c arg) c) outbuf) t) | 3548 | (sql-redirect sqlbuf (if arg (format c arg) c) outbuf) t) |
| 3535 | ((functionp c) | 3549 | ((functionp c) |
| 3536 | (apply c sqlbuf outbuf enhanced arg nil)) | 3550 | (apply c sqlbuf outbuf enhanced arg nil)) |
| 3537 | (t (error "Unknown sql-execute item %s" c)))) | 3551 | (t (error "Unknown sql-execute item %s" c)))) |
| 3538 | (if (consp command) command (cons command nil))) | 3552 | (if (consp command) command (cons command nil))) |
| 3539 | 3553 | ||
| 3540 | (setq outbuf (get-buffer outbuf)) | 3554 | (setq outbuf (get-buffer outbuf)) |
| 3541 | (if (zerop (buffer-size outbuf)) | 3555 | (if (zerop (buffer-size outbuf)) |
| 3542 | (kill-buffer outbuf) | 3556 | (kill-buffer outbuf) |
| @@ -3551,11 +3565,11 @@ buffer is popped into a view window." | |||
| 3551 | 3565 | ||
| 3552 | (defun sql-execute-feature (sqlbuf outbuf feature enhanced arg) | 3566 | (defun sql-execute-feature (sqlbuf outbuf feature enhanced arg) |
| 3553 | "List objects or details in a separate display buffer." | 3567 | "List objects or details in a separate display buffer." |
| 3554 | (let (command) | 3568 | (let (command |
| 3555 | (with-current-buffer sqlbuf | 3569 | (product (buffer-local-value 'sql-product (get-buffer sqlbuf)))) |
| 3556 | (setq command (sql-get-product-feature sql-product feature))) | 3570 | (setq command (sql-get-product-feature product feature)) |
| 3557 | (unless command | 3571 | (unless command |
| 3558 | (error "%s does not support %s" sql-product feature)) | 3572 | (error "%s does not support %s" product feature)) |
| 3559 | (when (consp command) | 3573 | (when (consp command) |
| 3560 | (setq command (if enhanced | 3574 | (setq command (if enhanced |
| 3561 | (cdr command) | 3575 | (cdr command) |
| @@ -3582,7 +3596,7 @@ The list is maintained in SQL interactive buffers.") | |||
| 3582 | (apply f (current-buffer) (cons schema nil))) | 3596 | (apply f (current-buffer) (cons schema nil))) |
| 3583 | cl) | 3597 | cl) |
| 3584 | (unless (member e cl) (setq cl (cons e cl)))) | 3598 | (unless (member e cl) (setq cl (cons e cl)))) |
| 3585 | (sort cl (function string<))))))) | 3599 | (sort cl #'string<)))))) |
| 3586 | 3600 | ||
| 3587 | (defun sql-build-completions (schema) | 3601 | (defun sql-build-completions (schema) |
| 3588 | "Generate a list of names in the database for use as completions." | 3602 | "Generate a list of names in the database for use as completions." |
| @@ -3646,7 +3660,7 @@ details or extends the listing to include other schemas objects." | |||
| 3646 | (interactive "P") | 3660 | (interactive "P") |
| 3647 | (let ((sqlbuf (sql-find-sqli-buffer))) | 3661 | (let ((sqlbuf (sql-find-sqli-buffer))) |
| 3648 | (unless sqlbuf | 3662 | (unless sqlbuf |
| 3649 | (error "No SQL interactive buffer found")) | 3663 | (user-error "No SQL interactive buffer found")) |
| 3650 | (sql-execute-feature sqlbuf "*List All*" :list-all enhanced nil) | 3664 | (sql-execute-feature sqlbuf "*List All*" :list-all enhanced nil) |
| 3651 | (with-current-buffer sqlbuf | 3665 | (with-current-buffer sqlbuf |
| 3652 | ;; Contains the name of database objects | 3666 | ;; Contains the name of database objects |
| @@ -3662,9 +3676,9 @@ ENHANCED, displays additional details about each column." | |||
| 3662 | current-prefix-arg)) | 3676 | current-prefix-arg)) |
| 3663 | (let ((sqlbuf (sql-find-sqli-buffer))) | 3677 | (let ((sqlbuf (sql-find-sqli-buffer))) |
| 3664 | (unless sqlbuf | 3678 | (unless sqlbuf |
| 3665 | (error "No SQL interactive buffer found")) | 3679 | (user-error "No SQL interactive buffer found")) |
| 3666 | (unless name | 3680 | (unless name |
| 3667 | (error "No table name specified")) | 3681 | (user-error "No table name specified")) |
| 3668 | (sql-execute-feature sqlbuf (format "*List %s*" name) | 3682 | (sql-execute-feature sqlbuf (format "*List %s*" name) |
| 3669 | :list-table enhanced name))) | 3683 | :list-table enhanced name))) |
| 3670 | 3684 | ||
| @@ -3898,7 +3912,7 @@ Sentinels will always get the two parameters PROCESS and EVENT." | |||
| 3898 | "Read a connection name." | 3912 | "Read a connection name." |
| 3899 | (let ((completion-ignore-case t)) | 3913 | (let ((completion-ignore-case t)) |
| 3900 | (completing-read prompt | 3914 | (completing-read prompt |
| 3901 | (mapcar (lambda (c) (car c)) | 3915 | (mapcar #'(lambda (c) (car c)) |
| 3902 | sql-connection-alist) | 3916 | sql-connection-alist) |
| 3903 | nil t initial 'sql-connection-history default))) | 3917 | nil t initial 'sql-connection-history default))) |
| 3904 | 3918 | ||
| @@ -3917,7 +3931,7 @@ is specified in the connection settings." | |||
| 3917 | (if sql-connection-alist | 3931 | (if sql-connection-alist |
| 3918 | (list (sql-read-connection "Connection: " nil '(nil)) | 3932 | (list (sql-read-connection "Connection: " nil '(nil)) |
| 3919 | current-prefix-arg) | 3933 | current-prefix-arg) |
| 3920 | nil)) | 3934 | (user-error "No SQL Connections defined"))) |
| 3921 | 3935 | ||
| 3922 | ;; Are there connections defined | 3936 | ;; Are there connections defined |
| 3923 | (if sql-connection-alist | 3937 | (if sql-connection-alist |
| @@ -3941,27 +3955,27 @@ is specified in the connection settings." | |||
| 3941 | ;; Params in the connection | 3955 | ;; Params in the connection |
| 3942 | (setq set-params | 3956 | (setq set-params |
| 3943 | (mapcar | 3957 | (mapcar |
| 3944 | (lambda (v) | 3958 | #'(lambda (v) |
| 3945 | (pcase (car v) | 3959 | (pcase (car v) |
| 3946 | (`sql-user 'user) | 3960 | (`sql-user 'user) |
| 3947 | (`sql-password 'password) | 3961 | (`sql-password 'password) |
| 3948 | (`sql-server 'server) | 3962 | (`sql-server 'server) |
| 3949 | (`sql-database 'database) | 3963 | (`sql-database 'database) |
| 3950 | (`sql-port 'port) | 3964 | (`sql-port 'port) |
| 3951 | (s s))) | 3965 | (s s))) |
| 3952 | (cdr connect-set))) | 3966 | (cdr connect-set))) |
| 3953 | 3967 | ||
| 3954 | ;; the remaining params (w/o the connection params) | 3968 | ;; the remaining params (w/o the connection params) |
| 3955 | (setq rem-params | 3969 | (setq rem-params |
| 3956 | (sql-for-each-login login-params | 3970 | (sql-for-each-login login-params |
| 3957 | (lambda (token plist) | 3971 | #'(lambda (token plist) |
| 3958 | (unless (member token set-params) | 3972 | (unless (member token set-params) |
| 3959 | (if plist (cons token plist) token))))) | 3973 | (if plist (cons token plist) token))))) |
| 3960 | 3974 | ||
| 3961 | ;; Set the parameters and start the interactive session | 3975 | ;; Set the parameters and start the interactive session |
| 3962 | (mapc | 3976 | (mapc |
| 3963 | (lambda (vv) | 3977 | #'(lambda (vv) |
| 3964 | (set-default (car vv) (eval (cadr vv)))) | 3978 | (set-default (car vv) (eval (cadr vv)))) |
| 3965 | (cdr connect-set)) | 3979 | (cdr connect-set)) |
| 3966 | (setq-default sql-connection connection) | 3980 | (setq-default sql-connection connection) |
| 3967 | 3981 | ||
| @@ -3969,10 +3983,10 @@ is specified in the connection settings." | |||
| 3969 | (eval `(let ((,param-var ',rem-params)) | 3983 | (eval `(let ((,param-var ',rem-params)) |
| 3970 | (sql-product-interactive ',sql-product ',new-name)))) | 3984 | (sql-product-interactive ',sql-product ',new-name)))) |
| 3971 | 3985 | ||
| 3972 | (message "SQL Connection <%s> does not exist" connection) | 3986 | (user-error "SQL Connection <%s> does not exist" connection) |
| 3973 | nil))) | 3987 | nil))) |
| 3974 | 3988 | ||
| 3975 | (message "No SQL Connections defined") | 3989 | (user-error "No SQL Connections defined") |
| 3976 | nil)) | 3990 | nil)) |
| 3977 | 3991 | ||
| 3978 | (defun sql-save-connection (name) | 3992 | (defun sql-save-connection (name) |
| @@ -3984,7 +3998,7 @@ optionally is saved to the user's init file." | |||
| 3984 | (interactive "sNew connection name: ") | 3998 | (interactive "sNew connection name: ") |
| 3985 | 3999 | ||
| 3986 | (unless (derived-mode-p 'sql-interactive-mode) | 4000 | (unless (derived-mode-p 'sql-interactive-mode) |
| 3987 | (error "Not in a SQL interactive mode!")) | 4001 | (user-error "Not in a SQL interactive mode!")) |
| 3988 | 4002 | ||
| 3989 | ;; Capture the buffer local settings | 4003 | ;; Capture the buffer local settings |
| 3990 | (let* ((buf (current-buffer)) | 4004 | (let* ((buf (current-buffer)) |
| @@ -4009,18 +4023,18 @@ optionally is saved to the user's init file." | |||
| 4009 | 4023 | ||
| 4010 | ;; Add the new connection if it doesn't exist | 4024 | ;; Add the new connection if it doesn't exist |
| 4011 | (if (assoc name alist) | 4025 | (if (assoc name alist) |
| 4012 | (message "Connection <%s> already exists" name) | 4026 | (user-error "Connection <%s> already exists" name) |
| 4013 | (setq connect | 4027 | (setq connect |
| 4014 | (cons name | 4028 | (cons name |
| 4015 | (sql-for-each-login | 4029 | (sql-for-each-login |
| 4016 | `(product ,@login) | 4030 | `(product ,@login) |
| 4017 | (lambda (token _plist) | 4031 | #'(lambda (token _plist) |
| 4018 | (pcase token | 4032 | (pcase token |
| 4019 | (`product `(sql-product ',product)) | 4033 | (`product `(sql-product ',product)) |
| 4020 | (`user `(sql-user ,user)) | 4034 | (`user `(sql-user ,user)) |
| 4021 | (`database `(sql-database ,database)) | 4035 | (`database `(sql-database ,database)) |
| 4022 | (`server `(sql-server ,server)) | 4036 | (`server `(sql-server ,server)) |
| 4023 | (`port `(sql-port ,port))))))) | 4037 | (`port `(sql-port ,port))))))) |
| 4024 | 4038 | ||
| 4025 | (setq alist (append alist (list connect))) | 4039 | (setq alist (append alist (list connect))) |
| 4026 | 4040 | ||
| @@ -4033,21 +4047,20 @@ optionally is saved to the user's init file." | |||
| 4033 | "Generate menu entries for using each connection." | 4047 | "Generate menu entries for using each connection." |
| 4034 | (append | 4048 | (append |
| 4035 | (mapcar | 4049 | (mapcar |
| 4036 | (lambda (conn) | 4050 | #'(lambda (conn) |
| 4037 | (vector | 4051 | (vector |
| 4038 | (format "Connection <%s>\t%s" (car conn) | 4052 | (format "Connection <%s>\t%s" (car conn) |
| 4039 | (let ((sql-user "") (sql-database "") | 4053 | (let ((sql-user "") (sql-database "") |
| 4040 | (sql-server "") (sql-port 0)) | 4054 | (sql-server "") (sql-port 0)) |
| 4041 | (eval `(let ,(cdr conn) (sql-make-alternate-buffer-name))))) | 4055 | (eval `(let ,(cdr conn) (sql-make-alternate-buffer-name))))) |
| 4042 | (list 'sql-connect (car conn)) | 4056 | (list 'sql-connect (car conn)) |
| 4043 | t)) | 4057 | t)) |
| 4044 | sql-connection-alist) | 4058 | sql-connection-alist) |
| 4045 | tail)) | 4059 | tail)) |
| 4046 | 4060 | ||
| 4047 | 4061 | ||
| 4048 | 4062 | ||
| 4049 | ;;; Entry functions for different SQL interpreters. | 4063 | ;;; Entry functions for different SQL interpreters. |
| 4050 | |||
| 4051 | ;;;###autoload | 4064 | ;;;###autoload |
| 4052 | (defun sql-product-interactive (&optional product new-name) | 4065 | (defun sql-product-interactive (&optional product new-name) |
| 4053 | "Run PRODUCT interpreter as an inferior process. | 4066 | "Run PRODUCT interpreter as an inferior process. |
| @@ -4140,7 +4153,7 @@ the call to \\[sql-product-interactive] with | |||
| 4140 | ;; All done. | 4153 | ;; All done. |
| 4141 | (message "Login...done") | 4154 | (message "Login...done") |
| 4142 | (pop-to-buffer new-sqli-buffer))))) | 4155 | (pop-to-buffer new-sqli-buffer))))) |
| 4143 | (message "No default SQL product defined. Set `sql-product'."))) | 4156 | (user-error "No default SQL product defined. Set `sql-product'."))) |
| 4144 | 4157 | ||
| 4145 | (defun sql-comint (product params) | 4158 | (defun sql-comint (product params) |
| 4146 | "Set up a comint buffer to run the SQL processor. | 4159 | "Set up a comint buffer to run the SQL processor. |
| @@ -4164,7 +4177,7 @@ passed as command line arguments." | |||
| 4164 | (setq buf-name (format "SQL-%s%d" product i)))) | 4177 | (setq buf-name (format "SQL-%s%d" product i)))) |
| 4165 | (setq i (1+ i)))))) | 4178 | (setq i (1+ i)))))) |
| 4166 | (set-buffer | 4179 | (set-buffer |
| 4167 | (apply 'make-comint buf-name program nil params)))) | 4180 | (apply #'make-comint buf-name program nil params)))) |
| 4168 | 4181 | ||
| 4169 | ;;;###autoload | 4182 | ;;;###autoload |
| 4170 | (defun sql-oracle (&optional buffer) | 4183 | (defun sql-oracle (&optional buffer) |
| @@ -4256,7 +4269,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4256 | ;; | 4269 | ;; |
| 4257 | 4270 | ||
| 4258 | (append | 4271 | (append |
| 4259 | ;; (apply 'concat (append | 4272 | ;; (apply #'concat (append |
| 4260 | ;; '("SET") | 4273 | ;; '("SET") |
| 4261 | 4274 | ||
| 4262 | ;; option value... | 4275 | ;; option value... |
| @@ -4304,8 +4317,8 @@ The default comes from `process-coding-system-alist' and | |||
| 4304 | 4317 | ||
| 4305 | ;; Remove any settings that haven't changed | 4318 | ;; Remove any settings that haven't changed |
| 4306 | (mapc | 4319 | (mapc |
| 4307 | (lambda (one-cur-setting) | 4320 | #'(lambda (one-cur-setting) |
| 4308 | (setq saved-settings (delete one-cur-setting saved-settings))) | 4321 | (setq saved-settings (delete one-cur-setting saved-settings))) |
| 4309 | (sql-oracle-save-settings sqlbuf)) | 4322 | (sql-oracle-save-settings sqlbuf)) |
| 4310 | 4323 | ||
| 4311 | ;; Restore the changed settings | 4324 | ;; Restore the changed settings |
| @@ -4822,10 +4835,10 @@ Try to set `comint-output-filter-functions' like this: | |||
| 4822 | (sql-redirect sqlbuf "\\a")) | 4835 | (sql-redirect sqlbuf "\\a")) |
| 4823 | 4836 | ||
| 4824 | ;; Return the list of table names (public schema name can be omitted) | 4837 | ;; Return the list of table names (public schema name can be omitted) |
| 4825 | (mapcar (lambda (tbl) | 4838 | (mapcar #'(lambda (tbl) |
| 4826 | (if (string= (car tbl) "public") | 4839 | (if (string= (car tbl) "public") |
| 4827 | (cadr tbl) | 4840 | (cadr tbl) |
| 4828 | (format "%s.%s" (car tbl) (cadr tbl)))) | 4841 | (format "%s.%s" (car tbl) (cadr tbl)))) |
| 4829 | cl)))) | 4842 | cl)))) |
| 4830 | 4843 | ||
| 4831 | 4844 | ||