From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Proposal: In-place formulas in tables Date: Mon, 7 May 2007 13:45:05 +0200 Message-ID: <06fc609c06154b668523fc012e10d767@science.uva.nl> References: <1070507102511.9304@cse.unsw.edu.au> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hl1lN-0002av-Dp for emacs-orgmode@gnu.org; Mon, 07 May 2007 07:52:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hl1lL-0002af-VG for emacs-orgmode@gnu.org; Mon, 07 May 2007 07:52:20 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hl1lL-0002ac-QA for emacs-orgmode@gnu.org; Mon, 07 May 2007 07:52:19 -0400 Received: from korteweg.uva.nl ([146.50.98.70]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hl1eN-0005QD-B4 for emacs-orgmode@gnu.org; Mon, 07 May 2007 07:45:07 -0400 In-Reply-To: <1070507102511.9304@cse.unsw.edu.au> 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: Simon Winwood Cc: emacs-orgmode@gnu.org On May 7, 2007, at 12:24, Simon Winwood wrote: > > Hi, I recently got bitten (not badly, say nibbled then), when I > had a formula in a field to sum a column of numbers and added another > data row --- when I C-c C-c'd to update the sum, the last data row was > overwritten (i.e, not the formula field). > > For example: > > |---+---| > | a | 1 | > | b | 2 | > |---+---| > | | 3 | > #+TBLFM: @3$2=vsum(@1$2..@-I$2) > > add row X and recalculate (note b is overwritten by 1): > |---+---| > | a | 1 | > | X | 7 | > | b | 1 | > |---+---| > | | 3 | > #+TBLFM: @3$2=vsum(@1$2..@-I$2) > > Obviously the code is doing the right thing according to the > TBLFM rules, it just isn't what I (and, I assume, other people) would > expect. > > So, a solution: rather than overwrite formulas in fields with > their values, use overlays to make the formula invisible and set > before-string (or after-string) to be the calculated value. You are hitting a very fundamental difference between org-mode tables an the usual "spreadsheet" programs. In a spreadsheet, a table field contains a formula, and the result is displayed. In Org-mode tables, the table fieldd only contains the field value, never a formula. This is because Org-mode tables are plain text that can be read as is. A field never contains a formula - one of the nice aspectes of this is that you can write column formulas without copying a formula to each field in the table. Now the problem is, that you can edit plain text any way you like and in this way break the implicit relation between formuals and fields. This is a fundamental problem, ven if we would store formulas in fields. What you can to do avoid problems like the one you encountered is to use org-mode commands to create new rows or columns. For example to make a new row, place the cursor on a row and press S-M-down. Then the formulas will be modified to account for this change. - Carsten