emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-attach: Consider inlinetasks when calculating attach dir
Date: Thu, 17 Dec 2020 14:17:41 +0800	[thread overview]
Message-ID: <87mtyd552y.fsf@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]


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.
<point>

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-attach-Consider-inlinetasks-when-calculating-att.patch --]
[-- Type: text/x-diff, Size: 1570 bytes --]

From 530d7f705acce53ecb11afd7b7ae91bc65db417e Mon Sep 17 00:00:00 2001
From: Ihor Radchenko <yantar92@gmail.com>
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


             reply	other threads:[~2020-12-17  6:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  6:17 Ihor Radchenko [this message]
2020-12-17  6:27 ` [PATCH] org-attach: Consider inlinetasks when calculating attach dir Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtyd552y.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).