emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Results with #+begin_example/#+end_example don't get overwritten
@ 2017-11-28 21:58 Kaushal Modi
  2017-11-28 22:07 ` Kaushal Modi
  0 siblings, 1 reply; 7+ messages in thread
From: Kaushal Modi @ 2017-11-28 21:58 UTC (permalink / raw)
  To: emacs-org list

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

Hello,

This issue is at the opposite spectrum of the previous issue where the Org
element after #+RESULTS got overwritten..

Here's a MWE:

=====
#+TITLE: Results with #+begin_example/#+end_example do not get overwritten
#+PROPERTY: header-args:python :exports both :results output

#+BEGIN_SRC python
print('a'.islower())
print('A'.islower())
print('abc'.islower())
print('Abc'.islower())
print('aBc'.islower())
print('012'.islower())
print('{}'.islower())
print('ABC'.islower())
print('À'.islower())
print('à'.islower())
#+END_SRC
=====

With point on the src block, hit C-c C-c; you will get:

=====
#+TITLE: Results with #+begin_example/#+end_example do not get overwritten
#+PROPERTY: header-args:python :exports both :results output

#+BEGIN_SRC python
print('a'.islower())
print('A'.islower())
print('abc'.islower())
print('Abc'.islower())
print('aBc'.islower())
print('012'.islower())
print('{}'.islower())
print('ABC'.islower())
print('À'.islower())
print('à'.islower())
#+END_SRC

#+RESULTS:
#+begin_example
True
False
True
False
False
False
False
False
False
True
#+end_example
=====

But doing C-c C-c again will now give:

=====
#+TITLE: Results with #+begin_example/#+end_example do not get overwritten
#+PROPERTY: header-args:python :exports both :results output

#+BEGIN_SRC python
print('a'.islower())
print('A'.islower())
print('abc'.islower())
print('Abc'.islower())
print('aBc'.islower())
print('012'.islower())
print('{}'.islower())
print('ABC'.islower())
print('À'.islower())
print('à'.islower())
#+END_SRC

#+RESULTS:
#+begin_example
True
False
True
False
False
False
False
False
False
True
#+end_example
#+begin_example
True
False
True
False
False
False
False
False
False
True
#+end_example
=====

I think that this behavior is on a safe side and good, but there needs to
be a way for Org to figure out if the stuff following #+RESULTS is safe to
delete..

Can be probably have #+begin_results and #+end_results instead of
#+begin_example and #+end_example? And then process the
begin_results/end_results elements the same as example elements?

That way, we can safely delete/overwrite the begin_results/end_results
blocks.

In the above example, Org cannot know if that example block is babel
generated or user-typed.

WDYT?


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 3180 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 21:58 Results with #+begin_example/#+end_example don't get overwritten Kaushal Modi
@ 2017-11-28 22:07 ` Kaushal Modi
  2017-11-28 22:36   ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Kaushal Modi @ 2017-11-28 22:07 UTC (permalink / raw)
  To: emacs-org list

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

On Tue, Nov 28, 2017 at 4:58 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:

> I think that this behavior is on a safe side and good, but there needs to
> be a way for Org to figure out if the stuff following #+RESULTS is safe to
> delete..
>
> Can be probably have #+begin_results and #+end_results instead of
> #+begin_example and #+end_example? And then process the
> begin_results/end_results elements the same as example elements?
>
> That way, we can safely delete/overwrite the begin_results/end_results
> blocks.
>
> In the above example, Org cannot know if that example block is babel
> generated or user-typed.
>
> WDYT?
>

