diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-21 12:17:07 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-21 12:17:07 +0200 |
commit | 547b431e70a888797cc8d743678c5bdb15e857cd (patch) | |
tree | 691e2bbf679309ee2e608e86bf81efa4de2976a6 | |
parent | c891b840d282a8ba83f7d369ac841cb3b583c620 (diff) | |
download | org-mode-547b431e70a888797cc8d743678c5bdb15e857cd.tar.gz |
org-capture: Fix row insertion in a table with a formula
* lisp/org-capture.el (org-capture-place-table-line): Insert new row
above the formula, not below.
* testing/lisp/test-org-capture.el (test-org-capture/table-line): Add
test.
-rw-r--r-- | lisp/org-capture.el | 7 | ||||
-rw-r--r-- | testing/lisp/test-org-capture.el | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 8d71c79..c1af0ae 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1220,10 +1220,11 @@ may have been stored before." (while (re-search-forward org-table-dataline-regexp end t) (pcase (org-element-lineage (org-element-at-point) '(table) t) (`nil nil) + ((and table + (guard (eq 'table.el (org-element-property :type table)))) + nil) (table - (goto-char (org-element-property :end table)) - (skip-chars-backward " \r\t\n") - (forward-line) + (goto-char (org-element-property :contents-end table)) (narrow-to-region (org-element-property :post-affiliated table) (point)) (throw :found t)))) diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el index 4b9b445..2e4a3b7 100644 --- a/testing/lisp/test-org-capture.el +++ b/testing/lisp/test-org-capture.el @@ -233,6 +233,16 @@ :immediate-finish t)))) (org-capture nil "t")) (buffer-string)))) + ;; Properly insert row with formulas. + (should + (equal "| 1 |\n| 2 |\n#+TBLFM: " + (org-test-with-temp-text-in-file "| 1 |\n#+TBLFM: " + (let* ((file (buffer-file-name)) + (org-capture-templates + `(("t" "Table" table-line (file ,file) + "| 2 |" :immediate-finish t)))) + (org-capture nil "t")) + (buffer-string)))) ;; When `:prepend' is nil, add the row at the end of the table. (should (equal "| a |\n| x |\n" |