From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8KCRBdgHbWBJDQEAgWs5BA (envelope-from ) for ; Wed, 07 Apr 2021 03:16:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GNMGO9cHbWA/KgAAB5/wlQ (envelope-from ) for ; Wed, 07 Apr 2021 01:16:07 +0000 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 6DDC3140A0 for ; Wed, 7 Apr 2021 03:16:07 +0200 (CEST) Received: from localhost ([::1]:51604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTwnc-00067R-8g for larch@yhetil.org; Tue, 06 Apr 2021 21:16:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTwmQ-00066y-Oq for emacs-orgmode@gnu.org; Tue, 06 Apr 2021 21:14:50 -0400 Received: from ciao.gmane.io ([116.202.254.214]:44146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTwmP-0007QI-B9 for emacs-orgmode@gnu.org; Tue, 06 Apr 2021 21:14:50 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lTwmN-000AXH-3c for emacs-orgmode@gnu.org; Wed, 07 Apr 2021 03:14:47 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Nick Dokos Subject: Re: Bug: Display Inline Images from Subdirectory [9.4.4 (9.4.4-33-g5450d6-elpaplus @ /home/ded/.emacs.d/elpa/org-plus-contrib-20210322/)] Date: Tue, 06 Apr 2021 21:14:39 -0400 Message-ID: <87blaq6glc.fsf@alphaville.usersys.redhat.com> References: <8735w3kshh.fsf@ddoherty.net> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:/l2UDQPyvAOHHPxiMYcWPhCz1Zc= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617758167; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=67fF/tHB8Vq0sXTM6o98b9u9dncSSKpJXMTLy00LXz8=; b=AXZE6hLIzEZTJ5Z1T9/mZDAPFclqnr9TAEQU3V/a2lWfsz/znqe0xNyryiHea/v5W3oPJA zC4xYUE19wOZCCdAxpKuyay9QCfQNc9UdGjtg4hohW99fUM7grzuWqlEUTr630ew7VSvQH WN0jmfld4S/QfRhIbY1RX22bos38c18Os7xdrU1XRXu1WqIMAhmZK28LGq6QryFCVGJFbZ FkgiCgXl8umG0nSkB1biqjcZePB2lkT2Ox38iVDMt+bJAln2me9HYIeVh4JosENhQbHgDq VnxTrufr82tcX4PcwFuWDSZk9/70T7kYaTrEDsWAOx2CX3Y8HBjQStvfDqtUMQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617758167; a=rsa-sha256; cv=none; b=FxyAqf+ZOJT/0A9Bq9dQzfJ7cVdmSZC1i7x79J4DxnMq0HP3VR4ovkZhdt0E5bk2WjjSYa nqPHll7SODHl7D9h82bqt7CwYhEL77nkS/5t8KVItyMbS1+Qg/z89Q6NbNK5MXq2mUR//Y GnbDd1KtyXTToI8Ew9VTfPJeosED5KwiWG2BI5DqtjVlJY0EsxWXiDh3q7xJISUS5818oI m4XUDSBvbX5VQLIveBwiZm7hZUJ3aU7AIVWp7bqApwKcrTuPl9XWOMDnfnKtukBhA/PKl/ h3Cc+HGt5iUEgYPAVN8Je/lpDUDPG+j9ftPaN76y0LfjF00tE6RL2nRn2nkSJg== 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@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.84 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@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 6DDC3140A0 X-Spam-Score: -1.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7ndnTjJW4uvv "Daniel E. Doherty" writes: > I have a hook function (cribbed from Emacs Stack Exchange) to re-display > inline images in the current subtree after execution of a source block > if the header argument contains, ':results graphics'. As its last > action, it calls: > > (org-display-inline-images nil nil beg end) > > where beg and end have been set to the bounds of the current subtree. > > This works perfectly if the image file is in the current directory. For > example, here is a block that displays as expected: > > #+begin_SRC dot :file lehman.svg :cmdline -Kdot -Tsvg :results graphics > digraph lehman { > Thomas [shape=circle]; > TideWater [shape = box, label="Tide Water\nSecurities\n(Issuer)"]; > Lehman [shape = box]; > Thomas -> TideWater [label="Director"]; > Lehman -> TideWater [label="Shareholder"]; > Thomas -> Lehman [label="Partner"]; > } > #+end_SRC > > > However, if I add a :dir header, it ceases to work: > > #+begin_SRC dot :dir dot :file lehman.svg :cmdline -Kdot -Tsvg :results > graphics > digraph lehman { > Thomas [shape=circle]; > TideWater [shape = box, label="Tide Water\nSecurities\n(Issuer)"]; > Lehman [shape = box]; > Thomas -> TideWater [label="Director"]; > Lehman -> TideWater [label="Shareholder"]; > Thomas -> Lehman [label="Partner"]; > } > #+end_SRC > > > #+RESULTS: > [[file:dot/lehman.svg]] > > I have run edebug on the function, and the only difference I can detect > is the location of the image file in a subdirectory called 'dot'. > > Here is my hook function, just for the record: > > #+begin_SRC emacs-lisp > (setq org-startup-with-inline-images t) > (require 'subr-x) > (defun ded:org-babel-display-subtree () > "Redisplay inline images in subtree if cursor in source block with > :result graphics." > > (when (org-in-src-block-p) > (let (beg end) > (save-excursion > (org-mark-subtree) > (setq beg (point)) > (setq end (mark))) > (when-let ((info (org-babel-get-src-block-info t)) > (params (org-babel-process-params (nth 2 info))) > (result-params (cdr (assq :result-params params))) > ((member "graphics" result-params))) > (org-display-inline-images nil nil beg end))))) > > (add-hook 'org-babel-after-execute-hook > #'ded:org-babel-display-subtree) > #+end_SRC > FWIW, this works fine for me: Org mode version 9.4.4 (release_9.4.4-231-gf46925 @ /home/nick/elisp/org-mode/lisp/) The only things I had to do was 1) to make the above into a tree by adding a headline (otherwise, I guess org-mark-subtree would complain: Not in a subtree) and 2) create the dot subdirectory. -- Nick "There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors." -Martin Fowler