From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Fantin Subject: Re: org-babel and emacs init Date: Fri, 16 Jul 2010 04:11:41 +0200 Message-ID: References: <87y6dz6nsd.fsf@gmail.com> <87mxu9wcp9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=56680 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OZaPE-00064j-ON for emacs-orgmode@gnu.org; Thu, 15 Jul 2010 22:12:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OZaPD-0000pm-6g for emacs-orgmode@gnu.org; Thu, 15 Jul 2010 22:12:04 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:61023) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZaPC-0000pd-Sc for emacs-orgmode@gnu.org; Thu, 15 Jul 2010 22:12:03 -0400 Received: by eydd26 with SMTP id d26so377260eyd.0 for ; Thu, 15 Jul 2010 19:12:01 -0700 (PDT) In-Reply-To: <87mxu9wcp9.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Still had some issues with your function Eric, but finally found the time to make it work on my system. Posting it here since I didn't use the first time around, and someone else might find it useful. (defun my-org-babel-load-file (file) (let ((orig-file (expand-file-name file dotfiles-dir)) (tmp-file (make-temp-file "my-ob-load" nil ".org"))) (with-temp-file tmp-file (insert-file-contents orig-file)) (org-babel-load-file tmp-file))) Thanks for your help ! Cheers On Sat, Jul 3, 2010 at 3:56 AM, Eric Schulte wrote= : > Hi Julien, > > Org-mode prefers when it is used in buffers that are associated with > files. =C2=A0The following version creates temporary files for each load.= =C2=A0It > will litter your /tmp directory instead of your emacs directory -- > although it shouldn't be hard to add a quick cleanup at the end of the > function. > > Cheers -- Eric > > > (defun my-org-babel-load-file (file) > (let ((tmp-file (make-temp-file "my-ob-load"))) > (with-temp-file tmp-file > (insert-file-contents > (expand-file-name file dotfiles-dir)) > (org-mode) > (org-babel-execute-buffer)))) > > > Julien Fantin writes: > >> Hi eric, >> I'v been trying to find a way to avoid the tangling involved in using >> org-babel-load-file when loading my config, as it clobbers my emacs dire= ctoy >> with files I don't use. >> >> But I'm getting errors with this function : >> >> (defun my-org-babel-load-file (file) >> =C2=A0 (with-temp-buffer (insert-file-contents (expand-file-name file >> dotfiles-dir)) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (o= rg-mode) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (o= rg-babel-execute-buffer))) >> >> (my-org-babel-load-file "init.org") >> >> It's giving me a hard time apparently due to org-babel-insert-result cal= ling >> orgtbl-to-orgtbl on blocks of emacs-lisp which return nil. >> >> =C2=A0Could you suggest how to do this properly ? >> >> cheers and congratulations on the integration ! >> >> On Mon, Jun 28, 2010 at 7:59 PM, Eric Schulte wr= ote: >> >>> Hi Richard, >>> >>> Happy this is sorted out. =C2=A0A similar startup example is available = in the >>> init.el file in my copy of the Emacs Starter Kit [1], which also tangle= s >>> all configuration from org files. >>> >>> Cheers -- Eric >>> >>> Richard Riley writes: >>> >>> > Firstly =C2=A0: Carsten and Eric I emailed you privately as I had no = news >>> > access - pls ignore. Problem solved. >>> > >>> > With the latest git pull for org-mode I couldn't start my emacs becau= se >>> > my init files are org files untangled using babel. Here is an updated >>> > init.el which which uses the new names and pulls in =C2=A0ob-tangle. >>> > >>> > >>> > (setq dotfiles-dir (file-name-directory (or (buffer-file-name) >>> load-file-name))) >>> > >>> > (let* ((org-dir (expand-file-name >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"lisp" = (expand-file-name >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0"org-mode" dotfiles-dir))) >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-contrib-dir (expand-file-name >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0"lisp" (expand-file-name >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"contrib" (expand-file-name >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ".." org-dir)))) >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(load-path (append (list org-dir org-contr= ib-dir (concat org-dir >>> "/babel")) >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 (or load-path nil)))) >>> > =C2=A0 (message "%s" org-dir) >>> > =C2=A0 ;; load up Org-mode and Org-babel >>> > =C2=A0 (require 'org-install) >>> > =C2=A0 (require 'ob) >>> > =C2=A0 (require 'ob-tangle) >>> > ) >>> >>> Footnotes: >>> [1] =C2=A0http://github.com/eschulte/emacs-starter-kit/blob/master/init= .el >>> >>> >>> _______________________________________________ >>> Emacs-orgmode mailing list >>> Please use `Reply All' to send replies to the list. >>> Emacs-orgmode@gnu.org >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>> > >