From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id gDkmIEpjHGSv/gAASxT56A (envelope-from ) for ; Thu, 23 Mar 2023 15:33:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id uFjFH0pjHGRfIAEAauVa8A (envelope-from ) for ; Thu, 23 Mar 2023 15:33:46 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1DAB21A234 for ; Thu, 23 Mar 2023 15:33:45 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfLzo-0007Fb-2m; Thu, 23 Mar 2023 10:32:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfLzm-0007EK-7E for emacs-orgmode@gnu.org; Thu, 23 Mar 2023 10:32:50 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfLzj-0001Vd-Cx for emacs-orgmode@gnu.org; Thu, 23 Mar 2023 10:32:49 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id EF2E324091B for ; Thu, 23 Mar 2023 15:32:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1679581965; bh=E+l8k5apwAd53Lo43f844K41uROczQoaZkv1QX+x+ws=; h=From:To:Cc:Subject:Date:From; b=DPmI637/xXcObaHRcojCybZLnUu+HP1H+ORlXs2X+5yHyrU0zRT0lVGWKkF/UFLU9 aj3mwFRoDGxAOO/pDnyclXwLlmht37v1zDyVW52Ffe6SdJtnYA9CRh9BXHrYov8SNz 8dWtuSdfn25GCV4MJUypBtYV1TcDd5GFURlPqfzzuboVOKGwrqhYegLh3h7Qep+WiR 4e6n5cRIxQaeyAqtF/wN8yOrLuNFz+6+OYq0jhTjM9ZApjxEEvrYspCaXVJizk+1Xs pyjHV18CvtQxSofu9JlBXsmmBti3+DKA9rWuDJuDBIB209n6zbHT3MCDtmbjYT7Vmc YLGlYRat4hwjQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pj7972Z7kz6trV; Thu, 23 Mar 2023 15:32:43 +0100 (CET) From: Ihor Radchenko To: Alexis Gallagher Cc: emacs-orgmode@gnu.org Subject: [RFC] Limit inline image width by default (was: feature request: easy embedding of images) In-Reply-To: References: Date: Thu, 23 Mar 2023 14:34:45 +0000 Message-ID: <87v8irlenu.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679582025; a=rsa-sha256; cv=none; b=LMZmZY+1389zoz1E/YLdN4808wa4u13xwblbSayc9TrGOwthPQFzeDH7ex2eH5ywdb6Bfe PeGK+C2iZBvDbke59NdPcbyznKsbRYNO062fU64gRO0gypBoACVoXZJBHsJ8+aqBSc4vpe H6pt6Qbk3/1Nv/TivZIgoOAEuLhIE8Unb279v+EJ2/1qWZ3+hId6ndczp9iUJMkLvAaLai aukTz0ElBR4zLdZIHlHvUfdZPXmanPuppVXSlUWilugKnhVRCGRH+N/tY3e37/HLpz6Mfc GWtWRThZ7T2DwwIQ0ngAiKeI1cA7q/7izOcvTK0JOwZLImiFBR8D5A5OpMgFtg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="DPmI637/"; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679582025; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=y9eZWh9kLn2ejebb3NEYpCs44/WvIzNPegxHxkkfTsk=; b=jf7zGiJTPaUjUJ9+OAMHlI5B9ovKkY5j4BbxH0yG6/EIqLusydoXEf0T7X7fcmIH3gQOjD mnpd8N98U1QAmHkhfaxAUKRLuI8QXsQCduV/HmG90KSSJUSivnG1m4F6X679n2rWFR5Woa VsRSnaGRO5N2gp34iz3VJ8aM6bNpmKpPFc52Yep9TAbNbQhr0WB0d72pI4NL+2Aga7XYON yJf4WxQxlt0kPkAi3e/4TXlLozGbNrA+8voM3GCDFer8U7grqxHoH0uhwPnoaRPBrooOz7 L01gaqiHrPLggJ1YNhVXhnmrTyW6MK5MJWr1vbt3QJcMncZAhbJgig1E2K1GiQ== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="DPmI637/"; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.77 X-Spam-Score: -4.77 X-Migadu-Queue-Id: 1DAB21A234 X-TUID: li3lTopcuVhu --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alexis Gallagher writes: > =E2=80=A2 the image is automatically resized to maintain aspect ratio an= d fit horizontally with a civilized margin, so that I can resize my emacs w= indow without the image disappearing or swamping the other content.=20 We cannot automatically resize images in Elisp. At least, I know no good way to do it reliably. But we can try to improve the defaults for wide images. See the tentative patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-org.el-Allow-limiting-inline-image-width.patch >From 180e322c2c79ea88d87f908299a5c0e69c47a7b2 Mon Sep 17 00:00:00 2001 Message-Id: <180e322c2c79ea88d87f908299a5c0e69c47a7b2.1679581960.git.yantar92@posteo.net> From: Ihor Radchenko Date: Thu, 23 Mar 2023 15:31:33 +0100 Subject: [PATCH] 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 37fd3df14..3d729bdf6 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -11495,14 +11495,19 @@ ** Images #+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. + It 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 @@ -11512,8 +11517,17 @@ ** Images #+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 4d45e6507..2611cc570 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -24,6 +24,21 @@ consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode] has been ported to. ** 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. + *** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style ~natbib~ citation export processor now uses diff --git a/lisp/org.el b/lisp/org.el index 20e6ea6d9..43d659536 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15096,6 +15096,24 @@ (defcustom org-image-actual-width t (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 @@ (defun org--create-inline-image (file width) width 'imagemagick) remote? - :width width :scale 1)))) + :width width + :max-width + (pcase org-image-max-width + (`fill-column (pixel-fill-width fill-column)) + (`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. -- 2.39.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--