all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-babel and emacs init
@ 2010-01-25  8:43 Richard Riley
  2010-01-26 18:37 ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Riley @ 2010-01-25  8:43 UTC (permalink / raw)
  To: emacs-orgmode


What approach have you taken to loading multiple files using the
org-babel method?

The example on the babel page searches out all org files and then
untangles the elisp snippets and rewrites files with a .el extensions
loading them as it goes.

But how to order  this or how best to load /decode/execute at run time
in say an autoload or eval after load? Simply call org-babel-load-file
instead of require? 

e.g say I wanted to keep my (typically large) .gnus.el file as an org
file. How best to deal with that? Currently I have an eval after load
with all the code in that used to be in my .gnus.el in my
emacs-init.org. Other approaches?

Would there be a way to get the load system to check for an org file
first and call org-babel-load-file?

Should possibly writing the org file auto create the .el file? Or is
that best left to load time?

Any opinions or discussions/pointers appreciated.

regards,

r.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-babel and emacs init
  2010-01-25  8:43 Richard Riley
@ 2010-01-26 18:37 ` Eric Schulte
  2010-01-26 19:42   ` Richard Riley
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2010-01-26 18:37 UTC (permalink / raw)
  To: Richard Riley; +Cc: emacs-orgmode

Hi Richard,

Richard Riley <rileyrgdev@gmail.com> writes:

> What approach have you taken to loading multiple files using the
> org-babel method?
>
> The example on the babel page searches out all org files and then
> untangles the elisp snippets and rewrites files with a .el extensions
> loading them as it goes.
>
> But how to order  this or how best to load /decode/execute at run time
> in say an autoload or eval after load? Simply call org-babel-load-file
> instead of require? 
>

Currently the only option is `org-babel-load-file'.  Off the top of my
head I don't see why an analogous `org-babel-require' function would not
work, and it seems that it would satisfy this need for conditional
loading.

>
> e.g say I wanted to keep my (typically large) .gnus.el file as an org
> file. How best to deal with that? Currently I have an eval after load
> with all the code in that used to be in my .gnus.el in my
> emacs-init.org. Other approaches?
>

again, maybe using something like the eventually-to-be-implemented
org-babel-require would work here?

>
> Would there be a way to get the load system to check for an org file
> first and call org-babel-load-file?
>

I'm not sure exactly what you mean here.

>
> Should possibly writing the org file auto create the .el file? Or is
> that best left to load time?
>

I think this will be more reliable if it is left as a load-time
operation, rather than as a save-hook or something.  Also, since the
file is only re-tangled when the .org file is newer than the .el file it
should not be a noticeable startup performance hit.

Thanks -- Eric

>
> Any opinions or discussions/pointers appreciated.
>
> regards,
>
> r.
>
>
>
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-babel and emacs init
  2010-01-26 18:37 ` Eric Schulte
@ 2010-01-26 19:42   ` Richard Riley
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Riley @ 2010-01-26 19:42 UTC (permalink / raw)
  To: emacs-orgmode

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi Richard,
>
> Richard Riley <rileyrgdev@gmail.com> writes:
>
>> What approach have you taken to loading multiple files using the
>> org-babel method?
>>
>> The example on the babel page searches out all org files and then
>> untangles the elisp snippets and rewrites files with a .el extensions
>> loading them as it goes.
>>
>> But how to order  this or how best to load /decode/execute at run time
>> in say an autoload or eval after load? Simply call org-babel-load-file
>> instead of require? 
>>
>
> Currently the only option is `org-babel-load-file'.  Off the top of my
> head I don't see why an analogous `org-babel-require' function would not
> work, and it seems that it would satisfy this need for conditional
> loading.
>
>>
>> e.g say I wanted to keep my (typically large) .gnus.el file as an org
>> file. How best to deal with that? Currently I have an eval after load
>> with all the code in that used to be in my .gnus.el in my
>> emacs-init.org. Other approaches?
>>
>
> again, maybe using something like the eventually-to-be-implemented
> org-babel-require would work here?
>
>>
>> Would there be a way to get the load system to check for an org file
>> first and call org-babel-load-file?
>>
>
> I'm not sure exactly what you mean here.

