emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: Embedded elisp formulas, was: Spreadsheet and weighted mea


From: Carsten Dominik
Subject: [Orgmode] Re: Embedded elisp formulas, was: Spreadsheet and weighted means
Date: Thu, 2 Oct 2008 13:44:06 +0200


On Oct 2, 2008, at 2:03 AM, Eric Schulte wrote:

Paul R <address@hidden> writes:

On Wed, 01 Oct 2008 12:45:34 -0700, "Eric Schulte" <address@hidden > said:

This raises an issue I've been running into recently, If I have
a multi-line elisp function (I guess same issue would apply for
multi-line shell commands) that I want to use from an org file (for
example to compute table columns), is there a way to save and load
the function from the org file? I've tried multiline [[elisp: ]]
links but they don't work well, maybe something like...

maybe you can use the emacs facility to load code when visiting
a file. For more information, read the following info node :
   File: emacs,  Node: Specifying File Variables

I looked at this, but then I ran across org-eval.el in the
org/contrib/lisp directory. With (require 'org-eval) in my .emacs I can
put something like the following

<lisp>
(defun my-specific-function-for-this-file (org-tabl-cell)
 (format "%S"
          (do-something-special
           (read org-tabl-cell))))
</lisp>

in an org file and org-eval is nice enough to evaluate the code defining
the function upon opening the file, to display only the name of the
function in a special face, and to allow me to edit the function in the
appropriate mode with C-' (also works for ruby/shell/python/etc...).
Everything I could have asked for!

It nice to request a feature and find it's already implemented.

Before starting to use org-eval.el, I'd like to make sure that everyone understands that loading org-eval.el turns any org-mode file into an executable. That means that you have to start being careful with org-mode files you receive from others or download from the internet. Just like you would run a program from the web only if you trust the source, you should then only load such files into Emacs if you trust the source. I am not saying this to keep you from using org- eval, I am am using it myself, but please be aware of this issue.

One more remark: a <lisp> tag is evaluated by jit-lock (i.e. by the font-lock mechanism), just before Emacs tries to make it visible. The reason for this is that the original indent for this functionality was to produce and display dynamic content on a page. In large files, font locking can be delayed until the segment in question comes into view in the Emacs window. To be sure to get this code evaluated immediately when visiting a file, you might want to put the snippets close to the beginning of the file.

- Carsten




reply via email to

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