From 22bbe7d651e1f27398597297c7c35ae4f3253773 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Mon, 22 Nov 2021 23:28:48 -0800 Subject: [PATCH 1/2] org.el: Prioritize attr_org when computing image width * lisp/org.el (org-display-inline-image--width): First look for attr_org: :width and then look for another attr_.* :width when that isn't specified. --- lisp/org.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 308bb7d51..bf5d08e09 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16853,13 +16853,20 @@ buffer boundaries with possible narrowing." ((listp org-image-actual-width) (let* ((case-fold-search t) (par (org-element-lineage link '(paragraph))) - (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)") + (attr-re (lambda (backend) + (concat "^[ \t]*#\\+attr_" + backend + ": +.*?:width +\\(\\S-+\\)"))) (par-end (org-element-property :post-affiliated par)) - ;; Try to find an attribute providing a :width. + ;; If an attr_org provides a :width, use that. Otherwise, + ;; use the first attribute that provides it, if any. (attr-width (when (and par (org-with-point-at (org-element-property :begin par) - (re-search-forward attr-re par-end t))) + (or (re-search-forward (funcall attr-re "org") + par-end t) + (re-search-forward (funcall attr-re ".*?") + par-end t)))) (match-string 1))) (width (cond -- 2.31.1