bug#3175: 23.0.92; [PATCH] Improve SQL-mode UX

Ian Eure <[email protected]>
Newsgroups gmane.emacs.bugs,gmane.emacs.pretest.bugs
Message-ID <[email protected]>
The user experience when using sql-mode is somewhat lacking. In  
particular, the behaviors when using a SQLi buffer could be more  
helpful.

The attached patch:
  - Adds a default binding (C-c C-t) to sql-set-sqli-buffer
  - Directs the user to the function if they attempt to call sql-send- 
* with an unusable sql-buffer.
  - Updates sql-help to mention sql-set-sqli-buffer.
sql-ux.diff (application/octet-stream, 3.7 KB)
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index da0794b..ab2b884 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -771,6 +771,7 @@ Based on `comint-mode-map'.")
 
 (defvar sql-mode-map
   (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c C-t") 'sql-set-sqli-buffer)
     (define-key map (kbd "C-c C-c") 'sql-send-paragraph)
     (define-key map (kbd "C-c C-r") 'sql-send-region)
     (define-key map (kbd "C-c C-s") 'sql-send-string)
@@ -1917,7 +1918,9 @@ anything.  The name of the major mode is SQL.
 
 In this SQL buffer (SQL mode), you can send the region or the entire
 buffer to the interactive SQL buffer (SQLi mode).  The results are
-appended to the SQLi buffer without disturbing your SQL buffer."
+appended to the SQLi buffer without disturbing your SQL buffer.
+
+You may change the SQLi buffer by calling \\[sql-set-sqli-buffer]."
   (interactive)
   (describe-function 'sql-help))
 
@@ -2148,7 +2151,10 @@ Every newline in STRING will be preceded with a space and a backslash."
 ;;; Sending the region to the SQLi buffer.
 
 (defun sql-send-region (start end)
-  "Send a region to the SQL process."
+  "Send a region to the SQL process.
+
+The region is sent to the process in the buffer referred to in
+`sql-buffer', and may be changed with \\[sql-set-sqli-buffer]."
   (interactive "r")
   (if (buffer-live-p sql-buffer)
       (save-excursion
@@ -2160,10 +2166,14 @@ Every newline in STRING will be preceded with a space and a backslash."
 	(if sql-pop-to-buffer-after-send-region
 	    (pop-to-buffer sql-buffer)
 	  (display-buffer sql-buffer)))
-    (message "No SQL process started.")))
+    (message (substitute-command-keys
+              "No SQL process started. Try \\[sql-set-sqli-buffer]."))))
 
 (defun sql-send-paragraph ()
-  "Send the current paragraph to the SQL process."
+  "Send the current paragraph to the SQL process.
+
+The paragraph is sent to the process in the buffer referred to in
+`sql-buffer', and may be changed with \\[sql-set-sqli-buffer]."
   (interactive)
   (let ((start (save-excursion
 		 (backward-paragraph)
@@ -2174,12 +2184,18 @@ Every newline in STRING will be preceded with a space and a backslash."
     (sql-send-region start end)))
 
 (defun sql-send-buffer ()
-  "Send the buffer contents to the SQL process."
+  "Send the buffer contents to the SQL process.
+
+The buffer is sent to the process in the buffer referred to in
+`sql-buffer', and may be changed with \\[sql-set-sqli-buffer]."
   (interactive)
   (sql-send-region (point-min) (point-max)))
 
 (defun sql-send-string (str)
-  "Send a string to the SQL process."
+  "Send a string to the SQL process.
+
+The string is sent to the process in the buffer referred to in
+`sql-buffer', and may be changed with \\[sql-set-sqli-buffer]."
   (interactive "sSQL Text: ")
   (if (buffer-live-p sql-buffer)
       (save-excursion
@@ -2189,7 +2205,8 @@ Every newline in STRING will be preceded with a space and a backslash."
         (if sql-pop-to-buffer-after-send-region
             (pop-to-buffer sql-buffer)
           (display-buffer sql-buffer)))
-    (message "No SQL process started.")))
+    (message (substitute-command-keys
+              "No SQL process started. Try \\[sql-set-sqli-buffer]."))))
 
 (defun sql-toggle-pop-to-buffer-after-send-region (&optional value)
   "Toggle `sql-pop-to-buffer-after-send-region'.
@@ -2266,6 +2283,8 @@ you must tell Emacs.  Here's how to do that in your `~/.emacs' file:
   (run-mode-hooks 'sql-mode-hook)
   ;; Catch changes to sql-product and highlight accordingly
   (sql-highlight-product)
+  (setq mode-line-process '((:eval (when sql-buffer
+                                     (concat " > " (buffer-name sql-buffer))))))
   (add-hook 'hack-local-variables-hook 'sql-highlight-product t t))
 
 
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.