emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-babel-execute-buffer "No surrounding element" error
@ 2017-08-30 19:02 Wei Tang
  2017-08-31  7:03 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Tang @ 2017-08-30 19:02 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 363 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-ob-core.el-Fix-No-surrounding-element-error.patch --]
[-- Type: text/x-patch; name="0001-ob-core.el-Fix-No-surrounding-element-error.patch", Size: 929 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] org-babel-execute-buffer "No surrounding element" error
  2017-08-30 19:02 [PATCH] org-babel-execute-buffer "No surrounding element" error Wei Tang
@ 2017-08-31  7:03 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-08-31  7:03 UTC (permalink / raw)
  To: Wei Tang; +Cc: emacs-orgmode

Hello,

Wei Tang <hi@that.world> writes:

> 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.

I cannot reproduce it.

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

I don't know. It sounds odd. Could you show an ECM?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-31  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 19:02 [PATCH] org-babel-execute-buffer "No surrounding element" error Wei Tang
2017-08-31  7:03 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).