emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Some Experiences with org-babel-load-file
@ 2012-12-10 22:33 Florian Beck
  2012-12-11 14:52 ` Eric Schulte
  2012-12-11 17:01 ` Memnon Anon
  0 siblings, 2 replies; 6+ messages in thread
From: Florian Beck @ 2012-12-10 22:33 UTC (permalink / raw)
  To: emacs-orgmode

Hello!

As an experiment, I moved my .emacs and all my personal packages into an 
org-file and now load it with 'org-babel-load-file. This works fine 
enough: the source code blocks can handle several thousand lines of code 
(for later splitting) without any quirks, tough editing in the org-file 
sure gets slow.

A couple of observations:

1. `org-babel-load-file' doesn't seem to be in the org docu. The 
instructions on worg are obsolete (mentions `org-install') and 
needlessly complicated. Just putting

(package-initialize) ;; only if you use the newest org
(require 'ob-tangle)
(org-babel-load-file "/path/to/your/org-init-file.org")

into your .emacs (no need for .emacs.d/init.el) seems to suffice.

2. Unless you are only setting variables, you want your functions to be 
byte-compiled. I modified `org-babel-load-file' to do that. Any reason 
not to?

3. While it saves some keystrokes not to have to write "tangle: yes", it 
seems to be at odds with `org-tangle-file (though it does respect 
"tangle: no").

4. When I babel-load "my-package.org", all emacs sees is the tangled 
"my-package.el", which of course is right. The problem, however, is that 
I often search for one of my functions, change it … and loose the 
changes the next time I start emacs (I already got zapped a couple of 
times). Integrating org-tangle with the emacs documentation would be 
tough I guess. But how about setting a read-only file locale variable to 
block the most stupid mistakes?

Overall, very nice. Thank you.

-- 
Florian Beck

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

* Re: Some Experiences with org-babel-load-file
  2012-12-10 22:33 Some Experiences with org-babel-load-file Florian Beck
@ 2012-12-11 14:52 ` Eric Schulte
  2012-12-11 19:52   ` Florian Beck
  2012-12-11 17:01 ` Memnon Anon
  1 sibling, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2012-12-11 14:52 UTC (permalink / raw)
  To: Florian Beck; +Cc: emacs-orgmode

Florian Beck <fb@miszellen.de> writes:

> Hello!
>
> As an experiment, I moved my .emacs and all my personal packages into
> an org-file and now load it with 'org-babel-load-file. This works fine
> enough: the source code blocks can handle several thousand lines of
> code (for later splitting) without any quirks, tough editing in the
> org-file sure gets slow.
>
> A couple of observations:
>
> 1. `org-babel-load-file' doesn't seem to be in the org docu. The
> instructions on worg are obsolete (mentions `org-install') and
> needlessly complicated. Just putting
>
> (package-initialize) ;; only if you use the newest org
> (require 'ob-tangle)
> (org-babel-load-file "/path/to/your/org-init-file.org")
>
> into your .emacs (no need for .emacs.d/init.el) seems to suffice.
>

Please go ahead and update the information on worg.  Note that Emacs24
users need only do

    (require 'org)
    (org-babel-load-file "/path/to/your/org-init-file.org")

while users of lesser Emacs will have to load a new version of Org-mode
before calling org-babel-load-file.

>
> 2. Unless you are only setting variables, you want your functions to
> be byte-compiled. I modified `org-babel-load-file' to do that. Any
> reason not to?
>

I disagree, I don't find a noticeable performance difference between
compiled and un-compiled code.  If this does pose a problem for you,
perhaps an optional extra argument to be added to org-babel-load-file to
enable compilation.

>
> 3. While it saves some keystrokes not to have to write "tangle: yes",
> it seems to be at odds with `org-tangle-file (though it does respect
> "tangle: no").
>

The `org-babel-load-file' function calls `org-tangle-file' so they are
definitely working in concert.  When a target file is passed to
`org-tangle-file' then that is used as the value of the ":tangle" header
argument, so the default behavior is to tangle.

>
> 4. When I babel-load "my-package.org", all emacs sees is the tangled
> "my-package.el", which of course is right. The problem, however, is
> that I often search for one of my functions, change it … and loose the
> changes the next time I start emacs (I already got zapped a couple of
> times). Integrating org-tangle with the emacs documentation would be
> tough I guess. But how about setting a read-only file locale variable
> to block the most stupid mistakes?
>

Great idea.  I don't have time to work on this right now, but it is
definitely on my stack.  I suppose this should be the default behavior
for all tangled files (not just those written by org-babel-load-file).

Thanks,

>
> Overall, very nice. Thank you.

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

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

* Re: Some Experiences with org-babel-load-file
  2012-12-10 22:33 Some Experiences with org-babel-load-file Florian Beck
  2012-12-11 14:52 ` Eric Schulte
@ 2012-12-11 17:01 ` Memnon Anon
  2012-12-11 17:36   ` Jonathan Leech-Pepin
  1 sibling, 1 reply; 6+ messages in thread
From: Memnon Anon @ 2012-12-11 17:01 UTC (permalink / raw)
  To: emacs-orgmode

Florian Beck <fb@miszellen.de> writes:

> 1. `org-babel-load-file' doesn't seem to be in the org docu. The
> instructions on worg are obsolete (mentions `org-install') and
> needlessly complicated. Just putting
>
> (package-initialize) ;; only if you use the newest org

... and the newest emacs!

> (require 'ob-tangle)
> (org-babel-load-file "/path/to/your/org-init-file.org")
>
> into your .emacs (no need for .emacs.d/init.el) seems to suffice.

This is one way to do it, not necessarily the only way.
I don't think a 4 line init.el is that complicated ;).

> 4. When I babel-load "my-package.org", all emacs sees is the tangled
> "my-package.el", which of course is right. The problem, however, is
> that I often search for one of my functions, change it … and loose the
> changes the next time I start emacs (I already got zapped a couple of
> times). Integrating org-tangle with the emacs documentation would be
> tough I guess. But how about setting a read-only file locale variable
> to block the most stupid mistakes?

How do you change your functions?
If I want to do it, I tinker with them directly in my emacs.org and
evaluate from there or copy the relevant bits to the *scratch* buffer
and bring them back to emacs.org once it works. If the file changed,
the el file gets tangled fresh automatically next time I start emacs and
used right away.

I don't really see a problem?

Memnon

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

* Re: Some Experiences with org-babel-load-file
  2012-12-11 17:01 ` Memnon Anon
@ 2012-12-11 17:36   ` Jonathan Leech-Pepin
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Leech-Pepin @ 2012-12-11 17:36 UTC (permalink / raw)
  To: Memnon Anon; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

Hello

On 11 December 2012 12:01, Memnon Anon <gegendosenfleisch@googlemail.com>wrote:

> Florian Beck <fb@miszellen.de> writes:
>
> > 1. `org-babel-load-file' doesn't seem to be in the org docu. The
> > instructions on worg are obsolete (mentions `org-install') and
> > needlessly complicated. Just putting
> >
> > (package-initialize) ;; only if you use the newest org
>
> ... and the newest emacs!
>
> > (require 'ob-tangle)
> > (org-babel-load-file "/path/to/your/org-init-file.org")
> >
> > into your .emacs (no need for .emacs.d/init.el) seems to suffice.
>
> This is one way to do it, not necessarily the only way.
> I don't think a 4 line init.el is that complicated ;).
>
> > 4. When I babel-load "my-package.org", all emacs sees is the tangled
> > "my-package.el", which of course is right. The problem, however, is
> > that I often search for one of my functions, change it … and loose the
> > changes the next time I start emacs (I already got zapped a couple of
> > times). Integrating org-tangle with the emacs documentation would be
> > tough I guess. But how about setting a read-only file locale variable
> > to block the most stupid mistakes?
>
> How do you change your functions?
> If I want to do it, I tinker with them directly in my emacs.org and
> evaluate from there or copy the relevant bits to the *scratch* buffer
> and bring them back to emacs.org once it works. If the file changed,
> the el file gets tangled fresh automatically next time I start emacs and
> used right away.
>

I suspect what he means is that if he uses `C-h f <function>` or `M-x
find-function RET <function>` it opens the .el associated with the
function when he would rather it open the associated .org file (or
better yet open the src block for editing) so that the changes can be
added without having to look for the correct file (if the functions
are split into sub-files based on associated mode/package).

I have had this problem before (on minor changes so I found them
again easily enough).


> I don't really see a problem?
>
> Memnon
>
> Regards,

--
Jon

[-- Attachment #2: Type: text/html, Size: 3112 bytes --]

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

* Re: Some Experiences with org-babel-load-file
  2012-12-11 14:52 ` Eric Schulte
@ 2012-12-11 19:52   ` Florian Beck
  2012-12-12  3:35     ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Beck @ 2012-12-11 19:52 UTC (permalink / raw)
  To: emacs-orgmode

On 12/11/2012 03:52 PM, Eric Schulte wrote:

> Please go ahead and update the information on worg.  Note that Emacs24
> users need only do
>
>      (require 'org)
>      (org-babel-load-file "/path/to/your/org-init-file.org")
>
> while users of lesser Emacs will have to load a new version of Org-mode
> before calling org-babel-load-file.

Sorry, I have no idea how to update worg.

> compiled and un-compiled code.  If this does pose a problem for you,
> perhaps an optional extra argument to be added to org-babel-load-file to
> enable compilation.

Yes, this would do nicely.

> The `org-babel-load-file' function calls `org-tangle-file' so they are
> definitely working in concert.  When a target file is passed to
> `org-tangle-file' then that is used as the value of the ":tangle" header
> argument, so the default behavior is to tangle.

Ok, that makes sense.

> Great idea.  I don't have time to work on this right now, but it is
> definitely on my stack.  I suppose this should be the default behavior
> for all tangled files (not just those written by org-babel-load-file).

Yes. Perhaps also include a comment that the file was tangled from an 
org-file plus the path to that file.

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

* Re: Some Experiences with org-babel-load-file
  2012-12-11 19:52   ` Florian Beck
@ 2012-12-12  3:35     ` Eric Schulte
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2012-12-12  3:35 UTC (permalink / raw)
  To: Florian Beck; +Cc: emacs-orgmode

Florian Beck <fb@miszellen.de> writes:

> On 12/11/2012 03:52 PM, Eric Schulte wrote:
>
>> Please go ahead and update the information on worg.  Note that Emacs24
>> users need only do
>>
>>      (require 'org)
>>      (org-babel-load-file "/path/to/your/org-init-file.org")
>>
>> while users of lesser Emacs will have to load a new version of Org-mode
>> before calling org-babel-load-file.
>
> Sorry, I have no idea how to update worg.
>

Don't worry, worg can tell you. http://orgmode.org/worg/#sec-4

>
>> compiled and un-compiled code.  If this does pose a problem for you,
>> perhaps an optional extra argument to be added to org-babel-load-file to
>> enable compilation.
>
> Yes, this would do nicely.
>

Done.

>
>> Great idea.  I don't have time to work on this right now, but it is
>> definitely on my stack.  I suppose this should be the default behavior
>> for all tangled files (not just those written by org-babel-load-file).
>
> Yes. Perhaps also include a comment that the file was tangled from an
> org-file plus the path to that file.
>

Done, the chmod value should probably be made customizable through a new
header argument at some point.  As for a "tangled from X" comment, I'd
rather not add extra comments to the code file by default, however there
already exists a tangle option which may fill this need [1].

Cheers,

Footnotes: 
[1]  http://orgmode.org/manual/comments.html

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

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

end of thread, other threads:[~2012-12-12 17:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-10 22:33 Some Experiences with org-babel-load-file Florian Beck
2012-12-11 14:52 ` Eric Schulte
2012-12-11 19:52   ` Florian Beck
2012-12-12  3:35     ` Eric Schulte
2012-12-11 17:01 ` Memnon Anon
2012-12-11 17:36   ` Jonathan Leech-Pepin

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).