Merge branch 'maint'

This commit is contained in:
Kyle Meyer 2016-11-28 18:56:17 -05:00
commit 3d80b3545e
2 changed files with 23 additions and 6 deletions

View File

@ -24693,7 +24693,8 @@ Move to the previous element at the same level, when possible."
"Move backward element at point." "Move backward element at point."
(interactive) (interactive)
(if (org-with-limited-levels (org-at-heading-p)) (org-move-subtree-up) (if (org-with-limited-levels (org-at-heading-p)) (org-move-subtree-up)
(let* ((elem (org-element-at-point)) (let* ((elem (or (org-element-at-point)
(user-error "No element at point")))
(prev-elem (prev-elem
(save-excursion (save-excursion
(goto-char (org-element-property :begin elem)) (goto-char (org-element-property :begin elem))
@ -24719,7 +24720,8 @@ Move to the previous element at the same level, when possible."
"Move forward element at point." "Move forward element at point."
(interactive) (interactive)
(let* ((pos (point)) (let* ((pos (point))
(elem (org-element-at-point))) (elem (or (org-element-at-point)
(user-error "No element at point"))))
(when (= (point-max) (org-element-property :end elem)) (when (= (point-max) (org-element-property :end elem))
(user-error "Cannot drag element forward")) (user-error "Cannot drag element forward"))
(goto-char (org-element-property :end elem)) (goto-char (org-element-property :end elem))

View File

@ -3244,18 +3244,27 @@ Outside."
;; Error when trying to move first element of buffer. ;; Error when trying to move first element of buffer.
(should-error (should-error
(org-test-with-temp-text "Paragraph 1.\n\nParagraph 2." (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
(org-drag-element-backward))) (org-drag-element-backward))
:type 'user-error)
;; Error when trying to swap nested elements. ;; Error when trying to swap nested elements.
(should-error (should-error
(org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER" (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
(forward-line) (forward-line)
(org-drag-element-backward))) (org-drag-element-backward))
:type 'user-error)
;; Error when trying to swap an headline element and a non-headline ;; Error when trying to swap an headline element and a non-headline
;; element. ;; element.
(should-error (should-error
(org-test-with-temp-text "Test.\n* Head 1" (org-test-with-temp-text "Test.\n* Head 1"
(forward-line) (forward-line)
(org-drag-element-backward))) (org-drag-element-backward))
:type 'user-error)
;; Error when called before first element.
(should-error
(org-test-with-temp-text "\n"
(forward-line)
(org-drag-element-backward))
:type 'user-error)
;; Preserve visibility of elements and their contents. ;; Preserve visibility of elements and their contents.
(should (should
(equal '((63 . 82) (26 . 48)) (equal '((63 . 82) (26 . 48))
@ -3287,7 +3296,13 @@ Text.
;; headline. ;; headline.
(org-test-with-temp-text "Test.\n* Head 1" (org-test-with-temp-text "Test.\n* Head 1"
(should-error (org-drag-element-forward))) (should-error (org-drag-element-forward)))
;; 4. Otherwise, swap elements, preserving column and blank lines ;; 4. Error when called before first element.
(should-error
(org-test-with-temp-text "\n"
(forward-line)
(org-drag-element-backward))
:type 'user-error)
;; 5. Otherwise, swap elements, preserving column and blank lines
;; between elements. ;; between elements.
(org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3" (org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
(search-forward "graph") (search-forward "graph")