From 4a56ec6b09e09d92a81e3aa72f4197d716d0ca87 Mon Sep 17 00:00:00 2001 From: stardiviner 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