From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Embedded elisp formulas, was: Spreadsheet and weighted means Date: Thu, 2 Oct 2008 13:44:06 +0200 Message-ID: <83E74583-842D-472D-98BD-3F445ED64FA4@uva.nl> References: <87wsh7w589.fsf@selenimh.orion.org> <9136F031-BBCD-4A80-A117-6047C5D3F777@uva.nl> <87y718nu0l.fsf@selenimh.orion.org> <871vz0t7z5.fsf_-_@gmail.com> <87prmk5ab6.fsf@gmail.com> <87y717uamj.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KlMbj-0004Va-O0 for emacs-orgmode@gnu.org; Thu, 02 Oct 2008 07:44:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KlMbi-0004UZ-6J for emacs-orgmode@gnu.org; Thu, 02 Oct 2008 07:44:34 -0400 Received: from [199.232.76.173] (port=33420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KlMbh-0004UW-Vr for emacs-orgmode@gnu.org; Thu, 02 Oct 2008 07:44:34 -0400 Received: from pony.ic.uva.nl ([145.18.40.181]:34710) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KlMbh-0001xH-5o for emacs-orgmode@gnu.org; Thu, 02 Oct 2008 07:44:33 -0400 In-Reply-To: <87y717uamj.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: Eric Schulte Cc: Paul R , emacs-orgmode@gnu.org On Oct 2, 2008, at 2:03 AM, Eric Schulte wrote: > Paul R writes: > >> On Wed, 01 Oct 2008 12:45:34 -0700, "Eric Schulte" > > 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 > > > (defun my-specific-function-for-this-file (org-tabl-cell) > (format "%S" > (do-something-special > (read org-tabl-cell)))) > > > 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 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