Merge branch 'maint'
This commit is contained in:
commit
0edd9aee38
2 changed files with 23 additions and 14 deletions
|
@ -1167,9 +1167,7 @@ may have been stored before."
|
|||
(unless (org-at-heading-p) (outline-next-heading))
|
||||
(org-capture-mark-kill-region origin (point))
|
||||
(org-capture-narrow beg (point))
|
||||
(when (or (search-backward "%?" beg t)
|
||||
(search-forward "%?" nil t))
|
||||
(replace-match ""))))))
|
||||
(org-capture--position-cursor beg (point))))))
|
||||
|
||||
(defun org-capture-place-item ()
|
||||
"Place the template as a new plain list item."
|
||||
|
@ -1281,9 +1279,7 @@ may have been stored before."
|
|||
;; not narrow at the beginning of the next line, possibly
|
||||
;; altering its structure (e.g., when it is a headline).
|
||||
(org-capture-narrow beg (1- end))
|
||||
(when (or (search-backward "%?" beg t)
|
||||
(search-forward "%?" end t))
|
||||
(replace-match ""))))))
|
||||
(org-capture--position-cursor beg end)))))
|
||||
|
||||
(defun org-capture-place-table-line ()
|
||||
"Place the template as a table line."
|
||||
|
@ -1365,9 +1361,7 @@ may have been stored before."
|
|||
;; TEXT is guaranteed to end with a newline character. Ignore
|
||||
;; it when narrowing so as to not alter data on the next line.
|
||||
(org-capture-narrow beg (1- end))
|
||||
(when (or (search-backward "%?" beg t)
|
||||
(search-forward "%?" end t))
|
||||
(replace-match ""))))))
|
||||
(org-capture--position-cursor beg (1- end))))))
|
||||
|
||||
(defun org-capture-place-plain-text ()
|
||||
"Place the template plainly.
|
||||
|
@ -1402,9 +1396,7 @@ Of course, if exact position has been required, just put it there."
|
|||
(org-capture-empty-lines-after)
|
||||
(org-capture-mark-kill-region origin (point))
|
||||
(org-capture-narrow beg end)
|
||||
(when (or (search-backward "%?" beg t)
|
||||
(search-forward "%?" end t))
|
||||
(replace-match ""))))))
|
||||
(org-capture--position-cursor beg end)))))
|
||||
|
||||
(defun org-capture-mark-kill-region (beg end)
|
||||
"Mark the region that will have to be killed when aborting capture."
|
||||
|
@ -1450,8 +1442,15 @@ Of course, if exact position has been required, just put it there."
|
|||
(defun org-capture-narrow (beg end)
|
||||
"Narrow, unless configuration says not to narrow."
|
||||
(unless (org-capture-get :unnarrowed)
|
||||
(narrow-to-region beg end)
|
||||
(goto-char beg)))
|
||||
(narrow-to-region beg end)))
|
||||
|
||||
(defun org-capture--position-cursor (beg end)
|
||||
"Move point to first \"%?\" location or at start of template.
|
||||
BEG and END are buffer positions at the begging and end position
|
||||
of the template."
|
||||
(goto-char beg)
|
||||
(when (search-forward "%?" end t)
|
||||
(replace-match "")))
|
||||
|
||||
(defun org-capture-empty-lines-before (&optional n)
|
||||
"Set the correct number of empty lines before the insertion point.
|
||||
|
|
|
@ -742,6 +742,16 @@
|
|||
`(("t" "Text" plain (file ,file) ""
|
||||
:immediate-finish t))))
|
||||
(org-capture nil "t")
|
||||
(buffer-string)))))
|
||||
;; Test :unnarrowed property without a "%?" marker.
|
||||
(should
|
||||
(equal "SUCCESS\n"
|
||||
(org-test-with-temp-text-in-file ""
|
||||
(let* ((file (buffer-file-name))
|
||||
(org-capture-templates
|
||||
`(("t" "Text" plain (file ,file) "SUCCESS"
|
||||
:unnarrowed t :immediate-finish t))))
|
||||
(org-capture nil "t")
|
||||
(buffer-string))))))
|
||||
|
||||
(provide 'test-org-capture)
|
||||
|
|
Loading…
Reference in a new issue