aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann1999-11-24 14:59:03 +0000
committerGerd Moellmann1999-11-24 14:59:03 +0000
commit46d94d0dfb254a2f663665a3d0d9f1fdc342ac40 (patch)
tree89664d9cd9f53c67a08d1a5d9839ccb2c6db21c5
parentfd6266202478e07a1a442edc76cc7dada7315843 (diff)
downloademacs-46d94d0dfb254a2f663665a3d0d9f1fdc342ac40.tar.gz
emacs-46d94d0dfb254a2f663665a3d0d9f1fdc342ac40.zip
(sql-find-sqli-buffer): New function.
(sql-set-sqli-buffer-generally): New function. (sql-set-sqli-buffer): Better checking of new-buffer. (sql-copy-column): Add comma after INTO clause, too. (sql-imenu-generic-expression): New, used to set imenu-generic-expression. (sql-mode): Use ?_ and ?. instead of 95 and 46 when setting font-lock-defaults' SYNTAX-ALIST. Set imenu-generic-expression, imenu-case-fold-search, and imenu-syntax-alist. (sql-interactive-mode): Use ?_ and ?. instead of 95 and 46 when setting font-lock-defaults' SYNTAX-ALIST.
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/progmodes/sql.el69
2 files changed, 81 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fff915096b9..8fdf096a87b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,23 @@
11999-11-24 Alex Schroeder <alex@gnu.org>
2
3 * sql.el (sql-find-sqli-buffer): New function.
4 (sql-set-sqli-buffer-generally): New function.
5 (sql-set-sqli-buffer): Better checking of new-buffer.
6 (sql-copy-column): Add comma after INTO clause, too.
7
81999-11-24 Alex Schroeder <alex@gnu.org>
9
10 * sql.el (sql-imenu-generic-expression): New, used to set
11 imenu-generic-expression.
12
13 * sql.el (sql-mode): Use ?_ and ?. instead of 95 and 46 when
14 setting font-lock-defaults' SYNTAX-ALIST. Set
15 imenu-generic-expression, imenu-case-fold-search, and
16 imenu-syntax-alist.
17
18 * sql.el (sql-interactive-mode): Use ?_ and ?. instead of 95
19 and 46 when setting font-lock-defaults' SYNTAX-ALIST.
20
11999-11-23 Andrew Innes <andrewi@gnu.org> 211999-11-23 Andrew Innes <andrewi@gnu.org>
2 22
3 * w32-win.el (w32-drag-n-drop): Load files in current window, if 23 * w32-win.el (w32-drag-n-drop): Load files in current window, if
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index f7defaf54e2..f3a1bb2a772 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -4,7 +4,7 @@
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.9 7;; Version: 1.4.10
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.
@@ -721,6 +721,48 @@ function like this: (sql-get-login 'user 'password 'database)."
721 (read-from-minibuffer "Database: " sql-database nil nil 721 (read-from-minibuffer "Database: " sql-database nil nil
722 sql-database-history)))) 722 sql-database-history))))
723 723
724(defun sql-find-sqli-buffer ()
725 "Return the current default SQLi buffer or nil.
726In order to qualify, the SQLi buffer must be alive,
727be in `sql-interactive-mode' and have a process."
728 (if (and (buffer-live-p (default-value 'sql-buffer))
729 (get-buffer-process (default-value 'sql-buffer)))
730 sql-buffer
731 (save-excursion
732 (let ((buflist (buffer-list))
733 (found))
734 (while (not (or (null buflist)
735 found))
736 (let ((candidate (car buflist)))
737 (set-buffer candidate)
738 (if (and (equal major-mode 'sql-interactive-mode)
739 (get-buffer-process candidate))
740 (setq found candidate))
741 (setq buflist (cdr buflist))))
742 found))))
743
744(defun sql-set-sqli-buffer-generally ()
745 "Set SQLi buffer for all SQL buffers that have none.
746This function checks all SQL buffers for their SQLi buffer. If their
747SQLi buffer is nonexistent or has no process, it is set to the current
748default SQLi buffer. The current default SQLi buffer is determined
749using `sql-find-sqli-buffer'. If `sql-buffer' is set,
750`sql-set-sqli-hook' is run."
751 (interactive)
752 (save-excursion
753 (let ((buflist (buffer-list))
754 (default-sqli-buffer (sql-find-sqli-buffer)))
755 (setq-default sql-buffer default-sqli-buffer)
756 (while (not (null buflist))
757 (let ((candidate (car buflist)))
758 (set-buffer candidate)
759 (if (and (equal major-mode 'sql-mode)
760 (not (buffer-live-p sql-buffer)))
761 (progn
762 (setq sql-buffer default-sqli-buffer)
763 (run-hooks 'sql-set-sqli-hook))))
764 (setq buflist (cdr buflist))))))
765
724(defun sql-set-sqli-buffer () 766(defun sql-set-sqli-buffer ()
725 "Set the SQLi buffer SQL strings are sent to. 767 "Set the SQLi buffer SQL strings are sent to.
726 768
@@ -734,11 +776,22 @@ If you call it from a SQL buffer, this sets the local copy of
734If you call it from anywhere else, it sets the global copy of 776If you call it from anywhere else, it sets the global copy of
735`sql-buffer'." 777`sql-buffer'."
736 (interactive) 778 (interactive)
737 (let ((new-buffer (get-buffer (read-buffer "New SQLi buffer: " nil t)))) 779 (let ((default-buffer (sql-find-sqli-buffer)))
738 (if new-buffer 780 (if (null default-buffer)
739 (progn 781 (error "There is no suitable SQLi buffer"))
740 (setq sql-buffer new-buffer) 782 (let ((new-buffer
741 (run-hooks 'sql-set-sqli-hook))))) 783 (get-buffer
784 (read-buffer "New SQLi buffer: " default-buffer t))))
785 (if (null (get-buffer-process new-buffer))
786 (error "Buffer %s has no process" (buffer-name new-buffer)))
787 (if (null (save-excursion
788 (set-buffer new-buffer)
789 (equal major-mode 'sql-interactive-mode)))
790 (error "Buffer %s is no SQLi buffer" (buffer-name new-buffer)))
791 (if new-buffer
792 (progn
793 (setq sql-buffer new-buffer)
794 (run-hooks 'sql-set-sqli-hook))))))
742 795
743(defun sql-show-sqli-buffer () 796(defun sql-show-sqli-buffer ()
744 "Show the name of current SQLi buffer. 797 "Show the name of current SQLi buffer.
@@ -788,9 +841,9 @@ Inserts SELECT or commas if appropriate."
788 ((save-excursion (beginning-of-line) 841 ((save-excursion (beginning-of-line)
789 (looking-at (concat comint-prompt-regexp "$"))) 842 (looking-at (concat comint-prompt-regexp "$")))
790 (insert "SELECT ")) 843 (insert "SELECT "))
791 ;; else if appending to SELECT or ORDER BY, insert a comma 844 ;; else if appending to INTO .* (, SELECT or ORDER BY, insert a comma
792 ((save-excursion 845 ((save-excursion
793 (re-search-backward "\\b\\(select\\|order by\\) .+" 846 (re-search-backward "\\b\\(\\(into\\s-+\\S-+\\s-+(\\)\\|select\\|order by\\) .+"
794 (save-excursion (beginning-of-line) (point)) t)) 847 (save-excursion (beginning-of-line) (point)) t))
795 (insert ", ")) 848 (insert ", "))
796 ;; else insert a space 849 ;; else insert a space