From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mikhail Titov" Subject: [babel] session initialization (was RE: python/babel inline images) Date: Wed, 6 Jun 2012 12:41:05 -0500 Message-ID: <000001cd440b$8d20abb0$a7620310$@us> References: <87pq9egifm.fsf@bye.fritz.box> <874nqp9580.fsf@gmx.com> <007401cd437f$ab542b20$01fc8160$@us> <878vg0bbwm.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScKEQ-0008FY-7W for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 13:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScKEH-0003AB-NS for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 13:41:17 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:55940 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ScKEH-00036h-Gg for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 13:41:09 -0400 In-Reply-To: <878vg0bbwm.fsf@gmx.com> Content-Language: en-us 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: 'Eric Schulte' Cc: emacs-orgmode@gnu.org, 'henry atting' > -----Original Message----- > From: emacs-orgmode-bounces+mlt=gmx.us@gnu.org [mailto:emacs-orgmode- > bounces+mlt=gmx.us@gnu.org] On Behalf Of Eric Schulte > Sent: Wednesday, June 06, 2012 12:20 AM > To: Mikhail Titov > Cc: emacs-orgmode@gnu.org; 'henry atting' > Subject: Re: [O] python/babel inline images > > "Mikhail Titov" writes: > > >> -----Original Message----- > >> From: emacs-orgmode-bounces+mlt=gmx.us@gnu.org [mailto:emacs-orgmode- > >> bounces+mlt=gmx.us@gnu.org] On Behalf Of Eric Schulte > >> Sent: Tuesday, June 05, 2012 9:57 AM > >> To: henry atting > >> Cc: emacs-orgmode@gnu.org > >> Subject: Re: [O] python/babel inline images > >> > >> I'm not python expert, but the code block should be run in your current > >> directory, e.g., the following outputs the current working path expected > >> for me. > >> > >> #+begin_src sh > >> pwd > >> #+end_src > >> > >> If you want to explicitly pass the current directory to your code block > >> as an argument, you could try something like the following > >> > >> #+begin_src python :var mydir=(file-name-directory (buffer-file-name)) > >> return mydir > >> #+end_src > >> > > > > I've noticed some inconsistency between various languages in this aspect. > > For instance, ob-R starts session in proper working directory, while all > > looks like everything (?) else does not. > > > > Should not it be somewhat standardized? I think it make sense to always cd > > to org doc folder. > > > > Most languages should and (at least those I use regularly) do run in the > directory of the containing Org-mode file. Which languages do not? I'm working on ob-octave.el which does not. So I'll fix it in this case. Which leads me to another question I was about to ask. How to comint commands in org-babel-XXX-initiate-session as session is not assigned yet? Right now I have something like the following in that function (comint-send-string (get-buffer-process (current-buffer)) "set(0, 'defaultfigurevisible', 'off');\n") I do it there as it does not make sense to call for each block. I was about to write that ob-R does show stuff but I believe it was in earlier versions of ob-R.el or something as I've checked and indeed nothing appears on screen as code being wrapped in a device output block. Also IIRC ob-sh does not change directory though I tried it on Windows with cmd.exe . Worth mentioning that it tangles into dot sh instead of dot bat or dot cmd on that platform. It misses platform specific (defvar org-babel-tangle-lang-exts) (if (string-equal system-type "windows-nt") (add-to-list 'org-babel-tangle-lang-exts '("sh" . "bat")) ) P.S. I feel like I'm hijacking the thread.... M.