[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org e816ae1 75/85: org: Display proportional image widt
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org e816ae1 75/85: org: Display proportional image widths |
Date: |
Mon, 27 Sep 2021 15:57:54 -0400 (EDT) |
branch: externals/org
commit e816ae1ff59a41c079be42a78883d29245876585
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>
org: Display proportional image widths
* lisp/org.el (org-display-inline-images): When the image width is given
as a float less than 2, interpret the value as that portion of the text
area width. This works well with cases such as "#+attr_latex: :width
0.6\linewidth" as this will now be interpreted as 60% of the text area
width. The upper bound is set to 2 not 1, as more than 100% of the text
width can be realistic, e.g. "1.2\linewidth" in LaTeX, but more than
200% seems unrealistic.
---
lisp/org.el | 46 ++++++++++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 8ae80e6..5a9f8a0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16617,22 +16617,36 @@ buffer boundaries with possible narrowing."
(cond
((eq org-image-actual-width t) nil)
((listp org-image-actual-width)
- (or
- ;; First try to find a width among
- ;; attributes associated to the paragraph
- ;; containing link.
- (pcase (org-element-lineage link '(paragraph))
- (`nil nil)
- (p
- (let* ((case-fold-search t)
- (end (org-element-property
:post-affiliated p))
- (re "^[ \t]*#\\+attr_.*?: +.*?:width
+\\(\\S-+\\)"))
- (when (org-with-point-at
- (org-element-property :begin p)
- (re-search-forward re end t))
- (string-to-number (match-string 1))))))
- ;; Otherwise, fall-back to provided number.
- (car org-image-actual-width)))
+ (let ((width
+ (or
+ ;; First try to find a width among
+ ;; attributes associated to the paragraph
+ ;; containing link.
+ (pcase (org-element-lineage link
'(paragraph))
+ (`nil nil)
+ (par (let* ((case-fold-search t)
+ (end (org-element-property
:post-affiliated par))
+ (re "^[ \t]*#\\+attr_.*?:
+.*?:width +\\(\\S-+\\)"))
+ (when (org-with-point-at
+ (org-element-property
:begin par)
+ (re-search-forward re
end t))
+ (string-to-number
(match-string 1)))))))
+ ;; Otherwise, fall-back to provided number.
+ (car org-image-actual-width))))
+ (if (and (floatp width) (<= 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))
+ (float (window-total-width)))))
+ width))
((numberp org-image-actual-width)
org-image-actual-width)
(t nil)))
- [elpa] externals/org be0cdd1 40/85: org-mouse: Support intermediate-state checkboxes, (continued)
- [elpa] externals/org be0cdd1 40/85: org-mouse: Support intermediate-state checkboxes, ELPA Syncer, 2021/09/27
- [elpa] externals/org db67c7e 55/85: Move some ob-*el files to the new org-contrib repo, ELPA Syncer, 2021/09/27
- [elpa] externals/org 2aa2615 59/85: Document new agenda faces in the ORG-NEWS, ELPA Syncer, 2021/09/27
- [elpa] externals/org b80b0a5 51/85: org-clock.el: Make org-notify support macOS notification, ELPA Syncer, 2021/09/27
- [elpa] externals/org 78783f4 48/85: ob-core.el: Add ability to use closures as default header arguments, ELPA Syncer, 2021/09/27
- [elpa] externals/org b2da9ea 64/85: Backport commit 0da8118dc from Emacs, ELPA Syncer, 2021/09/27
- [elpa] externals/org 7d67719 68/85: org-manual: comment about latex code-block export, ELPA Syncer, 2021/09/27
- [elpa] externals/org 80798fc 72/85: oc.el (org-cite-register-processor): Silence a compiler warning, ELPA Syncer, 2021/09/27
- [elpa] externals/org 593740c 74/85: etc/ORG-NEWS: Mention the citation engine and reorder items, ELPA Syncer, 2021/09/27
- [elpa] externals/org c76a7ee 76/85: org: Refactor width in `org-display-inline-images', ELPA Syncer, 2021/09/27
- [elpa] externals/org e816ae1 75/85: org: Display proportional image widths,
ELPA Syncer <=
- [elpa] externals/org 981bcbf 80/85: Merge branch 'bugfix', ELPA Syncer, 2021/09/27
- [elpa] externals/org c90f96c 77/85: org: Support displaying X% width images, ELPA Syncer, 2021/09/27
- [elpa] externals/org 4594423 79/85: doc/org-manual.org: Fix typo, ELPA Syncer, 2021/09/27
- [elpa] externals/org 09dc3fa 83/85: org-protocol.el: decode "+" in query part as space, ELPA Syncer, 2021/09/27
- [elpa] externals/org 663255e 85/85: org: Remove obsolete default LaTeX packages, ELPA Syncer, 2021/09/27
- [elpa] externals/org 3d35718 44/85: Merge branch 'bugfix', ELPA Syncer, 2021/09/27
- [elpa] externals/org 69850c1 58/85: ob-core.el (org-babel--file-desc): Remove unused condition, ELPA Syncer, 2021/09/27
- [elpa] externals/org ee0fd1e 37/85: Revert "org-src.el (org-src--contents-for-write-back): Do not indent blank lines", ELPA Syncer, 2021/09/27
- [elpa] externals/org 70e65a2 38/85: org-src.el: Do not indent blank lines, except current one, ELPA Syncer, 2021/09/27
- [elpa] externals/org fb75741 09/85: lisp/ob-gnuplot.el: Add Ihor Radchenko as maintainer, ELPA Syncer, 2021/09/27