From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Lindner Subject: Re: Moving and resetting attachments Date: Tue, 20 Jun 2017 20:12:32 +0200 Message-ID: <5b786b61-8cf2-6635-5000-fa25512242be@xgm.de> References: <874lw05njr.fsf@ericabrahamsen.net> <8737bi21dc.fsf@ericabrahamsen.net> <87mv9gz43o.fsf@nicolasgoaziou.fr> <87tw3jr2f8.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNNdm-0004K1-75 for emacs-orgmode@gnu.org; Tue, 20 Jun 2017 14:12:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNNdj-0006T2-3h for emacs-orgmode@gnu.org; Tue, 20 Jun 2017 14:12:38 -0400 Received: from venus.centershock.net ([188.68.38.242]:58010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNNdi-0006Sy-Sa for emacs-orgmode@gnu.org; Tue, 20 Jun 2017 14:12:35 -0400 In-Reply-To: <87tw3jr2f8.fsf@nicolasgoaziou.fr> Content-Language: en-US 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Am 13.06.2017 um 23:41 schrieb Nicolas Goaziou: > 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. Ok, so it's basically a conversion to bool. >> 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 Sure, I will do that. > would be nice to provide test for the feature. That I'm not so sure of. I try to get myself aquainted to ert, but my elisp knowledge, you surely know, is very limited. Do I understand correctly, that there is no test for any org-attach stuff so far? I've found lisp/test-org-attach-annex.el, but that's for git-annex stuff. Best, Florian