emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [QUESTION] How to specific image size attributes under headline scope?
@ 2021-11-22  6:34 Christopher M. Miles
  2021-11-22 18:31 ` Timothy
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Christopher M. Miles @ 2021-11-22  6:34 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

There is attributes setting above image link to specify image inline preview size. Like this:

#+begin_src org
,#+ATTR_ORG: :width 500
,#+ATTR_LATEX: :width 5.0in
,#+ATTR_HTML: :width 500px
[[file:kk/88320740_p0.jpg]]

#+end_src

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?

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [QUESTION] How to specific image size attributes under headline scope?
  2021-11-22  6:34 [QUESTION] How to specific image size attributes under headline scope? Christopher M. Miles
@ 2021-11-22 18:31 ` Timothy
  2022-08-18 12:44   ` Christopher M. Miles
       [not found]   ` <m2o7whra7j.fsf@numbchild>
  2022-09-11  2:20 ` [SOLVED] " Christopher M. Miles
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 21+ messages in thread
From: Timothy @ 2021-11-22 18:31 UTC (permalink / raw)
  To: numbchild; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

Hi Christopher,

> I want to specify image size under headline properties. Is it possible to do
> this?

As I understand org.el, this is solely governed by
`org-display-inline-image--width', which only looks at `#+attr_*' keywords when
setting an image width.

All the best,
Timothy

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [QUESTION] How to specific image size attributes under headline scope?
  2021-11-22 18:31 ` Timothy
@ 2022-08-18 12:44   ` Christopher M. Miles
       [not found]   ` <m2o7whra7j.fsf@numbchild>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-08-18 12:44 UTC (permalink / raw)
  To: Timothy; +Cc: numbchild, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]


Timothy <tecosaur@gmail.com> writes:

> Hi Christopher,
>
>> I want to specify image size under headline properties. Is it possible to do
>> this?
>
> As I understand org.el, this is solely governed by
> `org-display-inline-image--width', which only looks at `#+attr_*' keywords when
> setting an image width.
>
> All the best,
> Timothy

Yes, what about letting org-mode support headline level image size specification?
Is this a good idea and easy to implement?

-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [QUESTION] How to specific image size attributes under headline scope?
       [not found]   ` <m2o7whra7j.fsf@numbchild>
@ 2022-08-22 17:10     ` Timothy
  2022-08-23  0:24       ` Christopher M. Miles
  0 siblings, 1 reply; 21+ messages in thread
From: Timothy @ 2022-08-22 17:10 UTC (permalink / raw)
  To: numbchild; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

Hi Christopher,

>>> I want to specify image size under headline properties. Is it possible to do
>>> this?
>>
>> As I understand org.el, this is solely governed by
>> `org-display-inline-image–width’, which only looks at `#+attr_*’ keywords when
>> setting an image width.
>>
>> All the best,
>> Timothy
>
> Yes, what about letting org-mode support headline level image size specification?
> Is this a good idea and easy to implement?

Hmm, so would this basically be setting all images within a certain section to
inherit a different `org-image-actual-width' / `org-latex-image-default-width'
parameter?

All the best,
Timothy

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [QUESTION] How to specific image size attributes under headline scope?
  2022-08-22 17:10     ` Timothy
@ 2022-08-23  0:24       ` Christopher M. Miles
  0 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-08-23  0:24 UTC (permalink / raw)
  To: Timothy; +Cc: numbchild, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]


Timothy <orgmode@tec.tecosaur.net> writes:

> Hi Christopher,
>
>>>> I want to specify image size under headline properties. Is it possible to do
>>>> this?
>>>
>>> As I understand org.el, this is solely governed by
>>> `org-display-inline-image–width’, which only looks at `#+attr_*’ keywords when
>>> setting an image width.
>>>
>>> All the best,
>>> Timothy
>>
>> Yes, what about letting org-mode support headline level image size specification?
>> Is this a good idea and easy to implement?
>
> Hmm, so would this basically be setting all images within a certain section to
> inherit a different `org-image-actual-width' / `org-latex-image-default-width'
> parameter?
>
> All the best,
> Timothy

Yes, like this:

#+begin_src org
,* headline 1

This image will be displayed in 200 width.

,#+ATTR_ORG: :width 200
,#+ATTR_LATEX: :width 2.0in
,#+ATTR_HTML: :width 200px
[[file:kk.png]]


This image will be displayed in 600 width, it has no manually specified
image size, it will use ~org-image-actual-width~.

[[file:kk.png]]

,** headline 2
:PROPERTIES:
:IMAGE-WIDTH: 500
:END:

This image will be displayed in 200 width.

,#+ATTR_ORG: :width 200
,#+ATTR_LATEX: :width 2.0in
,#+ATTR_HTML: :width 200px
[[file:kk.png]]

This image will be displayed in 500 width, it has no manually specified
image size, it will use "headline 2" scope property ":IMAGE-WIDTH: 500".
This is what I want. (I assume there is a new property which maybe named
like :IMAGE-WIDTH:.)

[[file:kk.png]]
#+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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [SOLVED] Re: [QUESTION] How to specific image size attributes under headline scope?
  2021-11-22  6:34 [QUESTION] How to specific image size attributes under headline scope? Christopher M. Miles
  2021-11-22 18:31 ` Timothy
@ 2022-09-11  2:20 ` Christopher M. Miles
  2022-09-11  2:25 ` Christopher M. Miles
       [not found] ` <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com>
  3 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-11  2:20 UTC (permalink / raw)
  Cc: Christopher M. Miles, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3664 bytes --]


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

> [[PGP Signed Part:Undecided]]
> There is attributes setting above image link to specify image inline preview size. Like this:
>
> #+begin_src org
> ,#+ATTR_ORG: :width 500
> ,#+ATTR_LATEX: :width 5.0in
> ,#+ATTR_HTML: :width 500px
> [[file:kk/88320740_p0.jpg]]
>
> #+end_src
>
> 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:

#+begin_src emacs-lisp
;;; auto display inline images under current TAB cycle expanded "visible" subtree.
(defun org-display-subtree-with-inline-images (&optional state)
  "Toggle the display of inline images under current expanded visible subtree.
INCLUDE-LINKED is passed to `org-display-inline-images'."
  (interactive)
  ;; (not (memq state '(overview folded contents))) ; global state change
  (let ((display-inline-images-local
         (lambda (beg end)
           (org-display-inline-images t t beg end)
           ;; display number of inline images which is intersection of two image overlays lists.
           ;; (message "%d images displayed inline"
           ;;          (length (cl-intersection org-inline-image-overlays (overlays-in beg end))))
           ))
        (hide-inline-images-local
         (lambda ()
           (setq org-inline-image-overlays nil) ; (org-remove-inline-images)
           (message "Inline image display turned off")))
        (inline-image-width-override ; get headline property value as inline image width.
         (lambda ()
           ;; The property "INLINE-IMAGE-WIDTH" value should be integer.
           (let* ((property-value (ignore-errors (org-property-or-variable-value 'INLINE-IMAGE-WIDTH)))
                  (width-integer (or (and property-value
                                          (if (numberp property-value) property-value (string-to-number property-value)))
                                     (- (/ (window-width (selected-window) t) 2) 100))))
             (setq-local org-image-actual-width width-integer)))))
    (pcase state
      ('children
       (save-excursion
         (save-restriction
           (org-narrow-to-subtree)
           ;; If has nested headlines, beg,end only from parent headline
           ;; to first child headline which reference to upper let-binding
           ;; `org-next-visible-heading'.
           (funcall display-inline-images-local (point-min) (progn (org-next-visible-heading 1) (point))))))
      ('subtree
       (save-excursion
         (save-restriction
           (org-narrow-to-subtree)
           (funcall inline-image-width-override)
           ;; If has nested headlines, also inline display images under all sub-headlines.
           (funcall display-inline-images-local (point-min) (point-max)))))
      ('folded
       (funcall hide-inline-images-local)))))

(add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH")

(add-hook 'org-cycle-hook #'org-display-subtree-with-inline-images)

(define-key org-mode-map (kbd "C-c C-x C-v") 'org-display-subtree-with-inline-images)
#+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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [SOLVED] Re: [QUESTION] How to specific image size attributes under headline scope?
  2021-11-22  6:34 [QUESTION] How to specific image size attributes under headline scope? Christopher M. Miles
  2021-11-22 18:31 ` Timothy
  2022-09-11  2:20 ` [SOLVED] " Christopher M. Miles
@ 2022-09-11  2:25 ` Christopher M. Miles
       [not found] ` <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com>
  3 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-11  2:25 UTC (permalink / raw)
  Cc: Christopher M. Miles, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3664 bytes --]


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

> [[PGP Signed Part:Undecided]]
> There is attributes setting above image link to specify image inline preview size. Like this:
>
> #+begin_src org
> ,#+ATTR_ORG: :width 500
> ,#+ATTR_LATEX: :width 5.0in
> ,#+ATTR_HTML: :width 500px
> [[file:kk/88320740_p0.jpg]]
>
> #+end_src
>
> 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:

#+begin_src emacs-lisp
;;; auto display inline images under current TAB cycle expanded "visible" subtree.
(defun org-display-subtree-with-inline-images (&optional state)
  "Toggle the display of inline images under current expanded visible subtree.
INCLUDE-LINKED is passed to `org-display-inline-images'."
  (interactive)
  ;; (not (memq state '(overview folded contents))) ; global state change
  (let ((display-inline-images-local
         (lambda (beg end)
           (org-display-inline-images t t beg end)
           ;; display number of inline images which is intersection of two image overlays lists.
           ;; (message "%d images displayed inline"
           ;;          (length (cl-intersection org-inline-image-overlays (overlays-in beg end))))
           ))
        (hide-inline-images-local
         (lambda ()
           (setq org-inline-image-overlays nil) ; (org-remove-inline-images)
           (message "Inline image display turned off")))
        (inline-image-width-override ; get headline property value as inline image width.
         (lambda ()
           ;; The property "INLINE-IMAGE-WIDTH" value should be integer.
           (let* ((property-value (ignore-errors (org-property-or-variable-value 'INLINE-IMAGE-WIDTH)))
                  (width-integer (or (and property-value
                                          (if (numberp property-value) property-value (string-to-number property-value)))
                                     (- (/ (window-width (selected-window) t) 2) 100))))
             (setq-local org-image-actual-width width-integer)))))
    (pcase state
      ('children
       (save-excursion
         (save-restriction
           (org-narrow-to-subtree)
           ;; If has nested headlines, beg,end only from parent headline
           ;; to first child headline which reference to upper let-binding
           ;; `org-next-visible-heading'.
           (funcall display-inline-images-local (point-min) (progn (org-next-visible-heading 1) (point))))))
      ('subtree
       (save-excursion
         (save-restriction
           (org-narrow-to-subtree)
           (funcall inline-image-width-override)
           ;; If has nested headlines, also inline display images under all sub-headlines.
           (funcall display-inline-images-local (point-min) (point-max)))))
      ('folded
       (funcall hide-inline-images-local)))))

