From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Moving and resetting attachments Date: Tue, 13 Jun 2017 23:41:15 +0200 Message-ID: <87tw3jr2f8.fsf@nicolasgoaziou.fr> References: <874lw05njr.fsf@ericabrahamsen.net> <8737bi21dc.fsf@ericabrahamsen.net> <87mv9gz43o.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKtYs-0004L6-NT for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 17:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKtYr-0001oY-Pu for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 17:41:18 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:40035) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKtYr-0001nW-Jb for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 17:41:17 -0400 In-Reply-To: (Florian Lindner's message of "Tue, 13 Jun 2017 10:49:05 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Florian Lindner Cc: emacs-orgmode@gnu.org Hello, Florian Lindner writes: > What is the use of (and org-attach-allow-inheritance t)? Doesn't it always returns org-attach-allow-inheritance? It return nil if `org-attach-allow-inheritance' is nil, t otherwise. In particular, if `org-attach-allow-inheritance' is set to `selective', the S-exp returns t. > Anyways, I'm not really sure if I understand the doc of org-entry-get correctly. Does org-entry-get not automatically > take inheritance into account, based on the the per-entry or global > setting? No it doesn't. The caller choose if it should ignore inheritance (the default), use it unconditionally (a non-nil INHERIT argument), or let the user decide (`selective' INHERIT argument). >> ;; FIXME: Need a special case for directory reset (non-nil ARG). > > Why that? Aren't old and new holding the appropriate dirs in that case > and copy over / delete as they should? Probably. I was thinking to some special case that may not exist, after all. Never mind then. > Latest version: > > (defun flo/org-attach-move (&optional arg) > "Move current attachements to another directory. > When ARG is non-nil, reset attach directory. Create directory if > needed." > (interactive "P") > (let ((old (org-attach-dir)) > (new > (progn > (if arg (org-entry-delete nil "ATTACH_DIR") > (let ((dir (read-directory-name > "Attachment directory: " > (org-entry-get nil > "ATTACH_DIR" > (and org-attach-allow-inheritance t))))) > (org-entry-put nil "ATTACH_DIR" dir))) > (org-attach-dir t)))) > (unless (or (string= old new) > (not old)) > ;; FIXME: Need a special case for directory reset (non-nil ARG). > (when (yes-or-no-p "Copy over attachments from old directory? ") > (copy-directory old new t nil t)) > (when (yes-or-no-p (concat "Delete " old)) > (delete-directory old t))))) It looks good. Could you provide a patch for that, and an entry in ORG-NEWS? Also, it would be nice to provide test for the feature. Thank you ! Regards, -- Nicolas Goaziou