fixed insertion of results with hashes

No longer overwrites intervening #+ lines.

* lisp/ob-core.el (org-babel-where-is-src-block-result): Fixed
  insertion of results with hashes.
This commit is contained in:
Eric Schulte 2013-12-13 15:06:06 -07:00
parent b319475a86
commit ea993c6d8c
1 changed files with 24 additions and 23 deletions

View File

@ -1940,29 +1940,30 @@ following the source block."
(progn (end-of-line 1)
(if (eobp) (insert "\n") (forward-char 1))
(setq end (point))
(or (and
(not name)
(progn ;; unnamed results line already exists
(catch 'non-comment
(while (re-search-forward "[^ \f\t\n\r\v]" nil t)
(beginning-of-line 1)
(cond
((looking-at (concat org-babel-result-regexp "\n"))
(throw 'non-comment t))
((and (looking-at "^[ \t]*#")
(not (looking-at
org-babel-lob-one-liner-regexp)))
(end-of-line 1))
(t (throw 'non-comment nil))))))
(let ((this-hash (match-string 5)))
(prog1 (point)
;; must remove and rebuild if hash!=old-hash
(if (and hash (not (string= hash this-hash)))
(prog1 nil
(forward-line 1)
(delete-region
end (org-babel-result-end)))
(setq end nil)))))))))))
(and
(not name)
(progn ;; unnamed results line already exists
(catch 'non-comment
(while (re-search-forward "[^ \f\t\n\r\v]" nil t)
(beginning-of-line 1)
(cond
((looking-at (concat org-babel-result-regexp "\n"))
(throw 'non-comment t))
((and (looking-at "^[ \t]*#")
(not (looking-at
org-babel-lob-one-liner-regexp)))
(end-of-line 1))
(t (throw 'non-comment nil))))))
(let ((this-hash (match-string 5)))
(prog1 (point)
;; must remove and rebuild if hash!=old-hash
(if (and hash (not (string= hash this-hash)))
(progn
(setq end (point-at-bol))
(forward-line 1)
(delete-region end (org-babel-result-end))
(setq beg end))
(setq end nil))))))))))
(if (not (and insert end)) found
(goto-char end)
(unless beg