emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [babel] session initialization (was RE: python/babel inline imag


From: Eric Schulte
Subject: Re: [O] [babel] session initialization (was RE: python/babel inline images)
Date: Thu, 07 Jun 2012 16:48:39 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.97 (gnu/linux)

"Mikhail Titov" <address@hidden> writes:

>> -----Original Message-----
>> From: address@hidden [mailto:emacs-orgmode-
>> address@hidden On Behalf Of Eric Schulte
>> Sent: Wednesday, June 06, 2012 2:02 PM
>> To: Mikhail Titov
>> Cc: address@hidden; 'henry atting'; 'Eric Schulte'
>> Subject: Re: [O] [babel] session initialization (was RE: python/babel inline 
>> images)
>> 
>> > 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.
>> >
>> 
>> I'm not aware of a way to run code on the start of a session.  I do see
>> how this could be a useful addition.
>
> So the fragment above does look legitimate to you? I just add
>
> (format "cd('%s');\n" (file-name-directory (buffer-file-name)))
>
> and problem solved? Well... for sessions. I don't know if it is common to
> use non-session based calculations...
>

The vast majority of my code blocks do not use sessions but I don't use
matlab or octave.  Running something like the following as part of the
session start up does seem reasonable.

  (format "cd('%s');\n" default-directory)

>
>> > Also IIRC ob-sh does not change directory though I tried it on
>> > Windows with cmd.exe.
>> 
>> Granted I only run on linux, but (on linux) ob-sh *does* run in the
>> directory of the containing Org-mode file.
>> 
>> > 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"))
>> > )
>> >
>> 
>> OK, could you convert the above into a patch which we could apply to
>> ob-sh?
>
> I think there should be more than that. I do sometimes use bash from msys on
> Win32 so I'd expect sh as a tangled file name extension in this case. I
> believe it can be accomplished as with matlab / octave by adding a new
> language cmd that will reuse most of sh. I'll see what I can do.
>

The alternate (and probably simpler) solution here is to set the default
to whichever of .sh or .bat seems more likely to be desired based on the
OS, and then let the user customize the `org-babel-tangle-lang-exts' to
suite their preference.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



reply via email to

[Prev in Thread] Current Thread [Next in Thread]