diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2013-03-17 19:56:40 -0500 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2013-03-17 19:57:01 -0500 |
commit | a461b0a444ebef7b7c19e605c38eb090f0f7a839 (patch) | |
tree | 7ee57a2a0d40eb193db0e0125ed3b21cd6cc8c29 | |
parent | 90faed3672e8e765eb38a17de73bb763549f33f7 (diff) | |
download | org-mode-a461b0a444ebef7b7c19e605c38eb090f0f7a839.tar.gz |
allow comments between code blocks and un-named res
* lisp/ob-core.el (org-babel-where-is-src-block-result): Allow comments
between code blocks and un-named results.
-rw-r--r-- | lisp/ob-core.el | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 8625e3e..811e8d4 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1807,21 +1807,26 @@ 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 - (re-search-forward "[^ \f\t\n\r\v]" nil t) + (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) - (looking-at - (concat org-babel-result-regexp "\n"))) - (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))))))))))) + (cond + ((looking-at (concat org-babel-result-regexp "\n")) + (throw 'non-comment t)) + ((looking-at "^[ \t]*#") (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))))))))))) (if (not (and insert end)) found (goto-char end) (unless beg |