The following commit introduced a bug that prevents org-table from
evaluating formulas inserted into fields:

1c203d8d196aa9b46ea9a455cb891fefe2179d52

Steps to replicate:

1. Enter a simple table:

| 3 |
| 2 |
|---|
|   |

2. Add a formula:

| 3 |
| 2 |
|---|
| :=@1+@2 |

3. Press tab to evaluate:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  org-table-store-formulas((("@3$1" . #("@1+@2" 0 5 (face org-formula fontified 
t)))))
  org-table-get-formula(#("@1+@2" 0 5 (face org-formula fontified t)) t)
  org-table-eval-formula((4) #("@1+@2" 0 5 (face org-formula fontified t)))
  org-table-maybe-eval-formula()
  org-table-next-field()
  call-interactively(org-table-next-field)
  org-cycle(nil)
  call-interactively(org-cycle nil nil)

The problem is the if statement in org-table-store-formulas:

    (if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+tblfm:\\)\\(.*\n?\\)")
        (progn
          ;; don't overwrite TBLFM, we might use text properties to store stuff
          (goto-char (match-beginning 3))
          (delete-region (match-beginning 3) (match-end 0)))
      (org-indent-line-function)
      (insert (match-string 2)))

Notice the (insert (match-string 2)). This fails because if there is
no looking-at match, then there will be no (match-string 2).

Best,
Matt


Reply via email to