emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniele Pizzolli <dan@toel.it>
To: "Charles C. Berry" <ccberry@ucsd.edu>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: idempotency and inconsistency for org-babel-remove-inline-result
Date: Sat, 31 Jan 2015 00:06:41 +0100	[thread overview]
Message-ID: <86mw4zuav2.fsf@me.localhost.invalid> (raw)
In-Reply-To: <alpine.OSX.2.00.1501301045510.411@charles-berrys-macbook.local> (Charles C. Berry's message of "Fri, 30 Jan 2015 11:13:45 -0800")

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

Hello Charles,

"Charles C. Berry" writes:

> On Fri, 30 Jan 2015, Daniele Pizzolli wrote:
>
>> Hello,
>>
>> I really like the new inline results.  Thanks for this new cool feature.
>> I have only a few problems with it.
>>
>
> Thanks for your feedback.

Nice to hear.

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

[]

>> I see that the function docs says: Extraneous leading whitespace is
>> trimmed. Is this the intended result?
>
> It is intended to remove `extraneous' whitespace. But the way
> `extraneous' is operationalized leaves something to be desired if
> users wish to do as you have done. Maybe preserving whitespace (if any)
> after the result and deleting all that is before it might work.
>
> I'll take a look at changing the defn to deal with your ECM.

Thanks, see later.

>>
>> Also, is there anything that prevents to make
>> org-babel-remove-inline-result interactive as is
>> org-babel-remove-result?
>
> AFAICS, no.

Ok, patch attached.

>> 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.

Patch attached.  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.

>> I do no not know lisp a lot, but I can try to submit a patch if you
>> agree that will be useful.
>>
>
> The main issue (IMO) is figuring out what whitespace to delete around
> a `{{{results(...)}}}' macro. I can get to this in a day or so, but
> feel free to send a patch.

This is above my lisp coding abilities, with too many org-related
function to get lost into org-babel-remove-inline-result...  I can wait,
but if you have any pointer I will be happy to do some exploration.

Thanks again,
Daniele


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core.el-add-interactive-to-org-babel-remove-inlin.patch --]
[-- Type: text/x-diff, Size: 956 bytes --]

From 4f484ac1f9ae4adcf5551bf6e77e5545f124f11b Mon Sep 17 00:00:00 2001
From: Daniele Pizzolli <dan@toel.it>
Date: Fri, 30 Jan 2015 20:57:15 +0100
Subject: [PATCH 1/2] ob-core.el: add interactive to
 `org-babel-remove-inline-result'

* lisp/ob-core.el (org-babel-remove-inline-result): Add interactive.

TINYCHANGE
---
 lisp/ob-core.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index fcc44c1..ac9f63b 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2324,6 +2324,7 @@ INFO may provide the values of these header arguments (in the
   "Remove the result of the current inline-src-block or babel call.
 The result must be wrapped in a `results' macro to be
   removed. Extraneous leading whitespace is trimmed."
+  (interactive)
   (let* ((el (org-element-context))
 	 (post-blank (org-element-property :post-blank el)))
     (when (memq (org-element-type el) '(inline-src-block inline-babel-call))
-- 
2.1.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ob-core.el-Add-org-babel-remove-result-all.patch --]
[-- Type: text/x-diff, Size: 1199 bytes --]

From b108f6b8dfd28d6c6ebcdfcabb428438fe348ad9 Mon Sep 17 00:00:00 2001
From: Daniele Pizzolli <dan@toel.it>
Date: Fri, 30 Jan 2015 23:28:27 +0100
Subject: [PATCH 2/2] ob-core.el: Add `org-babel-remove-result-all'

* lisp/ob-core.el (org-babel-remove-result-all): New interactive
  function.

TINYCHANGE
---
 lisp/ob-core.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index ac9f63b..e09863d 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2348,6 +2348,16 @@ in the buffer."
       (org-babel-map-src-blocks nil (org-babel-remove-result))
     (org-babel-remove-result)))
 
+(defun org-babel-remove-result-all (x)
+  "Remove the results of all the source blocks and the results of all inline sources.
+If called with a prefix argument, keep the keyword in result
+blocks."
+  (interactive "P")
+  (if x
+      (org-babel-map-src-blocks nil (org-babel-remove-result nil t))
+    (org-babel-map-src-blocks nil (org-babel-remove-result)))
+  (org-babel-map-inline-src-blocks nil (org-babel-remove-inline-result)))
+
 (defun org-babel-result-end ()
   "Return the point at the end of the current set of results."
   (save-excursion
-- 
2.1.4


  reply	other threads:[~2015-01-30 23:06 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 [this message]
2015-01-31  4:13     ` [RFC] removing all results WAS: Re: idempotency ... org-babel-remove-inline-result Charles C. Berry
2015-01-31  8:34       ` 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=86mw4zuav2.fsf@me.localhost.invalid \
    --to=dan@toel.it \
    --cc=ccberry@ucsd.edu \
    --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).