emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Roger Mason <rmason@mun.ca>
To: emacs-orgmode@gnu.org
Subject: Re: Hiding results using :post
Date: Tue, 08 Jun 2021 08:08:03 -0230	[thread overview]
Message-ID: <y65zgw0r69g.fsf@mun.ca> (raw)
In-Reply-To: <CAJ51ETpyGMhu=yszgpk5Oshm5YH9Og_v7TgzM6UATVW4ELsrSA@mail.gmail.com>

Hello,

John Kitchin writes:

> This is doable with a hook and advice I think. The hook will hide the
> results if you use :results hide in the header.
>
> I had to use the advice to remove the results before hand, so that you
> toggle the visibility off. This is pretty lightly tested. you could
> eliminate
>
> (defun hide-results (&optional &rest args)
>   (let ((results (cdr (assoc :results (third (org-babel-get-src-block-info
> 'light))))))
>     (when (string-match "hide" results)
>       (org-babel-hide-result-toggle t))))
>
> (add-hook 'org-babel-after-execute-hook 'hide-results)
>
> (advice-add 'org-babel-execute-src-block :before (lambda (&rest args)
> (org-babel-remove-result)))
>
> I guess there are other ways that might work too.
>
> #+BEGIN_SRC jupyter-python :results hide
> print(5)
> #+END_SRC
>
> #+RESULTS:
> : 5

That works very well.

Many thanks.

Roger


      parent reply	other threads:[~2021-06-08 10:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 12:51 Hiding results using :post Roger Mason
2021-06-07 14:00 ` Nick Savage
2021-06-07 20:42   ` John Kitchin
2021-06-07 21:21     ` George Mauer
2021-06-07 21:30       ` John Kitchin
2021-06-07 21:51         ` George Mauer
2021-06-08 10:38     ` Roger Mason [this message]

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=y65zgw0r69g.fsf@mun.ca \
    --to=rmason@mun.ca \
    --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).