#+Title: debug messages #+Property: session *R* #+Property: prologue (format "print(\"entering %s\")" (get-current-name)) An elisp block to simplify the =:prologue= definition. #+begin_src emacs-lisp (defun get-current-name () (save-excursion (goto-char org-babel-current-src-block-location) (while (and (forward-line -1) (looking-at org-babel-multi-line-header-regexp))) (when (looking-at org-babel-src-name-w-name-regexp) (org-no-properties (match-string 3))))) #+end_src Two blocks with simple assignments. #+name: block-1 #+begin_src R x <- 2 + 2 #+end_src #+name: block-2 #+begin_src R y <- x + x #+end_src Execute the whole buffer =C-c C-v b= to see the prologue in action.