emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2-v1 (test v1)] New: auto display inline images under subtree


From: Christopher M. Miles
Subject: Re: [PATCH 2-v1 (test v1)] New: auto display inline images under subtree when `org-cycle'.
Date: Thu, 29 Sep 2022 14:57:26 +0800
User-agent: mu4e 1.8.9; emacs 29.0.50

Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> Ok, I created the patch for subtree cycling display inline images.
>> Tested by edebug when org cycling, it should works fine. I don't know
>> how to write test for this.
>
> Thanks for the update!
>
> For tests, you will need to test the existence of image overlays.
> You can refer to test-org-fold/org-fold-reveal-broken-structure but
> need to test overlays-at instead of just org-invisible-p.

I write a testing prototype, got a problem which I marked TODO in code.
And can you check whether my tests correct? Thanks

#+begin_src emacs-lisp
;;; TODO: reference `test-org-fold/org-fold-reveal-broken-structure'
(ert-deftest test-org-fold/org-fold-display-inline-images ()
  "Test inline images displaying when cycling."
  (let ((org-fold-core-style 'text-properties)
        (org-cycle-inline-images-display t))
    ;; `org-cycle' -(state)-> `'children' display child inline images.
    (org-test-with-temp-text
     "<point>* Heading 1
[[file:image.png]]"
     (org-overview)
     (org-cycle)
     (org-next-link)
     (should (overlays-at (point)))
     (org-toggle-inline-images)
     (should-not (overlays-at (point))))
    ;; `org-cycle' -(state)-> `'subtree' display subtrees inline images.
    (org-test-with-temp-text
     "<point>* Heading 1
[[file:image.png]]
** Subheading 1
[[file:image2.png]]
** Subheading 2
[[file:image3.png]]"
     (org-overview)
     (org-cycle)
     (org-cycle)
     (org-next-link)
     (org-next-link)
     (should (overlays-at (point)))
     (org-toggle-inline-images)
     (should-not (overlays-at (point))))
    ;; `org-cycle' -(state)-> `'folded' remove inline image overlays.
    (org-test-with-temp-text
     "<point>* Heading 1
[[file:image.png]]
** Subheading 1
[[file:image2.png]]
** Subheading 2
[[file:image3.png]]"
     (org-overview)
     (org-cycle)
     (org-cycle)
     (org-cycle)
     ;; TODO: how to detect inline image overlays are deleted after folded?
     (should (overlays-at (point)))
     (org-toggle-inline-images)
     (should-not (overlays-at (point))))))
#+end_src

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]