(add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH")

(add-hook 'org-cycle-hook #'org-display-subtree-with-inline-images)

(define-key org-mode-map (kbd "C-c C-x C-v") 'org-display-subtree-with-inline-images)
#+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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [SOLVED] Re: [QUESTION] How to specific image size attributes under headline scope?
       [not found] ` <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-11 12:34   ` Ihor Radchenko
  2022-09-12  1:54     ` [PATCH] " Christopher M. Miles
                       ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-11 12:34 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

"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?

-- 
Ihor Radchenko,
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH] Re: [SOLVED] Re: [QUESTION] How to specific image size attributes under headline scope?
  2022-09-11 12:34   ` Ihor Radchenko
@ 2022-09-12  1:54     ` Christopher M. Miles
  2022-09-12  1:59     ` [PATCH] New: auto display inline images under subtree when `org-cycle' Christopher M. Miles
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-12  1:54 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 569 bytes --]


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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Add-hook-function-to-auto-display-inline-imag.patch --]
[-- Type: text/x-patch, Size: 4279 bytes --]

From 2ba9c048dd2609eb22a3924dd15f041b648ef859 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Mon, 12 Sep 2022 09:45:09 +0800
Subject: [PATCH] org.el: Add hook function to auto display inline images of
 subtree

* lisp/org.el (org-display-subtree-with-inline-images): Add an option
and hook function to auto display of inline images under current
expanded visible subtree.
---
 lisp/org.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 6e6c437d5..594006551 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1108,6 +1108,14 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-cycle-display-inline-images nil
+  "Non-nil means show inline images when `org-cycle'.
+When this is t, org-mode will add function
+`org-display-subtree-with-inline-images' on hook `org-cycle-hook'."
+  :group 'org-startup
+  :version "24.1"
+  :type 'boolean)
+
 (defcustom org-startup-with-latex-preview nil
   "Non-nil means preview LaTeX fragments when loading a new Org file.
 
@@ -16284,6 +16292,57 @@ buffer boundaries with possible narrowing."
   (mapc #'delete-overlay org-inline-image-overlays)
   (setq org-inline-image-overlays nil))
 
+(defun org-display-subtree-with-inline-images (&optional state)
+  "Toggle the display of inline images under current expanded visible subtree.
+This hook function will auto display or hide inline images after `org-cycle'.
+It is used to hook on `org-cycle-hook'.
+The function behavior is controlled by `org-cycle-display-inline-images'."
+  (interactive)
+  ;; (not (memq state '(overview folded contents))) ; global state change
+  (when org-cycle-display-inline-images
+    (let ((display-inline-images-local
+           (lambda (beg end)
+             (org-display-inline-images t t beg end)
+             ;; display number of inline images which is intersection of two image overlays lists.
+             ;; (message "%d images displayed inline"
+             ;;          (length (cl-intersection org-inline-image-overlays (overlays-in beg end))))
+             ))
+          (hide-inline-images-local
+           (lambda ()
+             (setq org-inline-image-overlays nil) ; (org-remove-inline-images)
+             (message "Inline image display turned off")))
+          (inline-image-width-override    ; get headline property value as inline image width.
+           (lambda ()
+             ;; The property "INLINE-IMAGE-WIDTH" value should be integer. Reference `org-display-inline-image--width'.
+             (let* ((property-value (ignore-errors (org-property-or-variable-value 'INLINE-IMAGE-WIDTH)))
+                    (width-integer (or (and property-value
+                                            (if (numberp property-value) property-value (string-to-number property-value)))
+                                       (- (/ (window-width (selected-window) t) 2) 100))))
+               (setq-local org-image-actual-width width-integer)))))
+      (pcase state
+        ('children
+         (save-excursion
+           (save-restriction
+             (org-narrow-to-subtree)
+             ;; If has nested headlines, beg,end only from parent headline
+             ;; to first child headline which reference to upper let-binding
+             ;; `org-next-visible-heading'.
+             (funcall display-inline-images-local (point-min) (progn (org-next-visible-heading 1) (point))))))
+        ('subtree
+         (save-excursion
+           (save-restriction
+             (org-narrow-to-subtree)
+             (funcall inline-image-width-override)
+             ;; If has nested headlines, also inline display images under all sub-headlines.
+             (funcall display-inline-images-local (point-min) (point-max)))))
+        ('folded
+         (funcall hide-inline-images-local))
+        ('nil (funcall 'org-toggle-inline-images))))))
+
+(add-hook 'org-cycle-hook #'org-display-subtree-with-inline-images)
+
+(add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH")
+
 (defvar org-self-insert-command-undo-counter 0)
 (defvar org-speed-command nil)
 
-- 
2.37.2


[-- Attachment #1.3: Type: text/plain, Size: 267 bytes --]


-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH] New: auto display inline images under subtree when `org-cycle'.
  2022-09-11 12:34   ` Ihor Radchenko
  2022-09-12  1:54     ` [PATCH] " Christopher M. Miles
@ 2022-09-12  1:59     ` Christopher M. Miles
       [not found]     ` <m2wna9bbc2.fsf@numbchild>
       [not found]     ` <631e92ee.050a0220.f9c18.92f5SMTPIN_ADDED_BROKEN@mx.google.com>
  3 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-12  1:59 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 663 bytes --]


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Add-hook-function-to-auto-display-inline-imag.patch --]
[-- Type: text/x-patch, Size: 4271 bytes --]

From 4f66d9d10de5593b863da605ddc375d8f2e06456 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Mon, 12 Sep 2022 09:45:09 +0800
Subject: [PATCH] org.el: Add hook function to auto display inline images of
 subtree

* lisp/org.el (org-display-subtree-with-inline-images): Add an option
and hook function to auto display of inline images under current
expanded visible subtree.
---
 lisp/org.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 6e6c437d5..92086704e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1108,6 +1108,13 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-cycle-display-inline-images nil
+  "Non-nil means auto display inline images under subtree when `org-cycle'
+by the function `org-display-subtree-with-inline-images' on hook `org-cycle-hook'."
+  :group 'org-startup
+  :version "24.1"
+  :type 'boolean)
+
 (defcustom org-startup-with-latex-preview nil
   "Non-nil means preview LaTeX fragments when loading a new Org file.
 
@@ -16284,6 +16291,57 @@ buffer boundaries with possible narrowing."
   (mapc #'delete-overlay org-inline-image-overlays)
   (setq org-inline-image-overlays nil))
 
+(defun org-display-subtree-with-inline-images (&optional state)
+  "Toggle the display of inline images under current expanded visible subtree.
+This hook function will auto display or hide inline images after `org-cycle'.
+It is used to hook on `org-cycle-hook'.
+The function behavior is controlled by `org-cycle-display-inline-images'."
+  (interactive)
+  ;; (not (memq state '(overview folded contents))) ; global state change
+  (when org-cycle-display-inline-images
+    (let ((display-inline-images-local
+           (lambda (beg end)
+             (org-display-inline-images t t beg end)
+             ;; display number of inline images which is intersection of two image overlays lists.
+             ;; (message "%d images displayed inline"
+             ;;          (length (cl-intersection org-inline-image-overlays (overlays-in beg end))))
+             ))
+          (hide-inline-images-local
+           (lambda ()
+             (setq org-inline-image-overlays nil) ; (org-remove-inline-images)
+             (message "Inline image display turned off")))
+          (inline-image-width-override    ; get headline property value as inline image width.
+           (lambda ()
+             ;; The property "INLINE-IMAGE-WIDTH" value should be integer. Reference `org-display-inline-image--width'.
+             (let* ((property-value (ignore-errors (org-property-or-variable-value 'INLINE-IMAGE-WIDTH)))
+                    (width-integer (or (and property-value
+                                            (if (numberp property-value) property-value (string-to-number property-value)))
+                                       (- (/ (window-width (selected-window) t) 2) 100))))
+               (setq-local org-image-actual-width width-integer)))))
+      (pcase state
+        ('children
+         (save-excursion
+           (save-restriction
+             (org-narrow-to-subtree)
+             ;; If has nested headlines, beg,end only from parent headline
+             ;; to first child headline which reference to upper let-binding
+             ;; `org-next-visible-heading'.
+             (funcall display-inline-images-local (point-min) (progn (org-next-visible-heading 1) (point))))))
+        ('subtree
+         (save-excursion
+           (save-restriction
+             (org-narrow-to-subtree)
+             (funcall inline-image-width-override)
+             ;; If has nested headlines, also inline display images under all sub-headlines.
+             (funcall display-inline-images-local (point-min) (point-max)))))
+        ('folded
+         (funcall hide-inline-images-local))
+        ('nil (funcall 'org-toggle-inline-images))))))
+
+(add-hook 'org-cycle-hook #'org-display-subtree-with-inline-images)
+
+(add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH")
+
 (defvar org-self-insert-command-undo-counter 0)
 (defvar org-speed-command nil)
 
-- 
2.37.2


[-- Attachment #1.3: Type: text/plain, Size: 267 bytes --]


-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [ISSUE] Re: [PATCH] New: auto display inline images under subtree when `org-cycle'.
       [not found]     ` <m2wna9bbc2.fsf@numbchild>
@ 2022-09-12  6:03       ` Christopher M. Miles
  0 siblings, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-12  6:03 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1554 bytes --]


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

> [[PGP Signed Part:Undecided]]
>
> 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.
>
> [2. text/x-patch; 0001-org.el-Add-hook-function-to-auto-display-inline-imag.patch]...

I found an issue of this patch, this patch logic will ignore existing ~#+ATTR_ORG:~ size. How to let
this patch code also obey the ~#+ATTR_ORG:~ size too?

For example:

* heading 1
:PROPERTIES:
:INLINE-IMAGE-WIDTH: 100
:END:

#+ATTR_ORG: :width 300
#+ATTR_LATEX: :width 3.0in
#+ATTR_HTML: :width 300px
[[file:image-displayed-in-300-width.png]]


[[file:image-displayed-in-100-width.png]]

-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] New: auto display inline images under subtree when `org-cycle'.
       [not found]     ` <631e92ee.050a0220.f9c18.92f5SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-12 10:51       ` Ihor Radchenko
  2022-09-13  1:09         ` [PATCH 2] " Christopher M. Miles
       [not found]         ` <m2leqogiz8.fsf@numbchild>
  0 siblings, 2 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-12 10:51 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

"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.

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.

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).

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.

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'.

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

-- 
Ihor Radchenko,
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2] New: auto display inline images under subtree when `org-cycle'.
  2022-09-12 10:51       ` Ihor Radchenko
@ 2022-09-13  1:09         ` Christopher M. Miles
       [not found]         ` <m2leqogiz8.fsf@numbchild>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-13  1:09 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3164 bytes --]


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: subtree-level property width support --]
[-- Type: text/x-patch, Size: 2436 bytes --]

From cc322145c2248e95bc76fee7e6d33f575d93e79f Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Mon, 12 Sep 2022 09:45:09 +0800
Subject: [PATCH 1/2] org.el: Support subtree-level image width specification

* lisp/org.el (org-display-inline-image--width): Detect subtree-level
property "ORG-IMAGE-ACTUAL-WIDTH" value as image width before fallback.
---
 lisp/org.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 6e6c437d5..70333c609 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12199,7 +12199,8 @@ but in some other way.")
     "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
     "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
-    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
+    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
+    "ORG-IMAGE-ACTUAL-WIDTH")
   "Some properties that are used by Org mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -16241,14 +16242,19 @@ buffer boundaries with possible narrowing."
                                (org-element-property :begin par)
                              (re-search-forward attr-re par-end t)))
               (match-string 1)))
+           ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
+           (subtree-property-width
+            (ignore-errors (org-property-or-variable-value 'ORG-IMAGE-ACTUAL-WIDTH)))
            (width
             (cond
              ;; Treat :width t as if `org-image-actual-width' were t.
              ((string= attr-width "t") nil)
-             ;; Fallback to `org-image-actual-width' if no interprable width is given.
              ((or (null attr-width)
                   (string-match-p "\\`[^0-9]" attr-width))
-              (car org-image-actual-width))
+              ;; Try to use subtree-level width before fallback.
+              (or subtree-property-width
+                  ;; Fallback to `org-image-actual-width' if no interprable width is given.
+                  (car org-image-actual-width)))
              ;; Convert numeric widths to numbers, converting percentages.
              ((string-match-p "\\`[0-9.]+%" attr-width)
               (/ (string-to-number attr-width) 100.0))
-- 
2.37.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: org-cycle-hook function support --]
[-- Type: text/x-patch, Size: 2997 bytes --]

From 98babf12b2d9dbc38250186e0284fad6d937e3f3 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Tue, 13 Sep 2022 09:04:03 +0800
Subject: [PATCH 2/2] org.el: Add hook function to auto display inline images
 of subtree

* lisp/org.el (org-display-subtree-with-inline-images): Add an option
and hook function to auto display of inline images under current
expanded visible subtree.
---
 lisp/org.el | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 70333c609..30716c04e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1108,6 +1108,13 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-cycle-display-inline-images nil
+  "Non-nil means auto display inline images under subtree when `org-cycle'
+by the function `org-display-subtree-with-inline-images' on hook `org-cycle-hook'."
+  :group 'org-startup
+  :version "24.1"
+  :type 'boolean)
+
 (defcustom org-startup-with-latex-preview nil
   "Non-nil means preview LaTeX fragments when loading a new Org file.
 
@@ -16216,6 +16223,38 @@ buffer boundaries with possible narrowing."
 				(overlay-put ov 'keymap image-map))
 			      (push ov org-inline-image-overlays))))))))))))))))
 
+(defun org-display-subtree-inline-images (&optional state)
+  "Toggle the display of inline images under current expanded visible subtree.
+This hook function will auto display or hide inline images after `org-cycle'.
+It is used to hook on `org-cycle-hook'.
+The function behavior is controlled by `org-cycle-display-inline-images'."
+  (interactive)
+  (when (and org-cycle-display-inline-images
+             ;; not global state change from `org-cycle-global'.
+             (not (memq state '(overview contents all))))
+    (pcase state
+      ('children
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, beg,end only from parent headling
+           ;; to first child headline which reference to upper let-binding
+           ;; `org-next-visible-heading'.
+           (org-display-inline-images t t (point-min) (progn (org-next-visible-heading 1) (point))))))
+      ('subtree
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, also display inline images under all subtrees.
+           (org-display-inline-images t t (point-min) (point-max)))))
+      ('folded
+       (org-narrow-to-subtree)
+       (mapc #'delete-overlay (overlays-in (point-min) (point-max))))
+      ('nil (funcall 'org-toggle-inline-images))
+      (t nil))))
+
+(add-hook 'org-cycle-hook #'org-display-subtree-inline-images)
+
 (defvar visual-fill-column-width) ; Silence compiler warning
 (defun org-display-inline-image--width (link)
   "Determine the display width of the image LINK, in pixels.
-- 
2.37.2


[-- Attachment #1.4: Type: text/plain, Size: 269 bytes --]



-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3] New: auto display inline images under subtree when `org-cycle'.
       [not found]         ` <m2leqogiz8.fsf@numbchild>
@ 2022-09-13  1:48           ` Christopher M. Miles
       [not found]           ` <631fe1c9.050a0220.3ab2b.3f52SMTPIN_ADDED_BROKEN@mx.google.com>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-13  1:48 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 183 bytes --]


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

Ihor, My new patch still have some issue in the 'fold state which I
added "FIXME" marker. Hope can get some solution from you.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Support-subtree-level-image-width-specificati.patch --]
[-- Type: text/x-patch, Size: 2436 bytes --]

From 4a56ec6b09e09d92a81e3aa72f4197d716d0ca87 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Mon, 12 Sep 2022 09:45:09 +0800
Subject: [PATCH 1/2] org.el: Support subtree-level image width specification

* lisp/org.el (org-display-inline-image--width): Detect subtree-level
property "ORG-IMAGE-ACTUAL-WIDTH" value as image width before fallback.
---
 lisp/org.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4eef56f45..07c86229b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12128,7 +12128,8 @@ but in some other way.")
     "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
     "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
-    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
+    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
+    "ORG-IMAGE-ACTUAL-WIDTH")
   "Some properties that are used by Org mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -16164,14 +16165,19 @@ buffer boundaries with possible narrowing."
                                (org-element-property :begin par)
                              (re-search-forward attr-re par-end t)))
               (match-string 1)))
+           ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
+           (subtree-property-width
+            (ignore-errors (org-property-or-variable-value 'ORG-IMAGE-ACTUAL-WIDTH)))
            (width
             (cond
              ;; Treat :width t as if `org-image-actual-width' were t.
              ((string= attr-width "t") nil)
-             ;; Fallback to `org-image-actual-width' if no interprable width is given.
              ((or (null attr-width)
                   (string-match-p "\\`[^0-9]" attr-width))
-              (car org-image-actual-width))
+              ;; Try to use subtree-level width before fallback.
+              (or subtree-property-width
+                  ;; Fallback to `org-image-actual-width' if no interprable width is given.
+                  (car org-image-actual-width)))
              ;; Convert numeric widths to numbers, converting percentages.
              ((string-match-p "\\`[0-9.]+%" attr-width)
               (/ (string-to-number attr-width) 100.0))
-- 
2.37.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-org.el-Add-hook-function-to-auto-display-inline-imag.patch --]
[-- Type: text/x-patch, Size: 3177 bytes --]

From 2fc76c4581b60c6631186bfdc489732075432c26 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Tue, 13 Sep 2022 09:04:03 +0800
Subject: [PATCH 2/2] org.el: Add hook function to auto display inline images
 of subtree

* lisp/org.el (org-display-subtree-with-inline-images): Add an option
and hook function to auto display of inline images under current
expanded visible subtree.
---
 lisp/org.el | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 07c86229b..0bd942e07 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1104,6 +1104,13 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-cycle-display-inline-images nil
+  "Non-nil means auto display inline images under subtree when `org-cycle'
+by the function `org-display-subtree-with-inline-images' on hook `org-cycle-hook'."
+  :group 'org-startup
+  :version "24.1"
+  :type 'boolean)
+
 (defcustom org-startup-with-latex-preview nil
   "Non-nil means preview LaTeX fragments when loading a new Org file.
 
@@ -16139,6 +16146,42 @@ buffer boundaries with possible narrowing."
 				(overlay-put ov 'keymap image-map))
 			      (push ov org-inline-image-overlays))))))))))))))))
 
