From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Where to define functions for use with org Date: Fri, 31 Oct 2008 14:39:08 -0700 Message-ID: <87tzaso35v.fsf@gmail.com> References: <87bpx25eci.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kw1i7-0006rW-5S for emacs-orgmode@gnu.org; Fri, 31 Oct 2008 17:39:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kw1i5-0006ov-SN for emacs-orgmode@gnu.org; Fri, 31 Oct 2008 17:39:14 -0400 Received: from [199.232.76.173] (port=36955 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kw1i5-0006oB-EL for emacs-orgmode@gnu.org; Fri, 31 Oct 2008 17:39:13 -0400 Received: from qw-out-1920.google.com ([74.125.92.145]:47914) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kw1i4-0001mQ-VU for emacs-orgmode@gnu.org; Fri, 31 Oct 2008 17:39:13 -0400 Received: by qw-out-1920.google.com with SMTP id 4so581157qwk.24 for ; Fri, 31 Oct 2008 14:39:10 -0700 (PDT) In-Reply-To: <87bpx25eci.fsf@gmail.com> (Daniel Clemente's message of "Thu, 30 Oct 2008 15:47:57 +0100") 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: Daniel Clemente Cc: emacs-orgmode@gnu.org Daniel Clemente writes: > Hi, I'd like some suggestions about storing (defun)s in .org-files. > > Sometimes Org must use ELisp functions, for instance: > - a dynamic table uses a function org-dblock-write:some_name to create i= ts contents > - a table uses a formula like $5=3D'(my-function $2) which does a calcul= ation not available in calc > > These scenarios require that you have already the functions you will > use. If you wrote the (defun ...) in your code, you must go there > and do C-x C-e to evaluate all of them. > > My question is: =C2=BFhow would you make this process automatic and sti= ll > distribute the function code together with the .org file? > Hi Daniel, I ran into a problem similar to you description above, and developed a solution in the form of a modified version of org-eval.el (in the contrib directory of the org-mode source). It is like org-eval except for the following changes... ,----[org-eval-light.el] | ;;; Changes: by Eric Schulte | ;; | ;; 1) forms are only executed manually, (allowing for the execution of | ;; an entire subtree of forms) | ;; 2) use the org-mode style src blocks, rather than the muse style | ;; blocks | ;; 3) forms are not replaced by their outputs, but rather the output | ;; is placed in the buffer immediately following the src block | ;; commented by `org-eval-light-make-region-example' (when | ;; evaluated with a prefix argument no output is placed in the | ;; buffer) | ;; 4) add defadvice to org-ctrl-c-ctrl-c so that when called inside of | ;; a source block it will call `org-eval-light-current-snippet' `---- My modified version is available at http://github.com/eschulte/org-contrib/tree/master/org-eval-light.el It's been working fairly well for me, in fact I was going to push this to the mailing list anyways, but wanted to play with it some more. Cheers -- Eric