From 63d715db9d002929f38e4cede10f106bc767e208 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Wed, 15 Mar 2017 11:30:57 +0100 Subject: [PATCH] added bba-copy-and-yank-org-src-block - added bba-copy-and-yank-org-src-block without messing kill-ring. - modified bba-copy-org-src-block to just copy the current block around cursor. Signed-off-by: Andreas Gerler --- bba.org | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/bba.org b/bba.org index 1b18c0f8..21203a9a 100644 --- a/bba.org +++ b/bba.org @@ -1024,7 +1024,7 @@ Very useful for repetitive literate devops jobs. This is helpful in training sessions. #+BEGIN_SRC emacs-lisp :tangle yes - (defun bba-copy-org-src-block() + (defun bba-copy-and-yank-org-src-block() "copy last org src block and insert it at point." (interactive) (push-mark) @@ -1036,12 +1036,30 @@ This is helpful in training sessions. (kill-ring-save 1 1 1) (set-mark-command '1) (set-mark-command '1) - (yank) + (insert (pop kill-ring)) + (re-search-backward "\#\\+BEGIN_SRC") + (forward-line) + ) + + (defun bba-copy-org-src-block() + "copy last org src block and insert it at point." + (interactive) + (push-mark) (re-search-backward "\#\\+BEGIN_SRC") + (set-mark-command nil) + (re-search-forward "\#\\+END_SRC") (forward-line) + (beginning-of-line) + (kill-ring-save 1 1 1) + (set-mark-command '1) + (set-mark-command '1) ) - (define-key org-mode-map "\C-c\S-w" 'bba-copy-org-src-block) + (define-key org-mode-map "\C-c\S-w" 'bba-copy-and-yank-org-src-block) + (define-key org-mode-map (kbd "C-c s-w") 'bba-copy-org-src-block) + +#+END_SRC + #+END_SRC ** tmux capture-pane -- 2.47.3