I was thinking of (require 'xyz) somehow being overloaded to first check
for org files. Fuzzy thinking most likely ;) If I eval a block such as
(require 'mylib) it would be nice if it could detect the org has changed
and so re-create the el etc.  see below ....

>
>>
>> Should possibly writing the org file auto create the .el file? Or is
>> that best left to load time?
>>
>
> I think this will be more reliable if it is left as a load-time
> operation, rather than as a save-hook or something.  Also, since the
> file is only re-tangled when the .org file is newer than the .el file it
> should not be a noticeable startup performance hit.

It's true about the overhead being small but if you edit the org file
then the elisp file should, I think, always be up to date and not out of
sync until the next emacs startup. Especially for those of us who might
use the daemon and restarts are few and far between. Imagine I alter a
tangled block in the my org file and save and later want to email some
lisp to a friend - as happened to today I might forget the updated org
and instead copy from the .el file - oops! 

>
> Thanks -- Eric


Thanks for your reply. I really like org-babel. The only things I would
say about the current implementation, and being totally selfish as I
only use it for elisp at the moment ;), is that C-c C-c should use the
org-ctl-cl-ctl-c functionality to edit the code block as the default
instead of the harder to key "C-'". Would it be hard to make the default
org-file or src type configurable? On that note it would be wonderful if
somehow nxhtml would work with this so we could actually edit in place
in emacs-lisp mode. Is there anything in that direction?

Great stuff,

regard

r.

>
>>
>> Any opinions or discussions/pointers appreciated.
>>
>> regards,
>>
>> r.
>>
>>
>>
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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
>

-- 
Google Talk : rileyrgdev@googlemail.com  http://www.google.com/talk
ASCII ribbon campaign ( )
 - against HTML email  X
             & vCards / \

^ permalink raw reply	[flat|nested] 6+ messages in thread

* org-babel and emacs init
@ 2010-06-28 17:22 Richard Riley
  2010-06-28 17:59 ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Riley @ 2010-06-28 17:22 UTC (permalink / raw)
  To: emacs-orgmode


Firstly  : 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 because
my init files are org files untangled using babel. Here is an updated
init.el which which uses the new names and pulls in  ob-tangle.


--8<---------------cut here---------------start------------->8---
(setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))

