Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2015-11-26 22:57:21 +01:00
commit bd79085be0
2 changed files with 45 additions and 4 deletions

View file

@ -2290,10 +2290,19 @@ When NAMED is non-nil, look for a named equation."
" *:: *"))
eq-alist seen)
(dolist (string strings (nreverse eq-alist))
(when (string-match "\\`\\(@[-+I<>0-9.$@]+\\|@?[0-9]+\\|\
\\$\\([a-zA-Z0-9]+\\|[<>]+\\)\\) *= *\\(.*[^ \t]\\)" string)
(let* ((lhs (match-string 1 string))
(rhs (match-string 3 string)))
(when (string-match "\\`\\(@[-+I<>0-9.$@]+\\|\\$\\([_a-zA-Z0-9]+\\|\
[<>]+\\)\\) *= *\\(.*[^ \t]\\)"
string)
(let ((lhs
(let ((m (match-string 1 string)))
(cond
((not (match-end 2)) m)
;; Is it a column reference?
((org-string-match-p "\\`$\\([0-9]+\\|[<>]+\\)\\'" m) m)
;; Since named columns are not possible in
;; LHS, assume this is a named field.
(t (match-string 2 string)))))
(rhs (match-string 3 string)))
(push (cons lhs rhs) eq-alist)
(cond
((not (member lhs seen)) (push lhs seen))

View file

@ -1787,6 +1787,38 @@ is t, then new columns should be added as needed"
|---+---+---|
#+TBLFM: @3$2..@3$>=vsum(@1..@2)")))
(ert-deftest test-org-table/named-field ()
"Test formula with a named field."
(should
(org-string-match-p
"| +| +1 +|"
(org-test-with-temp-text "
| | |
| ^ | name |
<point>#+TBLFM: $name=1"
(org-table-calc-current-TBLFM)
(buffer-string))))
(should
(org-string-match-p
"| +| +1 +|"
(org-test-with-temp-text "
| _ | name |
| | |
<point>#+TBLFM: $name=1"
(org-table-calc-current-TBLFM)
(buffer-string)))))
(ert-deftest test-org-table/named-column ()
"Test formula with a named field."
(should
(org-string-match-p
"| +| +1 +| +1 +|"
(org-test-with-temp-text "
| ! | name | |
| | 1 | |
<point>#+TBLFM: @2$3=$name"
(org-table-calc-current-TBLFM)
(buffer-string)))))
(provide 'test-org-table)