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 yD3EIVP32l/7dQAA0tVLHw (envelope-from ) for ; Thu, 17 Dec 2020 06:14:43 +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 6GB7HVP32l9mLAAAbx9fmQ (envelope-from ) for ; Thu, 17 Dec 2020 06:14:43 +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 EA663940418 for ; Thu, 17 Dec 2020 06:14:42 +0000 (UTC) Received: from localhost ([::1]:38438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpmYi-0006Ka-OU for larch@yhetil.org; Thu, 17 Dec 2020 01:14:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpmXy-0006JQ-PL for emacs-orgmode@gnu.org; Thu, 17 Dec 2020 01:13:54 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:36790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpmXt-0005QZ-H5 for emacs-orgmode@gnu.org; Thu, 17 Dec 2020 01:13:54 -0500 Received: by mail-pf1-x436.google.com with SMTP id t22so8976644pfl.3 for ; Wed, 16 Dec 2020 22:13:49 -0800 (PST) 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=e7iYPqiobed+ITKr7ofKZUuuEnHnnX7r2Fpn9F7GVa8=; b=KEeDi+rpDXgr7CmIDlmEZRUxzjMHZ2vwCTHLcQ7nAdN7/H8EkW6c/sDdyWrOTDrvIH 4UpJSPuB1NjvEdzJRNVLt11Kz/HgtbKekuj3Qt2F45JghtstqM9ZykRukYiQeQbZj4BM EPpNm/2IvpIrExI+6LHQ7MaanlNOl4zdgxsyFG3MY/mWggU2vUvXaQyapZ08UVfY5OQF 8WNCu8n0N/zsih7svVRfQ/AEbK/pfupL3R5ZIIdhnb8PeshrnhN0VjDykbKLkL0dI9tR 682wflbCx7copgclc2ye2dYzOo8yuqeNutjxCY1RHvGCWTy/z5s31h1k+0DlpErFTlbz ZI/w== 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=e7iYPqiobed+ITKr7ofKZUuuEnHnnX7r2Fpn9F7GVa8=; b=F38GcL439SREhUU0P/v8BHYOwa4We+LyNlKhK4SYwRHOflI/+e+faY947U2N9Pjgoj XLGteDJP2Kl+CTXY19l//cBmsqG19j+CS3QGxHBHaEGU/WL2r5z6G/e90POAxXUiVZbN gVtIzH2t5WIQRYVoteBs12RMg0n3ihhQbnlUSZbI8F0qLz+Q7p4QoG98Z83GmryfWvdS CbWs9G1+TFZZjVnZ/NwWZ2QrvMj6Yu9f6Msqi1KeCEX57/Bbi9iN1Wc0dd4cIRvgYk4t xI9aWtYlgZq3uTP5HGygrzF72uHEmnfn6Mcb2H/UI0qxrdWd9zKQGcrwEW935a3YfTL9 li1w== X-Gm-Message-State: AOAM532H+yqJT9ytmu8dMWSAtFwFdXHY9GC83FdbfzUfApXLvRWOGH7u P0AHLGe4SQra22+W7kmIf5XfStCYbNLgKQ== X-Google-Smtp-Source: ABdhPJzlz7eK4s2fjU1Nfctbdinv/nHrTKdPL9/4Ii3k7xmH+gme59GCBZAghjFWJFV6FEVH1Up8RA== X-Received: by 2002:a62:4e95:0:b029:1a3:a372:8b3c with SMTP id c143-20020a624e950000b02901a3a3728b3cmr21453346pfb.28.1608185627636; Wed, 16 Dec 2020 22:13:47 -0800 (PST) Received: from localhost ([104.250.131.79]) by smtp.gmail.com with ESMTPSA id h4sm4948421pgp.8.2020.12.16.22.13.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Dec 2020 22:13:46 -0800 (PST) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH] org-attach: Consider inlinetasks when calculating attach dir Date: Thu, 17 Dec 2020 14:17:41 +0800 Message-ID: <87mtyd552y.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=yantar92@gmail.com; helo=mail-pf1-x436.google.com 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, T_SPF_TEMPERROR=0.01 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-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.51 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=KEeDi+rp; 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-Migadu-Queue-Id: EA663940418 X-Spam-Score: -2.51 X-Migadu-Scanner: scn0.migadu.com X-TUID: kJxRobfoy5Wu --=-=-= Content-Type: text/plain I have the following heading with attachments: * Headline :ATTACH: :PROPERTIES: :ID: some_id :END: Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. *************** TODO how can I? *************** END Etiam vel neque nec dui dignissim bibendum. When calling org-attach-open (C-c C-a f), in the above buffer, I get wrong attachment dir and stray property drawer below END: *************** END :PROPERTIES: :ID: some_other_id :END: Etiam vel neque nec dui dignissim bibendum. Patch is attached. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org-attach-Consider-inlinetasks-when-calculating-att.patch >From 530d7f705acce53ecb11afd7b7ae91bc65db417e Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 17 Dec 2020 14:03:30 +0800 Subject: [PATCH] org-attach: Consider inlinetasks when calculating attach dir * lisp/org-attach.el (org-attach): When inside inlinetask, return attachment dir of that task. When outside inlinetask, return attachment dir of the main task ignoring any inlinetasks above point. The call to `org-back-to-heading-or-point-min` does not move point to the actual heading when there is inlinetask above the point. The result is incorrect return value or even creation of property drawer below *...** END line of the last inline task before point. --- lisp/org-attach.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index e6aa97e00..d117bdd22 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -256,7 +256,14 @@ Shows a list of commands and prompts for another key to execute a command." (unless marker (error "No item in current line"))) (org-with-point-at marker - (org-back-to-heading-or-point-min t) + (if (and (featurep 'org-inlinetask) + (not (org-inlinetask-in-task-p))) + (org-with-limited-levels + (org-back-to-heading-or-point-min t)) + (if (and (featurep 'org-inlinetask) + (org-inlinetask-in-task-p)) + (org-inlinetask-goto-beginning) + (org-back-to-heading-or-point-min t))) (save-excursion (save-window-excursion (unless org-attach-expert -- 2.26.2 --=-=-=--