(let* ((org-dir (expand-file-name
                 "lisp" (expand-file-name
                         "org-mode" dotfiles-dir)))
       (org-contrib-dir (expand-file-name
                         "lisp" (expand-file-name
				 "contrib" (expand-file-name
                                            ".." org-dir))))
       (load-path (append (list org-dir org-contrib-dir (concat org-dir "/babel"))
                          (or load-path nil))))
  (message "%s" org-dir)
  ;; load up Org-mode and Org-babel
  (require 'org-install)
  (require 'ob)
  (require 'ob-tangle)
)
--8<---------------cut here---------------end--------------->8---

-- 
Google Talk : rileyrg@googlemail.com  http://www.google.com/talk

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-babel and emacs init
  2010-06-28 17:22 org-babel and emacs init Richard Riley
@ 2010-06-28 17:59 ` Eric Schulte
       [not found]   ` <AANLkTimTQEewn_27FFEaOD1TAydhceiGrVcdLuEZSHfP@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2010-06-28 17:59 UTC (permalink / raw)
  To: Richard Riley; +Cc: emacs-orgmode

Hi Richard,

Happy this is sorted out.  A similar startup example is available in the
init.el file in my copy of the Emacs Starter Kit [1], which also tangles
all configuration from org files.

Cheers -- Eric

Richard Riley <rileyrg@gmail.com> writes:

> Firstly  : 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 because
> my init files are org files untangled using babel. Here is an updated
> init.el which which uses the new names and pulls in  ob-tangle.
>
>
> (setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
>
> (let* ((org-dir (expand-file-name
>                  "lisp" (expand-file-name
>                          "org-mode" dotfiles-dir)))
>        (org-contrib-dir (expand-file-name
>                          "lisp" (expand-file-name
> 				 "contrib" (expand-file-name
>                                             ".." org-dir))))
>        (load-path (append (list org-dir org-contrib-dir (concat org-dir "/babel"))
>                           (or load-path nil))))
>   (message "%s" org-dir)
>   ;; load up Org-mode and Org-babel
>   (require 'org-install)
>   (require 'ob)
>   (require 'ob-tangle)
> )

Footnotes: 
[1]  http://github.com/eschulte/emacs-starter-kit/blob/master/init.el

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-babel and emacs init
       [not found]     ` <87mxu9wcp9.fsf@gmail.com>
@ 2010-07-16  2:11       ` Julien Fantin
  0 siblings, 0 replies; 6+ messages in thread
From: Julien Fantin @ 2010-07-16  2:11 UTC (permalink / raw)
  To: emacs-orgmode

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 <reply all> 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 <schulte.eric@gmail.com> wrote:
> Hi Julien,
>
> Org-mode prefers when it is used in buffers that are associated with
> files.  The following version creates temporary files for each load.  It
> 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 <julien.fantin@gmail.com> 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 directoy
>> with files I don't use.
>>
>> But I'm getting errors with this function :
>>
>> (defun my-org-babel-load-file (file)
>>   (with-temp-buffer (insert-file-contents (expand-file-name file
>> dotfiles-dir))
>>                     (org-mode)
>>                     (org-babel-execute-buffer)))
>>
>> (my-org-babel-load-file "init.org")
>>
>> It's giving me a hard time apparently due to org-babel-insert-result calling
>> orgtbl-to-orgtbl on blocks of emacs-lisp which return nil.
>>
>>  Could you suggest how to do this properly ?
>>
>> cheers and congratulations on the integration !
>>
>> On Mon, Jun 28, 2010 at 7:59 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
>>
>>> Hi Richard,
>>>
>>> Happy this is sorted out.  A similar startup example is available in the
>>> init.el file in my copy of the Emacs Starter Kit [1], which also tangles
>>> all configuration from org files.
>>>
>>> Cheers -- Eric
>>>
>>> Richard Riley <rileyrg@gmail.com> writes:
>>>
>>> > Firstly  : 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 because
>>> > my init files are org files untangled using babel. Here is an updated
>>> > init.el which which uses the new names and pulls in  ob-tangle.
>>> >
>>> >
>>> > (setq dotfiles-dir (file-name-directory (or (buffer-file-name)
>>> load-file-name)))
>>> >
>>> > (let* ((org-dir (expand-file-name
>>> >                  "lisp" (expand-file-name
>>> >                          "org-mode" dotfiles-dir)))
>>> >        (org-contrib-dir (expand-file-name
>>> >                          "lisp" (expand-file-name
>>> >                                "contrib" (expand-file-name
>>> >                                             ".." org-dir))))
>>> >        (load-path (append (list org-dir org-contrib-dir (concat org-dir
>>> "/babel"))
>>> >                           (or load-path nil))))
>>> >   (message "%s" org-dir)
>>> >   ;; load up Org-mode and Org-babel
>>> >   (require 'org-install)
>>> >   (require 'ob)
>>> >   (require 'ob-tangle)
>>> > )
>>>
>>> Footnotes:
>>> [1]  http://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
>>>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-16  2:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 17:22 org-babel and emacs init Richard Riley
2010-06-28 17:59 ` Eric Schulte
     [not found]   ` <AANLkTimTQEewn_27FFEaOD1TAydhceiGrVcdLuEZSHfP@mail.gmail.com>
     [not found]     ` <87mxu9wcp9.fsf@gmail.com>
2010-07-16  2:11       ` Julien Fantin
  -- strict thread matches above, loose matches on Subject: below --
2010-01-25  8:43 Richard Riley
2010-01-26 18:37 ` Eric Schulte
2010-01-26 19:42   ` Richard Riley

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.