Or may be just do this:

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 00f0fe33ecf..f04392a96d2 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2465,7 +2465,7 @@ in the buffer."
        (if (memq (org-element-type element)
              ;; Possible results types.
              '(drawer export-block fixed-width item plain-list src-block
-                  table))
+                  example-block table))
            (save-excursion
          (goto-char (min (point-max) ;for narrowed buffers
                  (org-element-property :end element)))


-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1919 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 22:07 ` Kaushal Modi
@ 2017-11-28 22:36   ` Nicolas Goaziou
  2017-11-28 22:45     ` Kaushal Modi
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-11-28 22:36 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Or may be just do this:
>
> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
> index 00f0fe33ecf..f04392a96d2 100644
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -2465,7 +2465,7 @@ in the buffer."
>         (if (memq (org-element-type element)
>               ;; Possible results types.
>               '(drawer export-block fixed-width item plain-list src-block
> -                  table))
> +                  example-block table))

Yes, I simply forgot to add the `example-block' type. Now fixed. Thank
you.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 22:36   ` Nicolas Goaziou
@ 2017-11-28 22:45     ` Kaushal Modi
  2017-11-28 23:16       ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Kaushal Modi @ 2017-11-28 22:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

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

On Tue, Nov 28, 2017 at 5:36 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Yes, I simply forgot to add the `example-block' type. Now fixed. Thank
> you.
>

Thanks.

Regarding the earlier point I made about data safety, should we mention in
the manual that a user must always leave a blank line after #+RESULTS,
especially if they have one of these following the #+RESULTS: keyword?

(drawer example-block export-block fixed-width item plain-list src-block
table)
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 962 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 22:45     ` Kaushal Modi
@ 2017-11-28 23:16       ` Nicolas Goaziou
  2017-11-28 23:24         ` Kaushal Modi
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-11-28 23:16 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Regarding the earlier point I made about data safety, should we mention in
> the manual that a user must always leave a blank line after #+RESULTS,
> especially if they have one of these following the #+RESULTS: keyword?
>
> (drawer example-block export-block fixed-width item plain-list src-block
> table)

AFAICT, there is no place in the manual that explains what is the
RESULTS keyword and under what circumstances it could be useful to write
it manually.

Therefore, I think detailing the caveats of RESULTS manual insertion is
a bit premature at this point.

WDYT?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 23:16       ` Nicolas Goaziou
@ 2017-11-28 23:24         ` Kaushal Modi
  2017-11-29 18:10           ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Kaushal Modi @ 2017-11-28 23:24 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

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

On Tue, Nov 28, 2017 at 6:16 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

>
> AFAICT, there is no place in the manual that explains what is the
> RESULTS keyword


OK, may be that's the first step :)

and under what circumstances it could be useful to write
> it manually.
>

No, I wasn't suggesting a use case where someone writes the #+RESULTS:
contents manually.

Here's what can happen though:

A user could have this to begin with:

=====
#+BEGIN_SRC emacs-lisp
(message "Hello")
#+END_SRC
#+RESULTS:
: Hello

| some | thing | important |
=====

Then for whatever reason, they choose to delete the RESULTS manually.. and
the blank line after that too!

=====
#+BEGIN_SRC emacs-lisp
(message "Hello")
#+END_SRC
#+RESULTS:
| some | thing | important |
=====

Now C-c C-c in the src block will wipe out the user-entered table!

=====
#+BEGIN_SRC emacs-lisp
(message "Hello")
#+END_SRC
#+RESULTS:
: Hello
=====

That's why I proposed earlier to wrap the Org generated results in
something like #+begin_results/#+end_results.

That way, Org is always sure that what it's deleting/overwriting is not
user-entered data.

The current behavior is risky, or at least should somehow be documented.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2172 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Results with #+begin_example/#+end_example don't get overwritten
  2017-11-28 23:24         ` Kaushal Modi
@ 2017-11-29 18:10           ` Nicolas Goaziou
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2017-11-29 18:10 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> No, I wasn't suggesting a use case where someone writes the #+RESULTS:
> contents manually.
>
> Here's what can happen though:
>
> A user could have this to begin with:

[...]

> Then for whatever reason, they choose to delete the RESULTS manually.. and
> the blank line after that too!

IMO, this is still a manual operation on RESULTS keyword.

> That's why I proposed earlier to wrap the Org generated results in
> something like #+begin_results/#+end_results.

I think this would add too much cruft in the document.

> The current behavior is risky, or at least should somehow be
> documented.

Documentation can certainly help. I wouldn't qualify it as risky
however. In any case, it not riskier than the many other ways to fumble
in Org.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-11-29 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 21:58 Results with #+begin_example/#+end_example don't get overwritten Kaushal Modi
2017-11-28 22:07 ` Kaushal Modi
2017-11-28 22:36   ` Nicolas Goaziou
2017-11-28 22:45     ` Kaushal Modi
2017-11-28 23:16       ` Nicolas Goaziou
2017-11-28 23:24         ` Kaushal Modi
2017-11-29 18:10           ` Nicolas Goaziou

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