Add org-fold-related tests
This commit is contained in:
parent
e8d8db63a0
commit
6d4e65a124
|
@ -50,6 +50,30 @@
|
||||||
(org-link-encode "http://some.host.com/form?&id=blah%2Bblah25"
|
(org-link-encode "http://some.host.com/form?&id=blah%2Bblah25"
|
||||||
'(?\s ?\[ ?\] ?%))))))
|
'(?\s ?\[ ?\] ?%))))))
|
||||||
|
|
||||||
|
(ert-deftest test-ol/org-toggle-link-display ()
|
||||||
|
"Make sure that `org-toggle-link-display' is working.
|
||||||
|
See https://github.com/yantar92/org/issues/4."
|
||||||
|
(dolist (org-link-descriptive '(nil t))
|
||||||
|
(org-test-with-temp-text "* Org link test
|
||||||
|
[[https://example.com][A link to a site]]"
|
||||||
|
(dotimes (_ 2)
|
||||||
|
(goto-char 1)
|
||||||
|
(re-search-forward "\\[")
|
||||||
|
(should-not (xor org-link-descriptive (org-invisible-p)))
|
||||||
|
(re-search-forward "example")
|
||||||
|
(should-not (xor org-link-descriptive (org-invisible-p)))
|
||||||
|
(re-search-forward "com")
|
||||||
|
(should-not (xor org-link-descriptive (org-invisible-p)))
|
||||||
|
(re-search-forward "]")
|
||||||
|
(should-not (xor org-link-descriptive (org-invisible-p)))
|
||||||
|
(re-search-forward "\\[")
|
||||||
|
(should-not (org-invisible-p))
|
||||||
|
(re-search-forward "link")
|
||||||
|
(should-not (org-invisible-p))
|
||||||
|
(re-search-forward "]")
|
||||||
|
(should-not (xor org-link-descriptive (org-invisible-p)))
|
||||||
|
(org-toggle-link-display)))))
|
||||||
|
|
||||||
|
|
||||||
;;; Escape and Unescape Links
|
;;; Escape and Unescape Links
|
||||||
|
|
||||||
|
|
|
@ -580,9 +580,27 @@ b. Item 2<point>"
|
||||||
(let ((org-list-use-circular-motion t)) (org-move-item-down))
|
(let ((org-list-use-circular-motion t)) (org-move-item-down))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
;; Preserve item visibility.
|
;; Preserve item visibility.
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(make-list 2 'org-fold-outline)
|
||||||
|
(let ((org-fold-core-style 'text-properties))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
|
||||||
|
(let ((org-cycle-include-plain-lists t))
|
||||||
|
(org-cycle)
|
||||||
|
(search-forward "- item 2")
|
||||||
|
(org-cycle))
|
||||||
|
(search-backward "- item 1")
|
||||||
|
(org-move-item-down)
|
||||||
|
(forward-line)
|
||||||
|
(list (org-fold-get-folding-spec)
|
||||||
|
(progn
|
||||||
|
(search-backward " body 2")
|
||||||
|
(org-fold-get-folding-spec)))))))
|
||||||
(should
|
(should
|
||||||
(equal
|
(equal
|
||||||
'(outline outline)
|
'(outline outline)
|
||||||
|
(let ((org-fold-core-style 'overlays))
|
||||||
(org-test-with-temp-text
|
(org-test-with-temp-text
|
||||||
"* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
|
"* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
|
||||||
(let ((org-cycle-include-plain-lists t))
|
(let ((org-cycle-include-plain-lists t))
|
||||||
|
@ -595,7 +613,7 @@ b. Item 2<point>"
|
||||||
(list (org-invisible-p2)
|
(list (org-invisible-p2)
|
||||||
(progn
|
(progn
|
||||||
(search-backward " body 2")
|
(search-backward " body 2")
|
||||||
(org-invisible-p2))))))
|
(org-invisible-p2)))))))
|
||||||
;; Preserve children visibility.
|
;; Preserve children visibility.
|
||||||
(org-test-with-temp-text "* Headline
|
(org-test-with-temp-text "* Headline
|
||||||
- item 1
|
- item 1
|
||||||
|
@ -869,9 +887,22 @@ b. Item 2<point>"
|
||||||
(org-insert-item)
|
(org-insert-item)
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
;; Preserve list visibility when inserting an item.
|
;; Preserve list visibility when inserting an item.
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
`(org-fold-outline org-fold-outline)
|
||||||
|
(let ((org-fold-core-style 'text-properties))
|
||||||
|
(org-test-with-temp-text "- A\n - B\n- C\n - D"
|
||||||
|
(let ((org-cycle-include-plain-lists t))
|
||||||
|
(org-cycle)
|
||||||
|
(forward-line 2)
|
||||||
|
(org-cycle)
|
||||||
|
(org-insert-item)
|
||||||
|
(list (org-fold-get-folding-spec nil (line-beginning-position 0))
|
||||||
|
(org-fold-get-folding-spec nil (line-end-position 2))))))))
|
||||||
(should
|
(should
|
||||||
(equal
|
(equal
|
||||||
'(outline outline)
|
'(outline outline)
|
||||||
|
(let ((org-fold-core-style 'overlays))
|
||||||
(org-test-with-temp-text "- A\n - B\n- C\n - D"
|
(org-test-with-temp-text "- A\n - B\n- C\n - D"
|
||||||
(let ((org-cycle-include-plain-lists t))
|
(let ((org-cycle-include-plain-lists t))
|
||||||
(org-cycle)
|
(org-cycle)
|
||||||
|
@ -879,7 +910,7 @@ b. Item 2<point>"
|
||||||
(org-cycle)
|
(org-cycle)
|
||||||
(org-insert-item)
|
(org-insert-item)
|
||||||
(list (get-char-property (line-beginning-position 0) 'invisible)
|
(list (get-char-property (line-beginning-position 0) 'invisible)
|
||||||
(get-char-property (line-end-position 2) 'invisible))))))
|
(get-char-property (line-end-position 2) 'invisible)))))))
|
||||||
;; Test insertion in area after a sub-list. In particular, if point
|
;; Test insertion in area after a sub-list. In particular, if point
|
||||||
;; is right at the end of the previous sub-list, still insert
|
;; is right at the end of the previous sub-list, still insert
|
||||||
;; a sub-item in that list.
|
;; a sub-item in that list.
|
||||||
|
|
|
@ -4462,7 +4462,33 @@ Outside."
|
||||||
;; Preserve visibility of elements and their contents.
|
;; Preserve visibility of elements and their contents.
|
||||||
(should
|
(should
|
||||||
(equal '((63 . 82) (26 . 48))
|
(equal '((63 . 82) (26 . 48))
|
||||||
(org-test-with-temp-text "
|
(let ((org-fold-core-style 'text-properties))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"
|
||||||
|
#+BEGIN_CENTER
|
||||||
|
Text.
|
||||||
|
#+END_CENTER
|
||||||
|
- item 1
|
||||||
|
#+BEGIN_QUOTE
|
||||||
|
Text.
|
||||||
|
#+END_QUOTE"
|
||||||
|
(while (search-forward "BEGIN_" nil t) (org-cycle))
|
||||||
|
(search-backward "- item 1")
|
||||||
|
(org-drag-element-backward)
|
||||||
|
(let (regions)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (< (point) (point-max))
|
||||||
|
(let ((region (org-fold-get-region-at-point)))
|
||||||
|
(if (not region)
|
||||||
|
(goto-char (org-fold-next-folding-state-change))
|
||||||
|
(goto-char (cdr region))
|
||||||
|
(push region regions))))
|
||||||
|
regions)))))
|
||||||
|
(should
|
||||||
|
(equal '((63 . 82) (26 . 48))
|
||||||
|
(let ((org-fold-core-style 'overlays))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"
|
||||||
#+BEGIN_CENTER
|
#+BEGIN_CENTER
|
||||||
Text.
|
Text.
|
||||||
#+END_CENTER
|
#+END_CENTER
|
||||||
|
@ -4474,7 +4500,7 @@ Text.
|
||||||
(search-backward "- item 1")
|
(search-backward "- item 1")
|
||||||
(org-drag-element-backward)
|
(org-drag-element-backward)
|
||||||
(mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
|
(mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
|
||||||
(overlays-in (point-min) (point-max))))))
|
(overlays-in (point-min) (point-max)))))))
|
||||||
;; Pathological case: handle call with point in blank lines right
|
;; Pathological case: handle call with point in blank lines right
|
||||||
;; after a headline.
|
;; after a headline.
|
||||||
(should
|
(should
|
||||||
|
@ -4511,7 +4537,34 @@ Text.
|
||||||
(should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
|
(should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
|
||||||
(should (looking-at " 1")))
|
(should (looking-at " 1")))
|
||||||
;; 5. Preserve visibility of elements and their contents.
|
;; 5. Preserve visibility of elements and their contents.
|
||||||
(org-test-with-temp-text "
|
(let ((org-fold-core-style 'text-properties))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"
|
||||||
|
#+BEGIN_CENTER
|
||||||
|
Text.
|
||||||
|
#+END_CENTER
|
||||||
|
- item 1
|
||||||
|
#+BEGIN_QUOTE
|
||||||
|
Text.
|
||||||
|
#+END_QUOTE"
|
||||||
|
(while (search-forward "BEGIN_" nil t) (org-cycle))
|
||||||
|
(search-backward "#+BEGIN_CENTER")
|
||||||
|
(org-drag-element-forward)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
'((63 . 82) (26 . 48))
|
||||||
|
(let (regions)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (< (point) (point-max))
|
||||||
|
(let ((region (org-fold-get-region-at-point)))
|
||||||
|
(if (not region)
|
||||||
|
(goto-char (org-fold-next-folding-state-change))
|
||||||
|
(goto-char (cdr region))
|
||||||
|
(push region regions))))
|
||||||
|
regions)))))
|
||||||
|
(let ((org-fold-core-style 'overlays))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"
|
||||||
#+BEGIN_CENTER
|
#+BEGIN_CENTER
|
||||||
Text.
|
Text.
|
||||||
#+END_CENTER
|
#+END_CENTER
|
||||||
|
@ -4526,7 +4579,7 @@ Text.
|
||||||
(equal
|
(equal
|
||||||
'((63 . 82) (26 . 48))
|
'((63 . 82) (26 . 48))
|
||||||
(mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
|
(mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
|
||||||
(overlays-in (point-min) (point-max)))))))
|
(overlays-in (point-min) (point-max))))))))
|
||||||
|
|
||||||
(ert-deftest test-org/next-block ()
|
(ert-deftest test-org/next-block ()
|
||||||
"Test `org-next-block' specifications."
|
"Test `org-next-block' specifications."
|
||||||
|
@ -8419,6 +8472,100 @@ Contents
|
||||||
(org-kill-note-or-show-branches)
|
(org-kill-note-or-show-branches)
|
||||||
(should (org-invisible-p (- (point-max) 2)))))
|
(should (org-invisible-p (- (point-max) 2)))))
|
||||||
|
|
||||||
|
(ert-deftest test-org/org-cycle-narrowed-subtree ()
|
||||||
|
"Test cycling in narrowed buffer."
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1<point>
|
||||||
|
** Child 1.1
|
||||||
|
** Child 1.2
|
||||||
|
some text
|
||||||
|
*** Sub-child 1.2.1
|
||||||
|
* Heading 2"
|
||||||
|
(org-overview)
|
||||||
|
(org-narrow-to-subtree)
|
||||||
|
(org-cycle)
|
||||||
|
(re-search-forward "Sub-child")
|
||||||
|
(should (org-invisible-p))))
|
||||||
|
|
||||||
|
(ert-deftest test-org/org-fold-reveal-broken-structure ()
|
||||||
|
"Test unfolding broken elements."
|
||||||
|
(let ((org-fold-core-style 'text-properties))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"<point>* Heading 1
|
||||||
|
Text here"
|
||||||
|
(org-overview)
|
||||||
|
(re-search-forward "Text")
|
||||||
|
(should (org-invisible-p))
|
||||||
|
(goto-char 1)
|
||||||
|
(delete-char 1)
|
||||||
|
(re-search-forward "Text")
|
||||||
|
(should-not (org-invisible-p)))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1
|
||||||
|
<point>:PROPERTIES:
|
||||||
|
:ID: something
|
||||||
|
:END:
|
||||||
|
Text here"
|
||||||
|
(org-cycle)
|
||||||
|
(org-fold-hide-drawer-all)
|
||||||
|
(re-search-forward "ID")
|
||||||
|
(should (org-invisible-p))
|
||||||
|
(re-search-backward ":PROPERTIES:")
|
||||||
|
(delete-char 1)
|
||||||
|
(re-search-forward "ID")
|
||||||
|
(should-not (org-invisible-p)))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1
|
||||||
|
<point>:PROPERTIES:
|
||||||
|
:ID: something
|
||||||
|
:END:
|
||||||
|
Text here"
|
||||||
|
(org-cycle)
|
||||||
|
(org-fold-hide-drawer-all)
|
||||||
|
(re-search-forward "ID")
|
||||||
|
(should (org-invisible-p))
|
||||||
|
(re-search-forward ":END:")
|
||||||
|
(delete-char -1)
|
||||||
|
(re-search-backward "ID")
|
||||||
|
(should-not (org-invisible-p)))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1
|
||||||
|
<point>#+begin_src emacs-lisp
|
||||||
|
(+ 1 2)
|
||||||
|
#+end_src
|
||||||
|
Text here"
|
||||||
|
(org-cycle)
|
||||||
|
(org-fold-hide-drawer-all)
|
||||||
|
(re-search-forward "end")
|
||||||
|
(should (org-invisible-p))
|
||||||
|
(delete-char -1)
|
||||||
|
(re-search-backward "2")
|
||||||
|
(should-not (org-invisible-p)))))
|
||||||
|
|
||||||
|
(ert-deftest test-org/re-hide-edits-inside-fold ()
|
||||||
|
"Test edits inside folded regions."
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"<point>* Heading 1
|
||||||
|
Text here"
|
||||||
|
(org-overview)
|
||||||
|
(org-set-property "TEST" "1")
|
||||||
|
(re-search-forward "TEST")
|
||||||
|
(should (org-invisible-p)))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1<point>
|
||||||
|
Text here"
|
||||||
|
(org-overview)
|
||||||
|
(insert " and extra heading text")
|
||||||
|
(re-search-backward "heading")
|
||||||
|
(should-not (org-invisible-p)))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* Heading 1
|
||||||
|
Text<point> here"
|
||||||
|
(org-overview)
|
||||||
|
(insert " and extra text")
|
||||||
|
(re-search-backward "extra")
|
||||||
|
(should (org-invisible-p))))
|
||||||
|
|
||||||
|
|
||||||
;;; Yank and Kill
|
;;; Yank and Kill
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue