emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH 2-v4] New: auto display inline images under subtree when `org


From: Christopher M. Miles
Subject: Re: [PATCH 2-v4] New: auto display inline images under subtree when `org-cycle'.
Date: Sat, 22 Oct 2022 09:29:24 +0800
User-agent: mu4e 1.8.10; emacs 29.0.50

Whether can this patch be merged at first, put the test in future to
finish? In recent days, I still have not figured out this image overlays
test.

"Christopher M. Miles" <numbchild@gmail.com> writes:

> [[PGP Signed Part:Undecided]]
>
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> "Christopher M. Miles" <numbchild@gmail.com> writes:
>>
>>>> I think that the best we can do in this situation is mocking
>>>> `create-image' in batch mode to return non-nil using `cl-letf'.
>>>
>>> I checked the `create-image' in image.el source code, don't know how to
>>> mocking this. I have no experience and idea about this. I also searched
>>> org testing. Have not found similar situations.
>>>
>>> If you have idea how to write this test, I suggest pass this word to
>>> you. What do you think?
>>
>> I imagine something like
>>
>> ;; Mock `create-image' to work noninteractively.
>> (cl-letf (((symbol-function 'create-image)
>>         (lambda (&rest _)
>>           `(image :type "dummy" :data "dummy"))))
>>   <your test code here>)
>
> After wrapped your cl-letf redefining function binding. Still failed on test.
>
> Here is the new test code:
>
> #+begin_src emacs-lisp
> (ert-deftest test-org-fold/org-fold-display-inline-images ()
>   "Test inline images displaying when cycling."
>   ;; Mock `create-image' to work noninteractively.
>   (cl-letf (((symbol-function 'create-image)
>            (lambda (&rest _) `(image :type "dummy" :data "dummy"))))
>     (let* ((org-cycle-inline-images-display t)
>            (images-dir (expand-file-name "examples/images/" org-test-dir))
>            (org-logo-image (expand-file-name "Org mode logo mono-color.png" 
> images-dir)))
>       ;; `org-cycle' -(state)-> `'children' display child inline images.
>       (org-test-with-temp-text
>        (format "<point>* Heading 1
> [[file:%s]]
> " org-logo-image)
>        (org-overview)
>        ;; (org-cycle)
>        ;; (org-cycle-internal-local)
>        ;; (org-cycle-display-inline-images 'children)
>        (org-fold-show-children)
>        (run-hook-with-args 'org-cycle-hook 'children)
>        (org-next-link)
>        (should org-inline-image-overlays)
>        (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
>        (format "<point>* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
>        (org-overview)
>        ;; (org-cycle)
>        ;; (org-cycle)
>        ;; (org-cycle-internal-global)
>        (org-fold-show-subtree)
>        (run-hook-with-args 'org-cycle-hook 'subtree)
>        (org-next-link)
>        (org-next-link)
>        ;; (should org-inline-image-overlays)
>        (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
>        (format "<point>* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
>        (org-overview)
>        (org-show-subtree)
>        (org-fold-subtree t)
>        (run-hook-with-args 'org-cycle-hook 'folded)
>        (should (null org-inline-image-overlays))
>        (should (null (overlays-in (point-min) (point-max))))
>        (org-show-subtree)
>        (should-not org-inline-image-overlays)
>        (should-not (overlays-in (point-min) (point-max)))))))
> #+end_src
>
>
> And failed after command:
>
> #+begin_src shell
> make BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty 
> #+end_src
>
>
> Here is the output:
>
> #+begin_example
> ~/Code/Emacs/org-mode:main*:1 λ make 
> BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty  
> install -m 755 -d 
> /var/folders/ym/f3v5_yk1279g5ls70x3hzblh0000gn/T//tmp-orgtest
> TMPDIR=/var/folders/ym/f3v5_yk1279g5ls70x3hzblh0000gn/T//tmp-orgtest emacs  
> -Q -batch --eval '(setq vc-handled-backends nil org-startup-folded nil 
> org-element-cache-persistent nil)'  --eval '(add-to-list '"'"'load-path 
> (concat default-directory "lisp"))' --eval '(add-to-list '"'"'load-path 
> (concat default-directory "testing"))'  -l org-batch-test-init --eval '(setq 
> org-batch-test t org-babel-load-languages (quote ( (awk . t)  (C . t)  
> (fortran . t)  (maxima . t)  (lilypond . t)  (octave . t)  (perl . t)  
> (python . t)  (emacs-lisp . t)  (shell . t)  (org . t))) org-test-select-re 
> "test-org-fold/org-fold-display-inline-images" )' -l org-loaddefs.el -l cl -l 
> testing/org-test.el -l ert -l org -l ox -l ol  --eval 
> '(org-test-run-batch-tests org-test-select-re)'
> Package cl is deprecated
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org.el' newer than 
> byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-compat.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-macs.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-keys.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/oc.el' newer than 
> byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol.el' newer than 
> byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-table.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-cycle.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-awk.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-core.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-comint.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-exp.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-ref.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-src.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-maxima.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-lilypond.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-octave.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-emacs-lisp.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-list.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-pcomplete.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-macro.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-id.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-refile.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org.el' newer than 
> byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol-doi.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol-irc.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-element.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox.el' newer than 
> byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox-html.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox-icalendar.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-agenda.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol.el' newer than 
> byte-compiled file; using older file
> Finding ID locations (1/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/setupfile3.org
> Finding ID locations (2/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/setupfile.org
> Finding ID locations (3/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/property-inheritance.org
> Finding ID locations (4/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/org-exp.org
> Finding ID locations (5/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-shell-test.org
> Finding ID locations (6/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-sed-test.org
> Finding ID locations (7/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-screen-test.org
> Finding ID locations (8/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-octave-test.org
> Finding ID locations (9/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-maxima-test.org
> Finding ID locations (10/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-lilypond-test.org
> Finding ID locations (11/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-lilypond-broken.org
> Finding ID locations (12/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-header-arg-defaults.org
> Finding ID locations (13/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-fortran-test.org
> Finding ID locations (14/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-awk-test.org
> Finding ID locations (15/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-C-test.org
> Finding ID locations (16/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/normal.org
> Finding ID locations (17/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/no-heading.org
> Finding ID locations (18/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/macro-templates.org
> Finding ID locations (19/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/links.org
> Finding ID locations (20/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/link-in-heading.org
> Finding ID locations (21/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/include2.org
> Finding ID locations (22/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/include.org
> Finding ID locations (23/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/babel.org
> Finding ID locations (24/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/babel-dangerous.org
> Finding ID locations (25/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/attachments.org
> Finding ID locations (26/26 files): 
> /Users/stardiviner/Code/Emacs/org-mode/testing/examples/agenda-file.org
> 26 files scanned, 14 files contains IDs, and 58 IDs found.
> 0 source block added to Library of Babel
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-sed.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-inlinetask.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-capture.el' 
> newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-clock.el' newer 
> than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-feed.el' newer 
> than byte-compiled file; using older file
> Local variables list is not properly terminated
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-lint.el' newer 
> than byte-compiled file; using older file
> selected tests: test-org-fold/org-fold-display-inline-images
> Running 1 tests (2022-10-10 16:31:04+0800, selector 
> `"test-org-fold/org-fold-display-inline-images"')
> Test test-org-fold/org-fold-display-inline-images backtrace:
>   signal(ert-test-failed (((should org-inline-image-overlays) :form or
>   ert-fail(((should org-inline-image-overlays) :form org-inline-image-
>   (if (unwind-protect (setq value-12536 org-inline-image-overlays) (se
>   (let (form-description-12537) (if (unwind-protect (setq value-12536 
>   (let ((value-12536 (gensym "ert-form-evaluation-aborted-"))) (let (f
>   (progn (org-mode) (let ((point (string-match "<point>" inside-text))
>   (unwind-protect (progn (org-mode) (let ((point (string-match "<point
>   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
>   (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
>   (let ((inside-text (if (stringp (format "<point>* Heading 1\n[[file:
>   (let* ((org-cycle-inline-images-display t) (images-dir (expand-file-
>   (progn (fset 'create-image vnew) (let* ((org-cycle-inline-images-dis
>   (unwind-protect (progn (fset 'create-image vnew) (let* ((org-cycle-i
>   (let* ((vnew #'(lambda (&rest _) '(image :type "dummy" :data "dummy"
>   (closure (t) nil (let* ((vnew #'(lambda (&rest _) '(image :type "dum
>   ert--run-test-internal(#s(ert--test-execution-info :test ... :result
>   ert-run-test(#s(ert-test :name test-org-fold/org-fold-display-inline
>   ert-run-or-rerun-test(#s(ert--stats :selector "test-org-fold/..." :t
>   ert-run-tests("test-org-fold/org-fold-display-inline-images" #f(comp
>   ert-run-tests-batch("test-org-fold/org-fold-display-inline-images")
>   ert-run-tests-batch-and-exit("test-org-fold/org-fold-display-inline-
>   (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
>   org-test-run-batch-tests("test-org-fold/org-fold-display-inline-imag
>   eval((org-test-run-batch-tests org-test-select-re) t)
>   command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
>   command-line()
>   normal-top-level()
> Test test-org-fold/org-fold-display-inline-images condition:
>     (ert-test-failed
>      ((should org-inline-image-overlays)
>       :form org-inline-image-overlays :value nil))
>    FAILED  1/1  test-org-fold/org-fold-display-inline-images (0.001214 sec) 
> at ../lisp/test-org-fold.el:607
>
> Ran 1 tests, 0 results as expected, 1 unexpected (2022-10-10 16:31:04+0800, 
> 0.166044 sec)
>
> 1 unexpected results:
>    FAILED  test-org-fold/org-fold-display-inline-images  ((should 
> org-inline-image-overlays) :form org-inline-image-overlays :value nil)
>
> make: *** [test-dirty] Error 1
> ~/Code/Emacs/org-mode:main*:1 λ 
> #+end_example


-- 

[ 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]