+(defun org-display-subtree-inline-images (&optional state)
+  "Toggle the display of inline images under current expanded visible subtree.
+This hook function will auto display or hide inline images after `org-cycle'.
+It is used to hook on `org-cycle-hook'.
+The function behavior is controlled by `org-cycle-display-inline-images'."
+  (interactive)
+  (when (and org-cycle-display-inline-images
+             ;; not global state change from `org-cycle-global'.
+             (not (memq state '(overview contents all))))
+    (pcase state
+      ('children
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, beg,end only from parent headling
+           ;; to first child headline which reference to upper let-binding
+           ;; `org-next-visible-heading'.
+           (org-display-inline-images t t (point-min) (progn (org-next-visible-heading 1) (point))))))
+      ('subtree
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, also display inline images under all subtrees.
+           (org-display-inline-images t t (point-min) (point-max)))))
+      ('folded
+       ;; (save-excursion
+       ;;   (save-restriction
+       ;;     (org-narrow-to-subtree)
+       ;;     ;; FIXME: this will auto expand heading caused `org-cycle' folded failed.
+       ;;     (mapc #'delete-overlay (overlays-in (point-min) (point-max)))))
+       )
+      ('nil (funcall 'org-toggle-inline-images))
+      (t nil))))
+
+(add-hook 'org-cycle-hook #'org-display-subtree-inline-images)
+
 (defvar visual-fill-column-width) ; Silence compiler warning
 (defun org-display-inline-image--width (link)
   "Determine the display width of the image LINK, in pixels.
-- 
2.37.2


[-- Attachment #1.4: Type: text/plain, Size: 269 bytes --]



-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3] New: auto display inline images under subtree when `org-cycle'.
       [not found]           ` <631fe1c9.050a0220.3ab2b.3f52SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-15  3:27             ` Ihor Radchenko
  2022-09-15  4:53               ` [PATCH 4] " Christopher M. Miles
       [not found]               ` <6322b0a8.050a0220.59bb8.6923SMTPIN_ADDED_BROKEN@mx.google.com>
  0 siblings, 2 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-15  3:27 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

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

> Ihor, My new patch still have some issue in the 'fold state which I
> added "FIXME" marker. Hope can get some solution from you.

I will comment only on the first patch for now.

>      "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
>      "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
>      "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
> -    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
> +    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
> +    "ORG-IMAGE-ACTUAL-WIDTH")

This change should also be mentioned in the commit message.

> @@ -16164,14 +16165,19 @@ buffer boundaries with possible narrowing."
>                                 (org-element-property :begin par)
>                               (re-search-forward attr-re par-end t)))
>                (match-string 1)))
> +           ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
> +           (subtree-property-width
> +            (ignore-errors (org-property-or-variable-value 'ORG-IMAGE-ACTUAL-WIDTH)))

You are checking the property too late. I suggest to let-bind
org-image-actual-width around the whole `cond' instead.

That way, subtree-local value of ORG-IMAGE-ACTUAL-WIDTH will have an
effect of setting `org-image-actual-width' value.

Also, is there any particular reason why you wrap
`org-property-or-variable-value' into `ignore-errors'?

Finally, you can simply do

  (org-property-or-variable-value 'org-image-actual-width) 

It will return the property value _or_ org-image-actual-width value.

> -              (car org-image-actual-width))
> +              ;; Try to use subtree-level width before fallback.
> +              (or subtree-property-width
> +                  ;; Fallback to `org-image-actual-width' if no interprable width is given.
> +                  (car org-image-actual-width)))

With my last suggestion, this code will not be needed.

Also, this change should be documented in etc/NEWS and also in
"12.7 Images" section of the manual.

-- 
Ihor Radchenko,
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 4] New: auto display inline images under subtree when `org-cycle'.
  2022-09-15  3:27             ` Ihor Radchenko
@ 2022-09-15  4:53               ` Christopher M. Miles
       [not found]               ` <6322b0a8.050a0220.59bb8.6923SMTPIN_ADDED_BROKEN@mx.google.com>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-15  4:53 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2681 bytes --]


Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> Ihor, My new patch still have some issue in the 'fold state which I
>> added "FIXME" marker. Hope can get some solution from you.
>
> I will comment only on the first patch for now.
>
>>      "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
>>      "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
>>      "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
>> -    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
>> +    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
>> +    "ORG-IMAGE-ACTUAL-WIDTH")
>
> This change should also be mentioned in the commit message.

Done

>
>> @@ -16164,14 +16165,19 @@ buffer boundaries with possible narrowing."
>>                                 (org-element-property :begin par)
>>                               (re-search-forward attr-re par-end t)))
>>                (match-string 1)))
>> +           ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
>> +           (subtree-property-width
>> +            (ignore-errors (org-property-or-variable-value 'ORG-IMAGE-ACTUAL-WIDTH)))
>
> You are checking the property too late. I suggest to let-bind
> org-image-actual-width around the whole `cond' instead.
>
> That way, subtree-local value of ORG-IMAGE-ACTUAL-WIDTH will have an
> effect of setting `org-image-actual-width' value.

Done

>
> Also, is there any particular reason why you wrap
> `org-property-or-variable-value' into `ignore-errors'?

Remove, I originally use another property keyword instead of
ORG-IMAGE-ACTUAL-WIDTH, so ~org-property-or-variable-value~ will raise
error if property does not exist. SO I added ~ignore-errors~. Now removed.

>
> Finally, you can simply do
>
>   (org-property-or-variable-value 'org-image-actual-width) 
>
> It will return the property value _or_ org-image-actual-width value.
>

Done

>> -              (car org-image-actual-width))
>> +              ;; Try to use subtree-level width before fallback.
>> +              (or subtree-property-width
>> +                  ;; Fallback to `org-image-actual-width' if no interprable width is given.
>> +                  (car org-image-actual-width)))
>
> With my last suggestion, this code will not be needed.

Done

>
> Also, this change should be documented in etc/NEWS and also in
> "12.7 Images" section of the manual.

Done. (the manual, you mean org-manual.org right? I found too many
documents under doc/ folder, confused for a while....)

P.S: I merged two commits into one for clear.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Add-hook-function-to-auto-display-inline-imag.patch --]
[-- Type: text/x-patch, Size: 10536 bytes --]

From 4ba9bb3063bde50511457b1d30f1299a85e3ffaf Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Mon, 12 Sep 2022 09:45:09 +0800
Subject: [PATCH] org.el: Add hook function to auto display inline images of
 subtree

* lisp/org.el (org-display-subtree-with-inline-images): Add an option
and hook function to auto display of inline images under current
expanded visible subtree.

* lisp/org.el (org-display-inline-image--width): support subtree-level
property "ORG-IMAGE-ACTUAL-WIDTH" specified width.

* lisp/org.el (org-default-properties): Add a new property in to
override global org-image-actual-width subtree level.
---
 doc/org-manual.org |   5 ++
 etc/ORG-NEWS       |   5 ++
 lisp/org.el        | 133 ++++++++++++++++++++++++++++++---------------
 3 files changed, 100 insertions(+), 43 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index a37b8390c..77274e250 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11314,6 +11314,11 @@ command:
   startup by configuring the variable
   ~org-startup-with-inline-images~[fn:119].
 
+If you want to override global variable ~org-image-actual-width~ of
+inline image display width, you can specify property
+"=ORG-IMAGE-ACTUAL-WIDTH=" in subtree level. It will only affect
+inline images under the specified subtree.
+
 ** Captions
 :PROPERTIES:
 :DESCRIPTION: Describe tables, images...
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a7f32671e..42e7e4292 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -296,6 +296,11 @@ headings in HTML export.
 Use the header argument =:var x=code-block[]= or
 : #+CALL: fn(x=code-block[])
 to pass the contents of a named code block as a string argument.
+*** New default property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~
+
+The subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" can override the
+global variable ~org-image-actual-width~ settings for inline images
+width under current property specified subtree.
 
 ** New options
 *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix=
diff --git a/lisp/org.el b/lisp/org.el
index 6e6c437d5..98cac1c1c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1108,6 +1108,13 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-cycle-display-inline-images nil
+  "Non-nil means auto display inline images under subtree when `org-cycle'
+by the function `org-display-subtree-with-inline-images' on hook `org-cycle-hook'."
+  :group 'org-startup
+  :version "24.1"
+  :type 'boolean)
+
 (defcustom org-startup-with-latex-preview nil
   "Non-nil means preview LaTeX fragments when loading a new Org file.
 
@@ -12199,7 +12206,8 @@ but in some other way.")
     "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
     "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
-    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
+    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
+    "ORG-IMAGE-ACTUAL-WIDTH")
   "Some properties that are used by Org mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -16215,6 +16223,42 @@ buffer boundaries with possible narrowing."
 				(overlay-put ov 'keymap image-map))
 			      (push ov org-inline-image-overlays))))))))))))))))
 
