emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH v4.0] Re: [PATCH] add a function to only refresh inline image


From: stardiviner
Subject: Re: [PATCH v4.0] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer
Date: Wed, 14 Aug 2024 10:04:52 +0800

I agree with your patch solution. I have tested fine. Thanks for your re-write.

I have an idea, would you like to add an function in bellowing:

#+begin_src emacs-lisp
(defun org-toggle-inline-images-in-results ()
  "Toggle inline images in babel source block results."
  (save-excursion
    ;; [C-c C-v C-o] `org-babel-open-src-block-result'
    (let ((begin (org-babel-where-is-src-block-result))
          (end (progn
                 (end-of-line)
                 (skip-chars-forward " \r\t\n")
                 (looking-at org-link-bracket-re)
                 ;; (org-babel-read-result)
                 (point))))
      (org-toggle-inline-images-command nil begin end))))

(add-hook 'org-babel-after-execute-hook 'org-toggle-inline-images-in-results)
#+end_src

WDYT? after all I originally propose this patch for this purpose to
improve the babel result inline image toggle displaying performance.


[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Mon, Aug 12, 2024 at 6:17 PM Ihor Radchenko <yantar92@posteo.net> wrote:
"Christopher M. Miles" <numbchild@gmail.com> writes:

>> What about the following treatment of ARG:
>>
>> 1. No argument, no region selected :: toggle (display or hide dwim) images in current section
>> 2. No argument, region selected: toggle images in region
>> 3. C-u argument :: toggle images in the whole buffer
>> 4. C-u C-u argument, no region selected :: unconditionally hide images in the buffer
>> 5. M-1 argument, no region selected :: display images in current section with INCLUDE-LINKED
>> 6. M-1 argument, region selected :: ... in region ...
>> 7. M-11 argument :: ... in the whole buffer ...
>> 8. Any other argument :: treat as INCLUDE-LINKED = t
>>
>> And please document all the new arguments in the manual and etc/ORG-NEWS file.
>
> I followed you upper 8 conditions to re-write my patch.
> Except the 8. condition I'm not sure I understand correctly.
> And I extend 1. condition to support the inline image link at point toggle displaying.
> ...

I do not like the code repetitions in the patch and relying upon
`use-region-p' even for non-interactive use.

I am attaching a complete rewrite of your idea.
Please let me know if my patch does everything you want to include into
the command.

Note that I went with a new idea of introducing a branch new function
instead of changing `org-toggle-inline-images'.  This way, existing
users of `org-toggle-inline-images' will not be affected at all.  We are
just changing the default C-c C-x C-v binding.  This way, the breakage
is a little as possible.


--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

reply via email to

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