emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Daniele Pizzolli <dan@toel.it>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: [RFC] removing all results WAS: Re: idempotency ... org-babel-remove-inline-result
Date: Fri, 30 Jan 2015 20:13:38 -0800	[thread overview]
Message-ID: <alpine.OSX.2.00.1501301931160.2444@charles-berrys-macbook.local> (raw)
In-Reply-To: <86mw4zuav2.fsf@me.localhost.invalid>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2113 bytes --]


RFC: the patch to `org-babel-remove-inline-result-one-or-many' 
removes inline results, too.

Do you see any bad consequences?

On Fri, 30 Jan 2015, Daniele Pizzolli wrote:

> Hello Charles,
>
> "Charles C. Berry" writes:
>
>> On Fri, 30 Jan 2015, Daniele Pizzolli wrote:
>>

[discussion of extra whitespace bug deleted]

There is now a bugfix on master. I've also added 'interactive' to 
`org-babel-remove-inline-result'.

>
>>> Is there a way to evaluate a buffer an then remove inline results or
>>> better, to get the very same buffer after:
>

Yes.

See attached patch which should clean *all* results (except `raw' results) 
from a buffer when `org-babel-remove-result-one-or-many' is called with a 
prefix.

Before pushing this, I'd like some feedback on the wisdom of doing what 
the patch does.

>>> Wwhy not have also
>>> org-babel-remove-inline-result-one-or-many and
>>> org-babel-remove-all-result-one-or-many to remove all the babel result
>>> with one function call?
>>
>> Easy enough, but is this really needed? What about call block/line
>> results?
>
> This is useful for me because I want to easily discard the results to
> have the commit with only the changes in the source.  I hope others find
> this a reasonable facility.  It is like a 'make clean' for your org
> files.

I think extending `org-babel-remove-all-result-one-or-many' to cover 
inline results is innocuous. So if nobody raises an objection, I will 
push the patch.

I got that you want to clean up your buffer. But an issue with adding 
more functions is 'feature bloat'. If you really need 
`org-babel-remove-result-all' and 
`org-babel-remove-inline-result-one-or-many' you can have private 
functions.

>
> Patch attached.

Thank you.

Regarding patches, if you haven't signed FSF copyright papers a TINYCHANGE 
is needed in the commit message.

> I am not sure about the default of discarding keyword
> Deleting the result line can cause some disorder, but it is the default
> in org-babel-remove-result.  Also the naming can be confusing.

Alas. Then there is the user error I have made of re-using names.

Best,

Chuck

[-- Attachment #2: remove inline results also --]
[-- Type: TEXT/PLAIN, Size: 1472 bytes --]

From af94ed1c07a914ba686076c83a08f80c3b21c32b Mon Sep 17 00:00:00 2001
From: Charles Berry <ccberry@ucsd.edu>
Date: Fri, 30 Jan 2015 19:14:51 -0800
Subject: [PATCH 2/2] ob-core.el: `org-babel-remove-result-one-or-many' removes
 inline results

* ob-core.el (org-babel-remove-result-one-or-many): Remove all results
  of babel executables, including inline results.
---
 lisp/ob-core.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index ceda1aa..6c8a587 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2339,13 +2339,16 @@ Leading whitespace is trimmed."
 		(org-element-property :post-blank el)))))))))
 
 (defun org-babel-remove-result-one-or-many (x)
-  "Remove the result of the current source block.
-If called with a prefix argument, remove all result blocks
-in the buffer."
+  "Remove the result of the current (inline) source block.
+If called with a prefix argument, remove all result blocks and
+macros in the buffer."
   (interactive "P")
   (if x
-      (org-babel-map-src-blocks nil (org-babel-remove-result))
-    (org-babel-remove-result)))
+      (org-babel-map-executables nil
+	(org-babel-remove-result)
+	(org-babel-remove-inline-result))
+    (org-babel-remove-result)
+    (org-babel-remove-inline-result)))
 
 (defun org-babel-result-end ()
   "Return the point at the end of the current set of results."
-- 
1.9.3 (Apple Git-50)


  reply	other threads:[~2015-01-31  4:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 16:04 idempotency and inconsistency for org-babel-remove-inline-result Daniele Pizzolli
2015-01-30 19:13 ` Charles C. Berry
2015-01-30 23:06   ` Daniele Pizzolli
2015-01-31  4:13     ` Charles C. Berry [this message]
2015-01-31  8:34       ` [RFC] removing all results WAS: Re: idempotency ... org-babel-remove-inline-result Nicolas Goaziou
2015-01-31 19:08         ` Charles C. Berry
2015-01-31 23:05           ` Nicolas Goaziou
2015-01-31 11:31       ` Daniele Pizzolli
2015-01-31 20:00         ` Charles C. Berry
2015-02-03 18:19           ` Charles C. Berry
2015-02-04  8:59             ` Daniele Pizzolli

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=alpine.OSX.2.00.1501301931160.2444@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=dan@toel.it \
    --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).