From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0AIgIa6RHmOmKAAAbAwnHQ (envelope-from ) for ; Mon, 12 Sep 2022 03:55:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aFwGIa6RHmOCEwEAauVa8A (envelope-from ) for ; Mon, 12 Sep 2022 03:55:58 +0200 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 0A80B2B0CD for ; Mon, 12 Sep 2022 03:55:58 +0200 (CEST) Received: from localhost ([::1]:42750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXYg0-0007hm-Mb for larch@yhetil.org; Sun, 11 Sep 2022 21:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXYfQ-0007gx-GE for emacs-orgmode@gnu.org; Sun, 11 Sep 2022 21:55:20 -0400 Received: from [39.171.214.225] (port=7625 helo=Mac-mini.local) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXYfO-0006N3-4b for emacs-orgmode@gnu.org; Sun, 11 Sep 2022 21:55:20 -0400 Received: by Mac-mini.local (Postfix, from userid 501) id 0E4A5631480E; Mon, 12 Sep 2022 09:55:08 +0800 (CST) References: <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com> <87h71ew0m0.fsf@localhost> User-agent: mu4e 1.8.9; emacs 29.0.50 From: "Christopher M. Miles" To: Ihor Radchenko Cc: "Christopher M. Miles" , emacs-orgmode@gnu.org Subject: [PATCH] Re: [SOLVED] Re: [QUESTION] How to specific image size attributes under headline scope? Date: Mon, 12 Sep 2022 09:54:17 +0800 In-reply-to: <87h71ew0m0.fsf@localhost> Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Host-Lookup-Failed: Reverse DNS lookup failed for 39.171.214.225 (deferred) Received-SPF: softfail client-ip=39.171.214.225; envelope-from=numbchild@gmail.com; helo=Mac-mini.local X-Spam_score_int: 69 X-Spam_score: 6.9 X-Spam_bar: ++++++ X-Spam_report: (6.9 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, MSGID_MULTIPLE_AT=1, NML_ADSP_CUSTOM_MED=0.9, RCVD_IN_PBL=3.335, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, SPOOFED_FREEMAIL_NO_RDNS=1.12, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: reject 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: , Reply-To: numbchild@gmail.com Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662947758; h=from:from:sender:sender:reply-to: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; bh=Xy05PU2JVbXDbmEsscgSka5YsuGjN1i//0ypWT/Om5c=; b=e/QyZFPEhKk/CtoFj2ZxFCPJDCJXFYfEjjgpcDxkGDhWQlRzQYivXI0pZXsC4/qmpQmYAJ scZdylhgANhzyl0UOv/3YQCoBYUdcU7TUJaBsHxCZOOF8yPWmPx9FhLniSB+BmTv+ep4VQ SZTIdshr9AsryjPH9nJt6yvw13BQDBbOxB6CYZic7gQVY2xY83x29Ejs1DTDbeBPJs9qjk wwu104k4AcIXbQJ9UgBWw3h4ysbF++c0CY5JPi10yROQuPyB4xun2V20oCXFvDxDQyy9yr Q76ycOehA98zPyc6XUJW0WcZix1l4aag9cAOKjfr0MdhUFEv+h13CuI4WJORAA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662947758; a=rsa-sha256; cv=none; b=p49kAjmCcx2XcS6eqrf1z/+HBbngjZcf7DxB5zGZJ6HKFVNUGBqJ0iQeRrGPH+e/Qw654I z7ZE0w4Whf5ARf4T/kkM7SabX2aJoHxYK/NZ9doAa/uQmRPAUlwmWbPNjG+t5NwziEbn3i 7BEf0abEIUNuN5n8VlgOksl9sgyOkhoe4MJGxwwSem2u8LMlDSzX1sRmFB/C2fvjGdBODR qpx9jhK8c/2uJ0/Fe50FVXUF3TVl99QRcjjXxbXk+eT1c2fKn5bmoE1P+kF7ua6jIt1oCN kHWBT6L/4ulKHaZa/k7haA2Lz03A4wl/1u7kc1ezYtBakrLpNq9jnXCDXr6rtg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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-Spam-Score: 2.30 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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-Queue-Id: 0A80B2B0CD X-Spam-Score: 2.30 X-Migadu-Scanner: scn1.migadu.com X-TUID: DHp0yLah+6VI --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Ihor Radchenko writes: > "Christopher M. Miles" writes: > >>> When I put it on beginning of org document, then preview inline images, but those global attributes >>> not affected. The inline images still display in actual image size. I want to specify image size >>> under headline properties. Is it possible to do this? >> >> I implemented this feature by written a hook. Hope this can be helpful >> for someone who also has this needs. Here is the code: > > This looks useful. > Would you be interested to write a patch? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org.el-Add-hook-function-to-auto-display-inline-imag.patch Content-Transfer-Encoding: quoted-printable From=202ba9c048dd2609eb22a3924dd15f041b648ef859 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Mon, 12 Sep 2022 09:45:09 +0800 Subject: [PATCH] org.el: Add hook function to auto display inline images of subtree * lisp/org.el (org-display-subtree-with-inline-images): Add an option and hook function to auto display of inline images under current expanded visible subtree. =2D-- lisp/org.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index 6e6c437d5..594006551 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -1108,6 +1108,14 @@ the following lines anywhere in the buffer: :version "24.1" :type 'boolean) =20 +(defcustom org-cycle-display-inline-images nil + "Non-nil means show inline images when `org-cycle'. +When this is t, org-mode will add function +`org-display-subtree-with-inline-images' on hook `org-cycle-hook'." + :group 'org-startup + :version "24.1" + :type 'boolean) + (defcustom org-startup-with-latex-preview nil "Non-nil means preview LaTeX fragments when loading a new Org file. =20 @@ -16284,6 +16292,57 @@ buffer boundaries with possible narrowing." (mapc #'delete-overlay org-inline-image-overlays) (setq org-inline-image-overlays nil)) =20 +(defun org-display-subtree-with-inline-images (&optional state) + "Toggle the display of inline images under current expanded visible subt= ree. +This hook function will auto display or hide inline images after `org-cycl= e'. +It is used to hook on `org-cycle-hook'. +The function behavior is controlled by `org-cycle-display-inline-images'." + (interactive) + ;; (not (memq state '(overview folded contents))) ; global state change + (when org-cycle-display-inline-images + (let ((display-inline-images-local + (lambda (beg end) + (org-display-inline-images t t beg end) + ;; display number of inline images which is intersection of t= wo image overlays lists. + ;; (message "%d images displayed inline" + ;; (length (cl-intersection org-inline-image-overlay= s (overlays-in beg end)))) + )) + (hide-inline-images-local + (lambda () + (setq org-inline-image-overlays nil) ; (org-remove-inline-ima= ges) + (message "Inline image display turned off"))) + (inline-image-width-override ; get headline property value as= inline image width. + (lambda () + ;; The property "INLINE-IMAGE-WIDTH" value should be integer.= Reference `org-display-inline-image--width'. + (let* ((property-value (ignore-errors (org-property-or-variab= le-value 'INLINE-IMAGE-WIDTH))) + (width-integer (or (and property-value + (if (numberp property-value) p= roperty-value (string-to-number property-value))) + (- (/ (window-width (selected-windo= w) t) 2) 100)))) + (setq-local org-image-actual-width width-integer))))) + (pcase state + ('children + (save-excursion + (save-restriction + (org-narrow-to-subtree) + ;; If has nested headlines, beg,end only from parent headline + ;; to first child headline which reference to upper let-bindi= ng + ;; `org-next-visible-heading'. + (funcall display-inline-images-local (point-min) (progn (org-= next-visible-heading 1) (point)))))) + ('subtree + (save-excursion + (save-restriction + (org-narrow-to-subtree) + (funcall inline-image-width-override) + ;; If has nested headlines, also inline display images under = all sub-headlines. + (funcall display-inline-images-local (point-min) (point-max))= ))) + ('folded + (funcall hide-inline-images-local)) + ('nil (funcall 'org-toggle-inline-images)))))) + +(add-hook 'org-cycle-hook #'org-display-subtree-with-inline-images) + +(add-to-list 'org-default-properties "INLINE-IMAGE-WIDTH") + (defvar org-self-insert-command-undo-counter 0) (defvar org-speed-command nil) =20 =2D-=20 2.37.2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express without mi= sunderstanding. Blog: https://stardiviner.github.io/ IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmMekXwACgkQG13xyVro msOuWggA0ROA6l3TCEMVlfONq3mcNF3T/5l0rrKY7M/2X8RlPCrDwc07GvNKYsxr h4uuiGawPhkNavjzG34jS0cAzUS2HPcnBc3xkTWy88ZKWADaqdCBBwOZQOdTshDL 5sA/dfwnUHvMZ479NCk3ZXlroq+EsNiQNlX8xMdJEn98P9pGRUNp57XcCIOc0fOD 9yLLkssqPqwWTg3uosKDQzL3qOduFEAz/+z7Gd22YOFUar6NV2XJQjdTocixnasj s8PVmfq4SYmNsnyl8p30890MMH8Gt7s5r+rhs721n1THF1swMPN+5VkYwmRh3hL9 2xjrUjhuX5nJ3Y5ZOqMyQcnNR/zC1Q== =hYBe -----END PGP SIGNATURE----- --==-=-=--