* Hiding results using :post
@ 2021-06-07 12:51 Roger Mason
2021-06-07 14:00 ` Nick Savage
0 siblings, 1 reply; 7+ messages in thread
From: Roger Mason @ 2021-06-07 12:51 UTC (permalink / raw)
To: org-mode-email
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)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
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
0 siblings, 1 reply; 7+ messages in thread
From: Nick Savage @ 2021-06-07 14:00 UTC (permalink / raw)
To: emacs-orgmode
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)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
2021-06-07 14:00 ` Nick Savage
@ 2021-06-07 20:42 ` John Kitchin
2021-06-07 21:21 ` George Mauer
2021-06-08 10:38 ` Roger Mason
0 siblings, 2 replies; 7+ messages in thread
From: John Kitchin @ 2021-06-07 20:42 UTC (permalink / raw)
To: Nick Savage; +Cc: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 2681 bytes --]
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 <nick@nicksavage.ca> 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)
> >
>
>
[-- Attachment #2: Type: text/html, Size: 3755 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
2021-06-07 20:42 ` John Kitchin
@ 2021-06-07 21:21 ` George Mauer
2021-06-07 21:30 ` John Kitchin
2021-06-08 10:38 ` Roger Mason
1 sibling, 1 reply; 7+ messages in thread
From: George Mauer @ 2021-06-07 21:21 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 2936 bytes --]
Woah woah. What is the jupyter-python language, John?
On Mon, Jun 7, 2021, 15:44 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> 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 <nick@nicksavage.ca> 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)
>> >
>>
>>
[-- Attachment #2: Type: text/html, Size: 4176 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
2021-06-07 21:21 ` George Mauer
@ 2021-06-07 21:30 ` John Kitchin
2021-06-07 21:51 ` George Mauer
0 siblings, 1 reply; 7+ messages in thread
From: John Kitchin @ 2021-06-07 21:30 UTC (permalink / raw)
To: gmauer; +Cc: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 3702 bytes --]
it is the name of blocks that use emacs-jupyter (
https://github.com/nnicandro/emacs-jupyter) (instead of ob-ipython).
Basically it is a connection between org-src blocks and a jupyter kernel
(it does not have to be python, it can be julia, R, etc.) I am trying it
out this summer.
I think that code should work on most src-blocks though.
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 5:21 PM George Mauer <gmauer@gmail.com> wrote:
> Woah woah. What is the jupyter-python language, John?
>
> On Mon, Jun 7, 2021, 15:44 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>
>> 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 <nick@nicksavage.ca> 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)
>>> >
>>>
>>>
[-- Attachment #2: Type: text/html, Size: 5483 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
2021-06-07 21:30 ` John Kitchin
@ 2021-06-07 21:51 ` George Mauer
0 siblings, 0 replies; 7+ messages in thread
From: George Mauer @ 2021-06-07 21:51 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 3948 bytes --]
Cool, thanks!
On Mon, Jun 7, 2021 at 4:31 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> it is the name of blocks that use emacs-jupyter (
> https://github.com/nnicandro/emacs-jupyter) (instead of ob-ipython).
> Basically it is a connection between org-src blocks and a jupyter kernel
> (it does not have to be python, it can be julia, R, etc.) I am trying it
> out this summer.
>
> I think that code should work on most src-blocks though.
>
> 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 5:21 PM George Mauer <gmauer@gmail.com> wrote:
>
>> Woah woah. What is the jupyter-python language, John?
>>
>> On Mon, Jun 7, 2021, 15:44 John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>>
>>> 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 <nick@nicksavage.ca> 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)
>>>> >
>>>>
>>>>
[-- Attachment #2: Type: text/html, Size: 5840 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding results using :post
2021-06-07 20:42 ` John Kitchin
2021-06-07 21:21 ` George Mauer
@ 2021-06-08 10:38 ` Roger Mason
1 sibling, 0 replies; 7+ messages in thread
From: Roger Mason @ 2021-06-08 10:38 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-06-08 10:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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).