diff options
Diffstat (limited to 'lisp/progmodes/sql.el')
| -rw-r--r-- | lisp/progmodes/sql.el | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 453386cdba5..781aa241802 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -723,15 +723,15 @@ this variable is nil, that buffer is shown using | |||
| 723 | 723 | ||
| 724 | (defvar sql-imenu-generic-expression | 724 | (defvar sql-imenu-generic-expression |
| 725 | ;; Items are in reverse order because they are rendered in reverse. | 725 | ;; Items are in reverse order because they are rendered in reverse. |
| 726 | '(("Rules/Defaults" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:rule\\|default\\)\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\s-+\\(\\w+\\)" 1) | 726 | '(("Rules/Defaults" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:rule\\|default\\)\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\s-+\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 727 | ("Sequences" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*sequence\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 727 | ("Sequences" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*sequence\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 728 | ("Triggers" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*trigger\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 728 | ("Triggers" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*trigger\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 729 | ("Functions" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?function\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 729 | ("Functions" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?function\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 730 | ("Procedures" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?proc\\(?:edure\\)?\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 730 | ("Procedures" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?proc\\(?:edure\\)?\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 731 | ("Packages" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*package\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 731 | ("Packages" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*package\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 732 | ("Types" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*type\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 732 | ("Types" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*type\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 733 | ("Indexes" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*index\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1) | 733 | ("Indexes" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*index\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1) |
| 734 | ("Tables/Views" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:table\\|view\\)\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)) | 734 | ("Tables/Views" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:table\\|view\\)\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\(?:\\w+\\s-*[.]\\s-*\\)*\\w+\\)" 1)) |
| 735 | "Define interesting points in the SQL buffer for `imenu'. | 735 | "Define interesting points in the SQL buffer for `imenu'. |
| 736 | 736 | ||
| 737 | This is used to set `imenu-generic-expression' when SQL mode is | 737 | This is used to set `imenu-generic-expression' when SQL mode is |
| @@ -1313,7 +1313,7 @@ Based on `comint-mode-map'.") | |||
| 1313 | "\\(?:table\\|view\\|\\(?:package\\|type\\)\\(?:\\s-+body\\)?\\|proc\\(?:edure\\)?" | 1313 | "\\(?:table\\|view\\|\\(?:package\\|type\\)\\(?:\\s-+body\\)?\\|proc\\(?:edure\\)?" |
| 1314 | "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+" | 1314 | "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+" |
| 1315 | "\\(?:if\\s-+not\\s-+exists\\s-+\\)?" ;; IF NOT EXISTS | 1315 | "\\(?:if\\s-+not\\s-+exists\\s-+\\)?" ;; IF NOT EXISTS |
| 1316 | "\\(\\w+\\)") | 1316 | "\\(\\w+\\(?:\\s-*[.]\\s-*\\w+\\)*\\)") |
| 1317 | 1 'font-lock-function-name-face)) | 1317 | 1 'font-lock-function-name-face)) |
| 1318 | 1318 | ||
| 1319 | "Pattern to match the names of top-level objects. | 1319 | "Pattern to match the names of top-level objects. |
| @@ -3219,9 +3219,6 @@ Every newline in STRING will be preceded with a space and a backslash." | |||
| 3219 | 3219 | ||
| 3220 | Allows the suppression of continuation prompts.") | 3220 | Allows the suppression of continuation prompts.") |
| 3221 | 3221 | ||
| 3222 | (defvar sql-output-by-send nil | ||
| 3223 | "Non-nil if the command in the input was generated by `sql-send-string'.") | ||
| 3224 | |||
| 3225 | (defun sql-input-sender (proc string) | 3222 | (defun sql-input-sender (proc string) |
| 3226 | "Send STRING to PROC after applying filters." | 3223 | "Send STRING to PROC after applying filters." |
| 3227 | 3224 | ||
| @@ -3288,8 +3285,7 @@ to avoid deleting non-prompt output." | |||
| 3288 | 3285 | ||
| 3289 | (if (= sql-output-newline-count 0) | 3286 | (if (= sql-output-newline-count 0) |
| 3290 | (setq sql-output-newline-count nil | 3287 | (setq sql-output-newline-count nil |
| 3291 | oline (concat "\n" oline) | 3288 | oline (concat "\n" oline)) |
| 3292 | sql-output-by-send nil) | ||
| 3293 | 3289 | ||
| 3294 | (setq sql-preoutput-hold oline | 3290 | (setq sql-preoutput-hold oline |
| 3295 | oline "")) | 3291 | oline "")) |
| @@ -3383,8 +3379,7 @@ to avoid deleting non-prompt output." | |||
| 3383 | (setq sql-output-newline-count | 3379 | (setq sql-output-newline-count |
| 3384 | (if sql-output-newline-count | 3380 | (if sql-output-newline-count |
| 3385 | (1+ sql-output-newline-count) | 3381 | (1+ sql-output-newline-count) |
| 3386 | 1))) | 3382 | 1))))) |
| 3387 | (setq sql-output-by-send t))) | ||
| 3388 | 3383 | ||
| 3389 | (defun sql-remove-tabs-filter (str) | 3384 | (defun sql-remove-tabs-filter (str) |
| 3390 | "Replace tab characters with spaces." | 3385 | "Replace tab characters with spaces." |
| @@ -3857,7 +3852,6 @@ you entered, right above the output it created. | |||
| 3857 | (sql-get-product-feature sql-product :prompt-cont-regexp)) | 3852 | (sql-get-product-feature sql-product :prompt-cont-regexp)) |
| 3858 | (make-local-variable 'sql-output-newline-count) | 3853 | (make-local-variable 'sql-output-newline-count) |
| 3859 | (make-local-variable 'sql-preoutput-hold) | 3854 | (make-local-variable 'sql-preoutput-hold) |
| 3860 | (make-local-variable 'sql-output-by-send) | ||
| 3861 | (add-hook 'comint-preoutput-filter-functions | 3855 | (add-hook 'comint-preoutput-filter-functions |
| 3862 | 'sql-interactive-remove-continuation-prompt nil t) | 3856 | 'sql-interactive-remove-continuation-prompt nil t) |
| 3863 | (make-local-variable 'sql-input-ring-separator) | 3857 | (make-local-variable 'sql-input-ring-separator) |
| @@ -3930,7 +3924,7 @@ is specified in the connection settings." | |||
| 3930 | ;; Was one selected | 3924 | ;; Was one selected |
| 3931 | (when connection | 3925 | (when connection |
| 3932 | ;; Get connection settings | 3926 | ;; Get connection settings |
| 3933 | (let ((connect-set (assoc connection sql-connection-alist))) | 3927 | (let ((connect-set (assoc-string connection sql-connection-alist t))) |
| 3934 | ;; Settings are defined | 3928 | ;; Settings are defined |
| 3935 | (if connect-set | 3929 | (if connect-set |
| 3936 | ;; Set the desired parameters | 3930 | ;; Set the desired parameters |
| @@ -4134,9 +4128,17 @@ the call to \\[sql-product-interactive] with | |||
| 4134 | (setq sql-buffer (buffer-name new-sqli-buffer)) | 4128 | (setq sql-buffer (buffer-name new-sqli-buffer)) |
| 4135 | (run-hooks 'sql-set-sqli-hook))) | 4129 | (run-hooks 'sql-set-sqli-hook))) |
| 4136 | 4130 | ||
| 4131 | ;; Make sure the connection is complete | ||
| 4132 | ;; (Sometimes start up can be slow) | ||
| 4133 | ;; and call the login hook | ||
| 4134 | (let ((proc (get-buffer-process new-sqli-buffer))) | ||
| 4135 | (while (and (memq (process-status proc) '(open run)) | ||
| 4136 | (accept-process-output proc 2.5) | ||
| 4137 | (progn (goto-char (point-max)) | ||
| 4138 | (not (looking-back sql-prompt-regexp)))))) | ||
| 4139 | (run-hooks 'sql-login-hook) | ||
| 4137 | ;; All done. | 4140 | ;; All done. |
| 4138 | (message "Login...done") | 4141 | (message "Login...done") |
| 4139 | (run-hooks 'sql-login-hook) | ||
| 4140 | (pop-to-buffer new-sqli-buffer))))) | 4142 | (pop-to-buffer new-sqli-buffer))))) |
| 4141 | (message "No default SQL product defined. Set `sql-product'."))) | 4143 | (message "No default SQL product defined. Set `sql-product'."))) |
| 4142 | 4144 | ||
| @@ -4202,7 +4204,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4202 | ;; is meaningless; database without user/password is meaningless, | 4204 | ;; is meaningless; database without user/password is meaningless, |
| 4203 | ;; because "@param" will ask sqlplus to interpret the script | 4205 | ;; because "@param" will ask sqlplus to interpret the script |
| 4204 | ;; "param". | 4206 | ;; "param". |
| 4205 | (let ((parameter nil)) | 4207 | (let (parameter nlslang coding) |
| 4206 | (if (not (string= "" sql-user)) | 4208 | (if (not (string= "" sql-user)) |
| 4207 | (if (not (string= "" sql-password)) | 4209 | (if (not (string= "" sql-password)) |
| 4208 | (setq parameter (concat sql-user "/" sql-password)) | 4210 | (setq parameter (concat sql-user "/" sql-password)) |
| @@ -4212,7 +4214,29 @@ The default comes from `process-coding-system-alist' and | |||
| 4212 | (if parameter | 4214 | (if parameter |
| 4213 | (setq parameter (nconc (list parameter) options)) | 4215 | (setq parameter (nconc (list parameter) options)) |
| 4214 | (setq parameter options)) | 4216 | (setq parameter options)) |
| 4215 | (sql-comint product parameter))) | 4217 | (sql-comint product parameter) |
| 4218 | ;; Set process coding system to agree with the interpreter | ||
| 4219 | (setq nlslang (or (getenv "NLS_LANG") "") | ||
| 4220 | coding (dolist (cs | ||
| 4221 | ;; Are we missing any common NLS character sets | ||
| 4222 | '(("US8PC437" . cp437) | ||
| 4223 | ("EL8PC737" . cp737) | ||
| 4224 | ("WE8PC850" . cp850) | ||
| 4225 | ("EE8PC852" . cp852) | ||
| 4226 | ("TR8PC857" . cp857) | ||
| 4227 | ("WE8PC858" . cp858) | ||
| 4228 | ("IS8PC861" . cp861) | ||
| 4229 | ("IW8PC1507" . cp862) | ||
| 4230 | ("N8PC865" . cp865) | ||
| 4231 | ("RU8PC866" . cp866) | ||
| 4232 | ("US7ASCII" . us-ascii) | ||
| 4233 | ("UTF8" . utf-8) | ||
| 4234 | ("AL32UTF8" . utf-8) | ||
| 4235 | ("AL16UTF16" . utf-16)) | ||
| 4236 | (or coding 'utf-8)) | ||
| 4237 | (when (string-match (format "\\.%s\\'" (car cs)) nlslang) | ||
| 4238 | (setq coding (cdr cs))))) | ||
| 4239 | (set-buffer-process-coding-system coding coding))) | ||
| 4216 | 4240 | ||
| 4217 | (defun sql-oracle-save-settings (sqlbuf) | 4241 | (defun sql-oracle-save-settings (sqlbuf) |
| 4218 | "Save most SQL*Plus settings so they may be reset by \\[sql-redirect]." | 4242 | "Save most SQL*Plus settings so they may be reset by \\[sql-redirect]." |