From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IATnIe8+gGXBMgEAkFu2QA (envelope-from ) for ; Mon, 18 Dec 2023 13:45:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id WJooHO8+gGVGawAAe85BDQ (envelope-from ) for ; Mon, 18 Dec 2023 13:45:35 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=k6650JCV; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1702903535; 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=jvLAARnmwZQU/tRy7p2DZwPZRp2pM8FbcVFfYbMw1Gs=; b=DkMV0D0AklUMYYHXX+DRM+gd6e1BaMV8GmaiwoXgqR/ME5+gWGl0UfX1H1yrfq/xM5cXQG PsksOslzAZVGuC0FuiDA7/nrPeUA4osV2X2cYAWbkrYeqCtDUoiezuF6NY2xG7RWAAcjD2 FT48/QEWwvXlg39sp7GzQ+wjMxR0csLSb5XLgHDLaPb+hlY0PwZwIWfKFvvWpbEWI/dZSW Tuy48a9NLgKiuXRebeU1U0yiDDN7kfB5XX9tYU8+TNGMQZlaJNTIRHe5Xgp/7vevSk1Gnj uEJ9VY19y43CPrxxJ14iUOY6lIMwqnWS9+0VZsUJ1N7Z92+N6dl8LQ8+eoOSZA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702903535; a=rsa-sha256; cv=none; b=fjB1MZ530aU7tn/nXhTsJ8Y3MeH7lLnT4EloBKqTZ6zsOn+uqlLTkKm51EMe6iSCPSuiaR UEvtRkpu2QfveQZz8P/PfWOtWL4zm5DEGp3cMyrC7VEPDNzBMI+zU+guBK5nsk0amIWgo8 2uBVlb070o+UYsdQRbY31cNiR6a9n33J5r6wZuBz7udjdbtQPlJU0Rc7lgt9ByceTZN6F7 74jZ2FiHS1lCWGXFcI275pZf9TMAsouIXxtcPeNTMHNW0yUASqqZg5k2+ZFfKpXEMZiAWC 4UrEByAOek/S0spLfKBeb4/yNvwo9s/vwAAXVU141xbrUBWSkpvrxz3WiD/ZRw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=k6650JCV; 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"; dmarc=pass (policy=none) header.from=posteo.net 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 3488C17290 for ; Mon, 18 Dec 2023 13:45:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFCzD-00064h-PT; Mon, 18 Dec 2023 07:44:43 -0500 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 1rFCzC-00062s-9C for emacs-orgmode@gnu.org; Mon, 18 Dec 2023 07:44:42 -0500 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 1rFCzA-000236-7a for emacs-orgmode@gnu.org; Mon, 18 Dec 2023 07:44:42 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 46102240103 for ; Mon, 18 Dec 2023 13:44:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1702903477; bh=ycFjjLs32dhTMcO3reyS3uUv9N5WeDUjj6mvzCWoj+w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=k6650JCVWp27cFuPobLnTnVpcUjwEFewJWLu/JA7KZsL47NfQg36H3xF+j/qJNscg JD+cX/s8ma8bc53o39bJ7g+vCDjMjtaIdfTZNexr3qMY/ULwyhLJctzrjx6j1etvoQ xapLwUYiF6jHjno0kvY9oLo6w12mDi+eaX9TL2eTreaZOoDS3b09s8vP5+dcSlr7Ez vGdDIaUSXxmSHZ97g/3UeBZFKzTlnOa7PI7uBrCgZv6yh7de0EOdqr0cZdhOg4zfG4 U8bn/S/tZlfeuqWySMUxfm3fzgK3pAo7eGq10dFBbkv1AYJhfIXa+oZHf5EC075R8x oIxmQP12JKCOg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Stzzm4YB0z6txq; Mon, 18 Dec 2023 13:44:36 +0100 (CET) From: Ihor Radchenko To: Karthik Chikmagalur Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Justify/align image previews in org-mode In-Reply-To: <8734vz3m16.fsf@gmail.com> References: <8734vz3m16.fsf@gmail.com> Date: Mon, 18 Dec 2023 12:47:46 +0000 Message-ID: <87jzpbr825.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.44 X-Spam-Score: -6.44 X-Migadu-Queue-Id: 3488C17290 X-Migadu-Scanner: mx12.migadu.com X-TUID: ZN5l8GzAKwrd Karthik Chikmagalur writes: > Please ignore the previous patch and use this one instead. I've fixed a > bug and a couple of formatting errors. Thanks for the patch! See my comments inline. > +(defcustom org-image-align nil > + "How to align images previewed using `org-display-inline-images'. > + > +Only stand-alone image links are affected by this setting. These > +are links without surrounding text. > + > +Possible values of this option are: > + > +nil Insert image at specified position (same as left-alignment). It would make sense to allow 'left value as well (same as nil). > + (when align > + (overlay-put > + ov 'before-string > + (propertize > + " " 'face 'default > + 'display > + (pcase align > + ((or 'center 'justify) I do not think that we need to consider 'justify value at this point. Maybe in future, when (or if) we add proper justification support to text. But not now. > +(defun org-image--align (link) > + "Determine the alignment of the image link. > + > +This is controlled globally by the option `org-image-align', and > +per image by the value of `:align' in the affiliated keyword > +`#+attr_org'. > + > +The result is one of the symbols center, justify or right. The > +first two will cause the image preview to be centered, the last > +will cause it to be right-aligned. A return value of nil implies > +no special alignment -- the image preview is overlaid on the link > +exactly where it appears in the buffer." > + (let ((par (org-element-lineage link 'paragraph))) > + ;; Only apply when image is not surrounded by paragraph text: > + (when (and (= (org-element-property :begin link) > + (org-element-property :contents-begin par)) > + (<= (- (org-element-property :contents-end par) > + (org-element-property :end link)) > + 1)) ;account for trailing newline This will not work when the image paragraph is indented: * This is test #+attr_org: :align center [[file:~/Downloads/wallpaper.png]] -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at