# HG changeset patch # User Oleksandr Gavenko # Date 1453576116 -7200 # Node ID 08ca6cc08d2c906d177e8f599b12d4af876ec66f # Parent 2806c88dc25a1d1873d85f1fd28aaf0d6b29debb Send the current paragraph to the SQL process with \"explain \" keyword. Works at least for MySql/MariaDB. diff -r 2806c88dc25a -r 08ca6cc08d2c .emacs-my --- a/.emacs-my Sat Jan 09 23:19:24 2016 +0200 +++ b/.emacs-my Sat Jan 23 21:08:36 2016 +0200 @@ -3095,6 +3095,20 @@ (add-hook 'sql-interactive-mode-hook (lambda () (toggle-truncate-lines 1))) +(defun my-sql-explain-paragraph () + "Send the current paragraph to the SQL process with \"explain \" keyword. +Works at least for MySql/MariaDB." + (interactive) + (let ((start (save-excursion + (backward-paragraph) + (point))) + (end (save-excursion + (forward-paragraph) + (point)))) + (sql-send-string (concat "explain " (buffer-substring-no-properties start end))))) +(eval-after-load 'sql-mode + (define-key sql-mode-map (kbd "C-c C-e") 'my-sql-explain-paragraph)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "backuping")