mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-24 22:02:52 +00:00
org-refile: Fix heading being removed when refiling into itself
* lisp/org-refile.el (org-refile): Throw an error when attempting to refile heading into itself and the point is not at bol. * testing/lisp/test-org.el (test-org/refile): Add tests. Reported-by: Oliver Epper <oliver.epper@gmail.com> Link: https://list.orgmode.org/orgmode/CAP8tsuSEScO+Q7=g7kL=9Dk-95reJvUmLoyqmJjd2-ZM6iycfA@mail.gmail.com/
This commit is contained in:
parent
6e6354c074
commit
30b790f42b
|
@ -523,7 +523,9 @@ prefix argument (`C-u C-u C-u C-c C-w')."
|
|||
(if regionp
|
||||
(and (>= pos region-start)
|
||||
(<= pos region-end))
|
||||
(and (>= pos (point))
|
||||
(and (>= pos (save-excursion
|
||||
(org-back-to-heading t)
|
||||
(point)))
|
||||
(< pos (save-excursion
|
||||
(org-end-of-subtree t t))))))
|
||||
(error "Cannot refile to position inside the tree or region"))
|
||||
|
|
|
@ -7050,8 +7050,20 @@ Paragraph<point>"
|
|||
** H2\n"
|
||||
(org-test-with-temp-text-in-file "* H1
|
||||
* H2<point>"
|
||||
(org-refile nil nil `("H1" ,(buffer-file-name) nil 1))
|
||||
(buffer-string))))
|
||||
;; Throw an error when trying to refile into itself.
|
||||
(should-error
|
||||
(org-test-with-temp-text-in-file "* H<point>1
|
||||
* H2"
|
||||
(org-refile nil nil `("H1" ,(buffer-file-name) nil 1))
|
||||
(buffer-string)))))
|
||||
(buffer-string)))
|
||||
(should-error
|
||||
(org-test-with-temp-text-in-file "* one
|
||||
* t<point>wo
|
||||
* three"
|
||||
(org-refile nil nil `("two" ,(buffer-file-name) nil 7))
|
||||
(buffer-string))))
|
||||
|
||||
|
||||
;;; Sparse trees
|
||||
|
|
Loading…
Reference in a new issue