From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: Re: [RFC] removing all results WAS: Re: idempotency ... org-babel-remove-inline-result Date: Wed, 04 Feb 2015 09:59:06 +0100 Message-ID: <86386mxdb9.fsf@me.localhost.invalid> References: <86fvasqmpb.fsf@me.localhost.invalid> <86mw4zuav2.fsf@me.localhost.invalid> <86fvar5gpf.fsf@me.localhost.invalid> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIvnq-0003VF-6g for emacs-orgmode@gnu.org; Wed, 04 Feb 2015 03:59:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIvnh-00008f-SI for emacs-orgmode@gnu.org; Wed, 04 Feb 2015 03:59:18 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:47388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIvnh-00007x-Jq for emacs-orgmode@gnu.org; Wed, 04 Feb 2015 03:59:09 -0500 In-Reply-To: (Charles C. Berry's message of "Tue, 3 Feb 2015 10:19:00 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Charles C. Berry" Cc: org-mode mailing list Hello Charles, "Charles C. Berry" writes: > Further Daniele's response to '[bug] Removing the Babel results': > > http://article.gmane.org/gmane.emacs.orgmode/94604 > > See below. > >> But why a `native' function? You know how to achieve this result and >> can >> >> 1. add a customized function to your init file, >> 2. submit a snippet to Worg, and/or >> 3. contribute an *add on*, and/or >> 4. argue for changes/additions to the Org code base, what you call a >> `native' function. >> >> Option 4 generates work for those who maintain Org code, so it needs >> to be justified in terms of usefulness to other users and >> issues in the code that it might fix or complicate. >> >> Even if 4 is the right path, a decision is needed on whether to add >> new functions, or change the behavior of existing functions (possibly >> adding a new variable or customization). The latter might be cleaner, >> but runs the risk of breaking someone's code. > > The latter notion is along these lines: Thanks for your reasoning and conclusion. > > #+BEGIN_SRC emacs-lisp > (defun org-babel-remove-result-one-or-many (x &optional keep-keyword) > "Remove the result of the current source block. > If called with a prefix argument, remove all result blocks and > results macros in the buffer. When KEEP-KEYWORD is non-nil, allow > RESULTS keywords to remain." > (interactive (list current-prefix-arg > (y-or-n-p "Keep RESULTS keyword(y/n):"))) (y/n) seems to be redundant: y-or-n-p prints the options by itself. > (if x > (org-babel-map-executables nil > (org-babel-remove-result nil keep-keyword) > (org-babel-remove-inline-result)) > (org-babel-remove-result nil keep-keyword) > (org-babel-remove-inline-result))) > #+END_SRC > > which seems to handle Sebastien's `bug' if the user responds with 'y' (or > a calling function has a non-nil `keep-keyword'. Seems reasonable to me. But I still think that one-or-many does not have a lot of sense since there is the one-case function already. Is it possible to call it by something like C-u C-u M-x org-babel-remove-result-one-or-many or by a custom keystroke and avoid the interactive prompt and have it to clean all the result keeping the keyword (without writing a function or using lambda)? As a novice I like interactive prompt because you can be lead through the choices, but I do not want to be annoyed by them when I become expert and have the answer ready and it is almost always the same one. If not, no worries, I think I will wrap in a custom one. Thanks again, Daniele