test-org-fold.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. ;;; test-org.el --- tests for org.el -*- lexical-binding: t; -*-
  2. ;; Authors: Ihor Radchenko
  3. ;; This file is not part of GNU Emacs.
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;; Org folding tests.
  15. ;;; Code:
  16. (eval-and-compile (require 'cl-lib))
  17. (ert-deftest test-org-fold/hide-drawer-toggle ()
  18. "Test `org-fold-hide-drawer-toggle' specifications."
  19. ;; Error when not at a drawer.
  20. (should-error
  21. (org-test-with-temp-text ":fake-drawer:\ncontents"
  22. (org-fold-hide-drawer-toggle 'off)
  23. (get-char-property (line-end-position) 'invisible)))
  24. (should-error
  25. (org-test-with-temp-text
  26. "#+begin_example\n<point>:D:\nc\n:END:\n#+end_example"
  27. (org-fold-hide-drawer-toggle t)))
  28. ;; Hide drawer.
  29. (should
  30. (org-test-with-temp-text ":drawer:\ncontents\n:end:"
  31. (org-fold-show-all)
  32. (org-fold-hide-drawer-toggle)
  33. (get-char-property (line-end-position) 'invisible)))
  34. ;; Show drawer unconditionally when optional argument is `off'.
  35. (should-not
  36. (org-test-with-temp-text ":drawer:\ncontents\n:end:"
  37. (org-fold-hide-drawer-toggle)
  38. (org-fold-hide-drawer-toggle 'off)
  39. (get-char-property (line-end-position) 'invisible)))
  40. ;; Hide drawer unconditionally when optional argument is non-nil.
  41. (should
  42. (org-test-with-temp-text ":drawer:\ncontents\n:end:"
  43. (org-fold-hide-drawer-toggle t)
  44. (get-char-property (line-end-position) 'invisible)))
  45. ;; Do not hide drawer when called from final blank lines.
  46. (should-not
  47. (org-test-with-temp-text ":drawer:\ncontents\n:end:\n\n<point>"
  48. (org-fold-show-all)
  49. (org-fold-hide-drawer-toggle)
  50. (goto-char (point-min))
  51. (get-char-property (line-end-position) 'invisible)))
  52. ;; Don't leave point in an invisible part of the buffer when hiding
  53. ;; a drawer away.
  54. (should-not
  55. (org-test-with-temp-text ":drawer:\ncontents\n<point>:end:"
  56. (org-fold-hide-drawer-toggle)
  57. (get-char-property (point) 'invisible))))
  58. (ert-deftest test-org/hide-block-toggle ()
  59. "Test `org-fold-hide-block-toggle' specifications."
  60. ;; Error when not at a block.
  61. (should-error
  62. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents"
  63. (org-fold-hide-block-toggle 'off)
  64. (get-char-property (line-end-position) 'invisible)))
  65. ;; Hide block.
  66. (should
  67. (org-test-with-temp-text "#+BEGIN_CENTER\ncontents\n#+END_CENTER"
  68. (org-fold-hide-block-toggle)
  69. (get-char-property (line-end-position) 'invisible)))
  70. (should
  71. (org-test-with-temp-text "#+BEGIN_EXAMPLE\ncontents\n#+END_EXAMPLE"
  72. (org-fold-hide-block-toggle)
  73. (get-char-property (line-end-position) 'invisible)))
  74. ;; Show block unconditionally when optional argument is `off'.
  75. (should-not
  76. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE"
  77. (org-fold-hide-block-toggle)
  78. (org-fold-hide-block-toggle 'off)
  79. (get-char-property (line-end-position) 'invisible)))
  80. (should-not
  81. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE"
  82. (org-fold-hide-block-toggle 'off)
  83. (get-char-property (line-end-position) 'invisible)))
  84. ;; Hide block unconditionally when optional argument is non-nil.
  85. (should
  86. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE"
  87. (org-fold-hide-block-toggle t)
  88. (get-char-property (line-end-position) 'invisible)))
  89. (should
  90. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE"
  91. (org-fold-hide-block-toggle)
  92. (org-fold-hide-block-toggle t)
  93. (get-char-property (line-end-position) 'invisible)))
  94. ;; Do not hide block when called from final blank lines.
  95. (should-not
  96. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n#+END_QUOTE\n\n<point>"
  97. (org-fold-hide-block-toggle)
  98. (goto-char (point-min))
  99. (get-char-property (line-end-position) 'invisible)))
  100. ;; Don't leave point in an invisible part of the buffer when hiding
  101. ;; a block away.
  102. (should-not
  103. (org-test-with-temp-text "#+BEGIN_QUOTE\ncontents\n<point>#+END_QUOTE"
  104. (org-fold-hide-block-toggle)
  105. (get-char-property (point) 'invisible))))
  106. (ert-deftest test-org-fold/hide-block-toggle-maybe ()
  107. "Test `org-fold-hide-block-toggle' specifications."
  108. (should
  109. (org-test-with-temp-text "#+BEGIN: dynamic\nContents\n#+END:"
  110. (org-hide-block-toggle)))
  111. (should-error
  112. (org-test-with-temp-text "Paragraph" (org-hide-block-toggle))))
  113. (ert-deftest test-org-fold/show-set-visibility ()
  114. "Test `org-fold-show-set-visibility' specifications."
  115. ;; Do not throw an error before first heading.
  116. (should
  117. (org-test-with-temp-text "Preamble\n* Headline"
  118. (org-fold-show-set-visibility 'tree)
  119. t))
  120. ;; Test all visibility spans, both on headline and in entry.
  121. (let ((list-visible-lines
  122. (lambda (state headerp)
  123. (org-test-with-temp-text "* Grandmother (0)
  124. ** Uncle (1)
  125. *** Heir (2)
  126. ** Father (3)
  127. Ancestor text (4)
  128. *** Sister (5)
  129. Sibling text (6)
  130. *** Self (7)
  131. Match (8)
  132. **** First born (9)
  133. Child text (10)
  134. **** The other child (11)
  135. *** Brother (12)
  136. ** Aunt (13)
  137. "
  138. (org-cycle t)
  139. (search-forward (if headerp "Self" "Match"))
  140. (org-fold-show-set-visibility state)
  141. (goto-char (point-min))
  142. (let (result (line 0))
  143. (while (not (eobp))
  144. (unless (org-invisible-p2) (push line result))
  145. (cl-incf line)
  146. (forward-line))
  147. (nreverse result))))))
  148. (should (equal '(0 7) (funcall list-visible-lines 'minimal t)))
  149. (should (equal '(0 7 8) (funcall list-visible-lines 'minimal nil)))
  150. (should (equal '(0 7 8 9) (funcall list-visible-lines 'local t)))
  151. (should (equal '(0 7 8 9) (funcall list-visible-lines 'local nil)))
  152. (should (equal '(0 3 7) (funcall list-visible-lines 'ancestors t)))
  153. (should (equal '(0 3 7 8) (funcall list-visible-lines 'ancestors nil)))
  154. (should (equal '(0 3 7 8 9 10 11)
  155. (funcall list-visible-lines 'ancestors-full t)))
  156. (should (equal '(0 3 7 8 9 10 11)
  157. (funcall list-visible-lines 'ancestors-full nil)))
  158. (should (equal '(0 3 5 7 12) (funcall list-visible-lines 'lineage t)))
  159. (should (equal '(0 3 5 7 8 9 12) (funcall list-visible-lines 'lineage nil)))
  160. (should (equal '(0 1 3 5 7 12 13) (funcall list-visible-lines 'tree t)))
  161. (should (equal '(0 1 3 5 7 8 9 11 12 13)
  162. (funcall list-visible-lines 'tree nil)))
  163. (should (equal '(0 1 3 4 5 7 12 13)
  164. (funcall list-visible-lines 'canonical t)))
  165. (should (equal '(0 1 3 4 5 7 8 9 11 12 13)
  166. (funcall list-visible-lines 'canonical nil))))
  167. ;; When point is hidden in a drawer or a block, make sure to make it
  168. ;; visible.
  169. (should-not
  170. (org-test-with-temp-text "#+BEGIN_QUOTE\nText\n#+END_QUOTE"
  171. (org-fold-hide-block-toggle)
  172. (search-forward "Text")
  173. (org-fold-show-set-visibility 'minimal)
  174. (org-invisible-p2)))
  175. (should-not
  176. (org-test-with-temp-text ":DRAWER:\nText\n:END:"
  177. (org-fold-hide-drawer-toggle)
  178. (search-forward "Text")
  179. (org-fold-show-set-visibility 'minimal)
  180. (org-invisible-p2)))
  181. (should-not
  182. (org-test-with-temp-text
  183. "#+BEGIN_QUOTE\n<point>:DRAWER:\nText\n:END:\n#+END_QUOTE"
  184. (org-fold-hide-drawer-toggle)
  185. (forward-line -1)
  186. (org-fold-hide-block-toggle)
  187. (search-forward "Text")
  188. (org-fold-show-set-visibility 'minimal)
  189. (org-invisible-p2))))
  190. (ert-deftest test-org-fold/copy-visible ()
  191. "Test `org-copy-visible' specifications."
  192. ;;`org-unfontify-region', which is wired up to
  193. ;; `font-lock-unfontify-region-function', removes the invisible text
  194. ;; property, among other things.
  195. (cl-letf (((symbol-function 'org-unfontify-region) #'ignore))
  196. (should
  197. (equal "Foo"
  198. (org-test-with-temp-text "Foo"
  199. (let ((kill-ring nil))
  200. (org-copy-visible (point-min) (point-max))
  201. (current-kill 0 t)))))
  202. ;; Skip invisible characters by text property.
  203. (should
  204. (equal "Foo"
  205. (org-test-with-temp-text #("F<hidden>oo" 1 9 (invisible t))
  206. (let ((kill-ring nil))
  207. (org-copy-visible (point-min) (point-max))
  208. (current-kill 0 t)))))
  209. ;; Skip invisible characters by overlay.
  210. (should
  211. (equal "Foo"
  212. (org-test-with-temp-text "F<hidden>oo"
  213. (let ((o (make-overlay 2 10)))
  214. (overlay-put o 'invisible t))
  215. (let ((kill-ring nil))
  216. (org-copy-visible (point-min) (point-max))
  217. (current-kill 0 t)))))
  218. ;; Handle invisible characters at the beginning and the end of the
  219. ;; buffer.
  220. (should
  221. (equal "Foo"
  222. (org-test-with-temp-text #("<hidden>Foo" 0 8 (invisible t))
  223. (let ((kill-ring nil))
  224. (org-copy-visible (point-min) (point-max))
  225. (current-kill 0 t)))))
  226. (should
  227. (equal "Foo"
  228. (org-test-with-temp-text #("Foo<hidden>" 3 11 (invisible t))
  229. (let ((kill-ring nil))
  230. (org-copy-visible (point-min) (point-max))
  231. (current-kill 0 t)))))
  232. ;; Handle multiple visible parts.
  233. (should
  234. (equal "abc"
  235. (org-test-with-temp-text
  236. #("aXbXc" 1 2 (invisible t) 3 4 (invisible t))
  237. (let ((kill-ring nil))
  238. (org-copy-visible (point-min) (point-max))
  239. (current-kill 0 t)))))
  240. ;; Handle adjacent invisible parts.
  241. (should
  242. (equal "ab"
  243. (org-test-with-temp-text
  244. #("aXXb" 1 2 (invisible t) 2 3 (invisible org-link))
  245. (let ((kill-ring nil))
  246. (org-copy-visible (point-min) (point-max))
  247. (current-kill 0 t)))))
  248. ;; Copies text based on what's actually visible, as defined by
  249. ;; `buffer-invisibility-spec'.
  250. (should
  251. (equal "aYb"
  252. (org-test-with-temp-text
  253. #("aXYb"
  254. 1 2 (invisible t)
  255. 2 3 (invisible org-test-copy-visible))
  256. (let ((kill-ring nil))
  257. (org-copy-visible (point-min) (point-max))
  258. (current-kill 0 t)))))))
  259. (ert-deftest test-org-fold/set-visibility-according-to-property ()
  260. "Test `org-set-visibility-according-to-property' specifications."
  261. ;; "folded" state.
  262. (should
  263. (org-test-with-temp-text
  264. "
  265. * a
  266. :PROPERTIES:
  267. :VISIBILITY: folded
  268. :END:
  269. ** <point>b"
  270. (org-set-visibility-according-to-property)
  271. (invisible-p (point))))
  272. ;; "children" state.
  273. (should
  274. (org-test-with-temp-text
  275. "
  276. * a
  277. :PROPERTIES:
  278. :VISIBILITY: children
  279. :END:
  280. ** b
  281. <point>Contents
  282. ** c"
  283. (org-set-visibility-according-to-property)
  284. (invisible-p (point))))
  285. (should
  286. (org-test-with-temp-text
  287. "
  288. * a
  289. :PROPERTIES:
  290. :VISIBILITY: children
  291. :END:
  292. ** b
  293. Contents
  294. *** <point>c"
  295. (org-set-visibility-according-to-property)
  296. (invisible-p (point))))
  297. ;; "content" state.
  298. (should
  299. (org-test-with-temp-text
  300. "
  301. * a
  302. :PROPERTIES:
  303. :VISIBILITY: content
  304. :END:
  305. ** b
  306. <point>Contents
  307. *** c"
  308. (org-set-visibility-according-to-property)
  309. (invisible-p (point))))
  310. (should
  311. (org-test-with-temp-text
  312. "
  313. * a
  314. :PROPERTIES:
  315. :VISIBILITY: content
  316. :END:
  317. ** b
  318. Contents
  319. *** <point>c"
  320. (org-set-visibility-according-to-property)
  321. (not (invisible-p (point)))))
  322. ;; "showall" state.
  323. (should
  324. (org-test-with-temp-text
  325. "
  326. * a
  327. :PROPERTIES:
  328. :VISIBILITY: showall
  329. :END:
  330. ** b
  331. <point>Contents
  332. *** c"
  333. (org-set-visibility-according-to-property)
  334. (not (invisible-p (point)))))
  335. (should
  336. (org-test-with-temp-text
  337. "
  338. * a
  339. :PROPERTIES:
  340. :VISIBILITY: showall
  341. :END:
  342. ** b
  343. Contents
  344. *** <point>c"
  345. (org-set-visibility-according-to-property)
  346. (not (invisible-p (point)))))
  347. ;; When VISIBILITY properties are nested, ignore inner ones.
  348. (should
  349. (org-test-with-temp-text
  350. "
  351. * A
  352. :PROPERTIES:
  353. :VISIBILITY: folded
  354. :END:
  355. ** <point>B
  356. :PROPERTIES:
  357. :VISIBILITY: folded
  358. :END:"
  359. (org-set-visibility-according-to-property)
  360. (invisible-p (point)))))
  361. (ert-deftest test-org-fold/visibility-show-branches ()
  362. "Test visibility of inline archived subtrees."
  363. (org-test-with-temp-text
  364. "* Foo<point>
  365. ** Bar :ARCHIVE:
  366. *** Baz
  367. "
  368. (org-kill-note-or-show-branches)
  369. (should (org-invisible-p (- (point-max) 2)))))
  370. (ert-deftest test-org-fold/org-cycle-narrowed-subtree ()
  371. "Test cycling in narrowed buffer."
  372. (org-test-with-temp-text
  373. "* Heading 1<point>
  374. ** Child 1.1
  375. ** Child 1.2
  376. some text
  377. *** Sub-child 1.2.1
  378. * Heading 2"
  379. (org-overview)
  380. (org-narrow-to-subtree)
  381. (org-cycle)
  382. (re-search-forward "Sub-child")
  383. (should (org-invisible-p))))
  384. (ert-deftest test-org-fold/org-fold-reveal-broken-structure ()
  385. "Test unfolding broken elements."
  386. (let ((org-fold-core-style 'text-properties))
  387. (org-test-with-temp-text
  388. "<point>* Heading 1
  389. Text here"
  390. (org-overview)
  391. (re-search-forward "Text")
  392. (should (org-invisible-p))
  393. (goto-char 1)
  394. (org-delete-char 1)
  395. (re-search-forward "Text")
  396. (should-not (org-invisible-p)))
  397. (org-test-with-temp-text
  398. "* Heading 1
  399. <point>:PROPERTIES:
  400. :ID: something
  401. :END:
  402. Text here"
  403. (org-cycle)
  404. (org-fold-hide-drawer-all)
  405. (re-search-forward "ID")
  406. (should (org-invisible-p))
  407. (re-search-backward ":PROPERTIES:")
  408. (delete-char 1)
  409. (re-search-forward "ID")
  410. (should-not (org-invisible-p)))
  411. (org-test-with-temp-text
  412. "* Heading 1
  413. <point>:PROPERTIES:
  414. :ID: something
  415. :END:
  416. Text here"
  417. (org-cycle)
  418. (org-fold-hide-drawer-all)
  419. (re-search-forward "ID")
  420. (should (org-invisible-p))
  421. (re-search-forward ":END:")
  422. (delete-char -1)
  423. (re-search-backward "ID")
  424. (should-not (org-invisible-p)))
  425. (org-test-with-temp-text
  426. "* Heading 1
  427. <point>#+begin_src emacs-lisp
  428. (+ 1 2)
  429. #+end_src
  430. Text here"
  431. (org-cycle)
  432. (org-fold-hide-drawer-all)
  433. (re-search-forward "end")
  434. (should (org-invisible-p))
  435. (delete-char -1)
  436. (re-search-backward "2")
  437. (should-not (org-invisible-p)))))
  438. (ert-deftest test-org-fold/re-hide-edits-inside-fold ()
  439. "Test edits inside folded regions."
  440. (org-test-with-temp-text
  441. "<point>* Heading 1
  442. Text here"
  443. (org-overview)
  444. (org-set-property "TEST" "1")
  445. (re-search-forward "TEST")
  446. (should (org-invisible-p)))
  447. (org-test-with-temp-text
  448. "* Heading 1<point>
  449. Text here"
  450. (org-overview)
  451. (insert " and extra heading text")
  452. (re-search-backward "heading")
  453. (should-not (org-invisible-p)))
  454. (org-test-with-temp-text
  455. "* Heading 1
  456. Text<point> here"
  457. (org-overview)
  458. (insert " and extra text")
  459. (re-search-backward "extra")
  460. (should (org-invisible-p))))
  461. (defmacro test-org-fold-with-default-template (&rest body)
  462. "Run `org-test-with-temp-text' using default folded template."
  463. (declare (indent 0))
  464. `(let ((org-link-descriptive t))
  465. (org-test-with-temp-text
  466. "#+STARTUP: showeverything
  467. * <point>Folded heading
  468. Folded Paragraph inside heading.
  469. * Unfolded heading
  470. :FOLDED-DRAWER:
  471. Folded Paragraph inside drawer.
  472. :END:
  473. Unfolded Paragraph.
  474. #+begin_src emacs-lisp
  475. (message \"Folded block\")
  476. #+end_src
  477. [[hiddenlink][link]]
  478. "
  479. (org-cycle)
  480. (search-forward "FOLDED-DRAWER")
  481. (org-hide-drawer-toggle t)
  482. (search-forward "begin_src")
  483. (org-hide-block-toggle t)
  484. (goto-char 1)
  485. ,@body)))
  486. (ert-deftest test-org-fold/org-catch-invisible-edits ()
  487. "Test invisible edits handling."
  488. ;; Disable delay in `org-fold-check-before-invisible-edit'.
  489. (cl-letf (((symbol-function 'sit-for) #'ignore))
  490. (dolist (org-fold-core-style '(text-properties overlays))
  491. (dolist (org-fold-catch-invisible-edits
  492. '(nil error smart show show-and-error))
  493. (dolist (kind '(insert delete-backward delete nil))
  494. (message "Testing invisible edits: %S:%S:%S"
  495. org-fold-core-style
  496. org-fold-catch-invisible-edits
  497. kind)
  498. ;; Edits outside invisible.
  499. (test-org-fold-with-default-template
  500. (search-forward "Unfolded Paragraph")
  501. (message "Outside invisible")
  502. (org-fold-check-before-invisible-edit kind)
  503. (should-not (org-invisible-p)))
  504. ;; Edits inside invisible region.
  505. (test-org-fold-with-default-template
  506. (dolist (txt '("Folded Paragraph inside heading"
  507. "Folded Paragraph inside drawer"
  508. "Folded block"))
  509. (search-forward txt)
  510. (message "Inside invisible %S" txt)
  511. (pcase org-fold-catch-invisible-edits
  512. (`nil
  513. (org-fold-check-before-invisible-edit kind)
  514. (should (org-invisible-p)))
  515. (`show
  516. (org-fold-check-before-invisible-edit kind)
  517. (should-not (org-invisible-p)))
  518. ((or `smart `show-and-error)
  519. (should-error (org-fold-check-before-invisible-edit kind))
  520. (should-not (org-invisible-p)))
  521. (`error
  522. (should-error (org-fold-check-before-invisible-edit kind))
  523. (should (org-invisible-p)))))
  524. (search-forward "hiddenlink")
  525. (message "Inside hidden link")
  526. (org-fold-check-before-invisible-edit kind)
  527. (should (org-invisible-p)))
  528. ;; Edits at the left border.
  529. (test-org-fold-with-default-template
  530. (dolist (txt '("Folded heading"
  531. ":FOLDED-DRAWER:"
  532. "#+begin_src emacs-lisp"))
  533. (search-forward txt)
  534. (message "Left of folded %S" txt)
  535. (pcase org-fold-catch-invisible-edits
  536. (`nil
  537. (org-fold-check-before-invisible-edit kind)
  538. (should (org-invisible-p (1+ (point)))))
  539. (`show
  540. (org-fold-check-before-invisible-edit kind)
  541. (should-not (org-invisible-p (1+ (point)))))
  542. (`smart
  543. (if (memq kind '(insert delete-backward))
  544. (org-fold-check-before-invisible-edit kind)
  545. (should-error (org-fold-check-before-invisible-edit kind)))
  546. (should-not (org-invisible-p (1+ (point)))))
  547. (`show-and-error
  548. (should-error (org-fold-check-before-invisible-edit kind))
  549. (should-not (org-invisible-p (1+ (point)))))
  550. (`error
  551. (should-error (org-fold-check-before-invisible-edit kind))
  552. (should (org-invisible-p (1+ (point)))))))
  553. (search-forward "hiddenlink")
  554. (search-forward "lin")
  555. (message "Left border of ]] in link")
  556. (org-fold-check-before-invisible-edit kind)
  557. (should (org-invisible-p (1+ (point)))))
  558. ;; Edits at the right border.
  559. (test-org-fold-with-default-template
  560. (dolist (txt '("Folded Paragraph inside heading."
  561. ":END:"
  562. "#+end_src"))
  563. (search-forward txt)
  564. (message "After %S" txt)
  565. (pcase org-fold-catch-invisible-edits
  566. (`nil
  567. (org-fold-check-before-invisible-edit kind)
  568. (should (org-invisible-p (1- (point)))))
  569. (`show
  570. (org-fold-check-before-invisible-edit kind)
  571. (should-not (org-invisible-p (1- (point)))))
  572. ((or `smart `show-and-error)
  573. (should-error (org-fold-check-before-invisible-edit kind))
  574. (should-not (org-invisible-p (1- (point)))))
  575. (`error
  576. (should-error (org-fold-check-before-invisible-edit kind))
  577. (should (org-invisible-p (1- (point)))))))
  578. (search-forward "hiddenlink")
  579. (search-forward "link]]")
  580. (message "Right border of ]] in link")
  581. (org-fold-check-before-invisible-edit kind)
  582. (should (org-invisible-p (1- (point))))))))))
  583. (provide 'test-org-fold)
  584. ;;; test-org-fold.el ends here