mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-26 01:32:53 +00:00
org-capture-set-target-location: Improve error reporting for malformed target
* lisp/org-capture.el (org-capture-set-target-location): Tighten matching the template target location when the location value is not properly formatted.
This commit is contained in:
parent
b2ee10545e
commit
0a58a53eda
|
@ -1001,12 +1001,12 @@ Store them in the capture property list."
|
||||||
((or `here
|
((or `here
|
||||||
`(here))
|
`(here))
|
||||||
(org-capture-put :exact-position (point) :insert-here t))
|
(org-capture-put :exact-position (point) :insert-here t))
|
||||||
(`(file ,path)
|
(`(file ,(and path (pred stringp)))
|
||||||
(set-buffer (org-capture-target-buffer path))
|
(set-buffer (org-capture-target-buffer path))
|
||||||
(org-capture-put-target-region-and-position)
|
(org-capture-put-target-region-and-position)
|
||||||
(widen)
|
(widen)
|
||||||
(setq target-entry-p nil))
|
(setq target-entry-p nil))
|
||||||
(`(id ,id)
|
(`(id ,(and id (or (pred stringp) (pred symbolp))))
|
||||||
(pcase (org-id-find id)
|
(pcase (org-id-find id)
|
||||||
(`(,path . ,position)
|
(`(,path . ,position)
|
||||||
(set-buffer (org-capture-target-buffer path))
|
(set-buffer (org-capture-target-buffer path))
|
||||||
|
@ -1014,7 +1014,7 @@ Store them in the capture property list."
|
||||||
(org-capture-put-target-region-and-position)
|
(org-capture-put-target-region-and-position)
|
||||||
(goto-char position))
|
(goto-char position))
|
||||||
(_ (error "Cannot find target ID \"%s\"" id))))
|
(_ (error "Cannot find target ID \"%s\"" id))))
|
||||||
(`(file+headline ,path ,headline)
|
(`(file+headline ,(and path (pred stringp)) ,(and headline (pred stringp)))
|
||||||
(set-buffer (org-capture-target-buffer path))
|
(set-buffer (org-capture-target-buffer path))
|
||||||
;; Org expects the target file to be in Org mode, otherwise
|
;; Org expects the target file to be in Org mode, otherwise
|
||||||
;; it throws an error. However, the default notes files
|
;; it throws an error. However, the default notes files
|
||||||
|
@ -1036,7 +1036,7 @@ Store them in the capture property list."
|
||||||
(unless (bolp) (insert "\n"))
|
(unless (bolp) (insert "\n"))
|
||||||
(insert "* " headline "\n")
|
(insert "* " headline "\n")
|
||||||
(forward-line -1)))
|
(forward-line -1)))
|
||||||
(`(file+olp ,path . ,outline-path)
|
(`(file+olp ,(and path (pred stringp)) . ,(and outline-path (guard outline-path)))
|
||||||
(let ((m (org-find-olp (cons (org-capture-expand-file path)
|
(let ((m (org-find-olp (cons (org-capture-expand-file path)
|
||||||
outline-path))))
|
outline-path))))
|
||||||
(set-buffer (marker-buffer m))
|
(set-buffer (marker-buffer m))
|
||||||
|
@ -1044,7 +1044,7 @@ Store them in the capture property list."
|
||||||
(widen)
|
(widen)
|
||||||
(goto-char m)
|
(goto-char m)
|
||||||
(set-marker m nil)))
|
(set-marker m nil)))
|
||||||
(`(file+regexp ,path ,regexp)
|
(`(file+regexp ,(and path (pred stringp)) ,(and regexp (pred stringp)))
|
||||||
(set-buffer (org-capture-target-buffer path))
|
(set-buffer (org-capture-target-buffer path))
|
||||||
(org-capture-put-target-region-and-position)
|
(org-capture-put-target-region-and-position)
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -1057,7 +1057,7 @@ Store them in the capture property list."
|
||||||
(org-capture-put :exact-position (point))
|
(org-capture-put :exact-position (point))
|
||||||
(setq target-entry-p
|
(setq target-entry-p
|
||||||
(and (derived-mode-p 'org-mode) (org-at-heading-p)))))
|
(and (derived-mode-p 'org-mode) (org-at-heading-p)))))
|
||||||
(`(file+olp+datetree ,path . ,outline-path)
|
(`(file+olp+datetree ,(and path (pred stringp)) . ,(and outline-path (guard outline-path)))
|
||||||
(let ((m (if outline-path
|
(let ((m (if outline-path
|
||||||
(org-find-olp (cons (org-capture-expand-file path)
|
(org-find-olp (cons (org-capture-expand-file path)
|
||||||
outline-path))
|
outline-path))
|
||||||
|
@ -1112,7 +1112,7 @@ Store them in the capture property list."
|
||||||
;; the following is the keep-restriction argument for
|
;; the following is the keep-restriction argument for
|
||||||
;; org-datetree-find-date-create
|
;; org-datetree-find-date-create
|
||||||
(when outline-path 'subtree-at-point))))
|
(when outline-path 'subtree-at-point))))
|
||||||
(`(file+function ,path ,function)
|
(`(file+function ,(and path (pred stringp)) ,(and function (pred functionp)))
|
||||||
(set-buffer (org-capture-target-buffer path))
|
(set-buffer (org-capture-target-buffer path))
|
||||||
(org-capture-put-target-region-and-position)
|
(org-capture-put-target-region-and-position)
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -1120,7 +1120,7 @@ Store them in the capture property list."
|
||||||
(org-capture-put :exact-position (point))
|
(org-capture-put :exact-position (point))
|
||||||
(setq target-entry-p
|
(setq target-entry-p
|
||||||
(and (derived-mode-p 'org-mode) (org-at-heading-p))))
|
(and (derived-mode-p 'org-mode) (org-at-heading-p))))
|
||||||
(`(function ,fun)
|
(`(function ,(and fun (pred functionp)))
|
||||||
(funcall fun)
|
(funcall fun)
|
||||||
(org-capture-put :exact-position (point))
|
(org-capture-put :exact-position (point))
|
||||||
(setq target-entry-p
|
(setq target-entry-p
|
||||||
|
|
Loading…
Reference in a new issue