Fix table formula bug with negative result numbers

Willian Henney writes:

> The following is using today's git trunk of org-mode with emacs
> 23.1.94.1 (aquamacs 2.0preview5)
>
>    Consider the following table
>
>    | -8 |
>    |    |
>    |    |
>    |    |
> #+TBLFM: $1=@-1 - 1::@1$1=-8
>
>    Evaluate formulas once (C-u C-c *):
>
>    | -8 |
>    | -9 |
>    |----|
>    | -1 |
>
>    Evaluate formulas again (C-u C-c *):
>
>    | -8 |
>    | -9 |
>    |----|
>    |----|
>
>    What I expected:
>
>    |  -8 |
>    |  -9 |
>    | -10 |
>    | -11 |
>
> The problem always seems to start at -10. When I turn on table
> debugging, it first calculates the -10 value correctly, but then fails
> to recognise the -10 cell as a number when calculating the next row,
> using 0 instead, which results in -1. This is because during the
> intermediate formatting of the cell the minus sign in -10 abuts the
> column separator: "|-10 |", and the "|-" part is then interpreted as
> the beginning of an hline.
This commit is contained in:
Carsten Dominik 2010-04-24 10:22:49 +02:00
parent 3a7f7dbcca
commit 4462229742
2 changed files with 6 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2010-04-24 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-justify-field-maybe): Make sure that
inserting a value does not turn a line into a hline.
2010-04-23 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-sum): New argument HEADLINE-FILTER.

View File

@ -830,6 +830,7 @@ Optional argument NEW may specify text to replace the current field content."
(if (<= (length new) l) ;; FIXME: length -> str-width?
(setq n (format f new))
(setq n (concat new "|") org-table-may-need-update t)))
(if (equal (string-to-char n) ?-) (setq n (concat " " n)))
(or (equal n o)
(let (org-table-may-need-update)
(replace-match n t t))))