forked from mirrors/org-mode
org-capture: Fix table line capture with custom location
* lisp/org-capture.el (org-capture-place-table-line): Fix error when a precise location is given, e.g. with `file+function' target. * testing/lisp/test-org-capture.el (test-org-capture/table-line): Add test. Reported-by: Thomas Holst <thomas_holst@gmx.de> <http://lists.gnu.org/r/emacs-orgmode/2018-05/msg00359.html>
This commit is contained in:
parent
1cfd5d04e3
commit
9d51a8b5a0
|
@ -1204,7 +1204,8 @@ may have been stored before."
|
|||
beg end)
|
||||
(cond
|
||||
((org-capture-get :exact-position)
|
||||
(goto-char (org-capture-get :exact-position)))
|
||||
(setq beg (org-capture-get :exact-position))
|
||||
(setq end (save-excursion (outline-next-heading) (point))))
|
||||
((not (org-capture-get :target-entry-p))
|
||||
;; Table is not necessarily under a heading. Find first table
|
||||
;; in the buffer.
|
||||
|
|
|
@ -207,6 +207,22 @@
|
|||
"| x |" :immediate-finish t))))
|
||||
(org-capture nil "t"))
|
||||
(buffer-string))))
|
||||
;; When a precise location is specified, find the first table after
|
||||
;; point, down to the end of the section.
|
||||
(should
|
||||
(equal "| a |
|
||||
|
||||
|
||||
| b |
|
||||
| x |
|
||||
"
|
||||
(org-test-with-temp-text-in-file "| a |\n\n\n| b |\n"
|
||||
(let* ((file (buffer-file-name))
|
||||
(org-capture-templates
|
||||
`(("t" "Table" table-line (file+function ,file forward-line)
|
||||
"| x |" :immediate-finish t))))
|
||||
(org-capture nil "t"))
|
||||
(buffer-string))))
|
||||
;; Create a new table with an empty header when none can be found.
|
||||
(should
|
||||
(equal "| | |\n|---+---|\n| a | b |\n"
|
||||
|
|
Loading…
Reference in New Issue