From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6LdeFXbbI18/HQAA0tVLHw (envelope-from ) for ; Fri, 31 Jul 2020 08:51:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WFwhEXbbI199IQAAbx9fmQ (envelope-from ) for ; Fri, 31 Jul 2020 08:51:02 +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 97C739403CB for ; Fri, 31 Jul 2020 08:51:01 +0000 (UTC) Received: from localhost ([::1]:41384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Qkl-0001CX-Fe for larch@yhetil.org; Fri, 31 Jul 2020 04:50:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1QkG-0001BK-Am for emacs-orgmode@gnu.org; Fri, 31 Jul 2020 04:50:28 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:52694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k1QkD-0007Ny-R9 for emacs-orgmode@gnu.org; Fri, 31 Jul 2020 04:50:28 -0400 Received: by mail-pj1-x102a.google.com with SMTP id kr4so4848856pjb.2 for ; Fri, 31 Jul 2020 01:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=/nm+bDT6708JEo70ChiSuqA1GV0ljEJO2vsyebwej7k=; b=u2GHDXYGe7KQ3GKHba5uj7FCA8XIjLPB8r1ZkTI7yPhm91yG1JSzK4oK/hVTKVoWPN lUzopOVFJ01pZ4zPxMt68M6IB9qV2kwJdjY7n+0lzj4pX7CoFV/C+HL0elRLsjbCPpGw OmxJzK/Y1wi4q38YUJ9KqTgRuywP7M06kQoWOUUFqDTxI6TYG8yLV9+nD+1RIaXSWzHN df24YkpByKZFVZKqsXZ4Gu0UAXiNsdE2X0GLObD7vbwrVesEvc1zr2xyMqOz6nhLS0pk zIrUAqhI8jWPvBXkcbhpVvFxZ25Jr6ALxoI48bcznmB/ITUFh0BCf8u5zFoZLlCI9CAx QBnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=/nm+bDT6708JEo70ChiSuqA1GV0ljEJO2vsyebwej7k=; b=YMkHniZc6tzCjrXolf6qG0k2lFr9zI7CZ7ZDwQgzByfRx+2UpYvxuYFjahBVAFVQ9S 00eidFcBkQRespK6JxBYqQKQICB5iRBT7th37Dd2el7/p7pL7/C/fZie2ZKvnW3GA92M If0tN3VVa09nQXpQNvdHkMFa9VHDqLbi29WE4fvGCilLeaYtFYqqumgAbLvPQPlZfO6y AD3SiQQIIVvi6M8rBON6vlUSdkm9CRSHWOfs+W+Chr7ErTkwTBIqr4zg+VVMz8GDApJb YmyfW4LcNmRYUNhBJ65MBlTlEDpKZKf60ncHsJ8dKggIw41SPIYrXy+2524wvs4VCYDa vpZA== X-Gm-Message-State: AOAM533IwYMElMxaufkCk5RDy2OR6MbpUcaHbvL+L8Z2pQenV7aDUu3d ERXtgoEAhSLiGfFVNnN0ruoJnFasF/0= X-Google-Smtp-Source: ABdhPJx3dTO5ilSsu5kboasStLidfUccblDzqnCfON6yiTkgXO5CxB02x0DlDQ4v6cFmoDMY+z56uA== X-Received: by 2002:a63:8f08:: with SMTP id n8mr2855007pgd.9.1596185423346; Fri, 31 Jul 2020 01:50:23 -0700 (PDT) Received: from localhost ([104.250.131.79]) by smtp.gmail.com with ESMTPSA id q24sm9406159pgg.3.2020.07.31.01.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 01:50:22 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: Bug: [patch] Fix org-babel-result-to-file never expanding links when babel is evaluated in indirect buffer [9.3.7 (release_9.3.7-728-g1efc4e @ /home/yantar92/.emacs.d/straight/build/org/)] Date: Fri, 31 Jul 2020 16:49:40 +0800 Message-ID: <87eeos3w7v.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=yantar92@gmail.com; helo=mail-pj1-x102a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=u2GHDXYG; dmarc=pass (policy=none) header.from=gmail.com; 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-Spam-Score: 2.79 X-TUID: 1+xf3eUOjhOC --=-=-= Content-Type: text/plain Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ I noticed that org-babel-result-to-file never expands file: links in src block results when ran from indirect buffer and default-directory is not same with base buffer file's directory. This is against the docstring stating that > If the `default-directory' is different from the containing > file's directory then expand relative links. The misbehavior happens because buffer-file-name variable is always nil in indirect buffers. We need to call (file-name-directory (buffer-file-name (buffer-base-buffer))) instead. The patch is attached. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=org-babel-eval-indirect.patch diff --git a/lisp/ob-core.el b/lisp/ob-core.el index f86282f0f..d37eef5f9 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2561,16 +2561,16 @@ If the `default-directory' is different from the containing file's directory then expand relative links." (when (stringp result) (let ((same-directory? - (and buffer-file-name + (and (buffer-file-name (buffer-base-buffer)) (not (string= (expand-file-name default-directory) - (expand-file-name - (file-name-directory buffer-file-name))))))) + (expand-file-name + (file-name-directory (buffer-file-name (buffer-base-buffer))))))))) (format "[[file:%s]%s]" - (if (and default-directory buffer-file-name same-directory?) + (if (and default-directory (buffer-file-name (buffer-base-buffer)) same-directory?) (if (eq org-link-file-path-type 'adaptive) (file-relative-name (expand-file-name result default-directory) - (file-name-directory (buffer-file-name))) + (file-name-directory (buffer-file-name (buffer-base-buffer)))) (expand-file-name result default-directory)) result) (if description (concat "[" description "]") ""))))) --=-=-= Content-Type: text/plain Emacs : GNU Emacs 28.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-07-27 Package: Org mode version 9.3.7 (release_9.3.7-728-g1efc4e @ /home/yantar92/.emacs.d/straight/build/org/) -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg --=-=-=--