[sql] Add send line functions

Add wrappers forcing non-pop commands to not pop to the SQLi buffer
This commit is contained in:
benbotwin 2018-10-26 11:39:08 -04:00 committed by duianto
parent ffffb90868
commit d1934f8e30
3 changed files with 59 additions and 14 deletions

View File

@ -2274,6 +2274,11 @@ Other:
- Added a code formatter for sql-mode (thanks to Seong Yong-ju)
- Added connection between =org-mode= and =SQL layer= (thanks to Magnus Therning)
- Added default jump handlers for SQL layer (thanks to Alex Palaistras)
- Added send line functions/key bindings (thanks to benbotwin):
- ~SPC m s l~ Send the current line to the SQLi buffer and move to the next
line =insert state=
- ~SPC m s L~ Send the current line to the SQLi buffer and move to the next
line and switch to it in =insert state=
**** Spell-checking
- Added spell checking transient state (thanks to Francesc Elies Henar)
- Update to flyspell-correct v0.5 (thanks to Boris Buliga)

View File

@ -116,17 +116,19 @@ auto-indent by setting the variable =sql-auto-indent= to =nil=.
*** Send SQL queries to SQLi:
| Key binding | Description |
|-------------+---------------------------------------------------------------------------------------|
| ~SPC m s b~ | Send the whole buffer to the SQLi buffer |
| ~SPC m s B~ | Send the whole buffer to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s i~ | Start the SQLi process |
| ~SPC m s f~ | Send the paragraph around point to the SQLi buffer |
| ~SPC m s F~ | Send the paragraph around point to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s q~ | Prompt for a string to send to the SQLi buffer |
| ~SPC m s Q~ | Prompt for a string to send to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s r~ | Send the selected region to the SQLi buffer |
| ~SPC m s R~ | Send the selected region to the SQLi buffer and switch to it in =insert state= |
| Key binding | Description |
|-------------+-------------------------------------------------------------------------------------------------------|
| ~SPC m s b~ | Send the whole buffer to the SQLi buffer |
| ~SPC m s B~ | Send the whole buffer to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s i~ | Start the SQLi process |
| ~SPC m s f~ | Send the paragraph around point to the SQLi buffer |
| ~SPC m s F~ | Send the paragraph around point to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s l~ | Send the current line to the SQLi buffer and move to the next line =insert state= |
| ~SPC m s L~ | Send the current line to the SQLi buffer and move to the next line and switch to it in =insert state= |
| ~SPC m s q~ | Prompt for a string to send to the SQLi buffer |
| ~SPC m s Q~ | Prompt for a string to send to the SQLi buffer and switch to it in =insert state= |
| ~SPC m s r~ | Send the selected region to the SQLi buffer |
| ~SPC m s R~ | Send the selected region to the SQLi buffer and switch to it in =insert state= |
** SQLi buffer

View File

@ -93,6 +93,42 @@
(sql-send-region start end)
(evil-insert-state)))
(defun spacemacs/sql-send-line-and-next-and-focus ()
"Send the current line to SQLi and switch to SQLi in `insert state'."
(interactive)
(let ((sql-pop-to-buffer-after-send-region t))
(sql-send-line-and-next)))
(defun spacemacs/sql-send-string ()
"Send a string to SQLi and stays in the same region."
(interactive)
(let ((sql-pop-to-buffer-after-send-region nil))
(call-interactively 'sql-send-string)))
(defun spacemacs/sql-send-buffer ()
"Send the buffer to SQLi and stays in the same region."
(interactive)
(let ((sql-pop-to-buffer-after-send-region nil))
(sql-send-buffer)))
(defun spacemacs/sql-send-paragraph ()
"Send the paragraph to SQLi and stays in the same region."
(interactive)
(let ((sql-pop-to-buffer-after-send-region nil))
(sql-send-paragraph)))
(defun spacemacs/sql-send-region (start end)
"Send region to SQLi and stays in the same region."
(interactive "r")
(let ((sql-pop-to-buffer-after-send-region nil))
(sql-send-region start end)))
(defun spacemacs/sql-send-line-and-next ()
"Send the current line to SQLi and stays in the same region."
(interactive)
(let ((sql-pop-to-buffer-after-send-region nil))
(sql-send-line-and-next)))
(spacemacs/declare-prefix-for-mode 'sql-mode "mb" "buffer")
(spacemacs/declare-prefix-for-mode 'sql-mode "mh" "dialects")
(spacemacs/declare-prefix-for-mode 'sql-mode "ms" "interactivity")
@ -114,11 +150,13 @@
;; paragraph gets "f" here because they can be assimilated to functions.
;; If you separate your commands in a SQL file, this key will send the
;; command around point, which is what you probably want.
"sf" 'sql-send-paragraph
"sf" 'spacemacs/sql-send-paragraph
"sF" 'spacemacs/sql-send-paragraph-and-focus
"sq" 'sql-send-string
"sl" 'spacemacs/sql-send-line-and-next
"sL" 'spacemacs/sql-send-line-and-next-and-focus
"sq" 'spacemacs/sql-send-string
"sQ" 'spacemacs/sql-send-string-and-focus
"sr" 'sql-send-region
"sr" 'spacemacs/sql-send-region
"sR" 'spacemacs/sql-send-region-and-focus
;; listing