Skip to content

Instantly share code, notes, and snippets.

@acbox
Created May 12, 2020
Embed
What would you like to do?
Remove all #+RESULTS: blocks including from #+CALL: blocks in an org-babel file (Spacemacs)
(defun dotspacemacs/user-config ()
(defconst help/org-special-pre "^\s*#[+]")
(defun help/org-2every-src-block (fn)
"Visit every Source-Block and evaluate `FN’."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((case-fold-search t))
(while (re-search-forward (concat help/org-special-pre "\\(BEGIN_SRC\\|CALL\\)") nil t)
(let ((element (org-element-at-point)))
(when (or (eq (org-element-type element) 'src-block) (eq (org-element-type element) 'babel-call))
(funcall fn element)))))
(save-buffer)))
(defun org-babel-remove-results()
"Remove all #+RESULTS: blocks from org-babel files"
(interactive)
(help/org-2every-src-block
'org-babel-remove-result))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment