emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Martyn Jago <martyn.jago@btinternet.com>
To: emacs-orgmode@gnu.org
Subject: [babel][patch] provide consistent result removal (type `wrap')
Date: Tue, 24 Jan 2012 15:53:07 +0000	[thread overview]
Message-ID: <m2bopt2j30.fsf@btinternet.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]


Patch to 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 patch also fixes the test
`test-ob/org-babel-remove-result--results-wrap' which is uncommented in
the patch.

Best, Martyn


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: provide consistent result removal (type `wrap') --]
[-- Type: text/x-patch, Size: 2488 bytes --]



From a4b2f8484ec4810e7a891b4db0caf5463e96a58d Mon Sep 17 00:00:00 2001
From: Martyn Jago <martyn.jago@btinternet.com>
Date: Tue, 24 Jan 2012 15:39:30 +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.
---
 lisp/ob.el              |    3 ++-
 testing/lisp/test-ob.el |   28 ++++++++++++++--------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/ob.el b/lisp/ob.el
index e8a6d88..895a5b6 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1920,7 +1920,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))
      (t
       (let ((case-fold-search t))
 	(if (looking-at (concat "[ \t]*#\\+begin_\\([^ \t\n\r]+\\)"))
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 178556e..7dccd22 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -771,20 +771,20 @@ replacement happens correctly."
 
 * next heading"))
 
-;; TODO FIXME Activate when Eric's trailing newline fix has been committed
-;; (ert-deftest test-ob/org-babel-remove-result--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-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."
-- 
1.7.3.4


             reply	other threads:[~2012-01-24 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24 15:53 Martyn Jago [this message]
2012-01-24 16:18 ` [babel][patch] provide consistent result removal (type `wrap') Martyn Jago
2012-01-24 16:37   ` Eric Schulte
2012-01-24 16:22 ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2bopt2j30.fsf@btinternet.com \
    --to=martyn.jago@btinternet.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).