]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added bba-copy-and-yank-org-src-block
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Mar 2017 10:30:57 +0000 (11:30 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Mar 2017 10:30:57 +0000 (11:30 +0100)
- 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 <baronNOSPAMbundesbrandschatzamt.de>
bba.org

diff --git a/bba.org b/bba.org
index 1b18c0f84ad04fef5721ad6efdda0c1d0803cccd..21203a9acce07dfe0bbb4f36c2d88093cc090155 100644 (file)
--- 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