From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2AjCFg+FvmC1egAAgWs5BA (envelope-from ) for ; Mon, 07 Jun 2021 22:43:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id oM/xEQ+FvmB+cQAAbx9fmQ (envelope-from ) for ; Mon, 07 Jun 2021 20:43:59 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1487B296C1 for ; Mon, 7 Jun 2021 22:43:58 +0200 (CEST) Received: from localhost ([::1]:42034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqM6H-0006gP-2u for larch@yhetil.org; Mon, 07 Jun 2021 16:43:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqM5V-0006dl-2B for emacs-orgmode@gnu.org; Mon, 07 Jun 2021 16:43:09 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:33370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lqM5P-0006GS-Cz for emacs-orgmode@gnu.org; Mon, 07 Jun 2021 16:43:08 -0400 Received: by mail-wr1-x42b.google.com with SMTP id a20so19142695wrc.0 for ; Mon, 07 Jun 2021 13:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EynEMHvyZ7tE5vRkdLp96PgKJxMEbtUzjmnCzD7THIE=; b=G4zhJ6PQiaBf0r6svvxA9iLX7PjtTqtjC0AyxFBxIkpoJnfLipuVSStVXiucn+vr3J vxpA0Ij40hmss4y5cALehsiRDFztDI0+OMCgJ0Cj0al/mz5lyDk8HfWSS0WB1e2pV8j/ K7ORmOs6yJ6Daqdo/3paL/TIrJVIK6IyHzqzBJSiaiITi0QwO2oMYFNQCFa+GGN0B+JB 28yqnKP9ISubThV43XcLXAT7enbfQa0Be56WoiWArhC26xZnSw/igA+cfx1eTFrZJRg1 EhXw+wD61zKczpgQFRxMQEA4qtQrjrlnZH1XDeZ3BqbD2J90ZSPsZyf6pSFb7z9Xm+fv 2F5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EynEMHvyZ7tE5vRkdLp96PgKJxMEbtUzjmnCzD7THIE=; b=Bja1/O5V9dC7pAHO5zgqBS2vHyPoghSvXtgDozNRBmNZwUrv3USvftdVe6QsUxliQG Ho+CQeii91IN7bx6o98dYQc82N65ipWtiqVbvU6LA2D8dnr/lC/bsY4sqtH+XRqlr3xl 7qkTzbebupfXmipQoa52owsjkoEUwCYwgibujxem2suqwhd2GNzXOHBhaUK4yiMSnC+4 QdKRrZKQg30HaHE7NZKGwZZurX5NPC1CMThk6krKIWcdKBXTqZco8PTSSZQNEtb8Xnky GbjPKuxUHPwNCJc9pYGbcMtOA2ywCUMEvKa/hLSQZfH4z+mN/ciaUNvioSLkdis0rteH gGpQ== X-Gm-Message-State: AOAM531rtM1sCou/x5dNl6pSYjgiO3SBMKUrQeV1RFzUjoXSX01BCzED TEuHXvS5YQ/1CRXQF2kmZRlQD34oK2MjbRLwsiM= X-Google-Smtp-Source: ABdhPJwuwx2nbWQaYH1FjpwMOH80/mJ8n4lOuxy+BuimJzaUrrWYz9L9wWfbKsAB3bt9Cbn1KlHEjE00vL8XGZL9GSg= X-Received: by 2002:adf:e404:: with SMTP id g4mr18664011wrm.414.1623098578372; Mon, 07 Jun 2021 13:42:58 -0700 (PDT) MIME-Version: 1.0 References: <4a32c014-cc70-f71d-aadf-f830bf5b8af8@nicksavage.ca> In-Reply-To: <4a32c014-cc70-f71d-aadf-f830bf5b8af8@nicksavage.ca> From: John Kitchin Date: Mon, 7 Jun 2021 16:42:47 -0400 Message-ID: Subject: Re: Hiding results using :post To: Nick Savage Content-Type: multipart/alternative; boundary="000000000000330a9705c4331603" Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=johnrkitchin@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_SBL_A=0.1 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1623098638; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=EynEMHvyZ7tE5vRkdLp96PgKJxMEbtUzjmnCzD7THIE=; b=tec0ZgitOOL0KxzASDg9b8hUcoBLYvZ+zUditvQu4VcTaTToGK/Wt9imCCn41tNt25nMRO pD0NNbiMIOh2ELvK4CdGNaw98vBMwh7kg5ILzTyzX02FfIv73NtrRPvjOVf/yv3UAl538d cfwGkiYuhsNDQz/+d3twPVJOoltGkuIhf82ZgZYefXkyjOlOTLRQgsAPQcHnmYNnnnZjLf az6g7vH/v/XJYAENbpt0LiaVH5kD9y+G+HOEWDU6/ieBRs362HjvLOx1GhnETQVH728Evx ruFrdz4ErIYUfQi0x3Ex05WfiuWcENvV4vlcZ8XxmbKt6ORZMKWq4oS9KU1SiQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623098638; a=rsa-sha256; cv=none; b=O+2EEFegn1/VK4dnBlgw9qxXmzreL93JvreUezWvTmfyW7KYa6QvHI3Ib1ToViJEJ66gL/ toqtNXtXQ2PzTyfa/w+u6+2RNikJWFhhtYg5jDWEfV+NOeZAbZ4AtUV3p3XGZbcZyf7z1D AsuiMNylACUCXM536fbl/+LspzXr6azuFxsCZiQ0Sx0HfQmcnm69ov+Zw+j3xsZHOnbmv9 J2q7+MYDwfgtYzOnvzUU8epQAGp9PtzB2exZbb1P7Hu7uo8wUZ9me1JMfi9Maad4/Vdzax oEidgW0wiLWQpOoFHcvKDGZnIXXQqMRuHFKtBdr0kl6sJ2L2/dBnOu8dbQJzcA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=G4zhJ6PQ; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.52 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=G4zhJ6PQ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 1487B296C1 X-Spam-Score: -2.52 X-Migadu-Scanner: scn0.migadu.com X-TUID: SprjP89y3H3D --000000000000330a9705c4331603 Content-Type: text/plain; charset="UTF-8" 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 John ----------------------------------- Professor John Kitchin (he/him/his) Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, Jun 7, 2021 at 10:03 AM Nick Savage wrote: > My initial thoughts are that this is very possible. This might be an > area where we could add a new defcustom on always hiding the results to > allow the user to choose it. Without looking at the code, I think it > would be pretty straight forward to make an excursion to the results > line, toggle showing it, then going back to where the point was. > > I can take a crack at a patch in the next day or so if no one else wants > to or gets there first. > > On 6/7/21 8:51 AM, Roger Mason wrote: > > Hello, > > > > I'd like to be able to hide results, for example when I expect the > > them to span many lines. I know I can hit =tab= on the #+RESULTS: line, > > but I'd like to be able to set this automatically. > > > > My most recent effort: > > > > #+name: hideresults > > #+begin_src emacs-lisp :results none :exports none > > (add-to-invisibility-spec '(org-babel-hide-result . t)) > > #+end_src > > > > run like this > > > > #+header: :engine postgresql :dbhost "localhost" :dbuser "rmason" > :database "test" :colnames yes > > #+header: :post hideresults > > #+name: pgquery > > #+begin_src sql > > select timestamp,nempty0 from settings where timestamp like '%20210528%' > > #+end_src > > > > produces > > > > #+RESULTS: pgquery > > : nil > > > > I'm sure there is a way to do this, but I need some pointers as to how. > > > > Thanks for any help. > > > > Roger > > > > Org mode version 9.2.3 (release_9.2.3-390-gfb5091 @ > > /home/rmason/.emacs.d/org-git/lisp/) > > > > GNU Emacs 27.2 (build 1, amd64-portbld-freebsd11.4, X toolkit, cairo > version 1.16.0, Xaw3d scroll bars) > > > > --000000000000330a9705c4331603 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is doable with a hook and advice I think. The hook wi= ll hide the results if you use :results hide in the header.

<= div>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 elimina= te=C2=A0

(defun hide-results (&optional &res= t args)
=C2=A0 (let ((results (cdr (assoc :results (third (org-babel-get= -src-block-info 'light))))))
=C2=A0 =C2=A0 (when (string-match "= ;hide" results)
=C2=A0 =C2=A0 =C2=A0 (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 jupyte= r-python :results hide
print(5)
#+END_SRC

#+RESULTS:
: 5


John

-----------------------------------
Professor J= ohn Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical En= gineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-= 7803


On Mon, Jun 7, 2021 at 10:0= 3 AM Nick Savage <nick@nicksavage.= ca> wrote: