Browse Source

babel: new function `org-babel-switch-to-session-with-code'

    * ob.el (org-babel-switch-to-session-with-code): new function
    to generate split frame displaying edit buffer and session.

    * ob-keys.el (org-babel-key-bindings): binding for
    `org-babel-switch-to-session-with-code'
Dan Davison 14 years ago
parent
commit
b05f8c91fe
2 changed files with 18 additions and 1 deletions
  1. 1 1
      lisp/ob-keys.el
  2. 17 0
      lisp/ob.el

+ 1 - 1
lisp/ob-keys.el

@@ -74,7 +74,7 @@ functions which are assigned key bindings, and see
     ("\C-i" . org-babel-lob-ingest)
     ("i" . org-babel-lob-ingest)
     ("\C-z" . org-babel-switch-to-session)
-    ("z" . org-babel-switch-to-session)
+    ("z" . org-babel-switch-to-session-with-code)
     ("\C-a" . org-babel-sha1-hash)
     ("a" . org-babel-sha1-hash)
     ("h" . org-babel-describe-bindings))

+ 17 - 0
lisp/ob.el

@@ -465,6 +465,23 @@ of the source block to the kill ring."
 
 (defalias 'org-babel-pop-to-session 'org-babel-switch-to-session)
 
+;;;###autoload
+(defun org-babel-switch-to-session-with-code (&optional arg info)
+    "Switch to code buffer and display session."
+    (interactive "P")
+    (flet ((swap-windows
+	    ()
+	    (let ((other-window-buffer (window-buffer (next-window))))
+	      (set-window-buffer (next-window) (current-buffer))
+	      (set-window-buffer (selected-window) other-window-buffer))
+	    (other-window 1)))
+      (let ((info (org-babel-get-src-block-info))
+	    (org-src-window-setup 'reorganize-frame))
+	(save-excursion
+	  (org-babel-switch-to-session arg info))
+	(org-edit-src-code))
+      (swap-windows)))
+
 (defvar org-bracket-link-regexp)
 ;;;###autoload
 (defun org-babel-open-src-block-result (&optional re-run)