From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Fantin Subject: [babel] ob-C.el annoyances Date: Fri, 15 Apr 2011 15:54:46 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAjUF-0008PN-P7 for emacs-orgmode@gnu.org; Fri, 15 Apr 2011 09:55:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAjUD-0008PQ-Op for emacs-orgmode@gnu.org; Fri, 15 Apr 2011 09:55:03 -0400 Received: from lo.gmane.org ([80.91.229.12]:52352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAjUD-0008P9-Et for emacs-orgmode@gnu.org; Fri, 15 Apr 2011 09:55:01 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QAjUC-0001Ai-Be for emacs-orgmode@gnu.org; Fri, 15 Apr 2011 15:55:00 +0200 Received: from 221.108.102-84.rev.gaoland.net ([84.102.108.221]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Apr 2011 15:55:00 +0200 Received: from julienfantin by 221.108.102-84.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Apr 2011 15:55:00 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi list, hi Eric, I've been using ob-C to go through the K&R book, and I've noticed a few annoyances along the way. * Use of the captial C identifier Support functions are defined as ob-C-*. In consequence, I need to #+begin_src C to get a block to execute, because #+begin_src c fails with "No org-babel-execute function for c!". The problem is that I can't edit the block since there is no C-mode. Defining an alias fixed the issue, but it doesn't work OOTB, and doesn't feel like a good solution at all. Is there a reasoning behind this, or where you, as I suspect, trying to define some support functions that would work for both C and C++ ? * Feeding text into blocks This is not directly related to ob-C.el, but I was looking for a way to feed some text to a block's STDIN while it was executed by babel. I wanted to specifiy this text either inline from the block's header arguments or from a dedicated text block. It'd ideally look like this : ** Inline #+begin_src c :feed foo bar int main(void) { while ((c = getchar()) != EOF) { putchar(c); } return 0; } #+end_src #+results: : foo bar ** From a text block #+source: my-stdin #+begin_src text foo bar #+end_src #+begin_src c :feed my-stdin int main(void) { while ((c = getchar()) != EOF) { putchar(c); } return 0; } #+end_src #+results: : foo bar TL;DR if this is already possible somehow please skip the following and let me know :) I couldn't figure out how to pipe the text from within babel though. So I resorted to tangling the text blocks, and redefined org-babel-C-execute to use that new header argument :feed. It gets prepended to the cmdline in the org-babel-eval function call ; if foo is an existing file it gets cat'ed through a pipe to the rest of the cmdline in org-babel-eval, otherwise it is simply echo'ed. This is not as good as what I described above, but after getting to use it, I really think a generalization of this use-case is desirable. Please let me know whar you think. Regards, Julien.