* Why is Babel-C trimming its output? @ 2020-07-15 23:12 Michaël Cadilhac 2020-07-17 12:30 ` ian martins 0 siblings, 1 reply; 5+ messages in thread From: Michaël Cadilhac @ 2020-07-15 23:12 UTC (permalink / raw) To: Org-Mode mailing list 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why is Babel-C trimming its output? 2020-07-15 23:12 Why is Babel-C trimming its output? Michaël Cadilhac @ 2020-07-17 12:30 ` ian martins 2020-07-17 17:30 ` Michaël Cadilhac 0 siblings, 1 reply; 5+ messages in thread From: ian martins @ 2020-07-17 12:30 UTC (permalink / raw) To: Michaël Cadilhac; +Cc: Org-Mode mailing list [-- 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 --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why is Babel-C trimming its output? 2020-07-17 12:30 ` ian martins @ 2020-07-17 17:30 ` Michaël Cadilhac 2020-07-25 15:18 ` ian martins 0 siblings, 1 reply; 5+ messages in thread From: Michaël Cadilhac @ 2020-07-17 17:30 UTC (permalink / raw) To: ian martins; +Cc: Org-Mode mailing list Thanks for the investigation Ian. So, since the tests run just fine without it, and it offers an inconsistent and at times detrimental feature, can we consider removing it, and/or adding some options for that? I'd be fine having to flag my src-block with a ":verbatim t" option to make sure that the output is not mangled. Thoughts? On Fri, Jul 17, 2020 at 7:30 AM ian martins <ianxm@jhu.edu> wrote: > > 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. >> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why is Babel-C trimming its output? 2020-07-17 17:30 ` Michaël Cadilhac @ 2020-07-25 15:18 ` ian martins 2020-09-04 10:13 ` Bastien 0 siblings, 1 reply; 5+ messages in thread From: ian martins @ 2020-07-25 15:18 UTC (permalink / raw) To: Michaël Cadilhac; +Cc: Org-Mode mailing list [-- Attachment #1: Type: text/plain, Size: 2184 bytes --] That's up to the maintainers. If you just want to fix it on your end you could advise/replace `org-babel-C-execute` but unfortunately there's a lot there. On Fri, Jul 17, 2020, 1:31 PM Michaël Cadilhac <michael@cadilhac.name> wrote: > Thanks for the investigation Ian. So, since the tests run just fine > without it, and it offers an inconsistent and at times detrimental > feature, can we consider removing it, and/or adding some options for > that? > > I'd be fine having to flag my src-block with a ":verbatim t" option to > make sure that the output is not mangled. > > Thoughts? > > On Fri, Jul 17, 2020 at 7:30 AM ian martins <ianxm@jhu.edu> wrote: > > > > 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: 3181 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why is Babel-C trimming its output? 2020-07-25 15:18 ` ian martins @ 2020-09-04 10:13 ` Bastien 0 siblings, 0 replies; 5+ messages in thread From: Bastien @ 2020-09-04 10:13 UTC (permalink / raw) To: ian martins; +Cc: Org-Mode mailing list, Michaël Cadilhac Hi Michael and Ian, I removed the call to `org-trim' which I believe was here for mere cosmetic purpose. Thanks for reporting this, -- Bastien ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-04 10:14 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-07-15 23:12 Why is Babel-C trimming its output? Michaël Cadilhac 2020-07-17 12:30 ` ian martins 2020-07-17 17:30 ` Michaël Cadilhac 2020-07-25 15:18 ` ian martins 2020-09-04 10:13 ` Bastien
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.