1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

babel: single function to execute executable babel elements

* ob.el (org-babel-execute-src-block-maybe): remove check for
    `org-babel-no-eval-on-ctrl-c-ctrl-c'; this is done in the new
    function `org-babel-execute-safely-maybe'

    (org-babel-execute-maybe): new function to execute src blocks
    or lob/call lines.

    (org-babel-execute-safely-maybe): new function to execute src blocks
    or lob/call lines via C-c C-c

    (org-ctrl-c-ctrl-c-hook): remove
    `org-babel-execute-src-block-maybe' and add
    `org-babel-execute-safely-maybe'.

    * ob-lob.el (org-ctrl-c-ctrl-c-hook): remove
    `org-babel-lob-execute-maybe'

    * ob-keys.el (org-babel-key-bindings): New function
    `org-babel-execute-maybe' is bound to C-c C-v e and C-c C-v
    C-e
This commit is contained in:
Dan Davison 2010-08-05 13:45:13 -04:00
parent 2935464811
commit 9330ad5b81
3 changed files with 18 additions and 10 deletions

View File

@ -52,8 +52,8 @@ functions which are assigned key bindings, and see
("\C-p" . org-babel-previous-src-block)
("n" . org-babel-next-src-block)
("\C-n" . org-babel-next-src-block)
("e" . org-babel-execute-src-block)
("\C-e" . org-babel-execute-src-block)
("e" . org-babel-execute-maybe)
("\C-e" . org-babel-execute-maybe)
("o" . org-babel-open-src-block-result)
("\C-o" . org-babel-open-src-block-result)
("\C-v" . org-babel-expand-src-block)

View File

@ -77,8 +77,6 @@ if so then run the appropriate source block from the Library."
(let ((info (org-babel-lob-get-info)))
(if (nth 0 info) (progn (org-babel-lob-execute info) t) nil)))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-lob-execute-maybe)
;;;###autoload
(defun org-babel-lob-get-info ()
"Return a Library of Babel function call as a string.

View File

@ -195,17 +195,26 @@ of potentially harmful code."
(error "evaluation aborted"))))
;;;###autoload
(defun org-babel-execute-safely-maybe ()
(unless org-babel-no-eval-on-ctrl-c-ctrl-c
(org-babel-execute-maybe)))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-safely-maybe)
;;;###autoload
(defun org-babel-execute-maybe ()
(interactive)
(or (org-babel-execute-src-block-maybe)
(org-babel-lob-execute-maybe)))
(defun org-babel-execute-src-block-maybe ()
"Conditionally execute a source block.
Detect if this is context for a Babel src-block and if so
then run `org-babel-execute-src-block'."
(interactive)
(if (not org-babel-no-eval-on-ctrl-c-ctrl-c)
(let ((info (org-babel-get-src-block-info)))
(if info
(progn (org-babel-execute-src-block current-prefix-arg info) t) nil))
nil))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-src-block-maybe)
(let ((info (org-babel-get-src-block-info)))
(if info
(progn (org-babel-execute-src-block current-prefix-arg info) t) nil)))
;;;###autoload
(defun org-babel-expand-src-block-maybe ()
@ -298,6 +307,7 @@ can not be resolved.")
;;; functions
(defvar call-process-region)
;;;###autoload
(defun org-babel-execute-src-block (&optional arg info params)
"Execute the current source code block.
Insert the results of execution into the buffer. Source code