First of all, I would like to correct my mistake in my earlier answer (now deleted).
When the point is in the source blocks, the org-src-mode-map is active.
org-src-mode-map is active in the temporary buffer that pops up after you hit
C-c ' (bound to
org-edit-special) when the point is in a source block like below.
So please disregard my earlier answer.
The solution that might work for your case is to advise the
org-ctrl-c-ctrl-c function. This is the function bound to
C-c C-c by default in
The below advice will made the
org-babel-execute-src-block-maybe if the point is in an org source block when you hit
C-c C-c. Otherwise, the
org-ctrl-c-ctrl-c function will run as usual.
(defun my/advice-org-ctrl-c-ctrl-c (&rest args)
"Run `org-babel-execute-src-block-maybe' if point is in an org source block."
(let ((do-not-run-orig-fn (org-in-src-block-p)))
(advice-add 'org-ctrl-c-ctrl-c :before-until #'my/advice-org-ctrl-c-ctrl-c)
Above solution is tested using
emacs -Q (version 25.0.94) and latest build of org from its git master.
By doing this, you will be overriding the default behavior of
C-c C-c in source blocks. Below is a snippet from the documentation we get on doing
C-h f org-ctrl-c-ctrl-c:
- If the cursor is on a code block, evaluate it. The variable
‘org-confirm-babel-evaluate’ can be used to control prompting
before code block evaluation, by default every code block
evaluation requires confirmation. Code block evaluation can be
inhibited by setting ‘org-babel-no-eval-on-ctrl-c-ctrl-c’.