From 50a35c42dbc1df91c69cf9bcf03fc72cc3a518d7 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Tue, 24 Jan 2012 16:12:29 +0000 Subject: [PATCH] Fix `org-babel-result-end' command to provide consistent result removal where result is type `wrap'. * lisp/ob.el: Fix `org-babel-result-end' command to provide consistent result removal where result is type `wrap'. Prior to this fix multiple (org-ctrl-c-ctrl-c) commands will add multiple newlines to the end of results (one newline per block execution). This fixes the test `test-ob/org-babel-remove-result--results-wrap' * testing/lisp/test-ob.el: Uncomment test since it now passes. Conflicts: testing/lisp/test-ob.el --- lisp/ob.el | 3 +- testing/lisp/test-ob.el | 108 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/lisp/ob.el b/lisp/ob.el index 9f4d1ccbc..6b62c6335 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1921,7 +1921,8 @@ code ---- the results are extracted in the syntax of the source (prvs (org-list-prevs-alist struct))) (org-list-get-list-end (point-at-bol) struct prvs))) ((looking-at "^\\([ \t]*\\):RESULTS:") - (re-search-forward (concat "^" (match-string 1) ":END:"))) + (progn (re-search-forward (concat "^" (match-string 1) ":END:")) + (forward-char 1) (point))) (t (let ((case-fold-search t) (blocks-re (regexp-opt diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 3c6b27db8..5de3e6948 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -618,6 +618,114 @@ on two lines (buffer-substring-no-properties (point-min) (point-max))))))) +(ert-deftest test-ob/org-babel-remove-result--results-default () + "Test `org-babel-remove-result' with default :results." + (mapcar (lambda (language) + (test-ob-verify-result-and-removed-result + "\n" + (concat +"* org-babel-remove-result +#+begin_src " language " +#+end_src + +* next heading"))) + '("sh" "emacs-lisp"))) + +(ert-deftest test-ob/org-babel-remove-result--results-list () + "Test `org-babel-remove-result' with :results list." + (test-ob-verify-result-and-removed-result + "- 1 +- 2 +- 3 +- (quote (4 5))" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results list +'(1 2 3 '(4 5)) +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-wrap () + "Test `org-babel-remove-result' with :results wrap." + (test-ob-verify-result-and-removed-result + ":RESULTS: +hello there +:END:" + + "* org-babel-remove-result + +#+begin_src emacs-lisp :results wrap +\"hello there\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-org () + "Test `org-babel-remove-result' with :results org." + (test-ob-verify-result-and-removed-result + "#+BEGIN_ORG +* heading +** subheading +content +#+END_ORG" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results org +\"* heading +** subheading +content\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-html () + "Test `org-babel-remove-result' with :results html." + (test-ob-verify-result-and-removed-result + "#+BEGIN_HTML + +#+END_HTML" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results html +\"\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-latex () + "Test `org-babel-remove-result' with :results latex." + (test-ob-verify-result-and-removed-result + "#+BEGIN_LaTeX +Line 1 +Line 2 +Line 3 +#+END_LaTeX" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results latex +\"Line 1 +Line 2 +Line 3\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-code () + "Test `org-babel-remove-result' with :results code." + + (test-ob-verify-result-and-removed-result + "#+BEGIN_SRC emacs-lisp +\"I am working!\" +#+END_SRC" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results code +(message \"I am working!\") +#+end_src + +* next heading")) + (ert-deftest test-org-babel/inline-src_blk-preceded-by-letter () "Test inline source block invalid where preceded by letter"