Function: org-babel--clear-results-maybe
org-babel--clear-results-maybe is a byte-compiled function defined in
ob-core.el.gz.
Signature
(org-babel--clear-results-maybe HASH)
Documentation
Clear results when hash doesn't match HASH.
When results hash does not match HASH, remove RESULTS keyword at point, along with related contents. Do nothing if HASH is nil.
Return a non-nil value if results were cleared. In this case, leave point where new results should be inserted.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
(defun org-babel--clear-results-maybe (hash)
"Clear results when hash doesn't match HASH.
When results hash does not match HASH, remove RESULTS keyword at
point, along with related contents. Do nothing if HASH is nil.
Return a non-nil value if results were cleared. In this case,
leave point where new results should be inserted."
(when hash
(let ((case-fold-search t)) (looking-at org-babel-result-regexp))
(unless (string= (match-string 1) hash)
(let* ((e (org-element-at-point))
(post (copy-marker (org-element-post-affiliated e))))
;; Delete contents.
(delete-region post
(save-excursion
(goto-char (org-element-end e))
(skip-chars-backward " \t\n")
(line-beginning-position 2)))
;; Delete RESULT keyword. However, if RESULTS keyword is
;; orphaned, ignore this part. The deletion above already
;; took care of it.
(unless (= (point) post)
(delete-region (line-beginning-position)
(line-beginning-position 2)))
(goto-char post)
(set-marker post nil)
t))))