]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added bba-copy-org-src-block
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 25 Aug 2016 21:45:40 +0000 (23:45 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 25 Aug 2016 21:45:40 +0000 (23:45 +0200)
- useful in training sessions to duplicate previous org src block.

bba.org

diff --git a/bba.org b/bba.org
index 8348ec8bae069b4ca53e0f1850975ad6a3075133..7b5cf0502cfcfe5577224a40c0bebacc82039255 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -871,6 +871,32 @@ Very useful for repetitive literate devops jobs.
 
 #+END_SRC
 
+
+** copy previous src block
+[2016-08-25 Thu 23:36]
+
+This is helpful in training sessions.
+
+#+BEGIN_SRC emacs-lisp
+  (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)
+    (yank)
+    )
+
+  (define-key org-mode-map "\C-c\S-w" 'bba-copy-org-src-block)
+#+END_SRC
+
+
 ** Define some shortcuts to access major org files.
 
 #+BEGIN_SRC emacs-lisp