emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [RFC] [patch] open/delete attachment with inherited directory
@ 2013-12-16  5:02 Aaron Ecay
  2013-12-17 17:34 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Ecay @ 2013-12-16  5:02 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello,

I have some org files where each headline corresponds to an entry in a
bibliography.  The headlines each have attached to them a pdf file of
the corresponding document.  The attachment directory is set as a
file-level property and inherited by the children (this is so that I can
access the files easily also outside of org).

In the current implementation of org-attach-{open,delete-one}, I am
prompted to choose among all files in the attachment directory (i.e. all
the pdfs of entries in the bibliography), not just the (usually single)
file attached to the headline at point.  I think the latter behavior
makes more sense.  The attached (heh) patch implements this change.  Are
there any comments?

Thanks,

[-- Attachment #2: 0001-org-attach-only-offer-to-delete-open-attachments-of-.patch --]
[-- Type: text/x-diff, Size: 1696 bytes --]

From 4681055651950bdd66090745dcd2cc9f2b90a0f2 Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Sun, 15 Dec 2013 23:52:02 -0500
Subject: [PATCH] org-attach: only offer to delete/open attachments of the
 current headline
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-attach.el (org-attach-open): Only get the files pertaining
to the present headline

This change is useful in cases where the attachment directory is
inherited – in such cases, the we don’t want to see all the files in
the directory, but rather only those associated to the present
headline.
---
 lisp/org-attach.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 58ec2d1..6ec5da8 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -374,7 +374,8 @@ The attachment is created as an Emacs buffer."
   "Delete a single attachment."
   (interactive)
   (let* ((attach-dir (org-attach-dir t))
-	 (files (org-attach-file-list attach-dir))
+	 (files (org-entry-get-multivalued-property
+		 nil org-attach-file-list-property))
 	 (file (or file
 		   (org-icompleting-read
 		    "Delete attachment: "
@@ -449,7 +450,8 @@ and in the system-specific variants of this variable.
 If IN-EMACS is non-nil, force opening in Emacs."
   (interactive "P")
   (let* ((attach-dir (org-attach-dir t))
-	 (files (org-attach-file-list attach-dir))
+	 (files (org-entry-get-multivalued-property
+		 nil org-attach-file-list-property))
 	 (file (if (= (length files) 1)
 		   (car files)
 		 (org-icompleting-read "Open attachment: "
-- 
1.8.5.1


[-- Attachment #3: Type: text/plain, Size: 15 bytes --]

-- 
Aaron Ecay

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC] [patch] open/delete attachment with inherited directory
  2013-12-16  5:02 [RFC] [patch] open/delete attachment with inherited directory Aaron Ecay
@ 2013-12-17 17:34 ` Nicolas Goaziou
  2013-12-18  5:11   ` Aaron Ecay
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2013-12-17 17:34 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> I have some org files where each headline corresponds to an entry in a
> bibliography.  The headlines each have attached to them a pdf file of
> the corresponding document.  The attachment directory is set as a
> file-level property and inherited by the children (this is so that I can
> access the files easily also outside of org).
>
> In the current implementation of org-attach-{open,delete-one}, I am
> prompted to choose among all files in the attachment directory (i.e. all
> the pdfs of entries in the bibliography), not just the (usually single)
> file attached to the headline at point.  I think the latter behavior
> makes more sense.  The attached (heh) patch implements this change.  Are
> there any comments?

Thanks for the patch.

I see one major problem, though. Org attach doesn't require to list
files attached to the entry (see `org-attach-file-list-property').
Therefore, `org-entry-get-multivalued-property' could return nil even
though there are attached files.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] [patch] open/delete attachment with inherited directory
  2013-12-17 17:34 ` Nicolas Goaziou
@ 2013-12-18  5:11   ` Aaron Ecay
  2013-12-18 13:57     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Ecay @ 2013-12-18  5:11 UTC (permalink / raw)
  To: Nicolas Goaziou, emacs-orgmode

Hi Nicolas,

2013ko abenudak 17an, Nicolas Goaziou-ek idatzi zuen:
> 
> Thanks for the patch.
> 
> I see one major problem, though. Org attach doesn't require to list
> files attached to the entry (see `org-attach-file-list-property').
> Therefore, `org-entry-get-multivalued-property' could return nil even
> though there are attached files.

Hmm, good catch.  Perhaps then we should read the property if it exists,
but fall back to querying the filesystem in case it does not.  WDYT?

Thanks,

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] [patch] open/delete attachment with inherited directory
  2013-12-18  5:11   ` Aaron Ecay
@ 2013-12-18 13:57     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2013-12-18 13:57 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> Hmm, good catch.  Perhaps then we should read the property if it exists,
> but fall back to querying the filesystem in case it does not.  WDYT?

I didn't test it, but there might be a problem if a file name contains
white spaces.

If there isn't, it doesn't hurt to provide this alternative way to get
attached files (and `org-attach-file-list-property' need to mention it).
Otherwise, I think there are too many limitations in this patch to be
worth applying.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-18 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-16  5:02 [RFC] [patch] open/delete attachment with inherited directory Aaron Ecay
2013-12-17 17:34 ` Nicolas Goaziou
2013-12-18  5:11   ` Aaron Ecay
2013-12-18 13:57     ` Nicolas Goaziou

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