1 ;;; test-org.el --- tests for org.el
3 ;; Copyright (c) David Maus
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;; Template test file for Org-mode tests
26 (ert-deftest test-org
/org-link-escape-ascii-character
()
27 "Escape an ascii character."
31 (org-link-escape "["))))
33 (ert-deftest test-org
/org-link-escape-ascii-ctrl-character
()
34 "Escape an ascii control character."
38 (org-link-escape "\t"))))
40 (ert-deftest test-org
/org-link-escape-multibyte-character
()
41 "Escape an unicode multibyte character."
45 (org-link-escape "€"))))
47 (ert-deftest test-org
/org-link-escape-custom-table
()
48 "Escape string with custom character table."
52 (org-link-escape "Foo:Bar\n" '(?\
: ?\B
)))))
54 (ert-deftest test-org
/org-link-escape-custom-table-merge
()
55 "Escape string with custom table merged with default table."
58 "%5BF%6F%6F%3A%42ar%0A%5D"
59 (org-link-escape "[Foo:Bar\n]" '(?\
: ?\B ?\o
) t
))))
61 (ert-deftest test-org
/org-link-unescape-ascii-character
()
62 "Unescape an ascii character."
66 (org-link-unescape "%5B"))))
68 (ert-deftest test-org
/org-link-unescape-ascii-ctrl-character
()
69 "Unescpae an ascii control character."
73 (org-link-unescape "%0A"))))
75 (ert-deftest test-org
/org-link-unescape-multibyte-character
()
76 "Unescape unicode multibyte character."
80 (org-link-unescape "%E2%82%AC"))))
82 (ert-deftest test-org
/org-link-unescape-ascii-extended-char
()
83 "Unescape old style percent escaped character."
87 (decode-coding-string (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1
))))
89 (ert-deftest test-org
/org-link-escape-url-with-escaped-char
()
90 "Escape and unscape a URL that includes an escaped char.
91 http://article.gmane.org/gmane.emacs.orgmode/21459/"
94 "http://some.host.com/form?&id=blah%2Bblah25"
95 (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
97 (ert-deftest test-org
/accumulated-properties-in-drawers
()
98 "Ensure properties accumulate in subtree drawers."
99 (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
100 (org-babel-next-src-block)
101 (should (equal '(2 1) (org-babel-execute-src-block)))))
107 (ert-deftest test-org
/org-read-date
()
108 "Test `org-read-date' specifications."
109 ;; Parse ISO date with abbreviated year and month.
110 (should (equal "2012-03-29 16:40"
111 (let ((org-time-was-given t
))
112 (org-read-date t nil
"12-3-29 16:40"))))
113 ;; Parse Europeans dates.
114 (should (equal "2012-03-29 16:40"
115 (let ((org-time-was-given t
))
116 (org-read-date t nil
"29.03.2012 16:40"))))
117 ;; Parse Europeans dates without year.
118 (should (string-match "2[0-9]\\{3\\}-03-29 16:40"
119 (let ((org-time-was-given t
))
120 (org-read-date t nil
"29.03. 16:40")))))
128 ;; Fuzzy links [[text]] encompass links to a target (<<text>>), to
129 ;; a target keyword (aka an invisible target: #+TARGET: text), to
130 ;; a named element (#+name: text) and to headlines (* Text).
132 (ert-deftest test-org
/fuzzy-links
()
133 "Test fuzzy links specifications."
134 ;; 1. Fuzzy link goes in priority to a matching target.
135 (org-test-with-temp-text
136 "#+TARGET: Test\n#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
139 (should (looking-at "<<Test>>")))
140 ;; 2. Fuzzy link should then go to a matching target keyword.
141 (org-test-with-temp-text
142 "#+NAME: Test\n|a|b|\n#+TARGET: Test\n* Test\n[[Test]]"
145 (should (looking-at "#\\+TARGET: Test")))
146 ;; 3. Then fuzzy link points to an element with a given name.
147 (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]"
150 (should (looking-at "#\\+NAME: Test")))
151 ;; 4. A target still lead to a matching headline otherwise.
152 (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]"
155 (should (looking-at "\\* Head2")))
156 ;; 5. With a leading star in link, enforce heading match.
157 (org-test-with-temp-text "#+TARGET: Test\n* Test\n<<Test>>\n[[*Test]]"
160 (should (looking-at "\\* Test"))))
166 (ert-deftest test-org
/fill-paragraph
()
167 "Test `org-fill-paragraph' specifications."
168 ;; At an Org table, align it.
169 (org-test-with-temp-text "|a|"
171 (should (equal (buffer-string) "| a |\n")))
172 ;; At a paragraph, preserve line breaks.
173 (org-test-with-temp-text "some \\\\\nlong\ntext"
174 (let ((fill-column 20))
176 (should (equal (buffer-string) "some \\\\\nlong text"))))
177 ;; Correctly fill a paragraph when point is at its very end.
180 (org-test-with-temp-text "A\nB"
181 (let ((fill-column 20))
182 (goto-char (point-max))
185 ;; Correctly fill the last paragraph of a greater element.
187 (equal "#+BEGIN_CENTER\n- 012345\n 789\n#+END_CENTER"
188 (org-test-with-temp-text "#+BEGIN_CENTER\n- 012345 789\n#+END_CENTER"
189 (let ((fill-column 8))
194 ;; Correctly fill an element in a narrowed buffer.
197 (org-test-with-temp-text "01234 6789"
198 (let ((fill-column 5))
199 (narrow-to-region 1 8)
202 ;; Special case: Fill first paragraph when point is at an item or
203 ;; a plain-list or a footnote reference.
206 (org-test-with-temp-text "- A\n B"
207 (let ((fill-column 20))
212 (org-test-with-temp-text "[fn:1] A\nB"
213 (let ((fill-column 20))
216 (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"
217 (let ((fill-column 20))
219 (should (equal (buffer-string)
220 "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"))))
221 ;; Fill contents of `comment-block' elements.
224 (org-test-with-temp-text "#+BEGIN_COMMENT\nSome\ntext\n#+END_COMMENT"
225 (let ((fill-column 20))
229 "#+BEGIN_COMMENT\nSome text\n#+END_COMMENT"))
230 ;; Fill `comment' elements.
233 (org-test-with-temp-text " # A\n # B"
234 (let ((fill-column 20))
237 ;; Do nothing at affiliated keywords.
238 (org-test-with-temp-text "#+NAME: para\nSome\ntext."
239 (let ((fill-column 20))
241 (should (equal (buffer-string) "#+NAME: para\nSome\ntext.")))))
243 (ert-deftest test-org
/auto-fill-function
()
244 "Test auto-filling features."
245 ;; Auto fill paragraph.
248 (org-test-with-temp-text "12345 7890"
249 (let ((fill-column 5))
251 (org-auto-fill-function)
253 ;; Auto fill first paragraph in an item.
255 (equal "- 12345\n 7890"
256 (org-test-with-temp-text "- 12345 7890"
257 (let ((fill-column 7))
259 (org-auto-fill-function)
261 ;; Auto fill comments.
263 (equal " # 12345\n # 7890"
264 (org-test-with-temp-text " # 12345 7890"
265 (let ((fill-column 10))
267 (org-auto-fill-function)
269 ;; A hash within a line isn't a comment.
271 (equal "12345 # 7890\n# 1"
272 (org-test-with-temp-text "12345 # 7890 1"
273 (let ((fill-column 12))
275 (org-auto-fill-function)
277 ;; Correctly interpret empty prefix.
279 (equal "# a\n# b\nRegular\n# paragraph"
280 (org-test-with-temp-text "# a\n# b\nRegular paragraph"
281 (let ((fill-column 12))
283 (org-auto-fill-function)
285 ;; Comment block: auto fill contents.
287 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
288 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
289 (let ((fill-column 5))
292 (org-auto-fill-function)
295 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
296 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
297 (let ((fill-column 5))
300 (org-auto-fill-function)
302 ;; Do not fill if a new item could be created.
305 (org-test-with-temp-text "12345 - 90"
306 (let ((fill-column 5))
308 (org-auto-fill-function)
310 ;; Do not fill if a line break could be introduced.
312 (equal "123\\\\\n7890"
313 (org-test-with-temp-text "123\\\\ 7890"
314 (let ((fill-column 6))
316 (org-auto-fill-function)
318 ;; Do not fill affiliated keywords.
320 (equal "#+ATTR_LATEX: ABC\nDEFGHIJKL"
321 (org-test-with-temp-text "#+ATTR_LATEX: ABC DEFGHIJKL"
322 (let ((fill-column 20))
324 (org-auto-fill-function)
331 (ert-deftest test-org
/comment-dwim
()
332 "Test `comment-dwim' behaviour in an Org buffer."
333 ;; No region selected, no comment on current line and line not
334 ;; empty: insert comment on line above.
337 (org-test-with-temp-text "Comment"
338 (progn (call-interactively 'comment-dwim
)
340 ;; No region selected, no comment on current line and line empty:
341 ;; insert comment on this line.
343 (equal "# \nParagraph"
344 (org-test-with-temp-text "\nParagraph"
345 (progn (call-interactively 'comment-dwim
)
347 ;; No region selected, and a comment on this line: indent it.
349 (equal "* Headline\n # Comment"
350 (org-test-with-temp-text "* Headline\n# Comment"
351 (progn (forward-line)
352 (let ((org-adapt-indentation t
))
353 (call-interactively 'comment-dwim
))
355 ;; Also recognize single # at column 0 as comments.
358 (org-test-with-temp-text "# Comment"
359 (progn (forward-line)
360 (call-interactively 'comment-dwim
)
362 ;; Region selected and only comments and blank lines within it:
363 ;; un-comment all commented lines.
365 (equal "Comment 1\n\nComment 2"
366 (org-test-with-temp-text "# Comment 1\n\n# Comment 2"
368 (transient-mark-mode 1)
369 (push-mark (point) t t
)
370 (goto-char (point-max))
371 (call-interactively 'comment-dwim
)
373 ;; Region selected without comments: comment all non-blank lines.
375 (equal "# Comment 1\n\n# Comment 2"
376 (org-test-with-temp-text "Comment 1\n\nComment 2"
378 (transient-mark-mode 1)
379 (push-mark (point) t t
)
380 (goto-char (point-max))
381 (call-interactively 'comment-dwim
)
383 ;; In front of a keyword without region, insert a new comment.
385 (equal "# \n#+KEYWORD: value"
386 (org-test-with-temp-text "#+KEYWORD: value"
387 (progn (call-interactively 'comment-dwim
)
394 (ert-deftest test-org
/mark-subtree
()
395 "Test `org-mark-subtree' specifications."
396 ;; Error when point is before first headline.
398 (org-test-with-temp-text "Paragraph\n* Headline\nBody"
399 (progn (transient-mark-mode 1)
400 (org-mark-subtree))))
401 ;; Without argument, mark current subtree.
405 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
406 (progn (transient-mark-mode 1)
409 (list (region-beginning) (region-end))))))
410 ;; With an argument, move ARG up.
414 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
415 (progn (transient-mark-mode 1)
418 (list (region-beginning) (region-end))))))
419 ;; Do not get fooled with inlinetasks.
420 (when (featurep 'org-inlinetask
)
423 (org-test-with-temp-text "* Headline\n*************** Task\nContents"
424 (progn (transient-mark-mode 1)
426 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
427 (region-beginning)))))))
433 (ert-deftest test-org
/beginning-of-line
()
434 "Test `org-beginning-of-line' specifications."
437 (org-test-with-temp-text "Some text\nSome other text"
438 (progn (org-beginning-of-line) (bolp))))
439 ;; Standard test with `visual-line-mode'.
441 (org-test-with-temp-text "A long line of text\nSome other text"
442 (progn (visual-line-mode)
444 (dotimes (i 1000) (insert "very "))
445 (org-beginning-of-line)
447 ;; At an headline with special movement.
449 (org-test-with-temp-text "* TODO Headline"
450 (let ((org-special-ctrl-a/e t
))
452 (and (progn (org-beginning-of-line) (looking-at "Headline"))
453 (progn (org-beginning-of-line) (bolp))
454 (progn (org-beginning-of-line) (looking-at "Headline")))))))
456 (ert-deftest test-org
/end-of-line
()
457 "Test `org-end-of-line' specifications."
460 (org-test-with-temp-text "Some text\nSome other text"
461 (progn (org-end-of-line) (eolp))))
462 ;; Standard test with `visual-line-mode'.
464 (org-test-with-temp-text "A long line of text\nSome other text"
465 (progn (visual-line-mode)
467 (dotimes (i 1000) (insert "very "))
468 (goto-char (point-min))
471 ;; At an headline with special movement.
473 (org-test-with-temp-text "* Headline1 :tag:\n"
474 (let ((org-special-ctrl-a/e t
))
475 (and (progn (org-end-of-line) (looking-at " :tag:"))
476 (progn (org-end-of-line) (eolp))
477 (progn (org-end-of-line) (looking-at " :tag:"))))))
478 ;; At an headline without special movement.
480 (org-test-with-temp-text "* Headline2 :tag:\n"
481 (let ((org-special-ctrl-a/e nil
))
482 (and (progn (org-end-of-line) (eolp))
483 (progn (org-end-of-line) (eolp))))))
484 ;; At an headline, with reversed movement.
486 (org-test-with-temp-text "* Headline3 :tag:\n"
487 (let ((org-special-ctrl-a/e
'reversed
)
488 (this-command last-command
))
489 (and (progn (org-end-of-line) (eolp))
490 (progn (org-end-of-line) (looking-at " :tag:"))))))
491 ;; At a block without hidden contents.
493 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
494 (progn (org-end-of-line) (eolp))))
495 ;; At a block with hidden contents.
497 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
498 (let ((org-special-ctrl-a/e t
))
499 (org-hide-block-toggle)
503 (ert-deftest test-org
/forward-element
()
504 "Test `org-forward-element' specifications."
505 ;; 1. At EOB: should error.
506 (org-test-with-temp-text "Some text\n"
507 (goto-char (point-max))
508 (should-error (org-forward-element)))
509 ;; 2. Standard move: expected to ignore blank lines.
510 (org-test-with-temp-text "First paragraph.\n\n\nSecond paragraph."
511 (org-forward-element)
512 (should (looking-at "Second paragraph.")))
513 ;; 3. Headline tests.
514 (org-test-with-temp-text "
519 ;; 3.1. At an headline beginning: move to next headline at the
522 (org-forward-element)
523 (should (looking-at "** Head 1.2"))
524 ;; 3.2. At an headline beginning: move to parent headline if no
525 ;; headline at the same level.
527 (org-forward-element)
528 (should (looking-at "** Head 1.2")))
529 ;; 4. Greater element tests.
530 (org-test-with-temp-text
531 "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside."
532 ;; 4.1. At a greater element: expected to skip contents.
533 (org-forward-element)
534 (should (looking-at "Outside."))
535 ;; 4.2. At the end of greater element contents: expected to skip
536 ;; to the end of the greater element.
538 (org-forward-element)
539 (should (looking-at "Outside.")))
541 (org-test-with-temp-text "
555 ;; 5.1. At list top point: expected to move to the element after
558 (org-forward-element)
559 (should (looking-at "Outside."))
560 ;; 5.2. Special case: at the first line of a sub-list, but not at
561 ;; beginning of line, move to next item.
564 (org-forward-element)
565 (should (looking-at "- item2"))
568 (org-forward-element)
569 (should (looking-at " - sub2"))
570 ;; 5.3 At sub-list beginning: expected to move after the sub-list.
572 (org-forward-element)
573 (should (looking-at " Inner paragraph."))
574 ;; 5.4. At sub-list end: expected to move outside the sub-list.
576 (org-forward-element)
577 (should (looking-at " Inner paragraph."))
578 ;; 5.5. At an item: expected to move to next item, if any.
580 (org-forward-element)
581 (should (looking-at " - sub3"))))
583 (ert-deftest test-org
/backward-element
()
584 "Test `org-backward-element' specifications."
585 ;; 1. Should error at BOB.
586 (org-test-with-temp-text " \nParagraph."
587 (should-error (org-backward-element)))
588 ;; 2. Should move at BOB when called on the first element in buffer.
590 (org-test-with-temp-text "\n#+TITLE: test"
591 (progn (forward-line)
592 (org-backward-element)
594 ;; 3. Not at the beginning of an element: move at its beginning.
595 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
598 (org-backward-element)
599 (should (looking-at "Paragraph2.")))
600 ;; 4. Headline tests.
601 (org-test-with-temp-text "
606 ;; 4.1. At an headline beginning: move to previous headline at the
609 (org-backward-element)
610 (should (looking-at "** Head 1.1"))
611 ;; 4.2. At an headline beginning: move to parent headline if no
612 ;; headline at the same level.
614 (org-backward-element)
615 (should (looking-at "* Head 1"))
616 ;; 4.3. At the first top-level headline: should error.
618 (should-error (org-backward-element)))
619 ;; 5. At beginning of first element inside a greater element:
620 ;; expected to move to greater element's beginning.
621 (org-test-with-temp-text "Before.\n#+BEGIN_CENTER\nInside.\n#+END_CENTER"
623 (org-backward-element)
624 (should (looking-at "#\\+BEGIN_CENTER")))
625 ;; 6. At the beginning of the first element in a section: should
626 ;; move back to headline, if any.
628 (org-test-with-temp-text "#+TITLE: test\n* Headline\n\nParagraph"
629 (progn (goto-char (point-max))
631 (org-backward-element)
632 (org-at-heading-p))))
634 (org-test-with-temp-text "
649 ;; 7.1. At beginning of sub-list: expected to move to the
650 ;; paragraph before it.
652 (org-backward-element)
653 (should (looking-at "item1"))
654 ;; 7.2. At an item in a list: expected to move at previous item.
656 (org-backward-element)
657 (should (looking-at " - sub2"))
659 (org-backward-element)
660 (should (looking-at "- item1"))
661 ;; 7.3. At end of list/sub-list: expected to move to list/sub-list
664 (org-backward-element)
665 (should (looking-at " - sub1"))
667 (org-backward-element)
668 (should (looking-at "- item1"))
669 ;; 7.4. At blank-lines before list end: expected to move to top
672 (org-backward-element)
673 (should (looking-at "- item1"))))
675 (ert-deftest test-org
/up-element
()
676 "Test `org-up-element' specifications."
677 ;; 1. At BOB or with no surrounding element: should error.
678 (org-test-with-temp-text "Paragraph."
679 (should-error (org-up-element)))
680 (org-test-with-temp-text "* Head1\n* Head2"
682 (should-error (org-up-element)))
683 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
685 (should-error (org-up-element)))
686 ;; 2. At an headline: move to parent headline.
687 (org-test-with-temp-text "* Head1\n** Sub-Head1\n** Sub-Head2"
690 (should (looking-at "\\* Head1")))
691 ;; 3. Inside a greater element: move to greater element beginning.
692 (org-test-with-temp-text
693 "Before.\n#+BEGIN_CENTER\nParagraph1\nParagraph2\n#+END_CENTER\n"
696 (should (looking-at "#\\+BEGIN_CENTER")))
698 (org-test-with-temp-text "* Top
705 Paragraph within sub2.
708 ;; 4.1. Within an item: move to the item beginning.
711 (should (looking-at " - sub2"))
712 ;; 4.2. At an item in a sub-list: move to parent item.
715 (should (looking-at "- item1"))
716 ;; 4.3. At an item in top list: move to beginning of whole list.
719 (should (looking-at "- item1"))
720 ;; 4.4. Special case. At very top point: should move to parent of
724 (should (looking-at "\\* Top"))))
726 (ert-deftest test-org
/down-element
()
727 "Test `org-down-element' specifications."
728 ;; Error when the element hasn't got a recursive type.
729 (org-test-with-temp-text "Paragraph."
730 (should-error (org-down-element)))
731 ;; Error when the element has no contents
732 (org-test-with-temp-text "* Headline"
733 (should-error (org-down-element)))
734 ;; When at a plain-list, move to first item.
735 (org-test-with-temp-text "- Item 1\n - Item 1.1\n - Item 2.2"
738 (should (looking-at " - Item 1.1")))
739 (org-test-with-temp-text "#+NAME: list\n- Item 1"
741 (should (looking-at " Item 1")))
742 ;; When at a table, move to first row
743 (org-test-with-temp-text "#+NAME: table\n| a | b |"
745 (should (looking-at " a | b |")))
746 ;; Otherwise, move inside the greater element.
747 (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph.\n#+END_CENTER"
749 (should (looking-at "Paragraph"))))
751 (ert-deftest test-org
/drag-element-backward
()
752 "Test `org-drag-element-backward' specifications."
753 ;; 1. Error when trying to move first element of buffer.
754 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
755 (should-error (org-drag-element-backward)))
756 ;; 2. Error when trying to swap nested elements.
757 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
759 (should-error (org-drag-element-backward)))
760 ;; 3. Error when trying to swap an headline element and
761 ;; a non-headline element.
762 (org-test-with-temp-text "Test.\n* Head 1"
764 (should-error (org-drag-element-backward)))
765 ;; 4. Otherwise, swap elements, preserving column and blank lines
767 (org-test-with-temp-text "Para1\n\n\nParagraph 2\n\nPara3"
768 (search-forward "graph")
769 (org-drag-element-backward)
770 (should (equal (buffer-string) "Paragraph 2\n\n\nPara1\n\nPara3"))
771 (should (looking-at " 2")))
772 ;; 5. Preserve visibility of elements and their contents.
773 (org-test-with-temp-text "
781 (while (search-forward "BEGIN_" nil t
) (org-cycle))
782 (search-backward "- item 1")
783 (org-drag-element-backward)
786 '((63 .
82) (26 .
48))
787 (mapcar (lambda (ov) (cons (overlay-start ov
) (overlay-end ov
)))
788 (overlays-in (point-min) (point-max)))))))
790 (ert-deftest test-org
/drag-element-forward
()
791 "Test `org-drag-element-forward' specifications."
792 ;; 1. Error when trying to move first element of buffer.
793 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
795 (should-error (org-drag-element-forward)))
796 ;; 2. Error when trying to swap nested elements.
797 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
799 (should-error (org-drag-element-forward)))
800 ;; 3. Error when trying to swap a non-headline element and an
802 (org-test-with-temp-text "Test.\n* Head 1"
803 (should-error (org-drag-element-forward)))
804 ;; 4. Otherwise, swap elements, preserving column and blank lines
806 (org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
807 (search-forward "graph")
808 (org-drag-element-forward)
809 (should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
810 (should (looking-at " 1")))
811 ;; 5. Preserve visibility of elements and their contents.
812 (org-test-with-temp-text "
820 (while (search-forward "BEGIN_" nil t
) (org-cycle))
821 (search-backward "#+BEGIN_CENTER")
822 (org-drag-element-forward)
825 '((63 .
82) (26 .
48))
826 (mapcar (lambda (ov) (cons (overlay-start ov
) (overlay-end ov
)))
827 (overlays-in (point-min) (point-max)))))))
832 ;;; test-org.el ends here