Skip to content

Instantly share code, notes, and snippets.

@acbox
Created May 12, 2020 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acbox/2bc3f981cc359736d1c948cccdb098b3 to your computer and use it in GitHub Desktop.
Save acbox/2bc3f981cc359736d1c948cccdb098b3 to your computer and use it in GitHub Desktop.
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