testing/lisp/test-org: actually check that org-open-at-point did the right thing
[org-mode.git] / testing / lisp / test-org.el
blob94dab8ecb4e94ec44ba6a9e63e3fee190ae60524
1 ;;; test-org.el --- tests for org.el
3 ;; Copyright (c) David Maus
4 ;; Authors: 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/>.
21 ;;; Comments:
23 ;; Template test file for Org-mode tests
25 ;;; Code:
28 ;;; Comments
30 (ert-deftest test-org/toggle-comment ()
31 "Test `org-toggle-comment' specifications."
32 ;; Simple headline.
33 (should
34 (equal "* Test"
35 (org-test-with-temp-text "* COMMENT Test"
36 (org-toggle-comment)
37 (buffer-string))))
38 (should
39 (equal "* COMMENT Test"
40 (org-test-with-temp-text "* Test"
41 (org-toggle-comment)
42 (buffer-string))))
43 ;; Headline with a regular keyword.
44 (should
45 (equal "* TODO Test"
46 (org-test-with-temp-text "* TODO COMMENT Test"
47 (org-toggle-comment)
48 (buffer-string))))
49 (should
50 (equal "* TODO COMMENT Test"
51 (org-test-with-temp-text "* TODO Test"
52 (org-toggle-comment)
53 (buffer-string))))
54 ;; Empty headline.
55 (should
56 (equal "* "
57 (org-test-with-temp-text "* COMMENT"
58 (org-toggle-comment)
59 (buffer-string))))
60 (should
61 (equal "* COMMENT"
62 (org-test-with-temp-text "* "
63 (org-toggle-comment)
64 (buffer-string))))
65 ;; Headline with a single keyword.
66 (should
67 (equal "* TODO "
68 (org-test-with-temp-text "* TODO COMMENT"
69 (org-toggle-comment)
70 (buffer-string))))
71 (should
72 (equal "* TODO COMMENT"
73 (org-test-with-temp-text "* TODO"
74 (org-toggle-comment)
75 (buffer-string))))
76 ;; Headline with a keyword, a priority cookie and contents.
77 (should
78 (equal "* TODO [#A] Headline"
79 (org-test-with-temp-text "* TODO [#A] COMMENT Headline"
80 (org-toggle-comment)
81 (buffer-string))))
82 (should
83 (equal "* TODO [#A] COMMENT Headline"
84 (org-test-with-temp-text "* TODO [#A] Headline"
85 (org-toggle-comment)
86 (buffer-string)))))
88 (ert-deftest test-org/comment-dwim ()
89 "Test `comment-dwim' behaviour in an Org buffer."
90 ;; No region selected, no comment on current line and line not
91 ;; empty: insert comment on line above.
92 (should
93 (equal "# \nComment"
94 (org-test-with-temp-text "Comment"
95 (progn (call-interactively 'comment-dwim)
96 (buffer-string)))))
97 ;; No region selected, no comment on current line and line empty:
98 ;; insert comment on this line.
99 (should
100 (equal "# \nParagraph"
101 (org-test-with-temp-text "\nParagraph"
102 (progn (call-interactively 'comment-dwim)
103 (buffer-string)))))
104 ;; No region selected, and a comment on this line: indent it.
105 (should
106 (equal "* Headline\n # Comment"
107 (org-test-with-temp-text "* Headline\n# Comment"
108 (progn (forward-line)
109 (let ((org-adapt-indentation t))
110 (call-interactively 'comment-dwim))
111 (buffer-string)))))
112 ;; Also recognize single # at column 0 as comments.
113 (should
114 (equal "# Comment"
115 (org-test-with-temp-text "# Comment"
116 (progn (forward-line)
117 (call-interactively 'comment-dwim)
118 (buffer-string)))))
119 ;; Region selected and only comments and blank lines within it:
120 ;; un-comment all commented lines.
121 (should
122 (equal "Comment 1\n\nComment 2"
123 (org-test-with-temp-text "# Comment 1\n\n# Comment 2"
124 (progn
125 (transient-mark-mode 1)
126 (push-mark (point) t t)
127 (goto-char (point-max))
128 (call-interactively 'comment-dwim)
129 (buffer-string)))))
130 ;; Region selected without comments: comment all lines if
131 ;; `comment-empty-lines' is non-nil, only non-blank lines otherwise.
132 (should
133 (equal "# Comment 1\n\n# Comment 2"
134 (org-test-with-temp-text "Comment 1\n\nComment 2"
135 (progn
136 (transient-mark-mode 1)
137 (push-mark (point) t t)
138 (goto-char (point-max))
139 (let ((comment-empty-lines nil))
140 (call-interactively 'comment-dwim))
141 (buffer-string)))))
142 (should
143 (equal "# Comment 1\n# \n# Comment 2"
144 (org-test-with-temp-text "Comment 1\n\nComment 2"
145 (progn
146 (transient-mark-mode 1)
147 (push-mark (point) t t)
148 (goto-char (point-max))
149 (let ((comment-empty-lines t))
150 (call-interactively 'comment-dwim))
151 (buffer-string)))))
152 ;; In front of a keyword without region, insert a new comment.
153 (should
154 (equal "# \n#+KEYWORD: value"
155 (org-test-with-temp-text "#+KEYWORD: value"
156 (progn (call-interactively 'comment-dwim)
157 (buffer-string)))))
158 ;; In a source block, use appropriate syntax.
159 (should
160 (equal " ;; "
161 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n\n#+END_SRC"
162 (forward-line)
163 (let ((org-edit-src-content-indentation 2))
164 (call-interactively 'comment-dwim))
165 (buffer-substring-no-properties (line-beginning-position) (point)))))
166 (should
167 (equal "#+BEGIN_SRC emacs-lisp\n ;; a\n ;; b\n#+END_SRC"
168 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\na\nb\n#+END_SRC"
169 (forward-line)
170 (transient-mark-mode 1)
171 (push-mark (point) t t)
172 (forward-line 2)
173 (let ((org-edit-src-content-indentation 2))
174 (call-interactively 'comment-dwim))
175 (buffer-string)))))
179 ;;; Date and time analysis
181 (ert-deftest test-org/org-read-date ()
182 "Test `org-read-date' specifications."
183 ;; Parse ISO date with abbreviated year and month.
184 (should (equal "2012-03-29 16:40"
185 (let ((org-time-was-given t))
186 (org-read-date t nil "12-3-29 16:40"))))
187 ;; Parse Europeans dates.
188 (should (equal "2012-03-29 16:40"
189 (let ((org-time-was-given t))
190 (org-read-date t nil "29.03.2012 16:40"))))
191 ;; Parse Europeans dates without year.
192 (should (string-match "2[0-9]\\{3\\}-03-29 16:40"
193 (let ((org-time-was-given t))
194 (org-read-date t nil "29.03. 16:40")))))
196 (ert-deftest test-org/org-parse-time-string ()
197 "Test `org-parse-time-string'."
198 (should (equal (org-parse-time-string "2012-03-29 16:40")
199 '(0 40 16 29 3 2012 nil nil nil)))
200 (should (equal (org-parse-time-string "[2012-03-29 16:40]")
201 '(0 40 16 29 3 2012 nil nil nil)))
202 (should (equal (org-parse-time-string "<2012-03-29 16:40>")
203 '(0 40 16 29 3 2012 nil nil nil)))
204 (should (equal (org-parse-time-string "<2012-03-29>")
205 '(0 0 0 29 3 2012 nil nil nil)))
206 (should (equal (org-parse-time-string "<2012-03-29>" t)
207 '(0 nil nil 29 3 2012 nil nil nil))))
210 ;;; Filling
212 (ert-deftest test-org/fill-paragraph ()
213 "Test `org-fill-paragraph' specifications."
214 ;; At an Org table, align it.
215 (should
216 (equal "| a |\n"
217 (org-test-with-temp-text "|a|"
218 (org-fill-paragraph)
219 (buffer-string))))
220 (should
221 (equal "#+name: table\n| a |\n"
222 (org-test-with-temp-text "#+name: table\n| a |"
223 (org-fill-paragraph)
224 (buffer-string))))
225 ;; At a paragraph, preserve line breaks.
226 (org-test-with-temp-text "some \\\\\nlong\ntext"
227 (let ((fill-column 20))
228 (org-fill-paragraph)
229 (should (equal (buffer-string) "some \\\\\nlong text"))))
230 ;; Correctly fill a paragraph when point is at its very end.
231 (should
232 (equal "A B"
233 (org-test-with-temp-text "A\nB"
234 (let ((fill-column 20))
235 (goto-char (point-max))
236 (org-fill-paragraph)
237 (buffer-string)))))
238 ;; Correctly fill the last paragraph of a greater element.
239 (should
240 (equal "#+BEGIN_CENTER\n- 012345\n 789\n#+END_CENTER"
241 (org-test-with-temp-text "#+BEGIN_CENTER\n- 012345 789\n#+END_CENTER"
242 (let ((fill-column 8))
243 (forward-line)
244 (end-of-line)
245 (org-fill-paragraph)
246 (buffer-string)))))
247 ;; Correctly fill an element in a narrowed buffer.
248 (should
249 (equal "01234\n6"
250 (org-test-with-temp-text "01234 6789"
251 (let ((fill-column 5))
252 (narrow-to-region 1 8)
253 (org-fill-paragraph)
254 (buffer-string)))))
255 ;; Handle `adaptive-fill-regexp' in paragraphs.
256 (should
257 (equal "> a b"
258 (org-test-with-temp-text "> a\n> b"
259 (let ((fill-column 5)
260 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
261 (org-fill-paragraph)
262 (buffer-string)))))
263 ;; Special case: Fill first paragraph when point is at an item or
264 ;; a plain-list or a footnote reference.
265 (should
266 (equal "- A B"
267 (org-test-with-temp-text "- A\n B"
268 (let ((fill-column 20))
269 (org-fill-paragraph)
270 (buffer-string)))))
271 (should
272 (equal "[fn:1] A B"
273 (org-test-with-temp-text "[fn:1] A\nB"
274 (let ((fill-column 20))
275 (org-fill-paragraph)
276 (buffer-string)))))
277 (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"
278 (let ((fill-column 20))
279 (org-fill-paragraph)
280 (should (equal (buffer-string)
281 "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"))))
282 ;; Fill contents of `comment-block' elements.
283 (should
284 (equal
285 (org-test-with-temp-text "#+BEGIN_COMMENT\nSome\ntext\n#+END_COMMENT"
286 (let ((fill-column 20))
287 (forward-line)
288 (org-fill-paragraph)
289 (buffer-string)))
290 "#+BEGIN_COMMENT\nSome text\n#+END_COMMENT"))
291 ;; Fill `comment' elements.
292 (should
293 (equal " # A B"
294 (org-test-with-temp-text " # A\n # B"
295 (let ((fill-column 20))
296 (org-fill-paragraph)
297 (buffer-string)))))
298 ;; Do not mix consecutive comments when filling one of them.
299 (should
300 (equal "# A B\n\n# C"
301 (org-test-with-temp-text "# A\n# B\n\n# C"
302 (let ((fill-column 20))
303 (org-fill-paragraph)
304 (buffer-string)))))
305 ;; Use commented empty lines as separators when filling comments.
306 (should
307 (equal "# A B\n#\n# C"
308 (org-test-with-temp-text "# A\n# B\n#\n# C"
309 (let ((fill-column 20))
310 (org-fill-paragraph)
311 (buffer-string)))))
312 ;; Handle `adaptive-fill-regexp' in comments.
313 (should
314 (equal "# > a b"
315 (org-test-with-temp-text "# > a\n# > b"
316 (let ((fill-column 20)
317 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
318 (org-fill-paragraph)
319 (buffer-string)))))
320 ;; Do nothing at affiliated keywords.
321 (org-test-with-temp-text "#+NAME: para\nSome\ntext."
322 (let ((fill-column 20))
323 (org-fill-paragraph)
324 (should (equal (buffer-string) "#+NAME: para\nSome\ntext."))))
325 ;; Do not move point after table when filling a table.
326 (should-not
327 (org-test-with-temp-text "| a | b |\n| c | d |\n"
328 (forward-char)
329 (org-fill-paragraph)
330 (eobp))))
332 (ert-deftest test-org/auto-fill-function ()
333 "Test auto-filling features."
334 ;; Auto fill paragraph.
335 (should
336 (equal "12345\n7890"
337 (org-test-with-temp-text "12345 7890"
338 (let ((fill-column 5))
339 (end-of-line)
340 (org-auto-fill-function)
341 (buffer-string)))))
342 ;; Auto fill first paragraph in an item.
343 (should
344 (equal "- 12345\n 7890"
345 (org-test-with-temp-text "- 12345 7890"
346 (let ((fill-column 7))
347 (end-of-line)
348 (org-auto-fill-function)
349 (buffer-string)))))
350 ;; Auto fill paragraph when `adaptive-fill-regexp' matches.
351 (should
352 (equal "> 12345\n 7890"
353 (org-test-with-temp-text "> 12345 7890"
354 (let ((fill-column 10)
355 (adaptive-fill-regexp "[ \t]*>+[ \t]*")
356 (adaptive-fill-first-line-regexp "\\`[ ]*\\'"))
357 (end-of-line)
358 (org-auto-fill-function)
359 (buffer-string)))))
360 (should
361 (equal "> 12345\n> 12345\n> 7890"
362 (org-test-with-temp-text "> 12345\n> 12345 7890"
363 (let ((fill-column 10)
364 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
365 (goto-char (point-max))
366 (org-auto-fill-function)
367 (buffer-string)))))
368 (should-not
369 (equal " 12345\n *12345\n *12345"
370 (org-test-with-temp-text " 12345\n *12345 12345"
371 (let ((fill-column 10)
372 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
373 (goto-char (point-max))
374 (org-auto-fill-function)
375 (buffer-string)))))
376 ;; Auto fill comments.
377 (should
378 (equal " # 12345\n # 7890"
379 (org-test-with-temp-text " # 12345 7890"
380 (let ((fill-column 10))
381 (end-of-line)
382 (org-auto-fill-function)
383 (buffer-string)))))
384 ;; A hash within a line isn't a comment.
385 (should-not
386 (equal "12345 # 7890\n# 1"
387 (org-test-with-temp-text "12345 # 7890 1"
388 (let ((fill-column 12))
389 (end-of-line)
390 (org-auto-fill-function)
391 (buffer-string)))))
392 ;; Correctly interpret empty prefix.
393 (should-not
394 (equal "# a\n# b\nRegular\n# paragraph"
395 (org-test-with-temp-text "# a\n# b\nRegular paragraph"
396 (let ((fill-column 12))
397 (end-of-line 3)
398 (org-auto-fill-function)
399 (buffer-string)))))
400 ;; Comment block: auto fill contents.
401 (should
402 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
403 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
404 (let ((fill-column 5))
405 (forward-line)
406 (end-of-line)
407 (org-auto-fill-function)
408 (buffer-string)))))
409 (should
410 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
411 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
412 (let ((fill-column 5))
413 (forward-line)
414 (end-of-line)
415 (org-auto-fill-function)
416 (buffer-string)))))
417 ;; Do not fill if a new item could be created.
418 (should-not
419 (equal "12345\n- 90"
420 (org-test-with-temp-text "12345 - 90"
421 (let ((fill-column 5))
422 (end-of-line)
423 (org-auto-fill-function)
424 (buffer-string)))))
425 ;; Do not fill if a line break could be introduced.
426 (should-not
427 (equal "123\\\\\n7890"
428 (org-test-with-temp-text "123\\\\ 7890"
429 (let ((fill-column 6))
430 (end-of-line)
431 (org-auto-fill-function)
432 (buffer-string)))))
433 ;; Do not fill affiliated keywords.
434 (should-not
435 (equal "#+ATTR_LATEX: ABC\nDEFGHIJKL"
436 (org-test-with-temp-text "#+ATTR_LATEX: ABC DEFGHIJKL"
437 (let ((fill-column 20))
438 (end-of-line)
439 (org-auto-fill-function)
440 (buffer-string))))))
444 ;;; Indentation
446 (ert-deftest test-org/indent-line ()
447 "Test `org-indent-line' specifications."
448 ;; Do not indent footnote definitions or headlines.
449 (should
450 (zerop
451 (org-test-with-temp-text "* H"
452 (org-indent-line)
453 (org-get-indentation))))
454 (should
455 (zerop
456 (org-test-with-temp-text "[fn:1] fn"
457 (let ((org-adapt-indentation t)) (org-indent-line))
458 (org-get-indentation))))
459 ;; Do not indent before first headline.
460 (should
461 (zerop
462 (org-test-with-temp-text ""
463 (org-indent-line)
464 (org-get-indentation))))
465 ;; Indent according to headline level otherwise, unless
466 ;; `org-adapt-indentation' is nil.
467 (should
468 (= 2
469 (org-test-with-temp-text "* H\nA"
470 (forward-line)
471 (let ((org-adapt-indentation t)) (org-indent-line))
472 (org-get-indentation))))
473 (should
474 (= 2
475 (org-test-with-temp-text "* H\n\nA"
476 (forward-line)
477 (let ((org-adapt-indentation t)) (org-indent-line))
478 (org-get-indentation))))
479 (should
480 (zerop
481 (org-test-with-temp-text "* H\nA"
482 (forward-line)
483 (let ((org-adapt-indentation nil)) (org-indent-line))
484 (org-get-indentation))))
485 ;; Indenting preserves point position.
486 (should
487 (org-test-with-temp-text "* H\nAB"
488 (forward-line)
489 (forward-char)
490 (let ((org-adapt-indentation t)) (org-indent-line))
491 (looking-at "B")))
492 ;; Do not change indentation at an item.
493 (should
494 (= 1
495 (org-test-with-temp-text "* H\n - A"
496 (forward-line)
497 (let ((org-adapt-indentation t)) (org-indent-line))
498 (org-get-indentation))))
499 ;; On blank lines at the end of a list, indent like last element
500 ;; within it if the line is still in the list. Otherwise, indent
501 ;; like the whole list.
502 (should
503 (= 4
504 (org-test-with-temp-text "* H\n- A\n - AA\n"
505 (goto-char (point-max))
506 (let ((org-adapt-indentation t)) (org-indent-line))
507 (org-get-indentation))))
508 (should
509 (zerop
510 (org-test-with-temp-text "* H\n- A\n - AA\n\n\n\n"
511 (goto-char (point-max))
512 (let ((org-adapt-indentation t)) (org-indent-line))
513 (org-get-indentation))))
514 ;; Likewise, on a blank line at the end of a footnote definition,
515 ;; indent at column 0 if line belongs to the definition. Otherwise,
516 ;; indent like the definition itself.
517 (should
518 (zerop
519 (org-test-with-temp-text "* H\n[fn:1] Definition\n"
520 (goto-char (point-max))
521 (let ((org-adapt-indentation t)) (org-indent-line))
522 (org-get-indentation))))
523 (should
524 (zerop
525 (org-test-with-temp-text "* H\n[fn:1] Definition\n\n\n\n"
526 (goto-char (point-max))
527 (let ((org-adapt-indentation t)) (org-indent-line))
528 (org-get-indentation))))
529 ;; After the end of the contents of a greater element, indent like
530 ;; the beginning of the element.
531 (should
532 (= 1
533 (org-test-with-temp-text " #+BEGIN_CENTER\n Contents\n#+END_CENTER"
534 (forward-line 2)
535 (org-indent-line)
536 (org-get-indentation))))
537 ;; At the first line of an element, indent like previous element's
538 ;; first line, ignoring footnotes definitions and inline tasks, or
539 ;; according to parent.
540 (should
541 (= 2
542 (org-test-with-temp-text "A\n\n B\n\nC"
543 (goto-char (point-max))
544 (org-indent-line)
545 (org-get-indentation))))
546 (should
547 (= 1
548 (org-test-with-temp-text " A\n\n[fn:1] B\n\n\nC"
549 (goto-char (point-max))
550 (org-indent-line)
551 (org-get-indentation))))
552 (should
553 (= 1
554 (org-test-with-temp-text " #+BEGIN_CENTER\n Contents\n#+END_CENTER"
555 (forward-line 1)
556 (org-indent-line)
557 (org-get-indentation))))
558 ;; Within code part of a source block, use language major mode if
559 ;; `org-src-tab-acts-natively' is non-nil. Otherwise, indent
560 ;; according to line above.
561 (should
562 (= 6
563 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC"
564 (forward-line 2)
565 (let ((org-src-tab-acts-natively t)
566 (org-edit-src-content-indentation 0))
567 (org-indent-line))
568 (org-get-indentation))))
569 (should
570 (= 1
571 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC"
572 (forward-line 2)
573 (let ((org-src-tab-acts-natively nil)
574 (org-edit-src-content-indentation 0))
575 (org-indent-line))
576 (org-get-indentation))))
577 ;; Otherwise, indent like the first non-blank line above.
578 (should
579 (zerop
580 (org-test-with-temp-text "#+BEGIN_CENTER\nline1\n\n line2\n#+END_CENTER"
581 (forward-line 3)
582 (org-indent-line)
583 (org-get-indentation))))
584 ;; Align node properties according to `org-property-format'. Handle
585 ;; nicely empty values.
586 (should
587 (equal ":PROPERTIES:\n:key: value\n:END:"
588 (org-test-with-temp-text ":PROPERTIES:\n:key: value\n:END:"
589 (forward-line)
590 (let ((org-property-format "%-10s %s"))
591 (org-indent-line)
592 (buffer-string)))))
593 (should
594 (equal ":PROPERTIES:\n:key:\n:END:"
595 (org-test-with-temp-text ":PROPERTIES:\n:key:\n:END:"
596 (forward-line)
597 (let ((org-property-format "%-10s %s"))
598 (org-indent-line)
599 (buffer-string))))))
601 (ert-deftest test-org/indent-region ()
602 "Test `org-indent-region' specifications."
603 ;; Indent paragraph.
604 (should
605 (equal "A\nB\nC"
606 (org-test-with-temp-text " A\nB\n C"
607 (org-indent-region (point-min) (point-max))
608 (buffer-string))))
609 ;; Indent greater elements along with their contents.
610 (should
611 (equal "#+BEGIN_CENTER\nA\nB\n#+END_CENTER"
612 (org-test-with-temp-text "#+BEGIN_CENTER\n A\n B\n#+END_CENTER"
613 (org-indent-region (point-min) (point-max))
614 (buffer-string))))
615 ;; Ignore contents of verse blocks and example blocks.
616 (should
617 (equal "#+BEGIN_VERSE\n A\n B\n#+END_VERSE"
618 (org-test-with-temp-text "#+BEGIN_VERSE\n A\n B\n#+END_VERSE"
619 (org-indent-region (point-min) (point-max))
620 (buffer-string))))
621 (should
622 (equal "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
623 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
624 (org-indent-region (point-min) (point-max))
625 (buffer-string))))
626 ;; Indent according to mode if `org-src-tab-acts-natively' is
627 ;; non-nil. Otherwise, do not indent code at all.
628 (should
629 (equal "#+BEGIN_SRC emacs-lisp\n(and A\n B)\n#+END_SRC"
630 (org-test-with-temp-text
631 "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC"
632 (let ((org-src-tab-acts-natively t)
633 (org-edit-src-content-indentation 0))
634 (org-indent-region (point-min) (point-max)))
635 (buffer-string))))
636 (should
637 (equal "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC"
638 (org-test-with-temp-text
639 "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC"
640 (let ((org-src-tab-acts-natively nil)
641 (org-edit-src-content-indentation 0))
642 (org-indent-region (point-min) (point-max)))
643 (buffer-string))))
644 ;; Align node properties according to `org-property-format'. Handle
645 ;; nicely empty values.
646 (should
647 (equal ":PROPERTIES:\n:key: value\n:END:"
648 (org-test-with-temp-text ":PROPERTIES:\n:key: value\n:END:"
649 (let ((org-property-format "%-10s %s"))
650 (org-indent-region (point-min) (point-max)))
651 (buffer-string))))
652 (should
653 (equal ":PROPERTIES:\n:key:\n:END:"
654 (org-test-with-temp-text ":PROPERTIES:\n:key:\n:END:"
655 (let ((org-property-format "%-10s %s"))
656 (org-indent-region (point-min) (point-max)))
657 (buffer-string))))
658 ;; Special case: plain lists and footnote definitions.
659 (should
660 (equal "- A\n B\n - C\n\n D"
661 (org-test-with-temp-text "- A\n B\n - C\n\n D"
662 (org-indent-region (point-min) (point-max))
663 (buffer-string))))
664 (should
665 (equal "[fn:1] Definition\n\nDefinition"
666 (org-test-with-temp-text "[fn:1] Definition\n\n Definition"
667 (org-indent-region (point-min) (point-max))
668 (buffer-string)))))
672 ;;; Editing
674 ;;;; Insert elements
676 (ert-deftest test-org/meta-return ()
677 "Test M-RET (`org-meta-return')."
678 ;; In a table field insert a row above.
679 (should
680 (org-test-with-temp-text "| a |"
681 (forward-char)
682 (org-meta-return)
683 (forward-line -1)
684 (looking-at "| |$")))
685 ;; In a paragraph change current line into a header.
686 (should
687 (org-test-with-temp-text "a"
688 (org-meta-return)
689 (beginning-of-line)
690 (looking-at "\* a$")))
691 ;; In an item insert an item, in this case above.
692 (should
693 (org-test-with-temp-text "- a"
694 (org-meta-return)
695 (beginning-of-line)
696 (looking-at "- $")))
697 ;; In a drawer and paragraph insert an empty line, in this case above.
698 (should
699 (org-test-with-temp-text ":MYDRAWER:\na\n:END:"
700 (forward-line)
701 (org-meta-return)
702 (forward-line -1)
703 (looking-at "$")))
704 ;; In a drawer and item insert an item, in this case above.
705 (should
706 (org-test-with-temp-text ":MYDRAWER:\n- a\n:END:"
707 (forward-line)
708 (org-meta-return)
709 (beginning-of-line)
710 (looking-at "- $"))))
712 (ert-deftest test-org/insert-todo-heading-respect-content ()
713 "Test `org-insert-todo-heading-respect-content' specifications."
714 ;; Create a TODO heading.
715 (should
716 (org-test-with-temp-text "* H1\n Body"
717 (org-insert-todo-heading-respect-content)
718 (nth 2 (org-heading-components))))
719 ;; Add headline at the end of the first subtree
720 (should
721 (org-test-with-temp-text "* H1\nH1Body\n** H2\nH2Body"
722 (search-forward "H1Body")
723 (org-insert-todo-heading-respect-content)
724 (and (eobp) (org-at-heading-p))))
725 ;; In a list, do not create a new item.
726 (should
727 (org-test-with-temp-text "* H\n- an item\n- another one"
728 (search-forward "an ")
729 (org-insert-todo-heading-respect-content)
730 (and (eobp) (org-at-heading-p)))))
734 ;;; Fixed-Width Areas
736 (ert-deftest test-org/toggle-fixed-width ()
737 "Test `org-toggle-fixed-width' specifications."
738 ;; No region: Toggle on fixed-width marker in paragraphs.
739 (should
740 (equal ": A"
741 (org-test-with-temp-text "A"
742 (org-toggle-fixed-width)
743 (buffer-string))))
744 ;; No region: Toggle off fixed-width markers in fixed-width areas.
745 (should
746 (equal "A"
747 (org-test-with-temp-text ": A"
748 (org-toggle-fixed-width)
749 (buffer-string))))
750 ;; No region: Toggle on marker in blank lines after elements or just
751 ;; after a headline.
752 (should
753 (equal "* H\n: "
754 (org-test-with-temp-text "* H\n"
755 (forward-line)
756 (org-toggle-fixed-width)
757 (buffer-string))))
758 (should
759 (equal "#+BEGIN_EXAMPLE\nContents\n#+END_EXAMPLE\n: "
760 (org-test-with-temp-text "#+BEGIN_EXAMPLE\nContents\n#+END_EXAMPLE\n"
761 (goto-char (point-max))
762 (org-toggle-fixed-width)
763 (buffer-string))))
764 ;; No region: Toggle on marker in front of one line elements (e.g.,
765 ;; headlines, clocks)
766 (should
767 (equal ": * Headline"
768 (org-test-with-temp-text "* Headline"
769 (org-toggle-fixed-width)
770 (buffer-string))))
771 (should
772 (equal ": #+KEYWORD: value"
773 (org-test-with-temp-text "#+KEYWORD: value"
774 (org-toggle-fixed-width)
775 (buffer-string))))
776 ;; No region: error in other situations.
777 (should-error
778 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n: A\n#+END_EXAMPLE"
779 (forward-line)
780 (org-toggle-fixed-width)
781 (buffer-string)))
782 ;; No region: Indentation is preserved.
783 (should
784 (equal "- A\n : B"
785 (org-test-with-temp-text "- A\n B"
786 (forward-line)
787 (org-toggle-fixed-width)
788 (buffer-string))))
789 ;; Region: If it contains only fixed-width elements and blank lines,
790 ;; toggle off fixed-width markup.
791 (should
792 (equal "A\n\nB"
793 (org-test-with-temp-text ": A\n\n: B"
794 (transient-mark-mode 1)
795 (push-mark (point) t t)
796 (goto-char (point-max))
797 (org-toggle-fixed-width)
798 (buffer-string))))
799 ;; Region: If it contains anything else, toggle on fixed-width but
800 ;; not on fixed-width areas.
801 (should
802 (equal ": A\n: \n: B\n: \n: C"
803 (org-test-with-temp-text "A\n\n: B\n\nC"
804 (transient-mark-mode 1)
805 (push-mark (point) t t)
806 (goto-char (point-max))
807 (org-toggle-fixed-width)
808 (buffer-string))))
809 ;; Region: Ignore blank lines at its end, unless it contains only
810 ;; such lines.
811 (should
812 (equal ": A\n\n"
813 (org-test-with-temp-text "A\n\n"
814 (transient-mark-mode 1)
815 (push-mark (point) t t)
816 (goto-char (point-max))
817 (org-toggle-fixed-width)
818 (buffer-string))))
819 (should
820 (equal ": \n: \n"
821 (org-test-with-temp-text "\n\n"
822 (transient-mark-mode 1)
823 (push-mark (point) t t)
824 (goto-char (point-max))
825 (org-toggle-fixed-width)
826 (buffer-string)))))
830 ;;; Headline
832 (ert-deftest test-org/in-commented-heading-p ()
833 "Test `org-in-commented-heading-p' specifications."
834 ;; Commented headline.
835 (should
836 (org-test-with-temp-text "* COMMENT Headline\nBody"
837 (goto-char (point-max))
838 (org-in-commented-heading-p)))
839 ;; Commented ancestor.
840 (should
841 (org-test-with-temp-text "* COMMENT Headline\n** Level 2\nBody"
842 (goto-char (point-max))
843 (org-in-commented-heading-p)))
844 ;; Comment keyword is case-sensitive.
845 (should-not
846 (org-test-with-temp-text "* Comment Headline\nBody"
847 (goto-char (point-max))
848 (org-in-commented-heading-p)))
849 ;; Keyword is standalone.
850 (should-not
851 (org-test-with-temp-text "* COMMENTHeadline\nBody"
852 (goto-char (point-max))
853 (org-in-commented-heading-p)))
854 ;; Optional argument.
855 (should-not
856 (org-test-with-temp-text "* COMMENT Headline\n** Level 2\nBody"
857 (goto-char (point-max))
858 (org-in-commented-heading-p t))))
862 ;;; Links
864 ;;;; Coderefs
866 (ert-deftest test-org/coderef ()
867 "Test coderef links specifications."
868 (should
869 (org-test-with-temp-text "
870 #+BEGIN_SRC emacs-lisp
871 \(+ 1 1) (ref:sc)
872 #+END_SRC
873 \[[(sc)]]"
874 (goto-char (point-max))
875 (org-open-at-point)
876 (looking-at "(ref:sc)"))))
878 ;;;; Custom ID
880 (ert-deftest test-org/custom-id ()
881 "Test custom ID links specifications."
882 (should
883 (org-test-with-temp-text
884 "* H1\n:PROPERTIES:\n:CUSTOM_ID: custom\n:END:\n* H2\n[[#custom]]"
885 (goto-char (point-max))
886 (org-open-at-point)
887 (org-looking-at-p "\\* H1"))))
889 ;;;; Fuzzy Links
891 ;; Fuzzy links [[text]] encompass links to a target (<<text>>), to
892 ;; a named element (#+name: text) and to headlines (* Text).
894 (ert-deftest test-org/fuzzy-links ()
895 "Test fuzzy links specifications."
896 ;; Fuzzy link goes in priority to a matching target.
897 (should
898 (org-test-with-temp-text "#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
899 (goto-line 5)
900 (org-open-at-point)
901 (looking-at "<<Test>>")))
902 ;; Then fuzzy link points to an element with a given name.
903 (should
904 (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]"
905 (goto-line 5)
906 (org-open-at-point)
907 (looking-at "#\\+NAME: Test")))
908 ;; A target still lead to a matching headline otherwise.
909 (should
910 (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]"
911 (goto-line 4)
912 (org-open-at-point)
913 (looking-at "\\* Head2")))
914 ;; With a leading star in link, enforce heading match.
915 (should
916 (org-test-with-temp-text "* Test\n<<Test>>\n[[*Test]]"
917 (goto-line 3)
918 (org-open-at-point)
919 (looking-at "\\* Test")))
920 ;; Correctly un-hexify fuzzy links.
921 (should
922 (org-test-with-temp-text "* With space\n[[*With%20space][With space]]"
923 (goto-char (point-max))
924 (org-open-at-point)
925 (bobp))))
928 ;;;; Link Escaping
930 (ert-deftest test-org/org-link-escape-ascii-character ()
931 "Escape an ascii character."
932 (should
933 (string=
934 "%5B"
935 (org-link-escape "["))))
937 (ert-deftest test-org/org-link-escape-ascii-ctrl-character ()
938 "Escape an ascii control character."
939 (should
940 (string=
941 "%09"
942 (org-link-escape "\t"))))
944 (ert-deftest test-org/org-link-escape-multibyte-character ()
945 "Escape an unicode multibyte character."
946 (should
947 (string=
948 "%E2%82%AC"
949 (org-link-escape "€"))))
951 (ert-deftest test-org/org-link-escape-custom-table ()
952 "Escape string with custom character table."
953 (should
954 (string=
955 "Foo%3A%42ar%0A"
956 (org-link-escape "Foo:Bar\n" '(?\: ?\B)))))
958 (ert-deftest test-org/org-link-escape-custom-table-merge ()
959 "Escape string with custom table merged with default table."
960 (should
961 (string=
962 "%5BF%6F%6F%3A%42ar%0A%5D"
963 (org-link-escape "[Foo:Bar\n]" '(?\: ?\B ?\o) t))))
965 (ert-deftest test-org/org-link-unescape-ascii-character ()
966 "Unescape an ascii character."
967 (should
968 (string=
970 (org-link-unescape "%5B"))))
972 (ert-deftest test-org/org-link-unescape-ascii-ctrl-character ()
973 "Unescpae an ascii control character."
974 (should
975 (string=
976 "\n"
977 (org-link-unescape "%0A"))))
979 (ert-deftest test-org/org-link-unescape-multibyte-character ()
980 "Unescape unicode multibyte character."
981 (should
982 (string=
983 "€"
984 (org-link-unescape "%E2%82%AC"))))
986 (ert-deftest test-org/org-link-unescape-ascii-extended-char ()
987 "Unescape old style percent escaped character."
988 (should
989 (string=
990 "àâçèéêîôùû"
991 (decode-coding-string
992 (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1))))
994 (ert-deftest test-org/org-link-escape-url-with-escaped-char ()
995 "Escape and unescape a URL that includes an escaped char.
996 http://article.gmane.org/gmane.emacs.orgmode/21459/"
997 (should
998 (string=
999 "http://some.host.com/form?&id=blah%2Bblah25"
1000 (org-link-unescape
1001 (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
1003 (ert-deftest test-org/org-link-escape-chars-browser ()
1004 "Test of the constant `org-link-escape-chars-browser'.
1005 See there why this test is a candidate to be removed once Org
1006 drops support for Emacs 24.1 and 24.2."
1007 (should
1008 (string=
1009 (concat "http://lists.gnu.org/archive/cgi-bin/namazu.cgi?query="
1010 "%22Release%208.2%22&idxname=emacs-orgmode")
1011 (org-link-escape-browser ; Do not replace with `url-encode-url',
1012 ; see docstring above.
1013 (concat "http://lists.gnu.org/archive/cgi-bin/namazu.cgi?query="
1014 "\"Release 8.2\"&idxname=emacs-orgmode")))))
1016 ;;;; Open at point
1018 (ert-deftest test-org/open-at-point ()
1019 "Test `org-open-at-point' with link being a heading property."
1020 (should
1021 (org-test-with-temp-text
1022 "* Headline
1023 :PROPERTIES:
1024 :URL: <point>[[info:org#Top]]
1025 :END:"
1026 (org-open-at-point)
1027 (and (switch-to-buffer "*info*")
1028 (prog1
1029 (looking-at "\nOrg Mode Manual")
1030 (kill-buffer))))))
1034 ;;; Node Properties
1036 (ert-deftest test-org/accumulated-properties-in-drawers ()
1037 "Ensure properties accumulate in subtree drawers."
1038 (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
1039 (org-babel-next-src-block)
1040 (should (equal '(2 1) (org-babel-execute-src-block)))))
1044 ;;; Mark Region
1046 (ert-deftest test-org/mark-subtree ()
1047 "Test `org-mark-subtree' specifications."
1048 ;; Error when point is before first headline.
1049 (should-error
1050 (org-test-with-temp-text "Paragraph\n* Headline\nBody"
1051 (progn (transient-mark-mode 1)
1052 (org-mark-subtree))))
1053 ;; Without argument, mark current subtree.
1054 (should
1055 (equal
1056 '(12 32)
1057 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
1058 (progn (transient-mark-mode 1)
1059 (forward-line 2)
1060 (org-mark-subtree)
1061 (list (region-beginning) (region-end))))))
1062 ;; With an argument, move ARG up.
1063 (should
1064 (equal
1065 '(1 32)
1066 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
1067 (progn (transient-mark-mode 1)
1068 (forward-line 2)
1069 (org-mark-subtree 1)
1070 (list (region-beginning) (region-end))))))
1071 ;; Do not get fooled by inlinetasks.
1072 (when (featurep 'org-inlinetask)
1073 (should
1074 (= 1
1075 (org-test-with-temp-text "* Headline\n*************** Task\nContents"
1076 (progn (transient-mark-mode 1)
1077 (forward-line 1)
1078 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
1079 (region-beginning)))))))
1083 ;;; Navigation
1085 (ert-deftest test-org/beginning-of-line ()
1086 "Test `org-beginning-of-line' specifications."
1087 ;; Standard test.
1088 (should
1089 (org-test-with-temp-text "Some text\nSome other text"
1090 (progn (org-beginning-of-line) (bolp))))
1091 ;; Standard test with `visual-line-mode'.
1092 (should-not
1093 (org-test-with-temp-text "A long line of text\nSome other text"
1094 (progn (visual-line-mode)
1095 (forward-char 2)
1096 (dotimes (i 1000) (insert "very "))
1097 (org-beginning-of-line)
1098 (bolp))))
1099 ;; At an headline with special movement.
1100 (should
1101 (org-test-with-temp-text "* TODO Headline"
1102 (let ((org-special-ctrl-a/e t))
1103 (org-end-of-line)
1104 (and (progn (org-beginning-of-line) (looking-at "Headline"))
1105 (progn (org-beginning-of-line) (bolp))
1106 (progn (org-beginning-of-line) (looking-at "Headline")))))))
1108 (ert-deftest test-org/end-of-line ()
1109 "Test `org-end-of-line' specifications."
1110 ;; Standard test.
1111 (should
1112 (org-test-with-temp-text "Some text\nSome other text"
1113 (progn (org-end-of-line) (eolp))))
1114 ;; Standard test with `visual-line-mode'.
1115 (should-not
1116 (org-test-with-temp-text "A long line of text\nSome other text"
1117 (progn (visual-line-mode)
1118 (forward-char 2)
1119 (dotimes (i 1000) (insert "very "))
1120 (goto-char (point-min))
1121 (org-end-of-line)
1122 (eolp))))
1123 ;; At an headline with special movement.
1124 (should
1125 (org-test-with-temp-text "* Headline1 :tag:\n"
1126 (let ((org-special-ctrl-a/e t))
1127 (and (progn (org-end-of-line) (looking-at " :tag:"))
1128 (progn (org-end-of-line) (eolp))
1129 (progn (org-end-of-line) (looking-at " :tag:"))))))
1130 ;; At an headline without special movement.
1131 (should
1132 (org-test-with-temp-text "* Headline2 :tag:\n"
1133 (let ((org-special-ctrl-a/e nil))
1134 (and (progn (org-end-of-line) (eolp))
1135 (progn (org-end-of-line) (eolp))))))
1136 ;; At an headline, with reversed movement.
1137 (should
1138 (org-test-with-temp-text "* Headline3 :tag:\n"
1139 (let ((org-special-ctrl-a/e 'reversed)
1140 (this-command last-command))
1141 (and (progn (org-end-of-line) (eolp))
1142 (progn (org-end-of-line) (looking-at " :tag:"))))))
1143 ;; At a block without hidden contents.
1144 (should
1145 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
1146 (progn (org-end-of-line) (eolp))))
1147 ;; At a block with hidden contents.
1148 (should-not
1149 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
1150 (let ((org-special-ctrl-a/e t))
1151 (org-hide-block-toggle)
1152 (org-end-of-line)
1153 (eobp)))))
1155 (ert-deftest test-org/forward-paragraph ()
1156 "Test `org-forward-paragraph' specifications."
1157 ;; At end of buffer, return an error.
1158 (should-error
1159 (org-test-with-temp-text "Paragraph"
1160 (goto-char (point-max))
1161 (org-forward-paragraph)))
1162 ;; Standard test.
1163 (should
1164 (org-test-with-temp-text "P1\n\nP2\n\nP3"
1165 (org-forward-paragraph)
1166 (looking-at "P2")))
1167 ;; Ignore depth.
1168 (should
1169 (org-test-with-temp-text "#+BEGIN_CENTER\nP1\n#+END_CENTER\nP2"
1170 (org-forward-paragraph)
1171 (looking-at "P1")))
1172 ;; Do not enter elements with invisible contents.
1173 (should
1174 (org-test-with-temp-text "#+BEGIN_CENTER\nP1\n\nP2\n#+END_CENTER\nP3"
1175 (org-hide-block-toggle)
1176 (org-forward-paragraph)
1177 (looking-at "P3")))
1178 ;; On an affiliated keyword, jump to the beginning of the element.
1179 (should
1180 (org-test-with-temp-text "#+name: para\n#+caption: caption\nPara"
1181 (org-forward-paragraph)
1182 (looking-at "Para")))
1183 ;; On an item or a footnote definition, move to the second element
1184 ;; inside, if any.
1185 (should
1186 (org-test-with-temp-text "- Item1\n\n Paragraph\n- Item2"
1187 (org-forward-paragraph)
1188 (looking-at " Paragraph")))
1189 (should
1190 (org-test-with-temp-text "[fn:1] Def1\n\nParagraph\n\n[fn:2] Def2"
1191 (org-forward-paragraph)
1192 (looking-at "Paragraph")))
1193 ;; On an item, or a footnote definition, when the first line is
1194 ;; empty, move to the first item.
1195 (should
1196 (org-test-with-temp-text "- \n\n Paragraph\n- Item2"
1197 (org-forward-paragraph)
1198 (looking-at " Paragraph")))
1199 (should
1200 (org-test-with-temp-text "[fn:1]\n\nParagraph\n\n[fn:2] Def2"
1201 (org-forward-paragraph)
1202 (looking-at "Paragraph")))
1203 ;; On a table (resp. a property drawer) do not move through table
1204 ;; rows (resp. node properties).
1205 (should
1206 (org-test-with-temp-text "| a | b |\n| c | d |\nParagraph"
1207 (org-forward-paragraph)
1208 (looking-at "Paragraph")))
1209 (should
1210 (org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:\nParagraph"
1211 (org-forward-paragraph)
1212 (looking-at "Paragraph")))
1213 ;; On a verse or source block, stop after blank lines.
1214 (should
1215 (org-test-with-temp-text "#+BEGIN_VERSE\nL1\n\nL2\n#+END_VERSE"
1216 (org-forward-paragraph)
1217 (looking-at "L2")))
1218 (should
1219 (org-test-with-temp-text "#+BEGIN_SRC\nL1\n\nL2\n#+END_SRC"
1220 (org-forward-paragraph)
1221 (looking-at "L2"))))
1223 (ert-deftest test-org/backward-paragraph ()
1224 "Test `org-backward-paragraph' specifications."
1225 ;; Error at beginning of buffer.
1226 (should-error
1227 (org-test-with-temp-text "Paragraph"
1228 (org-backward-paragraph)))
1229 ;; Regular test.
1230 (should
1231 (org-test-with-temp-text "P1\n\nP2\n\nP3"
1232 (goto-char (point-max))
1233 (org-backward-paragraph)
1234 (looking-at "P3")))
1235 (should
1236 (org-test-with-temp-text "P1\n\nP2\n\nP3"
1237 (goto-char (point-max))
1238 (beginning-of-line)
1239 (org-backward-paragraph)
1240 (looking-at "P2")))
1241 ;; Ignore depth.
1242 (should
1243 (org-test-with-temp-text "P1\n\n#+BEGIN_CENTER\nP2\n#+END_CENTER\nP3"
1244 (goto-char (point-max))
1245 (beginning-of-line)
1246 (org-backward-paragraph)
1247 (looking-at "P2")))
1248 ;; Ignore invisible elements.
1249 (should
1250 (org-test-with-temp-text "* H1\n P1\n* H2"
1251 (org-cycle)
1252 (goto-char (point-max))
1253 (beginning-of-line)
1254 (org-backward-paragraph)
1255 (bobp)))
1256 ;; On an affiliated keyword, jump to the first one.
1257 (should
1258 (org-test-with-temp-text "P1\n#+name: n\n#+caption: c1\n#+caption: c2\nP2"
1259 (search-forward "c2")
1260 (org-backward-paragraph)
1261 (looking-at "#\\+name")))
1262 ;; On the second element in an item or a footnote definition, jump
1263 ;; to item or the definition.
1264 (should
1265 (org-test-with-temp-text "- line1\n\n line2"
1266 (goto-char (point-max))
1267 (beginning-of-line)
1268 (org-backward-paragraph)
1269 (looking-at "- line1")))
1270 (should
1271 (org-test-with-temp-text "[fn:1] line1\n\n line2"
1272 (goto-char (point-max))
1273 (beginning-of-line)
1274 (org-backward-paragraph)
1275 (looking-at "\\[fn:1\\] line1")))
1276 ;; On a table (resp. a property drawer), ignore table rows
1277 ;; (resp. node properties).
1278 (should
1279 (org-test-with-temp-text "| a | b |\n| c | d |\nP1"
1280 (goto-char (point-max))
1281 (beginning-of-line)
1282 (org-backward-paragraph)
1283 (bobp)))
1284 (should
1285 (org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:\nP1"
1286 (goto-char (point-max))
1287 (beginning-of-line)
1288 (org-backward-paragraph)
1289 (bobp)))
1290 ;; On a source or verse block, stop before blank lines.
1291 (should
1292 (org-test-with-temp-text "#+BEGIN_VERSE\nL1\n\nL2\n\nL3\n#+END_VERSE"
1293 (search-forward "L3")
1294 (beginning-of-line)
1295 (org-backward-paragraph)
1296 (looking-at "L2")))
1297 (should
1298 (org-test-with-temp-text "#+BEGIN_SRC\nL1\n\nL2\n\nL3#+END_SRC"
1299 (search-forward "L3")
1300 (beginning-of-line)
1301 (org-backward-paragraph)
1302 (looking-at "L2"))))
1304 (ert-deftest test-org/forward-element ()
1305 "Test `org-forward-element' specifications."
1306 ;; 1. At EOB: should error.
1307 (org-test-with-temp-text "Some text\n"
1308 (goto-char (point-max))
1309 (should-error (org-forward-element)))
1310 ;; 2. Standard move: expected to ignore blank lines.
1311 (org-test-with-temp-text "First paragraph.\n\n\nSecond paragraph."
1312 (org-forward-element)
1313 (should (looking-at (regexp-quote "Second paragraph."))))
1314 ;; 3. Headline tests.
1315 (org-test-with-temp-text "
1316 * Head 1
1317 ** Head 1.1
1318 *** Head 1.1.1
1319 ** Head 1.2"
1320 ;; 3.1. At an headline beginning: move to next headline at the
1321 ;; same level.
1322 (goto-line 3)
1323 (org-forward-element)
1324 (should (looking-at (regexp-quote "** Head 1.2")))
1325 ;; 3.2. At an headline beginning: move to parent headline if no
1326 ;; headline at the same level.
1327 (goto-line 3)
1328 (org-forward-element)
1329 (should (looking-at (regexp-quote "** Head 1.2"))))
1330 ;; 4. Greater element tests.
1331 (org-test-with-temp-text
1332 "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside."
1333 ;; 4.1. At a greater element: expected to skip contents.
1334 (org-forward-element)
1335 (should (looking-at (regexp-quote "Outside.")))
1336 ;; 4.2. At the end of greater element contents: expected to skip
1337 ;; to the end of the greater element.
1338 (goto-line 2)
1339 (org-forward-element)
1340 (should (looking-at (regexp-quote "Outside."))))
1341 ;; 5. List tests.
1342 (org-test-with-temp-text "
1343 - item1
1345 - sub1
1347 - sub2
1349 - sub3
1351 Inner paragraph.
1353 - item2
1355 Outside."
1356 ;; 5.1. At list top point: expected to move to the element after
1357 ;; the list.
1358 (goto-line 2)
1359 (org-forward-element)
1360 (should (looking-at (regexp-quote "Outside.")))
1361 ;; 5.2. Special case: at the first line of a sub-list, but not at
1362 ;; beginning of line, move to next item.
1363 (goto-line 2)
1364 (forward-char)
1365 (org-forward-element)
1366 (should (looking-at "- item2"))
1367 (goto-line 4)
1368 (forward-char)
1369 (org-forward-element)
1370 (should (looking-at " - sub2"))
1371 ;; 5.3 At sub-list beginning: expected to move after the sub-list.
1372 (goto-line 4)
1373 (org-forward-element)
1374 (should (looking-at (regexp-quote " Inner paragraph.")))
1375 ;; 5.4. At sub-list end: expected to move outside the sub-list.
1376 (goto-line 8)
1377 (org-forward-element)
1378 (should (looking-at (regexp-quote " Inner paragraph.")))
1379 ;; 5.5. At an item: expected to move to next item, if any.
1380 (goto-line 6)
1381 (org-forward-element)
1382 (should (looking-at " - sub3"))))
1384 (ert-deftest test-org/backward-element ()
1385 "Test `org-backward-element' specifications."
1386 ;; 1. Should error at BOB.
1387 (org-test-with-temp-text " \nParagraph."
1388 (should-error (org-backward-element)))
1389 ;; 2. Should move at BOB when called on the first element in buffer.
1390 (should
1391 (org-test-with-temp-text "\n#+TITLE: test"
1392 (progn (forward-line)
1393 (org-backward-element)
1394 (bobp))))
1395 ;; 3. Not at the beginning of an element: move at its beginning.
1396 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
1397 (goto-line 3)
1398 (end-of-line)
1399 (org-backward-element)
1400 (should (looking-at (regexp-quote "Paragraph2."))))
1401 ;; 4. Headline tests.
1402 (org-test-with-temp-text "
1403 * Head 1
1404 ** Head 1.1
1405 *** Head 1.1.1
1406 ** Head 1.2"
1407 ;; 4.1. At an headline beginning: move to previous headline at the
1408 ;; same level.
1409 (goto-line 5)
1410 (org-backward-element)
1411 (should (looking-at (regexp-quote "** Head 1.1")))
1412 ;; 4.2. At an headline beginning: move to parent headline if no
1413 ;; headline at the same level.
1414 (goto-line 3)
1415 (org-backward-element)
1416 (should (looking-at (regexp-quote "* Head 1")))
1417 ;; 4.3. At the first top-level headline: should error.
1418 (goto-line 2)
1419 (should-error (org-backward-element)))
1420 ;; 5. At beginning of first element inside a greater element:
1421 ;; expected to move to greater element's beginning.
1422 (org-test-with-temp-text "Before.\n#+BEGIN_CENTER\nInside.\n#+END_CENTER"
1423 (goto-line 3)
1424 (org-backward-element)
1425 (should (looking-at "#\\+BEGIN_CENTER")))
1426 ;; 6. At the beginning of the first element in a section: should
1427 ;; move back to headline, if any.
1428 (should
1429 (org-test-with-temp-text "#+TITLE: test\n* Headline\n\nParagraph"
1430 (progn (goto-char (point-max))
1431 (beginning-of-line)
1432 (org-backward-element)
1433 (org-at-heading-p))))
1434 ;; 7. List tests.
1435 (org-test-with-temp-text "
1436 - item1
1438 - sub1
1440 - sub2
1442 - sub3
1444 Inner paragraph.
1446 - item2
1449 Outside."
1450 ;; 7.1. At beginning of sub-list: expected to move to the
1451 ;; paragraph before it.
1452 (goto-line 4)
1453 (org-backward-element)
1454 (should (looking-at "item1"))
1455 ;; 7.2. At an item in a list: expected to move at previous item.
1456 (goto-line 8)
1457 (org-backward-element)
1458 (should (looking-at " - sub2"))
1459 (goto-line 12)
1460 (org-backward-element)
1461 (should (looking-at "- item1"))
1462 ;; 7.3. At end of list/sub-list: expected to move to list/sub-list
1463 ;; beginning.
1464 (goto-line 10)
1465 (org-backward-element)
1466 (should (looking-at " - sub1"))
1467 (goto-line 15)
1468 (org-backward-element)
1469 (should (looking-at "- item1"))
1470 ;; 7.4. At blank-lines before list end: expected to move to top
1471 ;; item.
1472 (goto-line 14)
1473 (org-backward-element)
1474 (should (looking-at "- item1"))))
1476 (ert-deftest test-org/up-element ()
1477 "Test `org-up-element' specifications."
1478 ;; 1. At BOB or with no surrounding element: should error.
1479 (org-test-with-temp-text "Paragraph."
1480 (should-error (org-up-element)))
1481 (org-test-with-temp-text "* Head1\n* Head2"
1482 (goto-line 2)
1483 (should-error (org-up-element)))
1484 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
1485 (goto-line 3)
1486 (should-error (org-up-element)))
1487 ;; 2. At an headline: move to parent headline.
1488 (org-test-with-temp-text "* Head1\n** Sub-Head1\n** Sub-Head2"
1489 (goto-line 3)
1490 (org-up-element)
1491 (should (looking-at "\\* Head1")))
1492 ;; 3. Inside a greater element: move to greater element beginning.
1493 (org-test-with-temp-text
1494 "Before.\n#+BEGIN_CENTER\nParagraph1\nParagraph2\n#+END_CENTER\n"
1495 (goto-line 3)
1496 (org-up-element)
1497 (should (looking-at "#\\+BEGIN_CENTER")))
1498 ;; 4. List tests.
1499 (org-test-with-temp-text "* Top
1500 - item1
1502 - sub1
1504 - sub2
1506 Paragraph within sub2.
1508 - item2"
1509 ;; 4.1. Within an item: move to the item beginning.
1510 (goto-line 8)
1511 (org-up-element)
1512 (should (looking-at " - sub2"))
1513 ;; 4.2. At an item in a sub-list: move to parent item.
1514 (goto-line 4)
1515 (org-up-element)
1516 (should (looking-at "- item1"))
1517 ;; 4.3. At an item in top list: move to beginning of whole list.
1518 (goto-line 10)
1519 (org-up-element)
1520 (should (looking-at "- item1"))
1521 ;; 4.4. Special case. At very top point: should move to parent of
1522 ;; list.
1523 (goto-line 2)
1524 (org-up-element)
1525 (should (looking-at "\\* Top"))))
1527 (ert-deftest test-org/down-element ()
1528 "Test `org-down-element' specifications."
1529 ;; Error when the element hasn't got a recursive type.
1530 (org-test-with-temp-text "Paragraph."
1531 (should-error (org-down-element)))
1532 ;; Error when the element has no contents
1533 (org-test-with-temp-text "* Headline"
1534 (should-error (org-down-element)))
1535 ;; When at a plain-list, move to first item.
1536 (org-test-with-temp-text "- Item 1\n - Item 1.1\n - Item 2.2"
1537 (goto-line 2)
1538 (org-down-element)
1539 (should (looking-at " - Item 1.1")))
1540 (org-test-with-temp-text "#+NAME: list\n- Item 1"
1541 (org-down-element)
1542 (should (looking-at " Item 1")))
1543 ;; When at a table, move to first row
1544 (org-test-with-temp-text "#+NAME: table\n| a | b |"
1545 (org-down-element)
1546 (should (looking-at " a | b |")))
1547 ;; Otherwise, move inside the greater element.
1548 (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph.\n#+END_CENTER"
1549 (org-down-element)
1550 (should (looking-at "Paragraph"))))
1552 (ert-deftest test-org/drag-element-backward ()
1553 "Test `org-drag-element-backward' specifications."
1554 ;; 1. Error when trying to move first element of buffer.
1555 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
1556 (should-error (org-drag-element-backward)))
1557 ;; 2. Error when trying to swap nested elements.
1558 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
1559 (forward-line)
1560 (should-error (org-drag-element-backward)))
1561 ;; 3. Error when trying to swap an headline element and
1562 ;; a non-headline element.
1563 (org-test-with-temp-text "Test.\n* Head 1"
1564 (forward-line)
1565 (should-error (org-drag-element-backward)))
1566 ;; 4. Otherwise, swap elements, preserving column and blank lines
1567 ;; between elements.
1568 (org-test-with-temp-text "Para1\n\n\nParagraph 2\n\nPara3"
1569 (search-forward "graph")
1570 (org-drag-element-backward)
1571 (should (equal (buffer-string) "Paragraph 2\n\n\nPara1\n\nPara3"))
1572 (should (looking-at " 2")))
1573 ;; 5. Preserve visibility of elements and their contents.
1574 (org-test-with-temp-text "
1575 #+BEGIN_CENTER
1576 Text.
1577 #+END_CENTER
1578 - item 1
1579 #+BEGIN_QUOTE
1580 Text.
1581 #+END_QUOTE"
1582 (while (search-forward "BEGIN_" nil t) (org-cycle))
1583 (search-backward "- item 1")
1584 (org-drag-element-backward)
1585 (should
1586 (equal
1587 '((63 . 82) (26 . 48))
1588 (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
1589 (overlays-in (point-min) (point-max)))))))
1591 (ert-deftest test-org/drag-element-forward ()
1592 "Test `org-drag-element-forward' specifications."
1593 ;; 1. Error when trying to move first element of buffer.
1594 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
1595 (goto-line 3)
1596 (should-error (org-drag-element-forward)))
1597 ;; 2. Error when trying to swap nested elements.
1598 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
1599 (forward-line)
1600 (should-error (org-drag-element-forward)))
1601 ;; 3. Error when trying to swap a non-headline element and an
1602 ;; headline.
1603 (org-test-with-temp-text "Test.\n* Head 1"
1604 (should-error (org-drag-element-forward)))
1605 ;; 4. Otherwise, swap elements, preserving column and blank lines
1606 ;; between elements.
1607 (org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
1608 (search-forward "graph")
1609 (org-drag-element-forward)
1610 (should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
1611 (should (looking-at " 1")))
1612 ;; 5. Preserve visibility of elements and their contents.
1613 (org-test-with-temp-text "
1614 #+BEGIN_CENTER
1615 Text.
1616 #+END_CENTER
1617 - item 1
1618 #+BEGIN_QUOTE
1619 Text.
1620 #+END_QUOTE"
1621 (while (search-forward "BEGIN_" nil t) (org-cycle))
1622 (search-backward "#+BEGIN_CENTER")
1623 (org-drag-element-forward)
1624 (should
1625 (equal
1626 '((63 . 82) (26 . 48))
1627 (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
1628 (overlays-in (point-min) (point-max)))))))
1632 ;;; Planning
1634 (ert-deftest test-org/timestamp-has-time-p ()
1635 "Test `org-timestamp-has-time-p' specifications."
1636 ;; With time.
1637 (should
1638 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
1639 (org-timestamp-has-time-p (org-element-context))))
1640 ;; Without time.
1641 (should-not
1642 (org-test-with-temp-text "<2012-03-29 Thu>"
1643 (org-timestamp-has-time-p (org-element-context)))))
1645 (ert-deftest test-org/timestamp-format ()
1646 "Test `org-timestamp-format' specifications."
1647 ;; Regular test.
1648 (should
1649 (equal
1650 "2012-03-29 16:40"
1651 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
1652 (org-timestamp-format (org-element-context) "%Y-%m-%d %R"))))
1653 ;; Range end.
1654 (should
1655 (equal
1656 "2012-03-29"
1657 (org-test-with-temp-text "[2011-07-14 Thu]--[2012-03-29 Thu]"
1658 (org-timestamp-format (org-element-context) "%Y-%m-%d" t)))))
1660 (ert-deftest test-org/timestamp-split-range ()
1661 "Test `org-timestamp-split-range' specifications."
1662 ;; Extract range start (active).
1663 (should
1664 (equal '(2012 3 29)
1665 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1666 (let ((ts (org-timestamp-split-range (org-element-context))))
1667 (mapcar (lambda (p) (org-element-property p ts))
1668 '(:year-end :month-end :day-end))))))
1669 ;; Extract range start (inactive)
1670 (should
1671 (equal '(2012 3 29)
1672 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1673 (let ((ts (org-timestamp-split-range (org-element-context))))
1674 (mapcar (lambda (p) (org-element-property p ts))
1675 '(:year-end :month-end :day-end))))))
1676 ;; Extract range end (active).
1677 (should
1678 (equal '(2012 3 30)
1679 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1680 (let ((ts (org-timestamp-split-range
1681 (org-element-context) t)))
1682 (mapcar (lambda (p) (org-element-property p ts))
1683 '(:year-end :month-end :day-end))))))
1684 ;; Extract range end (inactive)
1685 (should
1686 (equal '(2012 3 30)
1687 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1688 (let ((ts (org-timestamp-split-range
1689 (org-element-context) t)))
1690 (mapcar (lambda (p) (org-element-property p ts))
1691 '(:year-end :month-end :day-end))))))
1692 ;; Return the timestamp if not a range.
1693 (should
1694 (org-test-with-temp-text "[2012-03-29 Thu]"
1695 (let* ((ts-orig (org-element-context))
1696 (ts-copy (org-timestamp-split-range ts-orig)))
1697 (eq ts-orig ts-copy))))
1698 (should
1699 (org-test-with-temp-text "<%%(org-float t 4 2)>"
1700 (let* ((ts-orig (org-element-context))
1701 (ts-copy (org-timestamp-split-range ts-orig)))
1702 (eq ts-orig ts-copy))))
1703 ;; Check that parent is the same when a range was split.
1704 (should
1705 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1706 (let* ((ts-orig (org-element-context))
1707 (ts-copy (org-timestamp-split-range ts-orig)))
1708 (eq (org-element-property :parent ts-orig)
1709 (org-element-property :parent ts-copy))))))
1711 (ert-deftest test-org/timestamp-translate ()
1712 "Test `org-timestamp-translate' specifications."
1713 ;; Translate whole date range.
1714 (should
1715 (equal "<29>--<30>"
1716 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1717 (let ((org-display-custom-times t)
1718 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1719 (org-timestamp-translate (org-element-context))))))
1720 ;; Translate date range start.
1721 (should
1722 (equal "<29>"
1723 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1724 (let ((org-display-custom-times t)
1725 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1726 (org-timestamp-translate (org-element-context) 'start)))))
1727 ;; Translate date range end.
1728 (should
1729 (equal "<30>"
1730 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1731 (let ((org-display-custom-times t)
1732 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1733 (org-timestamp-translate (org-element-context) 'end)))))
1734 ;; Translate time range.
1735 (should
1736 (equal "<08>--<16>"
1737 (org-test-with-temp-text "<2012-03-29 Thu 8:30-16:40>"
1738 (let ((org-display-custom-times t)
1739 (org-time-stamp-custom-formats '("<%d>" . "<%H>")))
1740 (org-timestamp-translate (org-element-context))))))
1741 ;; Translate non-range timestamp.
1742 (should
1743 (equal "<29>"
1744 (org-test-with-temp-text "<2012-03-29 Thu>"
1745 (let ((org-display-custom-times t)
1746 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1747 (org-timestamp-translate (org-element-context))))))
1748 ;; Do not change `diary' timestamps.
1749 (should
1750 (equal "<%%(org-float t 4 2)>"
1751 (org-test-with-temp-text "<%%(org-float t 4 2)>"
1752 (let ((org-display-custom-times t)
1753 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1754 (org-timestamp-translate (org-element-context)))))))
1758 ;;; Radio Targets
1760 (ert-deftest test-org/update-radio-target-regexp ()
1761 "Test `org-update-radio-target-regexp' specifications."
1762 ;; Properly update cache with no previous radio target regexp.
1763 (should
1764 (eq 'link
1765 (org-test-with-temp-text "radio\n\nParagraph\n\nradio"
1766 (save-excursion (goto-char (point-max)) (org-element-context))
1767 (insert "<<<")
1768 (search-forward "o")
1769 (insert ">>>")
1770 (org-update-radio-target-regexp)
1771 (goto-char (point-max))
1772 (org-element-type (org-element-context)))))
1773 ;; Properly update cache with previous radio target regexp.
1774 (should
1775 (eq 'link
1776 (org-test-with-temp-text "radio\n\nParagraph\n\nradio"
1777 (save-excursion (goto-char (point-max)) (org-element-context))
1778 (insert "<<<")
1779 (search-forward "o")
1780 (insert ">>>")
1781 (org-update-radio-target-regexp)
1782 (search-backward "r")
1783 (delete-char 5)
1784 (insert "new")
1785 (org-update-radio-target-regexp)
1786 (goto-char (point-max))
1787 (delete-region (line-beginning-position) (point))
1788 (insert "new")
1789 (org-element-type (org-element-context))))))
1793 ;;; Visibility
1795 (ert-deftest test-org/flag-drawer ()
1796 "Test `org-flag-drawer' specifications."
1797 ;; Hide drawer.
1798 (should
1799 (org-test-with-temp-text ":DRAWER:\ncontents\n:END:"
1800 (org-flag-drawer t)
1801 (get-char-property (line-end-position) 'invisible)))
1802 ;; Show drawer.
1803 (should-not
1804 (org-test-with-temp-text ":DRAWER:\ncontents\n:END:"
1805 (org-flag-drawer t)
1806 (org-flag-drawer nil)
1807 (get-char-property (line-end-position) 'invisible)))
1808 ;; Test optional argument.
1809 (should
1810 (org-test-with-temp-text ":D1:\nc1\n:END:\n\n:D2:\nc2\n:END:"
1811 (let ((drawer (save-excursion (search-forward ":D2")
1812 (org-element-at-point))))
1813 (org-flag-drawer t drawer)
1814 (get-char-property (progn (search-forward ":D2") (line-end-position))
1815 'invisible))))
1816 (should-not
1817 (org-test-with-temp-text ":D1:\nc1\n:END:\n\n:D2:\nc2\n:END:"
1818 (let ((drawer (save-excursion (search-forward ":D2")
1819 (org-element-at-point))))
1820 (org-flag-drawer t drawer)
1821 (get-char-property (line-end-position) 'invisible))))
1822 ;; Do not hide fake drawers.
1823 (should-not
1824 (org-test-with-temp-text "#+begin_example\n:D:\nc\n:END:\n#+end_example"
1825 (forward-line 1)
1826 (org-flag-drawer t)
1827 (get-char-property (line-end-position) 'invisible)))
1828 ;; Do not hide incomplete drawers.
1829 (should-not
1830 (org-test-with-temp-text ":D:\nparagraph"
1831 (forward-line 1)
1832 (org-flag-drawer t)
1833 (get-char-property (line-end-position) 'invisible)))
1834 ;; Do not hide drawers when called from final blank lines.
1835 (should-not
1836 (org-test-with-temp-text ":DRAWER:\nA\n:END:\n\n"
1837 (goto-char (point-max))
1838 (org-flag-drawer t)
1839 (goto-char (point-min))
1840 (get-char-property (line-end-position) 'invisible)))
1841 ;; Don't leave point in an invisible part of the buffer when hiding
1842 ;; a drawer away.
1843 (should-not
1844 (org-test-with-temp-text ":DRAWER:\ncontents\n:END:"
1845 (goto-char (point-max))
1846 (org-flag-drawer t)
1847 (get-char-property (point) 'invisible))))
1850 (provide 'test-org)
1852 ;;; test-org.el ends here