emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Christopher M. Miles
Subject: [PATCH 2] New: auto display inline images under subtree when `org-cycle'.
Date: Tue, 13 Sep 2022 09:09:08 +0800
User-agent: mu4e 1.8.9; emacs 29.0.50

Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> Ihor Radchenko <yantar92@gmail.com> writes:
>>
>>> "Christopher M. Miles" <numbchild@gmail.com> writes:
>>>
>>>>> When I put it on beginning of org document, then preview inline images, 
>>>>> but those global attributes
>>>>> not affected. The inline images still display in actual image size. I 
>>>>> want to specify image size
>>>>> under headline properties. Is it possible to do this?
>>>>
>>>> I implemented this feature by written a hook. Hope this can be helpful
>>>> for someone who also has this needs. Here is the code:
>>>
>>> This looks useful.
>>> Would you be interested to write a patch?
>>
>> The is the new patch which updated the defcustom variable docstring has 
>> correct description.
>
> Thanks for the patch!
> Before extending org-cycle functionality, let's first try to sort out
> subtree-level setting of the image size.

This is implemented by retrieve subtree-level property value in function
~~org-display-inline-image--width~~.

I submitted two separated patches.

>
> In the patch, you are suggesting to use INLINE-IMAGE-WIDTH property.
> However, if we apply the patch as is, this property will only be useful
> when calling a single function -
> `org-display-subtree-with-inline-images'.
> It is not ideal.

The patch's purpose is auto display inline images when [TAB] (~org-cycle~) 
expanding heading or
subtrees. Not for global ~org-toggle-inline-images~. Also, introduce a new 
extra argument "~state~" for
~org-display-inline-images~ like bellowing is not ideal. I think should 
separate the ~org-cycle~ logic
instead of put in ~org-display-inline-images~. In global scope, 
~org-toggle-inline-images~ already
respect the updated function ~org-display-inline-image--width~, it should 
respect the subtree property width.

#+begin_src emacs-lisp
;;                                           V
;;                                          -----
(defun org-display-inline-images (&optional state include-linked refresh beg 
end)
  ...)
#+end_src

*NOTE*: Because ~org-cycle-hook~ will pass a ~state~ variable to hook function.

>
> If we introduce subtree-level setting for inline image size, it should
> also work when displaying inline images by other existing means
> (org-toggle-inline-images).

This is implemented by retrieve subtree-level property value in function
~~org-display-inline-image--width~~.

>
> Instead of working around the existing code of
> `org-display-inline-images' and setting a custom
> `org-image-actual-width' variable in buffer, it is much better to change
> `org-display-inline-images' directly. At the end, the patch is not bound
> to your personal config - feel free to alter the existing Org functions.

This is implemented by retrieve subtree-level property value in function
~~org-display-inline-image--width~~.

>
> Similarly, you do not need to do
> (add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH")
> Simply change the default value of `org-default-properties'.

Updated

>
> Finally, it will be more consistent to name the property closer to the
> variable name: ORG-IMAGE-ACTUAL-WIDTH.

Updated

Attachment: 0001-org.el-Support-subtree-level-image-width-specificati.patch
Description: subtree-level property width support

Attachment: 0002-org.el-Add-hook-function-to-auto-display-inline-imag.patch
Description: org-cycle-hook function support


-- 

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