I was trying to use org-babel-execute-buffer to update all org-babel
code block results for a org document. It works fine when the code block
is visible, but when it's hidden, I got the "user-error: No surrounding
element" error and nothing was executed.

Adding `(outline-show-all)` fixed this issue for me. Does this look like
a good solution?

-- Wei
From 3b535fa389518b7d7c280952990bc56ddbe01206 Mon Sep 17 00:00:00 2001
From: Wei Tang <hi@that.world>
Date: Thu, 31 Aug 2017 02:39:54 +0800
Subject: [PATCH] ob-core.el: Fix "No surrounding element" error

* ob-core.el (org-babel-execute-buffer): Show all outlines before
execution.

Without this, when outlines are hidden,
executing (org-babel-execute-buffer) gives "No surrounding element"
error.

TINYCHANGE
---
 lisp/ob-core.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d25908d41..a69d4a66b 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1197,6 +1197,7 @@ the current buffer."
   (interactive "P")
   (org-babel-eval-wipe-error-buffer)
   (org-save-outline-visibility t
+    (outline-show-all)
     (org-babel-map-executables nil
       (if (memq (org-element-type (org-element-context))
 		'(babel-call inline-babel-call))
-- 
2.14.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to