aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/sql.el106
2 files changed, 64 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1195eb12757..d0256ff94b2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12014-11-01 Michael R. Mauger <michael@mauger.com> 12014-11-01 Michael R. Mauger <michael@mauger.com>
2 2
3 * sql.el (sql-mode-oracle-font-lock-keywords): Correct regexp
4 syntax, add new keywords, and parse longer keywords first.
5 (sql-redirect-one): Protect against empty command.
6 (sql-mode, sql-interactive-mode): Set `custom-mode-group' property
7 to SQL. (Bug#14759)
8
92014-11-01 Michael R. Mauger <michael@mauger.com>
10
3 * sql.el (sql-interactive-mode, sql-stop): Correct fix for 11 * sql.el (sql-interactive-mode, sql-stop): Correct fix for
4 Bug#16814 with let-bind of comint-input-ring variables around read 12 Bug#16814 with let-bind of comint-input-ring variables around read
5 and save functions. 13 and save functions.
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 04dc22ffdac..e8a95eccdd2 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -1577,8 +1577,6 @@ to add functions and PL/SQL keywords.")
1577 ;; Oracle SQL*Plus Commands 1577 ;; Oracle SQL*Plus Commands
1578 ;; Only recognized in they start in column 1 and the 1578 ;; Only recognized in they start in column 1 and the
1579 ;; abbreviation is followed by a space or the end of line. 1579 ;; abbreviation is followed by a space or the end of line.
1580
1581 "\\|"
1582 (list (concat "^" (sql-regexp-abbrev "rem~ark") "\\(?:\\s-.*\\)?$") 1580 (list (concat "^" (sql-regexp-abbrev "rem~ark") "\\(?:\\s-.*\\)?$")
1583 0 'font-lock-comment-face t) 1581 0 'font-lock-comment-face t)
1584 1582
@@ -1626,6 +1624,11 @@ to add functions and PL/SQL keywords.")
1626 0 'font-lock-doc-face t) 1624 0 'font-lock-doc-face t)
1627 '("&?&\\(?:\\sw\\|\\s_\\)+[.]?" 0 font-lock-preprocessor-face t) 1625 '("&?&\\(?:\\sw\\|\\s_\\)+[.]?" 0 font-lock-preprocessor-face t)
1628 1626
1627 ;; Oracle PL/SQL Attributes (Declare these first to match %TYPE correctly)
1628 (sql-font-lock-keywords-builder 'font-lock-builtin-face '("%" . "\\b")
1629"bulk_exceptions" "bulk_rowcount" "found" "isopen" "notfound"
1630"rowcount" "rowtype" "type"
1631)
1629 ;; Oracle Functions 1632 ;; Oracle Functions
1630 (sql-font-lock-keywords-builder 'font-lock-builtin-face nil 1633 (sql-font-lock-keywords-builder 'font-lock-builtin-face nil
1631"abs" "acos" "add_months" "appendchildxml" "ascii" "asciistr" "asin" 1634"abs" "acos" "add_months" "appendchildxml" "ascii" "asciistr" "asin"
@@ -1655,7 +1658,7 @@ to add functions and PL/SQL keywords.")
1655"prediction" "prediction_bounds" "prediction_cost" 1658"prediction" "prediction_bounds" "prediction_cost"
1656"prediction_details" "prediction_probability" "prediction_set" 1659"prediction_details" "prediction_probability" "prediction_set"
1657"presentnnv" "presentv" "previous" "rank" "ratio_to_report" "rawtohex" 1660"presentnnv" "presentv" "previous" "rank" "ratio_to_report" "rawtohex"
1658"rawtonhex" "ref" "reftohex" "regexp_count" "regexp_instr" 1661"rawtonhex" "ref" "reftohex" "regexp_count" "regexp_instr" "regexp_like"
1659"regexp_replace" "regexp_substr" "regr_avgx" "regr_avgy" "regr_count" 1662"regexp_replace" "regexp_substr" "regr_avgx" "regr_avgy" "regr_count"
1660"regr_intercept" "regr_r2" "regr_slope" "regr_sxx" "regr_sxy" 1663"regr_intercept" "regr_r2" "regr_slope" "regr_sxx" "regr_sxy"
1661"regr_syy" "remainder" "replace" "round" "rowidtochar" "rowidtonchar" 1664"regr_syy" "remainder" "replace" "round" "rowidtochar" "rowidtonchar"
@@ -1740,7 +1743,7 @@ to add functions and PL/SQL keywords.")
1740"password_life_time" "password_lock_time" "password_reuse_max" 1743"password_life_time" "password_lock_time" "password_reuse_max"
1741"password_reuse_time" "password_verify_function" "pctfree" 1744"password_reuse_time" "password_verify_function" "pctfree"
1742"pctincrease" "pctthreshold" "pctused" "pctversion" "percent" 1745"pctincrease" "pctthreshold" "pctused" "pctversion" "percent"
1743"performance" "permanent" "pfile" "physical" "pipelined" "plan" 1746"performance" "permanent" "pfile" "physical" "pipelined" "pivot" "plan"
1744"post_transaction" "pragma" "prebuilt" "preserve" "primary" "private" 1747"post_transaction" "pragma" "prebuilt" "preserve" "primary" "private"
1745"private_sga" "privileges" "procedure" "profile" "protection" "public" 1748"private_sga" "privileges" "procedure" "profile" "protection" "public"
1746"purge" "query" "quiesce" "quota" "range" "read" "reads" "rebuild" 1749"purge" "query" "quiesce" "quota" "range" "read" "reads" "rebuild"
@@ -1763,7 +1766,7 @@ to add functions and PL/SQL keywords.")
1763"temporary" "test" "than" "then" "thread" "through" "time_zone" 1766"temporary" "test" "than" "then" "thread" "through" "time_zone"
1764"timeout" "to" "trace" "transaction" "trigger" "triggers" "truncate" 1767"timeout" "to" "trace" "transaction" "trigger" "triggers" "truncate"
1765"trust" "type" "types" "unarchived" "under" "under_path" "undo" 1768"trust" "type" "types" "unarchived" "under" "under_path" "undo"
1766"uniform" "union" "unique" "unlimited" "unlock" "unquiesce" 1769"uniform" "union" "unique" "unlimited" "unlock" "unpivot" "unquiesce"
1767"unrecoverable" "until" "unusable" "unused" "update" "upgrade" "usage" 1770"unrecoverable" "until" "unusable" "unused" "update" "upgrade" "usage"
1768"use" "using" "validate" "validation" "value" "values" "variable" 1771"use" "using" "validate" "validation" "value" "values" "variable"
1769"varray" "version" "view" "wait" "when" "whenever" "where" "with" 1772"varray" "version" "view" "wait" "when" "whenever" "where" "with"
@@ -1778,12 +1781,6 @@ to add functions and PL/SQL keywords.")
1778"time" "timestamp" "urowid" "varchar2" "with" "year" "zone" 1781"time" "timestamp" "urowid" "varchar2" "with" "year" "zone"
1779) 1782)
1780 1783
1781 ;; Oracle PL/SQL Attributes
1782 (sql-font-lock-keywords-builder 'font-lock-builtin-face '("%" . "\\b")
1783"bulk_exceptions" "bulk_rowcount" "found" "isopen" "notfound"
1784"rowcount" "rowtype" "type"
1785)
1786
1787 ;; Oracle PL/SQL Functions 1784 ;; Oracle PL/SQL Functions
1788 (sql-font-lock-keywords-builder 'font-lock-builtin-face nil 1785 (sql-font-lock-keywords-builder 'font-lock-builtin-face nil
1789"delete" "trim" "extend" "exists" "first" "last" "count" "limit" 1786"delete" "trim" "extend" "exists" "first" "last" "count" "limit"
@@ -3507,45 +3504,51 @@ list of SQLi command strings."
3507 (message "Executing SQL command...done")))) 3504 (message "Executing SQL command...done"))))
3508 3505
3509(defun sql-redirect-one (sqlbuf command outbuf save-prior) 3506(defun sql-redirect-one (sqlbuf command outbuf save-prior)
3510 (with-current-buffer sqlbuf 3507 (when command
3511 (let ((buf (get-buffer-create (or outbuf " *SQL-Redirect*"))) 3508 (with-current-buffer sqlbuf
3512 (proc (get-buffer-process (current-buffer))) 3509 (let ((buf (get-buffer-create (or outbuf " *SQL-Redirect*")))
3513 (comint-prompt-regexp (sql-get-product-feature sql-product 3510 (proc (get-buffer-process (current-buffer)))
3514 :prompt-regexp)) 3511 (comint-prompt-regexp (sql-get-product-feature sql-product
3515 (start nil)) 3512 :prompt-regexp))
3516 (with-current-buffer buf 3513 (start nil))
3517 (setq-local view-no-disable-on-exit t) 3514 (with-current-buffer buf
3518 (read-only-mode -1) 3515 (setq-local view-no-disable-on-exit t)
3519 (unless save-prior 3516 (read-only-mode -1)
3520 (erase-buffer)) 3517 (unless save-prior
3521 (goto-char (point-max)) 3518 (erase-buffer))
3522 (unless (zerop (buffer-size)) 3519 (goto-char (point-max))
3523 (insert "\n")) 3520 (unless (zerop (buffer-size))
3524 (setq start (point))) 3521 (insert "\n"))
3525 3522 (setq start (point)))
3526 (when sql-debug-redirect 3523
3527 (message ">>SQL> %S" command)) 3524 (when sql-debug-redirect
3528 3525 (message ">>SQL> %S" command))
3529 ;; Run the command 3526
3530 (comint-redirect-send-command-to-process command buf proc nil t) 3527 ;; Run the command
3531 (while (null comint-redirect-completed) 3528 (let ((inhibit-quit t)
3532 (accept-process-output nil 1)) 3529 comint-preoutput-filter-functions)
3533 3530 (with-local-quit
3534 ;; Clean up the output results 3531 (comint-redirect-send-command-to-process command buf proc nil t)
3535 (with-current-buffer buf 3532 (while (or quit-flag (null comint-redirect-completed))
3536 ;; Remove trailing whitespace 3533 (accept-process-output nil 1)))
3537 (goto-char (point-max)) 3534
3538 (when (looking-back "[ \t\f\n\r]*" start) 3535 (if quit-flag
3539 (delete-region (match-beginning 0) (match-end 0))) 3536 (comint-redirect-cleanup)
3540 ;; Remove echo if there was one 3537 ;; Clean up the output results
3541 (goto-char start) 3538 (with-current-buffer buf
3542 (when (looking-at (concat "^" (regexp-quote command) "[\\n]")) 3539 ;; Remove trailing whitespace
3543 (delete-region (match-beginning 0) (match-end 0))) 3540 (goto-char (point-max))
3544 ;; Remove Ctrl-Ms 3541 (when (looking-back "[ \t\f\n\r]*" start)
3545 (goto-char start) 3542 (delete-region (match-beginning 0) (match-end 0)))
3546 (while (re-search-forward "\r+$" nil t) 3543 ;; Remove echo if there was one
3547 (replace-match "" t t)) 3544 (goto-char start)
3548 (goto-char start))))) 3545 (when (looking-at (concat "^" (regexp-quote command) "[\\n]"))
3546 (delete-region (match-beginning 0) (match-end 0)))
3547 ;; Remove Ctrl-Ms
3548 (goto-char start)
3549 (while (re-search-forward "\r+$" nil t)
3550 (replace-match "" t t))
3551 (goto-char start))))))))
3549 3552
3550(defun sql-redirect-value (sqlbuf command regexp &optional regexp-groups) 3553(defun sql-redirect-value (sqlbuf command regexp &optional regexp-groups)
3551 "Execute the SQL command and return part of result. 3554 "Execute the SQL command and return part of result.
@@ -3786,7 +3789,9 @@ must tell Emacs. Here's how to do that in your init file:
3786\(add-hook 'sql-mode-hook 3789\(add-hook 'sql-mode-hook
3787 (lambda () 3790 (lambda ()
3788 (modify-syntax-entry ?\\\\ \".\" sql-mode-syntax-table)))" 3791 (modify-syntax-entry ?\\\\ \".\" sql-mode-syntax-table)))"
3792 :group 'SQL
3789 :abbrev-table sql-mode-abbrev-table 3793 :abbrev-table sql-mode-abbrev-table
3794
3790 (if sql-mode-menu 3795 (if sql-mode-menu
3791 (easy-menu-add sql-mode-menu)); XEmacs 3796 (easy-menu-add sql-mode-menu)); XEmacs
3792 3797
@@ -3817,6 +3822,7 @@ must tell Emacs. Here's how to do that in your init file:
3817;;; SQL interactive mode 3822;;; SQL interactive mode
3818 3823
3819(put 'sql-interactive-mode 'mode-class 'special) 3824(put 'sql-interactive-mode 'mode-class 'special)
3825(put 'sql-interactive-mode 'custom-mode-group 'SQL)
3820 3826
3821(defun sql-interactive-mode () 3827(defun sql-interactive-mode ()
3822 "Major mode to use a SQL interpreter interactively. 3828 "Major mode to use a SQL interpreter interactively.