From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id pNHKOBFUJF/OYQAA0tVLHw (envelope-from ) for ; Fri, 31 Jul 2020 17:25:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wEEaNBFUJF94IQAAB5/wlQ (envelope-from ) for ; Fri, 31 Jul 2020 17:25:37 +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 550C7940667 for ; Fri, 31 Jul 2020 17:25:37 +0000 (UTC) Received: from localhost ([::1]:36304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ymk-00018I-NR for larch@yhetil.org; Fri, 31 Jul 2020 13:25:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ym7-00016x-7T for emacs-orgmode@gnu.org; Fri, 31 Jul 2020 13:24:55 -0400 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]:35569) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k1Ym5-0007DN-Ht for emacs-orgmode@gnu.org; Fri, 31 Jul 2020 13:24:54 -0400 Received: by mail-lf1-x142.google.com with SMTP id j22so11356908lfm.2 for ; Fri, 31 Jul 2020 10:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=PzIw1I4khwE3zzakJTabaSjC0I8WO3lkoCeC/rLwX5M=; b=tcHmGWyYg67yyNDbTP9lDh1nv2AXufgCAmpB6RNL11cxAKKrH6uPPd3+4zr7p3oWta CK+IMqIndW3NjXzGxt9GhDXc9U9utT1f8gjebUHKvpq+4hgv95Zq3vxxX3xqqKxQ4KAn NV/XiCjte4LwL6ecMUHvb2zxUaUe0wobZXNCrASHbpiYaads7Fes6QBXIYsN4w6KUA81 kJZH6ptnIVFHgY/LpVXQjD3TAnrxYay/qj+bT+2wJyMTAOMR9p9Yc3vJHk2RQGuMZXBm hOrCNXm4DkZESNM1Uha/SW+YCprtTz/FYNKo1t4hbY8be3AADRfQScr42S0A24NCBUVU O6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=PzIw1I4khwE3zzakJTabaSjC0I8WO3lkoCeC/rLwX5M=; b=QyrP0isFgKY0yk+ZIeXiJapOcxpkQNNzPwj8nNc5F+q1OZzvAti6nfIL8Fixi1hbbb 81fWdGqKv2fPg9K7SW2wRCSGn9ZNQ0DvEcvPdMCoaSyvOVCocDftBMR4q+0C9X9eU8JU hCp9bQESOcX6RM5BMSI3kSb9nZXP3JOV+Us91aYnUl4JryUcWibxSLTyaGrwOo9p0lqk GU/1lo4sz8bcfyhLcgDKENR+nxpVFOpNnM5ZsWbnsZY9cWrRgCp4fT9Epl2HTg8uG83Y v5+KY1lFa4pL07R24/NGyaRS1g/zq+Lmsf0Cc/p1M+Qw1A4CvwOorq7WbrhwbLLLfCKk c0GQ== X-Gm-Message-State: AOAM532n8MCzUuiOzB51o2yUTEn0dkwak8/t6lBPY0t3dsDRrT2yvSGr iywZCTK9X8WIm0Yq4mTiBOkISAmy X-Google-Smtp-Source: ABdhPJwEEQcQw1G415V9wzSlEynKsjZBIYGpExiRHZ/mJjLbRkqXwn7xMVUNbYwUTRZE+2ZCG2jb3Q== X-Received: by 2002:ac2:5223:: with SMTP id i3mr2544190lfl.57.1596216290619; Fri, 31 Jul 2020 10:24:50 -0700 (PDT) Received: from arch ([98.128.186.110]) by smtp.gmail.com with ESMTPSA id y22sm1788963ljn.2.2020.07.31.10.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 10:24:49 -0700 (PDT) References: <87eeos3w7v.fsf@localhost> User-agent: mu4e 1.4.10; emacs 26.3 From: John Herrlin To: Ihor Radchenko Subject: Re: 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/)] In-reply-to: <87eeos3w7v.fsf@localhost> Message-ID: <87k0yjoaw7.fsf@gmail.com> Date: Fri, 31 Jul 2020 19:24:42 +0200 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::142; envelope-from=jherrlin@gmail.com; helo=mail-lf1-x142.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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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: , Cc: emacs-orgmode@gnu.org 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=tcHmGWyY; 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: 3.29 X-TUID: AGHHSlF1334Y Hey Ihor, Could not get the patch to work. I used this use case. (with-current-buffer (find-file "/tmp/tmp.org") (insert "* A\n** b\n** c\n\n some text") (dired "~/") (make-indirect-buffer "tmp.org" "tmp-indirect") (switch-to-buffer "tmp-indirect") (goto-char (point-max)) (funcall 'org-mode) (insert (concat "\n\n| default-directory | " default-directory " |\n" "| org-link-file-path-type | " (symbol-name org-link-file-path-type) " |\n" "| (expand-file-name default-directory) | " (expand-file-name default-directory) " |\n" "| (buffer-file-name (buffer-base-buffer)) | " (buffer-file-name (buffer-base-buffer)) " |\n")) (org-table-align) (insert "\n\n#+BEGIN_SRC shell :results file :file script.sh echo \"#!/bin/bash\" echo \"echo Hey\"\n#+END_SRC") (org-babel-execute-src-block)) In my case the result is a relative link, but if I follow the link I end up in the wrong place. src_emacs-lisp{emacs-version} {{{results(=26.3=)}}} src_emacs-lisp{org-version} {{{results(=9.3.7=)}}} Best regards John Ihor Radchenko writes: > 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 > > 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 "]") ""))))) > > 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/) -- Mvh John