Refile: Catch invalid target specification

Patch by Jason Dunsmore.
This commit is contained in:
Carsten Dominik 2010-03-19 14:09:30 +01:00
parent b3ffb6a9b9
commit e45c431ce9
2 changed files with 18 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2010-03-19 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-refile-get-location): Catch an invalid target
specification.
2010-03-18 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):

View File

@ -9481,15 +9481,19 @@ See also `org-refile-use-outline-path' and `org-completion-use-ido'"
(if (equal (car org-refile-history) (nth 1 org-refile-history))
(pop org-refile-history)))
pa)
(when (string-match "\\`\\(.*\\)/\\([^/]+\\)\\'" answ)
(setq parent (match-string 1 answ)
child (match-string 2 answ))
(setq parent-target (or (assoc parent tbl) (assoc (concat parent "/") tbl)))
(when (and parent-target
(or (eq new-nodes t)
(and (eq new-nodes 'confirm)
(y-or-n-p (format "Create new node \"%s\"? " child)))))
(org-refile-new-child parent-target child))))))
(if (string-match "\\`\\(.*\\)/\\([^/]+\\)\\'" answ)
(progn
(setq parent (match-string 1 answ)
child (match-string 2 answ))
(setq parent-target (or (assoc parent tbl)
(assoc (concat parent "/") tbl)))
(when (and parent-target
(or (eq new-nodes t)
(and (eq new-nodes 'confirm)
(y-or-n-p (format "Create new node \"%s\"? "
child)))))
(org-refile-new-child parent-target child)))
(error "Invalid target location")))))
(defun org-refile-new-child (parent-target child)
"Use refile target PARENT-TARGET to add new CHILD below it."