emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org ddd8281e62 2/2: lisp/org.el: Allow limiting inline


From: ELPA Syncer
Subject: [elpa] externals/org ddd8281e62 2/2: lisp/org.el: Allow limiting inline image width
Date: Sun, 9 Apr 2023 04:59:40 -0400 (EDT)

branch: externals/org
commit ddd8281e62cab09bfb3cf1e49581940aea831f40
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    lisp/org.el: Allow limiting inline image width
    
    * lisp/org.el (org-image-max-width): New custom variable controlling
    max inline image width.
    (org--create-inline-image): Use the new variable.
    * doc/org-manual.org (Images):
    * etc/ORG-NEWS (New customization ~org-image-max-width~ limiting the
    displayed inline image width): Document the new variable.
---
 doc/org-manual.org | 20 +++++++++++++++++---
 etc/ORG-NEWS       | 15 +++++++++++++++
 lisp/org.el        | 29 ++++++++++++++++++++++++++++-
 3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 4644e5adc7..5c66a40e69 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11499,14 +11499,19 @@ command:
 
 
   #+vindex: org-image-actual-width
+  #+vindex: org-image-max-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
+  actual width, but no wider than ~fill-column~ characters.
+
+  You can customize the displayed image width using
   ~org-image-actual-width~ variable (globally) or
   =ORG-IMAGE-ACTUAL-WIDTH= property (subtree-level)[fn:: The width can
   be customized in Emacs >= 24.1, built with imagemagick support.].
   Their value can be the following:
   - (default) Non-nil, use the actual width of images when inlining them.
+    If the actual width is too wide, limit it according to
+    ~org-image-max-width~.
   - 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
@@ -11516,8 +11521,17 @@ command:
     #+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.
-
+    and fall back on the original width or ~org-image-max-width~ if
+    none is found.
+
+  ~org-image-max-width~ limits the maximum displayed image width, but
+  only when the image width is not set explicitly.  Possible maximum
+  width can be set to:
+  - (default) ~fill-column~, limit width to ~fill-column~ number of
+    characters.
+  - ~window~, limit width to current window width.
+  - integer number, limit width that specified number of pixels.
+  - nil, do not limit the width.
 
 #+vindex: org-cycle-inline-images-display
 Inline images can also be displayed when cycling the folding state.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a2de76dee5..b7c88fdbb7 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -51,6 +51,21 @@ encounter issues, and users are advised to update to the 
most recent
 version of org-caldav.  See 
[[https://github.com/dengste/org-caldav/commit/618bf4cdc9be140ca1993901d017b7f18297f1b8][this
 org-caldav commit]] for more information.
 
 ** New and changed options
+*** New customization ~org-image-max-width~ limiting the displayed inline 
image width
+
+New custom variable ~org-image-max-width~ limits the maximum inline
+image width, but only when the inline image width is not explicitly
+set via ~org-image-actual-width~, =ORG-IMAGE-ACTUAL-WIDTH= property,
+or =#+ATTR*= keyword.
+
+By default, when ~org-image-actual-width~ is set to t,
+~org-image-max-width~ takes effect.  Its default value is set to
+~fill-column~, limiting the image previews to ~fill-column~ number of
+characters.
+
+To fall back to previous defaults, where the inline image width is not
+constrained, set ~org-image-max-width~ to nil.
+
 *** ~org-src-block-faces~ now accepts empty string ~""~ as language name
 
 It is now possible to customize face of source blocks without language 
specifier.
diff --git a/lisp/org.el b/lisp/org.el
index d6c5803465..26d2a86102 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15096,6 +15096,24 @@ This requires Emacs >= 24.1, built with imagemagick 
support."
          (list :tag "Use #+ATTR* or a number of pixels" (integer))
          (const :tag "Use #+ATTR* or don't resize" nil)))
 
+(defcustom org-image-max-width 'fill-column
+  "When non-nil, limit the displayed image width.
+This setting only takes effect when `org-image-actual-width' is set to
+t or when #+ATTR* is set to t.
+
+Possible values:
+- `fill-column' :: limit width to `fill-column'
+- `window'      :: limit width to window width
+- number        :: limit width to number in pixels
+- nil             :: do not limit image width"
+  :group 'org-appearance
+  :package-version '(Org . "9.7")
+  :type '(choice
+          (const :tag "Do not limit image width" nil)
+          (const :tag "Limit to `fill-column'" fill-column)
+          (const :tag "Limit to window width" window)
+          (integer :tag "Limit to a number of pixels")))
+
 (defcustom org-agenda-inhibit-startup nil
   "Inhibit startup when preparing agenda buffers.
 When this variable is t, the initialization of the Org agenda
@@ -16229,7 +16247,16 @@ according to the value of 
`org-display-remote-inline-images'."
                         width
                         'imagemagick)
                    remote?
-                   :width width :scale 1))))
+                   :width width
+                    :max-width
+                    (pcase org-image-max-width
+                      (`fill-column (* fill-column (frame-char-width 
(selected-frame))))
+                      (`window (window-width nil t))
+                      ((pred integerp) org-image-max-width)
+                      (`nil nil)
+                      (_ (error "Unsupported value of `org-image-max-width': 
%S"
+                                org-image-max-width)))
+                    :scale 1))))
 
 (defun org-display-inline-images (&optional include-linked refresh beg end)
   "Display inline images.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]