emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: ian martins <ianxm@jhu.edu>
To: "Michaël Cadilhac" <michael@cadilhac.name>
Cc: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Why is Babel-C trimming its output?
Date: Fri, 17 Jul 2020 08:30:24 -0400	[thread overview]
Message-ID: <CAC=rjb7V19GHQzP84MQd9Z0_W0KZwLEdq8-vrUwg_G9JQ03AjA@mail.gmail.com> (raw)
In-Reply-To: <CADt3fpO7mF_QD30dn-NgED1+CHPggt++pEoQ4DCdRicq9VX9xg@mail.gmail.com>

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

Fortunately the author wrote tests, so we can tie the behavior of the code
to use cases. Unfortunately all the tests pass with the call to org-trim
removed. Also the call is there from the first commit of the file in git,
so there's no commit message to explain.

My guess is that it was added to clean up cases that resulted in extra
trailing whitespace, but I dunno.


On Wed, Jul 15, 2020 at 7:12 PM Michaël Cadilhac <michael@cadilhac.name>
wrote:

> Hello,
>
> Quick question here: in ob-C.el, before returning the output of a C
> file, there's this line:
>
> (setq results (org-trim (org-remove-indentation results)))
>
> That seems quite arbitrary; is it on purpose?  I have a C file that
> outputs some sort of list of formatted numbers, e.g.:
>
>   0  -17.8
>  40    4.4
>  80   26.7
> 120   48.9
>
> and only the first line gets trimmed, leading to a faulty output.
>
> This does not seem to be a universal thing in Babel; for instance:
>
> #+begin_src emacs-lisp :exports both :results value raw
>   " 0\n 1\n2\n"
> #+end_src
>
> …results in:
>
> #+RESULTS:
>  0
>  1
> 2
>
> But the same thing in C:
>
> #+begin_src C :exports both :results output raw
>   printf (" 0\n 1\n2\n");
> #+end_src
>
> …results in:
> #+RESULTS:
> 0
>  1
> 2
>
> Cheers,
> M.
>
>

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

  reply	other threads:[~2020-07-17 12:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 23:12 Michaël Cadilhac
2020-07-17 12:30 ` ian martins [this message]
2020-07-17 17:30   ` Michaël Cadilhac
2020-07-25 15:18     ` ian martins
2020-09-04 10:13       ` Bastien

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='CAC=rjb7V19GHQzP84MQd9Z0_W0KZwLEdq8-vrUwg_G9JQ03AjA@mail.gmail.com' \
    --to=ianxm@jhu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael@cadilhac.name \
    --subject='Re: Why is Babel-C trimming its output?' \
    /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

Code repositories for project(s) associated with this 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).