From c386183291a47857317139a7cf49b547d57b89e7 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 13 May 2022 13:44:27 +0200 Subject: [PATCH] add bba-edit-sql Use edit-indirect-region to edit embedded sql code. Signed-off-by: Andreas Gerler --- bba.org | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bba.org b/bba.org index 8278cb5b..4cf2728f 100644 --- a/bba.org +++ b/bba.org @@ -1368,6 +1368,30 @@ Get reveal.js as well: (goto-char (point-min)) (flush-lines "^$")) #+END_SRC + +** bba-edit-sql +[2022-05-13 Fri 13:23] + +use edit-indirect-region to zoom into a END_PREPARE region in +sql-mode. Handy for embedded SQL in Perl. + +#+begin_src emacs-lisp + (defun bba-edit-sql () + "Find the region between previous END_PREPARE and the one after it. + Open that block in edit-indirect-region and switch to sql-mode." + (interactive) + (save-mark-and-excursion + (search-backward "END_PREPARE") + (next-line) + (beginning-of-line) + (set-mark-command nil) + (search-forward "END_PREPARE") + (beginning-of-line) + (edit-indirect-region (mark) (point) t) + (sql-mode) + )) + (global-set-key (kbd "s-S") 'bba-edit-sql) +#+end_src ** search notes [2018-02-09 Fri 10:57] -- 2.47.3