emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Mikhail Titov <mlt@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] session initialization (was RE: python/babel inline images)
Date: Thu, 07 Jun 2012 16:48:39 -0600	[thread overview]
Message-ID: <87oboun3f7.fsf@gmx.com> (raw)
In-Reply-To: 002601cd441c$685c60b0$39152210$@us

"Mikhail Titov" <mlt@gmx.us> 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: Wednesday, June 06, 2012 2:02 PM
>> To: Mikhail Titov
>> Cc: emacs-orgmode@gnu.org; '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

      parent reply	other threads:[~2012-06-07 22:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05 10:30 python/babel inline images henry atting
2012-06-05 12:46 ` Brett Viren
2012-06-05 14:57 ` Eric Schulte
2012-06-05 22:34   ` William LÉCHELLE
2012-06-06 15:19     ` henry atting
2012-06-06 19:16       ` Mikhail Titov
2012-06-06 19:25         ` Eric Schulte
2012-06-06 19:32           ` Mikhail Titov
2012-06-07  8:43         ` henry atting
2012-06-07 15:09           ` Mikhail Titov
2012-06-06  0:59   ` Mikhail Titov
2012-06-06  5:19     ` Eric Schulte
2012-06-06 17:41       ` [babel] session initialization (was RE: python/babel inline images) Mikhail Titov
2012-06-06 19:01         ` Eric Schulte
2012-06-06 19:41           ` Mikhail Titov
2012-06-06 23:06             ` Mikhail Titov
2012-06-07 22:32               ` Mikhail Titov
2012-06-07 22:44                 ` Eric Schulte
2012-06-07 23:02                   ` Mikhail Titov
2012-06-08  1:56                     ` Mikhail Titov
2012-06-08  2:18                       ` Eric Schulte
2012-06-07 22:48             ` Eric Schulte [this message]

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=87oboun3f7.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mlt@gmx.us \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).