+(defun org-display-subtree-inline-images (&optional state)
+  "Toggle the display of inline images under current expanded visible subtree.
+This hook function will auto display or hide inline images after `org-cycle'.
+It is used to hook on `org-cycle-hook'.
+The function behavior is controlled by `org-cycle-display-inline-images'."
+  (interactive)
+  (when (and org-cycle-display-inline-images
+             ;; not global state change from `org-cycle-global'.
+             (not (memq state '(overview contents all))))
+    (pcase state
+      ('children
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, beg,end only from parent headling
+           ;; to first child headline which reference to upper let-binding
+           ;; `org-next-visible-heading'.
+           (org-display-inline-images t t (point-min) (progn (org-next-visible-heading 1) (point))))))
+      ('subtree
+       (save-excursion
+         (save-restriction
+           (org-narrow-to-subtree)
+           ;; If has nested headlines, also display inline images under all subtrees.
+           (org-display-inline-images t t (point-min) (point-max)))))
+      ('folded
+       ;; (save-excursion
+       ;;   (save-restriction
+       ;;     (org-narrow-to-subtree)
+       ;;     ;; FIXME: this will auto expand heading caused `org-cycle' folded failed.
+       ;;     (mapc #'delete-overlay (overlays-in (point-min) (point-max)))))
+       )
+      ('nil (funcall 'org-toggle-inline-images))
+      (_ nil))))
+
+(add-hook 'org-cycle-hook #'org-display-subtree-inline-images)
+
 (defvar visual-fill-column-width) ; Silence compiler warning
 (defun org-display-inline-image--width (link)
   "Determine the display width of the image LINK, in pixels.
@@ -16228,48 +16272,51 @@ buffer boundaries with possible narrowing."
   If the value is a float between 0 and 2, it interpreted as that proportion
   of the text width in the buffer."
   ;; Apply `org-image-actual-width' specifications.
-  (cond
-   ((eq org-image-actual-width t) nil)
-   ((listp org-image-actual-width)
-    (let* ((case-fold-search t)
-           (par (org-element-lineage link '(paragraph)))
-           (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
-           (par-end (org-element-property :post-affiliated par))
-           ;; Try to find an attribute providing a :width.
-           (attr-width
-            (when (and par (org-with-point-at
-                               (org-element-property :begin par)
-                             (re-search-forward attr-re par-end t)))
-              (match-string 1)))
-           (width
-            (cond
-             ;; Treat :width t as if `org-image-actual-width' were t.
-             ((string= attr-width "t") nil)
-             ;; Fallback to `org-image-actual-width' if no interprable width is given.
-             ((or (null attr-width)
-                  (string-match-p "\\`[^0-9]" attr-width))
-              (car org-image-actual-width))
-             ;; Convert numeric widths to numbers, converting percentages.
-             ((string-match-p "\\`[0-9.]+%" attr-width)
-              (/ (string-to-number attr-width) 100.0))
-             (t (string-to-number attr-width)))))
-      (if (and (floatp width) (<= 0.0 width 2.0))
-          ;; A float in [0,2] should be interpereted as this portion of
-          ;; the text width in the window.  This works well with cases like
-          ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
-          ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
-          ;; bound as cases such as 1.2\linewidth are feasible.
-          (round (* width
-                    (window-pixel-width)
-                    (/ (or (and (bound-and-true-p visual-fill-column-mode)
-                                (or visual-fill-column-width auto-fill-function))
-                           (when auto-fill-function fill-column)
-                           (- (window-text-width) (line-number-display-width)))
-                       (float (window-total-width)))))
-        width)))
-   ((numberp org-image-actual-width)
-    org-image-actual-width)
-   (t nil)))
+  ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
+  (let ((org-image-actual-width (org-property-or-variable-value 'org-image-actual-width)))
+    (cond
+     ((eq org-image-actual-width t) nil)
+     ((listp org-image-actual-width)
+      (let* ((case-fold-search t)
+             (par (org-element-lineage link '(paragraph)))
+             (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
+             (par-end (org-element-property :post-affiliated par))
+             ;; Try to find an attribute providing a :width.
+             (attr-width
+              (when (and par (org-with-point-at
+                                 (org-element-property :begin par)
+                               (re-search-forward attr-re par-end t)))
+                (match-string 1)))
+             (width
+              (cond
+               ;; Treat :width t as if `org-image-actual-width' were t.
+               ((string= attr-width "t") nil)
+               ((or (null attr-width)
+                    (string-match-p "\\`[^0-9]" attr-width))
+                ;; Try to use subtree-level width before fallback.
+                ;; Fallback to `org-image-actual-width' if no interprable width is given.
+                (car org-image-actual-width))
+               ;; Convert numeric widths to numbers, converting percentages.
+               ((string-match-p "\\`[0-9.]+%" attr-width)
+                (/ (string-to-number attr-width) 100.0))
+               (t (string-to-number attr-width)))))
+        (if (and (floatp width) (<= 0.0 width 2.0))
+            ;; A float in [0,2] should be interpereted as this portion of
+            ;; the text width in the window.  This works well with cases like
+            ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
+            ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
+            ;; bound as cases such as 1.2\linewidth are feasible.
+            (round (* width
+                      (window-pixel-width)
+                      (/ (or (and (bound-and-true-p visual-fill-column-mode)
+                                  (or visual-fill-column-width auto-fill-function))
+                             (when auto-fill-function fill-column)
+                             (- (window-text-width) (line-number-display-width)))
+                         (float (window-total-width)))))
+          width)))
+     ((numberp org-image-actual-width)
+      org-image-actual-width)
+     (t nil))))
 
 (defun org-display-inline-remove-overlay (ov after _beg _end &optional _len)
   "Remove inline-display overlay if a corresponding region is modified."
-- 
2.37.2


[-- Attachment #1.3: Type: text/plain, Size: 267 bytes --]


-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 4] New: auto display inline images under subtree when `org-cycle'.
       [not found]               ` <6322b0a8.050a0220.59bb8.6923SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-15  8:47                 ` Ihor Radchenko
  2022-09-15  9:43                   ` [PATCH 5] " Christopher M. Miles
       [not found]                   ` <6322f5ad.c80a0220.5e936.823eSMTPIN_ADDED_BROKEN@mx.google.com>
  0 siblings, 2 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-15  8:47 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

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

>> Also, this change should be documented in etc/NEWS and also in
>> "12.7 Images" section of the manual.
>
> Done. (the manual, you mean org-manual.org right? I found too many
> documents under doc/ folder, confused for a while....)

I meant doc/org-manual.org
Note doc/Documentation_Standards.org for the conventions we use in the
manual. Your patch does not follow those conventions (double space
between sentences).

> P.S: I merged two commits into one for clear.

Let's not do it. They are two distinct changes and I will have
significant comments regarding subtree cycling. (I had plans to
implement <TAB> cycling at point for images, and we may as well take this
chance to create some generic infrastructure for showing/hiding the
inline images).

For now, lets sort out the ORG-IMAGE-ACTUAL-WIDTH property and get it
merges. Then, we can move ahead to the subtree cycling feature.

> * lisp/org.el (org-display-inline-image--width): support subtree-level
                                                  ^S

> +If you want to override global variable ~org-image-actual-width~ of
> +inline image display width, you can specify property
> +"=ORG-IMAGE-ACTUAL-WIDTH=" in subtree level. It will only affect
> +inline images under the specified subtree.

Could you also add a paragraph describing what org-image-actual-width
does?

> +*** New default property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~

I think that people may be confused by "default property" here. Just say
"new property".

> +The subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" can override the
> +global variable ~org-image-actual-width~ settings for inline images
> +width under current property specified subtree.

It is not necessarily subtree-level. You can as well set it in
document-wide property drawer. Just say "The new property ... overrides ...".

-- 
Ihor Radchenko,
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 5] New: auto display inline images under subtree when `org-cycle'.
  2022-09-15  8:47                 ` Ihor Radchenko
@ 2022-09-15  9:43                   ` Christopher M. Miles
       [not found]                   ` <6322f5ad.c80a0220.5e936.823eSMTPIN_ADDED_BROKEN@mx.google.com>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-15  9:43 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2414 bytes --]


Sorry for this hard work on this patch. And thanks for your carefully
code reviewing. I have not contribute to org-mode for a long time,
already forgot most guidelines. Regards

Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>>> Also, this change should be documented in etc/NEWS and also in
>>> "12.7 Images" section of the manual.
>>
>> Done. (the manual, you mean org-manual.org right? I found too many
>> documents under doc/ folder, confused for a while....)
>
> I meant doc/org-manual.org
> Note doc/Documentation_Standards.org for the conventions we use in the
> manual. Your patch does not follow those conventions (double space
> between sentences).

Done

>
>> P.S: I merged two commits into one for clear.
>
> Let's not do it. They are two distinct changes and I will have
> significant comments regarding subtree cycling. (I had plans to
> implement <TAB> cycling at point for images, and we may as well take this
> chance to create some generic infrastructure for showing/hiding the
> inline images).
>
> For now, lets sort out the ORG-IMAGE-ACTUAL-WIDTH property and get it
> merges. Then, we can move ahead to the subtree cycling feature.
>

Ok, I will submit the first patch of new property at first. If you're
going to implement this <TAB> cycling inline image display feature,
that's great!

>> * lisp/org.el (org-display-inline-image--width): support subtree-level
>                                                   ^S
>
>> +If you want to override global variable ~org-image-actual-width~ of
>> +inline image display width, you can specify property
>> +"=ORG-IMAGE-ACTUAL-WIDTH=" in subtree level. It will only affect
>> +inline images under the specified subtree.
>
> Could you also add a paragraph describing what org-image-actual-width
> does?

Done in doc/org-manual.org

>
>> +*** New default property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~
>
> I think that people may be confused by "default property" here. Just say
> "new property".

Done

>
>> +The subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" can override the
>> +global variable ~org-image-actual-width~ settings for inline images
>> +width under current property specified subtree.
>
> It is not necessarily subtree-level. You can as well set it in
> document-wide property drawer. Just say "The new property ...
> overrides ...".

Done



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Support-subtree-level-org-image-actual-width-.patch --]
[-- Type: text/x-patch, Size: 8384 bytes --]

From 1bc3224220ec71292e08ebc6b25e0064f7243f2e Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 15 Sep 2022 17:25:13 +0800
Subject: [PATCH] org.el: Support subtree-level org-image-actual-width
 overriding

* lisp/org.el (org-display-inline-image--width): Support new property
"ORG-IMAGE-ACTUAL-WIDTH" overriding global variable
`org-image-actual-width'.
---
 doc/org-manual.org | 21 +++++++++++
 etc/ORG-NEWS       |  4 +++
 lisp/org.el        | 89 ++++++++++++++++++++++++----------------------
 3 files changed, 71 insertions(+), 43 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index a37b8390c..2d2b93694 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11314,6 +11314,27 @@ command:
   startup by configuring the variable
   ~org-startup-with-inline-images~[fn:119].
 
+  #+vindex: org-image-actual-width
+  Control the display size of inline images.
+  The value can be bellowing formats:
+  - When non-nil, use the actual width of images when inlining them.
+  - When set to a number, use imagemagick (when available) to set the
+    image's width to this value.
+  - When set to a number in a list, try to get the width from any
+    =#+ATTR.*= keyword if it matches a width specification like:
+    #+ATTR_HTML: :width 300px
+    and fall back on that number if none is found.
+  - When set to nil, try to get the width from an =#+ATTR.*= keyword
+    and fall back on the original width if none is found.
+  - When set to any other non-nil value, always use the image width.
+
+  This requires Emacs >= 24.1, built with imagemagick support.
+
+  #+cindex: @samp{NOBLOCKING}, property
+  If you want to override the global variable ~org-image-actual-width~
+  of inline image display width, you can specify property
+  "=ORG-IMAGE-ACTUAL-WIDTH=".
+
 ** Captions
 :PROPERTIES:
 :DESCRIPTION: Describe tables, images...
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a7f32671e..f30809973 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -296,6 +296,10 @@ headings in HTML export.
 Use the header argument =:var x=code-block[]= or
 : #+CALL: fn(x=code-block[])
 to pass the contents of a named code block as a string argument.
+*** New property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~
+
+The new property "=ORG-IMAGE-ACTUAL-WIDTH=" can override the global
+variable ~org-image-actual-width~ value for inline images display width.
 
 ** New options
 *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix=
diff --git a/lisp/org.el b/lisp/org.el
index 6e6c437d5..d2d66038d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12199,7 +12199,8 @@ but in some other way.")
     "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
     "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
-    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
+    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
+    "ORG-IMAGE-ACTUAL-WIDTH")
   "Some properties that are used by Org mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -16228,48 +16229,50 @@ buffer boundaries with possible narrowing."
   If the value is a float between 0 and 2, it interpreted as that proportion
   of the text width in the buffer."
   ;; Apply `org-image-actual-width' specifications.
-  (cond
-   ((eq org-image-actual-width t) nil)
-   ((listp org-image-actual-width)
-    (let* ((case-fold-search t)
-           (par (org-element-lineage link '(paragraph)))
-           (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
-           (par-end (org-element-property :post-affiliated par))
-           ;; Try to find an attribute providing a :width.
-           (attr-width
-            (when (and par (org-with-point-at
-                               (org-element-property :begin par)
-                             (re-search-forward attr-re par-end t)))
-              (match-string 1)))
-           (width
-            (cond
-             ;; Treat :width t as if `org-image-actual-width' were t.
-             ((string= attr-width "t") nil)
-             ;; Fallback to `org-image-actual-width' if no interprable width is given.
-             ((or (null attr-width)
-                  (string-match-p "\\`[^0-9]" attr-width))
-              (car org-image-actual-width))
-             ;; Convert numeric widths to numbers, converting percentages.
-             ((string-match-p "\\`[0-9.]+%" attr-width)
-              (/ (string-to-number attr-width) 100.0))
-             (t (string-to-number attr-width)))))
-      (if (and (floatp width) (<= 0.0 width 2.0))
-          ;; A float in [0,2] should be interpereted as this portion of
-          ;; the text width in the window.  This works well with cases like
-          ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
-          ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
-          ;; bound as cases such as 1.2\linewidth are feasible.
-          (round (* width
-                    (window-pixel-width)
-                    (/ (or (and (bound-and-true-p visual-fill-column-mode)
-                                (or visual-fill-column-width auto-fill-function))
-                           (when auto-fill-function fill-column)
-                           (- (window-text-width) (line-number-display-width)))
-                       (float (window-total-width)))))
-        width)))
-   ((numberp org-image-actual-width)
-    org-image-actual-width)
-   (t nil)))
+  ;; support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified width.
+  (let ((org-image-actual-width (org-property-or-variable-value 'org-image-actual-width)))
+    (cond
+     ((eq org-image-actual-width t) nil)
+     ((listp org-image-actual-width)
+      (let* ((case-fold-search t)
+             (par (org-element-lineage link '(paragraph)))
+             (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
+             (par-end (org-element-property :post-affiliated par))
+             ;; Try to find an attribute providing a :width.
+             (attr-width
+              (when (and par (org-with-point-at
+                                 (org-element-property :begin par)
+                               (re-search-forward attr-re par-end t)))
+                (match-string 1)))
+             (width
+              (cond
+               ;; Treat :width t as if `org-image-actual-width' were t.
+               ((string= attr-width "t") nil)
+               ;; Fallback to `org-image-actual-width' if no interprable width is given.
+               ((or (null attr-width)
+                    (string-match-p "\\`[^0-9]" attr-width))
+                (car org-image-actual-width))
+               ;; Convert numeric widths to numbers, converting percentages.
+               ((string-match-p "\\`[0-9.]+%" attr-width)
+                (/ (string-to-number attr-width) 100.0))
+               (t (string-to-number attr-width)))))
+        (if (and (floatp width) (<= 0.0 width 2.0))
+            ;; A float in [0,2] should be interpereted as this portion of
+            ;; the text width in the window.  This works well with cases like
+            ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
+            ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
+            ;; bound as cases such as 1.2\linewidth are feasible.
+            (round (* width
+                      (window-pixel-width)
+                      (/ (or (and (bound-and-true-p visual-fill-column-mode)
+                                  (or visual-fill-column-width auto-fill-function))
+                             (when auto-fill-function fill-column)
+                             (- (window-text-width) (line-number-display-width)))
+                         (float (window-total-width)))))
+          width)))
+     ((numberp org-image-actual-width)
+      org-image-actual-width)
+     (t nil))))
 
 (defun org-display-inline-remove-overlay (ov after _beg _end &optional _len)
   "Remove inline-display overlay if a corresponding region is modified."
-- 
2.37.2


[-- Attachment #1.3: Type: text/plain, Size: 267 bytes --]


-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v6] Re: [PATCH 5] New: auto display inline images under subtree when `org-cycle'.
       [not found]                   ` <6322f5ad.c80a0220.5e936.823eSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-20  7:01                     ` Ihor Radchenko
  2022-09-20 11:32                       ` [PATCH v6] " Christopher M. Miles
       [not found]                       ` <6329c8b0.050a0220.412d.0a6cSMTPIN_ADDED_BROKEN@mx.google.com>
  0 siblings, 2 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-20  7:01 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]

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

> Ok, I will submit the first patch of new property at first. If you're
> going to implement this <TAB> cycling inline image display feature,
> that's great!

The changes to the manual are confusing after exporting. Note that
#+vindex: org-image-actual-width will not be visible in html/pdf export.
They only serve as info search nodes and do not appear in the actual
text.

I am attaching an alternative version of the patch. Let me know if you
have any objections.


[-- Attachment #2: v6-0001-org.el-Support-subtree-level-org-image-actual-wid.patch --]
[-- Type: text/x-patch, Size: 34756 bytes --]

From 475c607f874e4e78c1e13d15e36ae894b121acad Mon Sep 17 00:00:00 2001
Message-Id: <475c607f874e4e78c1e13d15e36ae894b121acad.1663656903.git.yantar92@gmail.com>
From: stardiviner <numbchild@gmail.com>
Date: Thu, 15 Sep 2022 17:25:13 +0800
Subject: [PATCH v6] org.el: Support subtree-level org-image-actual-width
 overriding

* lisp/org.el (org-display-inline-image--width): Support new property
"ORG-IMAGE-ACTUAL-WIDTH" overriding global variable
`org-image-actual-width'.
---
 doc/org-manual.org | 186 +++++++++++++++++++++++++--------------------
 etc/ORG-NEWS       |   4 +
 lisp/org.el        |  90 +++++++++++-----------
 3 files changed, 155 insertions(+), 125 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index a37b8390c..4c9c087a7 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11314,6 +11314,24 @@ ** Images
   startup by configuring the variable
   ~org-startup-with-inline-images~[fn:119].
 
+
+  #+vindex: org-image-actual-width
+  #+cindex: @samp{ORG-IMAGE-ACTUAL-WIDTH}, property
+  By default, Org mode displays inline images according to their actual width.
+  You can customize the displayed image width using ~org-image-actual-width~ variable (globally) or =ORG-IMAGE-ACTUAL-WIDTH= property (subtree-level)[fn:120].
+  Their value can be the following:
+  - (default) Non-nil, use the actual width of images when inlining them.
+  - When set to a number, use imagemagick (when available) to set the
+    image's width to this value.
+  - When set to a number in a list, try to get the width from any
+    =#+ATTR.*= keyword if it matches a width specification like:
+    #+begin_example
+    ,#+ATTR_HTML: :width 300px
+    #+end_example
+    and fall back on that number if none is found.
+  - When set to nil, try to get the width from an =#+ATTR.*= keyword
+    and fall back on the original width if none is found.
+
 ** Captions
 :PROPERTIES:
 :DESCRIPTION: Describe tables, images...
@@ -11404,7 +11422,7 @@ ** Creating Footnotes
   #+vindex: org-footnote-define-inline
   #+vindex: org-footnote-section
   Otherwise, create a new footnote.  Depending on the variable
-  ~org-footnote-define-inline~[fn:120], the definition is placed right
+  ~org-footnote-define-inline~[fn:121], the definition is placed right
   into the text as part of the reference, or separately into the
   location determined by the variable ~org-footnote-section~.
 
@@ -11419,7 +11437,7 @@ ** Creating Footnotes
   | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
 
   #+vindex: org-footnote-auto-adjust
-  Depending on the variable ~org-footnote-auto-adjust~[fn:121],
+  Depending on the variable ~org-footnote-auto-adjust~[fn:122],
   renumbering and sorting footnotes can be automatic after each
   insertion or deletion.
 
@@ -11609,7 +11627,7 @@ ** Export Settings
 
   #+cindex: @samp{DATE}, keyword
   #+vindex: org-export-date-timestamp-format
-  A date or a time-stamp[fn:122].
+  A date or a time-stamp[fn:123].
 
 - =EMAIL= ::
 
@@ -11624,7 +11642,7 @@ ** Export Settings
   Language to use for translating certain strings
   (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
   example, Org translates =Table of contents= to the French =Table des
-  matières=[fn:123].
+  matières=[fn:124].
 
 - =SELECT_TAGS= ::
 
@@ -11901,7 +11919,7 @@ ** Table of Contents
 #+cindex: excluding entries from table of contents
 #+cindex: table of contents, exclude entries
 Org includes both numbered and unnumbered headlines in the table of
-contents[fn:124].  If you need to exclude an unnumbered headline,
+contents[fn:125].  If you need to exclude an unnumbered headline,
 along with all its children, set the =UNNUMBERED= property to =notoc=
 value.
 
@@ -12020,7 +12038,7 @@ ** Include Files
 | =#+INCLUDE: "~/.emacs" :lines "10-"=  | Include lines from 10 to EOF       |
 
 Inclusions may specify a file-link to extract an object matched by
-~org-link-search~[fn:125] (see [[*Search Options in File Links]]).  The
+~org-link-search~[fn:126] (see [[*Search Options in File Links]]).  The
 ranges for =:lines= keyword are relative to the requested element.
 Therefore,
 
@@ -12060,7 +12078,7 @@ ** Macro Replacement
 : #+MACRO: name   replacement text; $1, $2 are arguments
 
 #+texinfo: @noindent
-which can be referenced using ={{{name(arg1, arg2)}}}=[fn:126].  For
+which can be referenced using ={{{name(arg1, arg2)}}}=[fn:127].  For
 example
 
 #+begin_example
@@ -12179,7 +12197,7 @@ ** Comment Lines
 Finally, a =COMMENT= keyword at the beginning of an entry, but after
 any other keyword or priority cookie, comments out the entire subtree.
 In this case, the subtree is not exported and no code block within it
-is executed either[fn:127].  The command below helps changing the
+is executed either[fn:128].  The command below helps changing the
 comment status of a headline.
 
 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
@@ -12451,7 +12469,7 @@ *** Frames and Blocks in Beamer
 
 - Org exports a Beamer frame's objects as block environments.  Org can
   enforce wrapping in special block types when =BEAMER_ENV= property
-  is set[fn:128].  For valid values see
+  is set[fn:129].  For valid values see
   ~org-beamer-environments-default~.  To add more values, see
   ~org-beamer-environments-extra~.
   #+vindex: org-beamer-environments-default
@@ -13039,7 +13057,7 @@ *** Math formatting in HTML export
 #+vindex: org-html-mathjax-options~
 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the [[https://www.mathjax.org][MathJax]],
-which should work out of the box with Org[fn:129][fn:130].  Some MathJax
+which should work out of the box with Org[fn:130][fn:131].  Some MathJax
 display options can be configured via ~org-html-mathjax-options~, or
 in the buffer.  For example, with the following settings,
 
@@ -13051,7 +13069,7 @@ *** Math formatting in HTML export
 #+texinfo: @noindent
 equation labels are displayed on the left margin and equations are
 five em from the left margin.  In addition, it loads the two MathJax
-extensions =cancel.js= and =noErrors.js=[fn:131].
+extensions =cancel.js= and =noErrors.js=[fn:132].
 
 #+vindex: org-html-mathjax-template
 See the docstring of ~org-html-mathjax-options~ for all supported
@@ -13114,7 +13132,7 @@ *** CSS support
 #+vindex: org-export-html-todo-kwd-class-prefix
 #+vindex: org-export-html-tag-class-prefix
 You can modify the CSS style definitions for the exported file.  The
-HTML exporter assigns the following special CSS classes[fn:132] to
+HTML exporter assigns the following special CSS classes[fn:133] to
 appropriate parts of the document---your style specifications may
 change these, in addition to any of the standard classes like for
 headlines, tables, etc.
@@ -13351,7 +13369,7 @@ *** LaTeX/PDF export commands
 Org file.  See the docstring for the
 ~org-latex-default-packages-alist~ for loading packages with certain
 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
-bibliography compiler[fn:133].
+bibliography compiler[fn:134].
 
 *** LaTeX specific export settings
 :PROPERTIES:
@@ -13889,7 +13907,7 @@ *** Source blocks in LaTeX export
 packages for customization of that specific source block.  In the
 example below, the =:options= are set for Engraved or Minted.  Minted
 is a source code highlighting LaTeX package with many configurable
-options[fn:134].  Both Minted and Engraved are built on [[https://www.ctan.org/pkg/fvextra][fvextra]], and
+options[fn:135].  Both Minted and Engraved are built on [[https://www.ctan.org/pkg/fvextra][fvextra]], and
 so support many of the same options.
 
 #+begin_example
@@ -14142,7 +14160,7 @@ ** OpenDocument Text Export
 
 The ODT export back-end handles creating of OpenDocument Text (ODT)
 format.  Documents created by this exporter use the
-{{{cite(OpenDocument-v1.2 specification)}}}[fn:135] and are compatible
+{{{cite(OpenDocument-v1.2 specification)}}}[fn:136] and are compatible
 with LibreOffice 3.4.
 
 *** Pre-requisites for ODT export
@@ -14543,7 +14561,7 @@ **** LaTeX math snippets
   variables ~org-latex-to-mathml-convert-command~ and
   ~org-latex-to-mathml-jar-file~.
 
-  If you prefer to use MathToWeb[fn:136] as your converter, you can
+  If you prefer to use MathToWeb[fn:137] as your converter, you can
   configure the above variables as shown below.
 
   #+begin_src emacs-lisp
@@ -14554,7 +14572,7 @@ **** LaTeX math snippets
   #+end_src
 
   #+texinfo: @noindent
-  or, to use LaTeX​ML[fn:137] instead,
+  or, to use LaTeX​ML[fn:138] instead,
 
   #+begin_src emacs-lisp
   (setq org-latex-to-mathml-convert-command
@@ -14873,7 +14891,7 @@ **** Customizing tables in ODT export
 tables, see [[*Tables in ODT export]].
 
 This feature closely mimics the way table templates are defined in the
-OpenDocument-v1.2 specification[fn:138].
+OpenDocument-v1.2 specification[fn:139].
 
 #+vindex: org-odt-table-styles
 For quick preview of this feature, install the settings below and export the
@@ -14907,7 +14925,7 @@ **** Customizing tables in ODT export
 
 To use this feature proceed as follows:
 
-1. Create a table template[fn:139].
+1. Create a table template[fn:140].
 
    A table template is set of =table-cell= and =paragraph= styles for
    each of the following table cell categories:
@@ -14946,7 +14964,7 @@ **** Customizing tables in ODT export
    =</office:automatic-styles>= element of the content template file
    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
 
-2. Define a table style[fn:140].
+2. Define a table style[fn:141].
 
    #+vindex: org-odt-table-styles
    To define a table style, create an entry for the style in the
@@ -16177,7 +16195,7 @@ *** Publishing action
 ~org-org-publish-to-org~.  This produces =file.org= and puts it in the
 publishing directory.  If you want a htmlized version of this file,
 set the parameter ~:htmlized-source~ to ~t~.  It produces
-=file.org.html= in the publishing directory[fn:141].
+=file.org.html= in the publishing directory[fn:142].
 
 Other files like images only need to be copied to the publishing
 destination; for this you can use ~org-publish-attachment~.  For
@@ -17795,13 +17813,13 @@ *** How to evaluate source code
 #+kindex: C-c C-v e
 #+findex: org-babel-execute-src-block
 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
-{{{kbd(C-c C-v e)}}} with the point on a code block[fn:142] calls the
+{{{kbd(C-c C-v e)}}} with the point on a code block[fn:143] calls the
 ~org-babel-execute-src-block~ function, which executes the code in the
 block, collects the results, and inserts them in the buffer.
 
 #+cindex: @samp{CALL}, keyword
 #+vindex: org-babel-inline-result-wrap
-By calling a named code block[fn:143] from an Org mode buffer or
+By calling a named code block[fn:144] from an Org mode buffer or
 a table.  Org can call the named code blocks from the current Org mode
 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
 
@@ -18002,7 +18020,7 @@ *** Collection
 
 - =value= ::
 
-  Default for most Babel libraries[fn:143].  Functional mode.  Org
+  Default for most Babel libraries[fn:144].  Functional mode.  Org
   gets the value by wrapping the code in a function definition in the
   language of the source block.  That is why when using =:results
   value=, code should execute like a function and return a value.  For
@@ -18731,7 +18749,7 @@ ** Noweb Reference Syntax
 
 #+cindex: @samp{noweb-ref}, header argument
 Source code blocks can include references to other source code blocks,
-using a noweb[fn:144] style syntax:
+using a noweb[fn:145] style syntax:
 
 : <<CODE-BLOCK-ID>>
 
@@ -19259,7 +19277,7 @@ ** Structure Templates
 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
 customizing ~org-modules~ or add =(require 'org-tempo)= to your Emacs
-init file[fn:145].
+init file[fn:146].
 
 #+attr_texinfo: :columns 0.1 0.9
 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
@@ -19339,7 +19357,7 @@ *** Org Indent Mode
 To display the buffer in the indented view, activate Org Indent minor
 mode, using {{{kbd(M-x org-indent-mode)}}}.  Text lines that are not
 headlines are prefixed with virtual spaces to vertically align with
-the headline text[fn:146].
+the headline text[fn:147].
 
 #+vindex: org-indent-indentation-per-level
 To make more horizontal space, the headlines are shifted by two
@@ -19367,9 +19385,9 @@ *** Hard indentation
 
 It is possible to use hard spaces to achieve the indentation instead,
 if the bare ASCII file should have the indented look also outside
-Emacs[fn:147].  With Org's support, you have to indent all lines to
+Emacs[fn:148].  With Org's support, you have to indent all lines to
 line up with the outline headers.  You would use these
-settings[fn:148]:
+settings[fn:149]:
 
 #+begin_src emacs-lisp
 (setq org-adapt-indentation t
@@ -19640,7 +19658,7 @@ ** Summary of In-Buffer Settings
 
   #+vindex: org-startup-indented
   Dynamic virtual indentation is controlled by the variable
-  ~org-startup-indented~[fn:149].
+  ~org-startup-indented~[fn:150].
 
   | =indent=   | Start with Org Indent mode turned on.  |
   | =noindent= | Start with Org Indent mode turned off. |
@@ -20498,7 +20516,7 @@ *** Setting up the staging area
 
 #+vindex: org-mobile-directory
 The mobile application needs access to a file directory on
-a server[fn:150] to interact with Emacs.  Pass its location through
+a server[fn:151] to interact with Emacs.  Pass its location through
 the ~org-mobile-directory~ variable.  If you can mount that directory
 locally just set the variable to point to that directory:
 
@@ -20519,7 +20537,7 @@ *** Setting up the staging area
 requires OpenSSL installed on the local computer.  To turn on
 encryption, set the same password in the mobile application and in
 Emacs.  Set the password in the variable
-~org-mobile-use-encryption~[fn:151].  Note that even after the mobile
+~org-mobile-use-encryption~[fn:152].  Note that even after the mobile
 application encrypts the file contents, the file name remains visible
 on the file systems of the local computer, the server, and the mobile
 device.
@@ -20535,15 +20553,15 @@ *** Pushing to the mobile application
 ~org-mobile-files~ into the staging area.  Files include agenda files
 (as listed in ~org-agenda-files~).  Customize ~org-mobile-files~ to
 add other files.  File names are staged with paths relative to
-~org-directory~, so all files should be inside this directory[fn:152].
+~org-directory~, so all files should be inside this directory[fn:153].
 
 Push creates a special Org file =agendas.org= with custom agenda views
-defined by the user[fn:153].
+defined by the user[fn:154].
 
 Finally, Org writes the file =index.org=, containing links to other
 files.  The mobile application reads this file first from the server
 to determine what other files to download for agendas.  For faster
-downloads, it is expected to only read files whose checksums[fn:154]
+downloads, it is expected to only read files whose checksums[fn:155]
 have changed.
 
 *** Pulling from the mobile application
@@ -20560,7 +20578,7 @@ *** Pulling from the mobile application
 
 1.
    #+vindex: org-mobile-inbox-for-pull
-   Org moves all entries found in =mobileorg.org=[fn:155] and appends
+   Org moves all entries found in =mobileorg.org=[fn:156] and appends
    them to the file pointed to by the variable
    ~org-mobile-inbox-for-pull~.  It should reside neither in the
    staging area nor on the server.  Each captured entry and each
@@ -20854,9 +20872,9 @@ *** A LaTeX example of radio tables
 #+cindex: @LaTeX{}, and Orgtbl mode
 
 To wrap a source table in LaTeX, use the =comment= environment
-provided by =comment.sty=[fn:156].  To activate it, put
+provided by =comment.sty=[fn:157].  To activate it, put
 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
-a radio table skeleton[fn:157] with the command {{{kbd(M-x
+a radio table skeleton[fn:158] with the command {{{kbd(M-x
 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
 example, if =salesfigures= is the name, the template inserts:
 
@@ -20875,7 +20893,7 @@ *** A LaTeX example of radio tables
 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
 the table at the target (receive) location named =salesfigures=.  Now
 the table is ready for data entry.  It can even use spreadsheet
-features[fn:158]:
+features[fn:159]:
 
 #+begin_example
 % BEGIN RECEIVE ORGTBL salesfigures
@@ -21091,7 +21109,7 @@ ** Special Agenda Views
 #+vindex: org-agenda-skip-function
 #+vindex: org-agenda-skip-function-global
 Org provides a special hook to further limit items in agenda views:
-~agenda~, ~agenda*~[fn:159], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
+~agenda~, ~agenda*~[fn:160], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
 ~tags-tree~.  Specify a custom function that tests inclusion of every
 matched item in the view.  This function can also skip as much as is
 needed.
@@ -21134,7 +21152,7 @@ ** Special Agenda Views
 #+vindex: org-agenda-skip-function
 Search for entries with a limit set on levels for the custom search.
 This is a general approach to creating custom searches in Org.  To
-include all levels, use =LEVEL>0=[fn:160].  Then to selectively pick
+include all levels, use =LEVEL>0=[fn:161].  Then to selectively pick
 the matched entries, use ~org-agenda-skip-function~, which also
 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
 ~org-agenda-skip-subtree-if~.  For example:
@@ -22258,6 +22276,7 @@ * Footnotes
 #+findex: org-anniversary
 #+findex: org-cyclic
 #+findex: org-block
+
 [fn:60] When working with the standard diary expression functions, you
 need to be very careful with the order of the arguments.  That order
 depends evilly on the variable ~calendar-date-style~.  For example, to
@@ -22496,140 +22515,143 @@ * Footnotes
 within a buffer with the =STARTUP= options =inlineimages= and
 =noinlineimages=.
 
-[fn:120] The corresponding in-buffer setting is: =#+STARTUP: fninline=
+[fn:120] The width can be customized in Emacs >= 24.1, built with
+imagemagick support. 
+
+[fn:121] The corresponding in-buffer setting is: =#+STARTUP: fninline=
 or =#+STARTUP: nofninline=.
 
-[fn:121] The corresponding in-buffer options are =#+STARTUP: fnadjust=
+[fn:122] The corresponding in-buffer options are =#+STARTUP: fnadjust=
 and =#+STARTUP: nofnadjust=.
 
-[fn:122] The variable ~org-export-date-timestamp-format~ defines how
+[fn:123] The variable ~org-export-date-timestamp-format~ defines how
 this timestamp are exported.
 
-[fn:123] For export to LaTeX format---or LaTeX-related formats such as
+[fn:124] For export to LaTeX format---or LaTeX-related formats such as
 Beamer---, the =org-latex-package-alist= variable needs further
 configuration.  See [[LaTeX specific export settings]].
 
-[fn:124] At the moment, some export back-ends do not obey this
+[fn:125] At the moment, some export back-ends do not obey this
 specification.  For example, LaTeX export excludes every unnumbered
 headline from the table of contents.
 
-[fn:125] Note that ~org-link-search-must-match-exact-headline~ is
+[fn:126] Note that ~org-link-search-must-match-exact-headline~ is
 locally bound to non-~nil~.  Therefore, ~org-link-search~ only matches
 headlines and named elements.
 
-[fn:126] Since commas separate the arguments, commas within arguments
+[fn:127] Since commas separate the arguments, commas within arguments
 have to be escaped with the backslash character.  So only those
 backslash characters before a comma need escaping with another
 backslash character.
 
-[fn:127] For a less drastic behavior, consider using a select tag (see
+[fn:128] For a less drastic behavior, consider using a select tag (see
 [[*Export Settings]]) instead.
 
-[fn:128] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
+[fn:129] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
 to make it visible.  The tag serves as a visual aid and has no
 semantic relevance.
 
-[fn:129] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
+[fn:130] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
 [[https://www.mathjax.org][MathJax]].
 
-[fn:130] Please note that exported formulas are part of an HTML
+[fn:131] Please note that exported formulas are part of an HTML
 document, and that signs such as =<=, =>=, or =&= have special
 meanings.  See [[http://docs.mathjax.org/en/latest/input/tex/html.html#tex-and-latex-in-html-documents][MathJax TeX and LaTeX in HTML documents]].
 
-[fn:131] See [[http://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
+[fn:132] See [[http://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
 about extensions.
 
-[fn:132] If the classes on TODO keywords and tags lead to conflicts,
+[fn:133] If the classes on TODO keywords and tags lead to conflicts,
 use the variables ~org-html-todo-kwd-class-prefix~ and
 ~org-html-tag-class-prefix~ to make them unique.
 
-[fn:133] This does not allow setting different bibliography compilers
+[fn:134] This does not allow setting different bibliography compilers
 for different files.  However, "smart" LaTeX compilation systems, such
 as latexmk, can select the correct bibliography compiler.
 
-[fn:134] Minted uses an external Python package for code highlighting,
+[fn:135] Minted uses an external Python package for code highlighting,
 which requires the flag =-shell-escape= to be added to
 ~org-latex-pdf-process~.
 
-[fn:135] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
+[fn:136] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
 (OpenDocument) Version 1.2]].
 
-[fn:136] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
+[fn:137] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
 
-[fn:137] See [[http://dlmf.nist.gov/LaTeXML/]].
+[fn:138] See [[http://dlmf.nist.gov/LaTeXML/]].
 
-[fn:138] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
+[fn:139] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
 
-[fn:139] See the =<table:table-template>= element of the
+[fn:140] See the =<table:table-template>= element of the
 OpenDocument-v1.2 specification.
 
-[fn:140] See the attributes =table:template-name=,
+[fn:141] See the attributes =table:template-name=,
 =table:use-first-row-styles=, =table:use-last-row-styles=,
 =table:use-first-column-styles=, =table:use-last-column-styles=,
 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
 of the =<table:table>= element in the OpenDocument-v1.2 specification.
 
-[fn:141] If the publishing directory is the same as the source
+[fn:142] If the publishing directory is the same as the source
 directory, =file.org= is exported as =file.org.org=, so you probably
 do not want to do this.
 
-[fn:142] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
+[fn:143] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
 
-[fn:143] Actually, the constructs =call_<name>()= and =src_<lang>{}=
+[fn:144] Actually, the constructs =call_<name>()= and =src_<lang>{}=
 are not evaluated when they appear in a keyword (see [[*Summary of
 In-Buffer Settings]]).
 
-[fn:144] For noweb literate programming details, see
+[fn:145] For noweb literate programming details, see
 http://www.cs.tufts.edu/~nr/noweb/.
 
-[fn:145] For more information, please refer to the commentary section
+[fn:146] For more information, please refer to the commentary section
 in =org-tempo.el=.
 
-[fn:146] Org Indent mode also sets ~wrap-prefix~ correctly for
+[fn:147] Org Indent mode also sets ~wrap-prefix~ correctly for
 indenting and wrapping long lines of headlines or text.  This minor
 mode also handles Visual Line mode and directly applied settings
 through ~word-wrap~.
 
-[fn:147] This works, but requires extra effort.  Org Indent mode is
+[fn:148] This works, but requires extra effort.  Org Indent mode is
 more convenient for most applications.
 
-[fn:148] ~org-adapt-indentation~ can also be set to ='headline-data=,
+[fn:149] ~org-adapt-indentation~ can also be set to ='headline-data=,
 in which case only data lines below the headline will be indented.
 
-[fn:149] Note that Org Indent mode also sets the ~wrap-prefix~
+[fn:150] Note that Org Indent mode also sets the ~wrap-prefix~
 property, such that Visual Line mode (or purely setting ~word-wrap~)
 wraps long lines, including headlines, correctly indented.
 
-[fn:150] For a server to host files, consider using a WebDAV server,
+[fn:151] For a server to host files, consider using a WebDAV server,
 such as [[https://nextcloud.com][Nextcloud]].  Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
 
-[fn:151] If Emacs is configured for safe storing of passwords, then
+[fn:152] If Emacs is configured for safe storing of passwords, then
 configure the variable ~org-mobile-encryption-password~; please read
 the docstring of that variable.
 
-[fn:152] Symbolic links in ~org-directory~ need to have the same name
+[fn:153] Symbolic links in ~org-directory~ need to have the same name
 as their targets.
 
-[fn:153] While creating the agendas, Org mode forces =ID= properties
+[fn:154] While creating the agendas, Org mode forces =ID= properties
 on all referenced entries, so that these entries can be uniquely
 identified if Org Mobile flags them for further action.  To avoid
 setting properties configure the variable
 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
 on outline paths, assuming they are unique.
 
-[fn:154] Checksums are stored automatically in the file
+[fn:155] Checksums are stored automatically in the file
 =checksums.dat=.
 
-[fn:155] The file will be empty after this operation.
+[fn:156] The file will be empty after this operation.
 
-[fn:156] https://www.ctan.org/pkg/comment
+[fn:157] https://www.ctan.org/pkg/comment
 
-[fn:157] By default this works only for LaTeX, HTML, and Texinfo.
+[fn:158] By default this works only for LaTeX, HTML, and Texinfo.
 Configure the variable ~orgtbl-radio-table-templates~ to install
 templates for other modes.
 
-[fn:158] If the =TBLFM= keyword contains an odd number of dollar
+[fn:159] If the =TBLFM= keyword contains an odd number of dollar
 characters, this may cause problems with Font Lock in LaTeX mode.  As
 shown in the example you can fix this by adding an extra line inside
 the =comment= environment that is used to balance the dollar
@@ -22637,9 +22659,9 @@ * Footnotes
 a much better solution is to add the =comment= environment to the
 variable ~LaTeX-verbatim-environments~.
 
-[fn:159] The ~agenda*~ view is the same as ~agenda~ except that it
+[fn:160] The ~agenda*~ view is the same as ~agenda~ except that it
 only considers /appointments/, i.e., scheduled and deadline items that
 have a time specification =[h]h:mm= in their time-stamps.
 
-[fn:160] Note that, for ~org-odd-levels-only~, a level number
+[fn:161] Note that, for ~org-odd-levels-only~, a level number
 corresponds to order in the hierarchy, not to the number of stars.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a7f32671e..d9b41515b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -296,6 +296,10 @@ headings in HTML export.
 Use the header argument =:var x=code-block[]= or
 : #+CALL: fn(x=code-block[])
 to pass the contents of a named code block as a string argument.
+*** New property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~
+
+The new property =ORG-IMAGE-ACTUAL-WIDTH= can override the global
+variable ~org-image-actual-width~ value for inline images display width.
 
 ** New options
 *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix=
diff --git a/lisp/org.el b/lisp/org.el
index a50921519..bba1b5233 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12224,7 +12224,8 @@ (defconst org-default-properties
     "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
     "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
-    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
+    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
+    "ORG-IMAGE-ACTUAL-WIDTH")
   "Some properties that are used by Org mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -16255,48 +16256,51 @@ (defun org-display-inline-image--width (link)
   If the value is a float between 0 and 2, it interpreted as that proportion
   of the text width in the buffer."
   ;; Apply `org-image-actual-width' specifications.
-  (cond
-   ((eq org-image-actual-width t) nil)
-   ((listp org-image-actual-width)
-    (let* ((case-fold-search t)
-           (par (org-element-lineage link '(paragraph)))
-           (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
-           (par-end (org-element-property :post-affiliated par))
-           ;; Try to find an attribute providing a :width.
-           (attr-width
-            (when (and par (org-with-point-at
-                               (org-element-property :begin par)
-                             (re-search-forward attr-re par-end t)))
-              (match-string 1)))
-           (width
-            (cond
-             ;; Treat :width t as if `org-image-actual-width' were t.
-             ((string= attr-width "t") nil)
-             ;; Fallback to `org-image-actual-width' if no interprable width is given.
-             ((or (null attr-width)
-                  (string-match-p "\\`[^0-9]" attr-width))
-              (car org-image-actual-width))
-             ;; Convert numeric widths to numbers, converting percentages.
-             ((string-match-p "\\`[0-9.]+%" attr-width)
-              (/ (string-to-number attr-width) 100.0))
-             (t (string-to-number attr-width)))))
-      (if (and (floatp width) (<= 0.0 width 2.0))
-          ;; A float in [0,2] should be interpereted as this portion of
-          ;; the text width in the window.  This works well with cases like
-          ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
-          ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
-          ;; bound as cases such as 1.2\linewidth are feasible.
-          (round (* width
-                    (window-pixel-width)
-                    (/ (or (and (bound-and-true-p visual-fill-column-mode)
-                                (or visual-fill-column-width auto-fill-function))
-                           (when auto-fill-function fill-column)
-                           (- (window-text-width) (line-number-display-width)))
-                       (float (window-total-width)))))
-        width)))
-   ((numberp org-image-actual-width)
-    org-image-actual-width)
-   (t nil)))
+  ;; Support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified
+  ;; width.
+  (let ((org-image-actual-width (org-property-or-variable-value 'org-image-actual-width)))
+    (cond
+     ((eq org-image-actual-width t) nil)
+     ((listp org-image-actual-width)
+      (let* ((case-fold-search t)
+             (par (org-element-lineage link '(paragraph)))
+             (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
+             (par-end (org-element-property :post-affiliated par))
+             ;; Try to find an attribute providing a :width.
+             (attr-width
+              (when (and par (org-with-point-at
+                                 (org-element-property :begin par)
+                               (re-search-forward attr-re par-end t)))
+                (match-string 1)))
+             (width
+              (cond
+               ;; Treat :width t as if `org-image-actual-width' were t.
+               ((string= attr-width "t") nil)
+               ;; Fallback to `org-image-actual-width' if no interprable width is given.
+               ((or (null attr-width)
+                    (string-match-p "\\`[^0-9]" attr-width))
+                (car org-image-actual-width))
+               ;; Convert numeric widths to numbers, converting percentages.
+               ((string-match-p "\\`[0-9.]+%" attr-width)
+                (/ (string-to-number attr-width) 100.0))
+               (t (string-to-number attr-width)))))
+        (if (and (floatp width) (<= 0.0 width 2.0))
+            ;; A float in [0,2] should be interpereted as this portion of
+            ;; the text width in the window.  This works well with cases like
+            ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
+            ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
+            ;; bound as cases such as 1.2\linewidth are feasible.
+            (round (* width
+                      (window-pixel-width)
+                      (/ (or (and (bound-and-true-p visual-fill-column-mode)
+                                  (or visual-fill-column-width auto-fill-function))
+                             (when auto-fill-function fill-column)
+                             (- (window-text-width) (line-number-display-width)))
+                         (float (window-total-width)))))
+          width)))
+     ((numberp org-image-actual-width)
+      org-image-actual-width)
+     (t nil))))
 
 (defun org-display-inline-remove-overlay (ov after _beg _end &optional _len)
   "Remove inline-display overlay if a corresponding region is modified."
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 207 bytes --]



-- 
Ihor Radchenko,
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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v6] New: auto display inline images under subtree when `org-cycle'.
  2022-09-20  7:01                     ` [PATCH v6] " Ihor Radchenko
@ 2022-09-20 11:32                       ` Christopher M. Miles
       [not found]                       ` <6329c8b0.050a0220.412d.0a6cSMTPIN_ADDED_BROKEN@mx.google.com>
  1 sibling, 0 replies; 21+ messages in thread
From: Christopher M. Miles @ 2022-09-20 11:32 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christopher M. Miles, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 37144 bytes --]


I checked out your patch, it's fine to me. Should be fine to apply.

Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>> Ok, I will submit the first patch of new property at first. If you're
>> going to implement this <TAB> cycling inline image display feature,
>> that's great!
>
> The changes to the manual are confusing after exporting. Note that
>
> #+vindex: org-image-actual-width will not be visible in html/pdf export.
> They only serve as info search nodes and do not appear in the actual
>
> text.
>
> I am attaching an alternative version of the patch. Let me know if you
> have any objections.
>
> From 475c607f874e4e78c1e13d15e36ae894b121acad Mon Sep 17 00:00:00 2001
> Message-Id: <475c607f874e4e78c1e13d15e36ae894b121acad.1663656903.git.yantar92@gmail.com>
> From: stardiviner <numbchild@gmail.com>
> Date: Thu, 15 Sep 2022 17:25:13 +0800
> Subject: [PATCH v6] org.el: Support subtree-level org-image-actual-width
>  overriding
>
> * lisp/org.el (org-display-inline-image--width): Support new property
> "ORG-IMAGE-ACTUAL-WIDTH" overriding global variable
> `org-image-actual-width'.
> ---
>  doc/org-manual.org | 186 +++++++++++++++++++++++++--------------------
>  etc/ORG-NEWS       |   4 +
>  lisp/org.el        |  90 +++++++++++-----------
>  3 files changed, 155 insertions(+), 125 deletions(-)
>
> diff --git a/doc/org-manual.org b/doc/org-manual.org
> index a37b8390c..4c9c087a7 100644
> --- a/doc/org-manual.org
> +++ b/doc/org-manual.org
> @@ -11314,6 +11314,24 @@ ** Images
>    startup by configuring the variable
>    ~org-startup-with-inline-images~[fn:119].
>  
> +
> +  #+vindex: org-image-actual-width
> +  #+cindex: @samp{ORG-IMAGE-ACTUAL-WIDTH}, property
> +  By default, Org mode displays inline images according to their actual width.
> +  You can customize the displayed image width using ~org-image-actual-width~ variable (globally) or =ORG-IMAGE-ACTUAL-WIDTH= property (subtree-level)[fn:120].
> +  Their value can be the following:
> +  - (default) Non-nil, use the actual width of images when inlining them.
> +  - When set to a number, use imagemagick (when available) to set the
> +    image's width to this value.
> +  - When set to a number in a list, try to get the width from any
> +    =#+ATTR.*= keyword if it matches a width specification like:
> +    #+begin_example
> +    ,#+ATTR_HTML: :width 300px
> +    #+end_example
> +    and fall back on that number if none is found.
> +  - When set to nil, try to get the width from an =#+ATTR.*= keyword
> +    and fall back on the original width if none is found.
> +
>  ** Captions
>  :PROPERTIES:
>  :DESCRIPTION: Describe tables, images...
> @@ -11404,7 +11422,7 @@ ** Creating Footnotes
>    #+vindex: org-footnote-define-inline
>    #+vindex: org-footnote-section
>    Otherwise, create a new footnote.  Depending on the variable
> -  ~org-footnote-define-inline~[fn:120], the definition is placed right
> +  ~org-footnote-define-inline~[fn:121], the definition is placed right
>    into the text as part of the reference, or separately into the
>    location determined by the variable ~org-footnote-section~.
>  
> @@ -11419,7 +11437,7 @@ ** Creating Footnotes
>    | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
>  
>    #+vindex: org-footnote-auto-adjust
> -  Depending on the variable ~org-footnote-auto-adjust~[fn:121],
> +  Depending on the variable ~org-footnote-auto-adjust~[fn:122],
>    renumbering and sorting footnotes can be automatic after each
>    insertion or deletion.
>  
> @@ -11609,7 +11627,7 @@ ** Export Settings
>  
>    #+cindex: @samp{DATE}, keyword
>    #+vindex: org-export-date-timestamp-format
> -  A date or a time-stamp[fn:122].
> +  A date or a time-stamp[fn:123].
>  
>  - =EMAIL= ::
>  
> @@ -11624,7 +11642,7 @@ ** Export Settings
>    Language to use for translating certain strings
>    (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
>    example, Org translates =Table of contents= to the French =Table des
> -  matières=[fn:123].
> +  matières=[fn:124].
>  
>  - =SELECT_TAGS= ::
>  
> @@ -11901,7 +11919,7 @@ ** Table of Contents
>  #+cindex: excluding entries from table of contents
>  #+cindex: table of contents, exclude entries
>  Org includes both numbered and unnumbered headlines in the table of
> -contents[fn:124].  If you need to exclude an unnumbered headline,
> +contents[fn:125].  If you need to exclude an unnumbered headline,
>  along with all its children, set the =UNNUMBERED= property to =notoc=
>  value.
>  
> @@ -12020,7 +12038,7 @@ ** Include Files
>  | =#+INCLUDE: "~/.emacs" :lines "10-"=  | Include lines from 10 to EOF       |
>  
>  Inclusions may specify a file-link to extract an object matched by
> -~org-link-search~[fn:125] (see [[*Search Options in File Links]]).  The
> +~org-link-search~[fn:126] (see [[*Search Options in File Links]]).  The
>  ranges for =:lines= keyword are relative to the requested element.
>  Therefore,
>  
> @@ -12060,7 +12078,7 @@ ** Macro Replacement
>  : #+MACRO: name   replacement text; $1, $2 are arguments
>  
>  #+texinfo: @noindent
> -which can be referenced using ={{{name(arg1, arg2)}}}=[fn:126].  For
> +which can be referenced using ={{{name(arg1, arg2)}}}=[fn:127].  For
>  example
>  
>  #+begin_example
> @@ -12179,7 +12197,7 @@ ** Comment Lines
>  Finally, a =COMMENT= keyword at the beginning of an entry, but after
>  any other keyword or priority cookie, comments out the entire subtree.
>  In this case, the subtree is not exported and no code block within it
> -is executed either[fn:127].  The command below helps changing the
> +is executed either[fn:128].  The command below helps changing the
>  comment status of a headline.
>  
>  - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
> @@ -12451,7 +12469,7 @@ *** Frames and Blocks in Beamer
>  
>  - Org exports a Beamer frame's objects as block environments.  Org can
>    enforce wrapping in special block types when =BEAMER_ENV= property
> -  is set[fn:128].  For valid values see
> +  is set[fn:129].  For valid values see
>    ~org-beamer-environments-default~.  To add more values, see
>    ~org-beamer-environments-extra~.
>    #+vindex: org-beamer-environments-default
> @@ -13039,7 +13057,7 @@ *** Math formatting in HTML export
>  #+vindex: org-html-mathjax-options~
>  LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
>  different ways on HTML pages.  The default is to use the [[https://www.mathjax.org][MathJax]],
> -which should work out of the box with Org[fn:129][fn:130].  Some MathJax
> +which should work out of the box with Org[fn:130][fn:131].  Some MathJax
>  display options can be configured via ~org-html-mathjax-options~, or
>  in the buffer.  For example, with the following settings,
>  
> @@ -13051,7 +13069,7 @@ *** Math formatting in HTML export
>  #+texinfo: @noindent
>  equation labels are displayed on the left margin and equations are
>  five em from the left margin.  In addition, it loads the two MathJax
> -extensions =cancel.js= and =noErrors.js=[fn:131].
> +extensions =cancel.js= and =noErrors.js=[fn:132].
>  
>  #+vindex: org-html-mathjax-template
>  See the docstring of ~org-html-mathjax-options~ for all supported
> @@ -13114,7 +13132,7 @@ *** CSS support
>  #+vindex: org-export-html-todo-kwd-class-prefix
>  #+vindex: org-export-html-tag-class-prefix
>  You can modify the CSS style definitions for the exported file.  The
> -HTML exporter assigns the following special CSS classes[fn:132] to
> +HTML exporter assigns the following special CSS classes[fn:133] to
>  appropriate parts of the document---your style specifications may
>  change these, in addition to any of the standard classes like for
>  headlines, tables, etc.
> @@ -13351,7 +13369,7 @@ *** LaTeX/PDF export commands
>  Org file.  See the docstring for the
>  ~org-latex-default-packages-alist~ for loading packages with certain
>  compilers.  Also see ~org-latex-bibtex-compiler~ to set the
> -bibliography compiler[fn:133].
> +bibliography compiler[fn:134].
>  
>  *** LaTeX specific export settings
>  :PROPERTIES:
> @@ -13889,7 +13907,7 @@ *** Source blocks in LaTeX export
>  packages for customization of that specific source block.  In the
>  example below, the =:options= are set for Engraved or Minted.  Minted
>  is a source code highlighting LaTeX package with many configurable
> -options[fn:134].  Both Minted and Engraved are built on [[https://www.ctan.org/pkg/fvextra][fvextra]], and
> +options[fn:135].  Both Minted and Engraved are built on [[https://www.ctan.org/pkg/fvextra][fvextra]], and
>  so support many of the same options.
>  
>  #+begin_example
> @@ -14142,7 +14160,7 @@ ** OpenDocument Text Export
>  
>  The ODT export back-end handles creating of OpenDocument Text (ODT)
>  format.  Documents created by this exporter use the
> -{{{cite(OpenDocument-v1.2 specification)}}}[fn:135] and are compatible
> +{{{cite(OpenDocument-v1.2 specification)}}}[fn:136] and are compatible
>  with LibreOffice 3.4.
>  
>  *** Pre-requisites for ODT export
> @@ -14543,7 +14561,7 @@ **** LaTeX math snippets
>    variables ~org-latex-to-mathml-convert-command~ and
>    ~org-latex-to-mathml-jar-file~.
>  
> -  If you prefer to use MathToWeb[fn:136] as your converter, you can
> +  If you prefer to use MathToWeb[fn:137] as your converter, you can
>    configure the above variables as shown below.
>  
>    #+begin_src emacs-lisp
> @@ -14554,7 +14572,7 @@ **** LaTeX math snippets
>    #+end_src
>  
>    #+texinfo: @noindent
> -  or, to use LaTeX​ML[fn:137] instead,
> +  or, to use LaTeX​ML[fn:138] instead,
>  
>    #+begin_src emacs-lisp
>    (setq org-latex-to-mathml-convert-command
> @@ -14873,7 +14891,7 @@ **** Customizing tables in ODT export
>  tables, see [[*Tables in ODT export]].
>  
>  This feature closely mimics the way table templates are defined in the
> -OpenDocument-v1.2 specification[fn:138].
> +OpenDocument-v1.2 specification[fn:139].
>  
>  #+vindex: org-odt-table-styles
>  For quick preview of this feature, install the settings below and export the
> @@ -14907,7 +14925,7 @@ **** Customizing tables in ODT export
>  
>  To use this feature proceed as follows:
>  
> -1. Create a table template[fn:139].
> +1. Create a table template[fn:140].
>  
>     A table template is set of =table-cell= and =paragraph= styles for
>     each of the following table cell categories:
> @@ -14946,7 +14964,7 @@ **** Customizing tables in ODT export
>     =</office:automatic-styles>= element of the content template file
>     (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
>  
> -2. Define a table style[fn:140].
> +2. Define a table style[fn:141].
>  
>     #+vindex: org-odt-table-styles
>     To define a table style, create an entry for the style in the
> @@ -16177,7 +16195,7 @@ *** Publishing action
>  ~org-org-publish-to-org~.  This produces =file.org= and puts it in the
>  publishing directory.  If you want a htmlized version of this file,
>  set the parameter ~:htmlized-source~ to ~t~.  It produces
> -=file.org.html= in the publishing directory[fn:141].
> +=file.org.html= in the publishing directory[fn:142].
>  
>  Other files like images only need to be copied to the publishing
>  destination; for this you can use ~org-publish-attachment~.  For
> @@ -17795,13 +17813,13 @@ *** How to evaluate source code
>  #+kindex: C-c C-v e
>  #+findex: org-babel-execute-src-block
>  Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
> -{{{kbd(C-c C-v e)}}} with the point on a code block[fn:142] calls the
> +{{{kbd(C-c C-v e)}}} with the point on a code block[fn:143] calls the
>  ~org-babel-execute-src-block~ function, which executes the code in the
>  block, collects the results, and inserts them in the buffer.
>  
>  #+cindex: @samp{CALL}, keyword
>  #+vindex: org-babel-inline-result-wrap
> -By calling a named code block[fn:143] from an Org mode buffer or
> +By calling a named code block[fn:144] from an Org mode buffer or
>  a table.  Org can call the named code blocks from the current Org mode
>  buffer or from the "Library of Babel" (see [[*Library of Babel]]).
>  
> @@ -18002,7 +18020,7 @@ *** Collection
>  
>  - =value= ::
>  
> -  Default for most Babel libraries[fn:143].  Functional mode.  Org
> +  Default for most Babel libraries[fn:144].  Functional mode.  Org
>    gets the value by wrapping the code in a function definition in the
>    language of the source block.  That is why when using =:results
>    value=, code should execute like a function and return a value.  For
> @@ -18731,7 +18749,7 @@ ** Noweb Reference Syntax
>  
>  #+cindex: @samp{noweb-ref}, header argument
>  Source code blocks can include references to other source code blocks,
> -using a noweb[fn:144] style syntax:
> +using a noweb[fn:145] style syntax:
>  
>  : <<CODE-BLOCK-ID>>
>  
> @@ -19259,7 +19277,7 @@ ** Structure Templates
>  ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
>  example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
>  customizing ~org-modules~ or add =(require 'org-tempo)= to your Emacs
> -init file[fn:145].
> +init file[fn:146].
>  
>  #+attr_texinfo: :columns 0.1 0.9
>  | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
> @@ -19339,7 +19357,7 @@ *** Org Indent Mode
>  To display the buffer in the indented view, activate Org Indent minor
>  mode, using {{{kbd(M-x org-indent-mode)}}}.  Text lines that are not
>  headlines are prefixed with virtual spaces to vertically align with
> -the headline text[fn:146].
> +the headline text[fn:147].
>  
>  #+vindex: org-indent-indentation-per-level
>  To make more horizontal space, the headlines are shifted by two
> @@ -19367,9 +19385,9 @@ *** Hard indentation
>  
>  It is possible to use hard spaces to achieve the indentation instead,
>  if the bare ASCII file should have the indented look also outside
> -Emacs[fn:147].  With Org's support, you have to indent all lines to
> +Emacs[fn:148].  With Org's support, you have to indent all lines to
>  line up with the outline headers.  You would use these
> -settings[fn:148]:
> +settings[fn:149]:
>  
>  #+begin_src emacs-lisp
>  (setq org-adapt-indentation t
> @@ -19640,7 +19658,7 @@ ** Summary of In-Buffer Settings
>  
>    #+vindex: org-startup-indented
>    Dynamic virtual indentation is controlled by the variable
> -  ~org-startup-indented~[fn:149].
> +  ~org-startup-indented~[fn:150].
>  
>    | =indent=   | Start with Org Indent mode turned on.  |
>    | =noindent= | Start with Org Indent mode turned off. |
> @@ -20498,7 +20516,7 @@ *** Setting up the staging area
>  
>  #+vindex: org-mobile-directory
>  The mobile application needs access to a file directory on
> -a server[fn:150] to interact with Emacs.  Pass its location through
> +a server[fn:151] to interact with Emacs.  Pass its location through
>  the ~org-mobile-directory~ variable.  If you can mount that directory
>  locally just set the variable to point to that directory:
>  
> @@ -20519,7 +20537,7 @@ *** Setting up the staging area
>  requires OpenSSL installed on the local computer.  To turn on
>  encryption, set the same password in the mobile application and in
>  Emacs.  Set the password in the variable
> -~org-mobile-use-encryption~[fn:151].  Note that even after the mobile
> +~org-mobile-use-encryption~[fn:152].  Note that even after the mobile
>  application encrypts the file contents, the file name remains visible
>  on the file systems of the local computer, the server, and the mobile
>  device.
> @@ -20535,15 +20553,15 @@ *** Pushing to the mobile application
>  ~org-mobile-files~ into the staging area.  Files include agenda files
>  (as listed in ~org-agenda-files~).  Customize ~org-mobile-files~ to
>  add other files.  File names are staged with paths relative to
> -~org-directory~, so all files should be inside this directory[fn:152].
> +~org-directory~, so all files should be inside this directory[fn:153].
>  
>  Push creates a special Org file =agendas.org= with custom agenda views
> -defined by the user[fn:153].
> +defined by the user[fn:154].
>  
>  Finally, Org writes the file =index.org=, containing links to other
>  files.  The mobile application reads this file first from the server
>  to determine what other files to download for agendas.  For faster
> -downloads, it is expected to only read files whose checksums[fn:154]
> +downloads, it is expected to only read files whose checksums[fn:155]
>  have changed.
>  
>  *** Pulling from the mobile application
> @@ -20560,7 +20578,7 @@ *** Pulling from the mobile application
>  
>  1.
>     #+vindex: org-mobile-inbox-for-pull
> -   Org moves all entries found in =mobileorg.org=[fn:155] and appends
> +   Org moves all entries found in =mobileorg.org=[fn:156] and appends
>     them to the file pointed to by the variable
>     ~org-mobile-inbox-for-pull~.  It should reside neither in the
>     staging area nor on the server.  Each captured entry and each
> @@ -20854,9 +20872,9 @@ *** A LaTeX example of radio tables
>  #+cindex: @LaTeX{}, and Orgtbl mode
>  
>  To wrap a source table in LaTeX, use the =comment= environment
> -provided by =comment.sty=[fn:156].  To activate it, put
> +provided by =comment.sty=[fn:157].  To activate it, put
>  ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
> -a radio table skeleton[fn:157] with the command {{{kbd(M-x
> +a radio table skeleton[fn:158] with the command {{{kbd(M-x
>  orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
>  example, if =salesfigures= is the name, the template inserts:
>  
> @@ -20875,7 +20893,7 @@ *** A LaTeX example of radio tables
>  ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
>  the table at the target (receive) location named =salesfigures=.  Now
>  the table is ready for data entry.  It can even use spreadsheet
> -features[fn:158]:
> +features[fn:159]:
>  
>  #+begin_example
>  % BEGIN RECEIVE ORGTBL salesfigures
> @@ -21091,7 +21109,7 @@ ** Special Agenda Views
>  #+vindex: org-agenda-skip-function
>  #+vindex: org-agenda-skip-function-global
>  Org provides a special hook to further limit items in agenda views:
> -~agenda~, ~agenda*~[fn:159], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
> +~agenda~, ~agenda*~[fn:160], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
>  ~tags-tree~.  Specify a custom function that tests inclusion of every
>  matched item in the view.  This function can also skip as much as is
>  needed.
> @@ -21134,7 +21152,7 @@ ** Special Agenda Views
>  #+vindex: org-agenda-skip-function
>  Search for entries with a limit set on levels for the custom search.
>  This is a general approach to creating custom searches in Org.  To
> -include all levels, use =LEVEL>0=[fn:160].  Then to selectively pick
> +include all levels, use =LEVEL>0=[fn:161].  Then to selectively pick
>  the matched entries, use ~org-agenda-skip-function~, which also
>  accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
>  ~org-agenda-skip-subtree-if~.  For example:
> @@ -22258,6 +22276,7 @@ * Footnotes
>  #+findex: org-anniversary
>  #+findex: org-cyclic
>  #+findex: org-block
> +
>  [fn:60] When working with the standard diary expression functions, you
>  need to be very careful with the order of the arguments.  That order
>  depends evilly on the variable ~calendar-date-style~.  For example, to
> @@ -22496,140 +22515,143 @@ * Footnotes
>  within a buffer with the =STARTUP= options =inlineimages= and
>  =noinlineimages=.
>  
> -[fn:120] The corresponding in-buffer setting is: =#+STARTUP: fninline=
> +[fn:120] The width can be customized in Emacs >= 24.1, built with
> +imagemagick support. 
> +
> +[fn:121] The corresponding in-buffer setting is: =#+STARTUP: fninline=
>  or =#+STARTUP: nofninline=.
>  
> -[fn:121] The corresponding in-buffer options are =#+STARTUP: fnadjust=
> +[fn:122] The corresponding in-buffer options are =#+STARTUP: fnadjust=
>  and =#+STARTUP: nofnadjust=.
>  
> -[fn:122] The variable ~org-export-date-timestamp-format~ defines how
> +[fn:123] The variable ~org-export-date-timestamp-format~ defines how
>  this timestamp are exported.
>  
> -[fn:123] For export to LaTeX format---or LaTeX-related formats such as
> +[fn:124] For export to LaTeX format---or LaTeX-related formats such as
>  Beamer---, the =org-latex-package-alist= variable needs further
>  configuration.  See [[LaTeX specific export settings]].
>  
> -[fn:124] At the moment, some export back-ends do not obey this
> +[fn:125] At the moment, some export back-ends do not obey this
>  specification.  For example, LaTeX export excludes every unnumbered
>  headline from the table of contents.
>  
> -[fn:125] Note that ~org-link-search-must-match-exact-headline~ is
> +[fn:126] Note that ~org-link-search-must-match-exact-headline~ is
>  locally bound to non-~nil~.  Therefore, ~org-link-search~ only matches
>  headlines and named elements.
>  
> -[fn:126] Since commas separate the arguments, commas within arguments
> +[fn:127] Since commas separate the arguments, commas within arguments
>  have to be escaped with the backslash character.  So only those
>  backslash characters before a comma need escaping with another
>  backslash character.
>  
> -[fn:127] For a less drastic behavior, consider using a select tag (see
> +[fn:128] For a less drastic behavior, consider using a select tag (see
>  [[*Export Settings]]) instead.
>  
> -[fn:128] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
> +[fn:129] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
>  to make it visible.  The tag serves as a visual aid and has no
>  semantic relevance.
>  
> -[fn:129] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
> +[fn:130] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
>  [[https://www.mathjax.org][MathJax]].
>  
> -[fn:130] Please note that exported formulas are part of an HTML
> +[fn:131] Please note that exported formulas are part of an HTML
>  document, and that signs such as =<=, =>=, or =&= have special
>  meanings.  See [[http://docs.mathjax.org/en/latest/input/tex/html.html#tex-and-latex-in-html-documents][MathJax TeX and LaTeX in HTML documents]].
>  
> -[fn:131] See [[http://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
> +[fn:132] See [[http://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
>  about extensions.
>  
> -[fn:132] If the classes on TODO keywords and tags lead to conflicts,
> +[fn:133] If the classes on TODO keywords and tags lead to conflicts,
>  use the variables ~org-html-todo-kwd-class-prefix~ and
>  ~org-html-tag-class-prefix~ to make them unique.
>  
> -[fn:133] This does not allow setting different bibliography compilers
> +[fn:134] This does not allow setting different bibliography compilers
>  for different files.  However, "smart" LaTeX compilation systems, such
>  as latexmk, can select the correct bibliography compiler.
>  
> -[fn:134] Minted uses an external Python package for code highlighting,
> +[fn:135] Minted uses an external Python package for code highlighting,
>  which requires the flag =-shell-escape= to be added to
>  ~org-latex-pdf-process~.
>  
> -[fn:135] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
> +[fn:136] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
>  (OpenDocument) Version 1.2]].
>  
> -[fn:136] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
> +[fn:137] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
>  
> -[fn:137] See [[http://dlmf.nist.gov/LaTeXML/]].
> +[fn:138] See [[http://dlmf.nist.gov/LaTeXML/]].
>  
> -[fn:138] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
> +[fn:139] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
>  
> -[fn:139] See the =<table:table-template>= element of the
> +[fn:140] See the =<table:table-template>= element of the
>  OpenDocument-v1.2 specification.
>  
> -[fn:140] See the attributes =table:template-name=,
> +[fn:141] See the attributes =table:template-name=,
>  =table:use-first-row-styles=, =table:use-last-row-styles=,
>  =table:use-first-column-styles=, =table:use-last-column-styles=,
>  =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
>  of the =<table:table>= element in the OpenDocument-v1.2 specification.
>  
> -[fn:141] If the publishing directory is the same as the source
> +[fn:142] If the publishing directory is the same as the source
>  directory, =file.org= is exported as =file.org.org=, so you probably
>  do not want to do this.
>  
> -[fn:142] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
> +[fn:143] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
>  to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
>  
> -[fn:143] Actually, the constructs =call_<name>()= and =src_<lang>{}=
> +[fn:144] Actually, the constructs =call_<name>()= and =src_<lang>{}=
>  are not evaluated when they appear in a keyword (see [[*Summary of
>  In-Buffer Settings]]).
>  
> -[fn:144] For noweb literate programming details, see
> +[fn:145] For noweb literate programming details, see
>  http://www.cs.tufts.edu/~nr/noweb/.
>  
> -[fn:145] For more information, please refer to the commentary section
> +[fn:146] For more information, please refer to the commentary section
>  in =org-tempo.el=.
>  
> -[fn:146] Org Indent mode also sets ~wrap-prefix~ correctly for
> +[fn:147] Org Indent mode also sets ~wrap-prefix~ correctly for
>  indenting and wrapping long lines of headlines or text.  This minor
>  mode also handles Visual Line mode and directly applied settings
>  through ~word-wrap~.
>  
> -[fn:147] This works, but requires extra effort.  Org Indent mode is
> +[fn:148] This works, but requires extra effort.  Org Indent mode is
>  more convenient for most applications.
>  
> -[fn:148] ~org-adapt-indentation~ can also be set to ='headline-data=,
> +[fn:149] ~org-adapt-indentation~ can also be set to ='headline-data=,
>  in which case only data lines below the headline will be indented.
>  
> -[fn:149] Note that Org Indent mode also sets the ~wrap-prefix~
> +[fn:150] Note that Org Indent mode also sets the ~wrap-prefix~
>  property, such that Visual Line mode (or purely setting ~word-wrap~)
>  wraps long lines, including headlines, correctly indented.
>  
> -[fn:150] For a server to host files, consider using a WebDAV server,
> +[fn:151] For a server to host files, consider using a WebDAV server,
>  such as [[https://nextcloud.com][Nextcloud]].  Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
>  
> -[fn:151] If Emacs is configured for safe storing of passwords, then
> +[fn:152] If Emacs is configured for safe storing of passwords, then
>  configure the variable ~org-mobile-encryption-password~; please read
>  the docstring of that variable.
>  
> -[fn:152] Symbolic links in ~org-directory~ need to have the same name
> +[fn:153] Symbolic links in ~org-directory~ need to have the same name
>  as their targets.
>  
> -[fn:153] While creating the agendas, Org mode forces =ID= properties
> +[fn:154] While creating the agendas, Org mode forces =ID= properties
>  on all referenced entries, so that these entries can be uniquely
>  identified if Org Mobile flags them for further action.  To avoid
>  setting properties configure the variable
>  ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
>  on outline paths, assuming they are unique.
>  
> -[fn:154] Checksums are stored automatically in the file
> +[fn:155] Checksums are stored automatically in the file
>  =checksums.dat=.
>  
> -[fn:155] The file will be empty after this operation.
> +[fn:156] The file will be empty after this operation.
>  
> -[fn:156] https://www.ctan.org/pkg/comment
> +[fn:157] https://www.ctan.org/pkg/comment
>  
> -[fn:157] By default this works only for LaTeX, HTML, and Texinfo.
> +[fn:158] By default this works only for LaTeX, HTML, and Texinfo.
>  Configure the variable ~orgtbl-radio-table-templates~ to install
>  templates for other modes.
>  
> -[fn:158] If the =TBLFM= keyword contains an odd number of dollar
> +[fn:159] If the =TBLFM= keyword contains an odd number of dollar
>  characters, this may cause problems with Font Lock in LaTeX mode.  As
>  shown in the example you can fix this by adding an extra line inside
>  the =comment= environment that is used to balance the dollar
> @@ -22637,9 +22659,9 @@ * Footnotes
>  a much better solution is to add the =comment= environment to the
>  variable ~LaTeX-verbatim-environments~.
>  
> -[fn:159] The ~agenda*~ view is the same as ~agenda~ except that it
> +[fn:160] The ~agenda*~ view is the same as ~agenda~ except that it
>  only considers /appointments/, i.e., scheduled and deadline items that
>  have a time specification =[h]h:mm= in their time-stamps.
>  
> -[fn:160] Note that, for ~org-odd-levels-only~, a level number
> +[fn:161] Note that, for ~org-odd-levels-only~, a level number
>  corresponds to order in the hierarchy, not to the number of stars.
> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> index a7f32671e..d9b41515b 100644
> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -296,6 +296,10 @@ headings in HTML export.
>  Use the header argument =:var x=code-block[]= or
>  : #+CALL: fn(x=code-block[])
>  to pass the contents of a named code block as a string argument.
> +*** New property =ORG-IMAGE-ACTUAL-WIDTH= for overriding global ~org-image-actual-width~
> +
> +The new property =ORG-IMAGE-ACTUAL-WIDTH= can override the global
> +variable ~org-image-actual-width~ value for inline images display width.
>  
>  ** New options
>  *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix=
> diff --git a/lisp/org.el b/lisp/org.el
> index a50921519..bba1b5233 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12224,7 +12224,8 @@ (defconst org-default-properties
>      "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
>      "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" "UNNUMBERED"
>      "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
> -    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
> +    "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS"
> +    "ORG-IMAGE-ACTUAL-WIDTH")
>    "Some properties that are used by Org mode for various purposes.
>  Being in this list makes sure that they are offered for completion.")
>  
> @@ -16255,48 +16256,51 @@ (defun org-display-inline-image--width (link)
>    If the value is a float between 0 and 2, it interpreted as that proportion
>    of the text width in the buffer."
>    ;; Apply `org-image-actual-width' specifications.
> -  (cond
> -   ((eq org-image-actual-width t) nil)
> -   ((listp org-image-actual-width)
> -    (let* ((case-fold-search t)
> -           (par (org-element-lineage link '(paragraph)))
> -           (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
> -           (par-end (org-element-property :post-affiliated par))
> -           ;; Try to find an attribute providing a :width.
> -           (attr-width
> -            (when (and par (org-with-point-at
> -                               (org-element-property :begin par)
> -                             (re-search-forward attr-re par-end t)))
> -              (match-string 1)))
> -           (width
> -            (cond
> -             ;; Treat :width t as if `org-image-actual-width' were t.
> -             ((string= attr-width "t") nil)
> -             ;; Fallback to `org-image-actual-width' if no interprable width is given.
> -             ((or (null attr-width)
> -                  (string-match-p "\\`[^0-9]" attr-width))
> -              (car org-image-actual-width))
> -             ;; Convert numeric widths to numbers, converting percentages.
> -             ((string-match-p "\\`[0-9.]+%" attr-width)
> -              (/ (string-to-number attr-width) 100.0))
> -             (t (string-to-number attr-width)))))
> -      (if (and (floatp width) (<= 0.0 width 2.0))
> -          ;; A float in [0,2] should be interpereted as this portion of
> -          ;; the text width in the window.  This works well with cases like
> -          ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
> -          ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
> -          ;; bound as cases such as 1.2\linewidth are feasible.
> -          (round (* width
> -                    (window-pixel-width)
> -                    (/ (or (and (bound-and-true-p visual-fill-column-mode)
> -                                (or visual-fill-column-width auto-fill-function))
> -                           (when auto-fill-function fill-column)
> -                           (- (window-text-width) (line-number-display-width)))
> -                       (float (window-total-width)))))
> -        width)))
> -   ((numberp org-image-actual-width)
> -    org-image-actual-width)
> -   (t nil)))
> +  ;; Support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified
> +  ;; width.
> +  (let ((org-image-actual-width (org-property-or-variable-value 'org-image-actual-width)))
> +    (cond
> +     ((eq org-image-actual-width t) nil)
> +     ((listp org-image-actual-width)
> +      (let* ((case-fold-search t)
> +             (par (org-element-lineage link '(paragraph)))
> +             (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
> +             (par-end (org-element-property :post-affiliated par))
> +             ;; Try to find an attribute providing a :width.
> +             (attr-width
> +              (when (and par (org-with-point-at
> +                                 (org-element-property :begin par)
> +                               (re-search-forward attr-re par-end t)))
> +                (match-string 1)))
> +             (width
> +              (cond
> +               ;; Treat :width t as if `org-image-actual-width' were t.
> +               ((string= attr-width "t") nil)
> +               ;; Fallback to `org-image-actual-width' if no interprable width is given.
> +               ((or (null attr-width)
> +                    (string-match-p "\\`[^0-9]" attr-width))
> +                (car org-image-actual-width))
> +               ;; Convert numeric widths to numbers, converting percentages.
> +               ((string-match-p "\\`[0-9.]+%" attr-width)
> +                (/ (string-to-number attr-width) 100.0))
> +               (t (string-to-number attr-width)))))
> +        (if (and (floatp width) (<= 0.0 width 2.0))
> +            ;; A float in [0,2] should be interpereted as this portion of
> +            ;; the text width in the window.  This works well with cases like
> +            ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
> +            ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
> +            ;; bound as cases such as 1.2\linewidth are feasible.
> +            (round (* width
> +                      (window-pixel-width)
> +                      (/ (or (and (bound-and-true-p visual-fill-column-mode)
> +                                  (or visual-fill-column-width auto-fill-function))
> +                             (when auto-fill-function fill-column)
> +                             (- (window-text-width) (line-number-display-width)))
> +                         (float (window-total-width)))))
> +          width)))
> +     ((numberp org-image-actual-width)
> +      org-image-actual-width)
> +     (t nil))))
>  
>  (defun org-display-inline-remove-overlay (ov after _beg _end &optional _len)
>    "Remove inline-display overlay if a corresponding region is modified."
> -- 
> 2.35.1


-- 

[ 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v6] New: auto display inline images under subtree when `org-cycle'.
       [not found]                       ` <6329c8b0.050a0220.412d.0a6cSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-21  7:54                         ` Ihor Radchenko
  0 siblings, 0 replies; 21+ messages in thread
From: Ihor Radchenko @ 2022-09-21  7:54 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: emacs-orgmode

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

> I checked out your patch, it's fine to me. Should be fine to apply.

Done.
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=95df82c5fcf926088da2aaab9354a902956ae881

Going back to cycling inline image visibility now.

I think that the first step should be extending
`org-remove-inline-images' and `org-display-inline-images' to work on
regions. `org-display-inline-images' already provides BEG and END
optional arguments, but it currently clears all the images in buffer
unconditionally.

We will need to make `org-remove-inline-images' work on region and
modify `org-display-inline-images' to not affect images outside the
provided region.

Then, we can modify `org-toggle-inline-images' accordingly and make use
of it in org-cycle.el to toggle images in section/subtree.

-- 
Ihor Radchenko,
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-09-21  7:57 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  6:34 [QUESTION] How to specific image size attributes under headline scope? Christopher M. Miles
2021-11-22 18:31 ` Timothy
2022-08-18 12:44   ` Christopher M. Miles
     [not found]   ` <m2o7whra7j.fsf@numbchild>
2022-08-22 17:10     ` Timothy
2022-08-23  0:24       ` Christopher M. Miles
2022-09-11  2:20 ` [SOLVED] " Christopher M. Miles
2022-09-11  2:25 ` Christopher M. Miles
     [not found] ` <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-11 12:34   ` Ihor Radchenko
2022-09-12  1:54     ` [PATCH] " Christopher M. Miles
2022-09-12  1:59     ` [PATCH] New: auto display inline images under subtree when `org-cycle' Christopher M. Miles
     [not found]     ` <m2wna9bbc2.fsf@numbchild>
2022-09-12  6:03       ` [ISSUE] " Christopher M. Miles
     [not found]     ` <631e92ee.050a0220.f9c18.92f5SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-12 10:51       ` Ihor Radchenko
2022-09-13  1:09         ` [PATCH 2] " Christopher M. Miles
     [not found]         ` <m2leqogiz8.fsf@numbchild>
2022-09-13  1:48           ` [PATCH 3] " Christopher M. Miles
     [not found]           ` <631fe1c9.050a0220.3ab2b.3f52SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-15  3:27             ` Ihor Radchenko
2022-09-15  4:53               ` [PATCH 4] " Christopher M. Miles
     [not found]               ` <6322b0a8.050a0220.59bb8.6923SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-15  8:47                 ` Ihor Radchenko
2022-09-15  9:43                   ` [PATCH 5] " Christopher M. Miles
     [not found]                   ` <6322f5ad.c80a0220.5e936.823eSMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-20  7:01                     ` [PATCH v6] " Ihor Radchenko
2022-09-20 11:32                       ` [PATCH v6] " Christopher M. Miles
     [not found]                       ` <6329c8b0.050a0220.412d.0a6cSMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-21  7:54                         ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).