From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Moving and resetting attachments Date: Fri, 02 Jun 2017 20:34:03 +0800 Message-ID: <874lvy8t6s.fsf@ericabrahamsen.net> References: <874lw05njr.fsf@ericabrahamsen.net> <8737bi21dc.fsf@ericabrahamsen.net> <87d1am4t0h.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGln7-0005gS-PF for emacs-orgmode@gnu.org; Fri, 02 Jun 2017 08:34:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGln3-0001dK-Ac for emacs-orgmode@gnu.org; Fri, 02 Jun 2017 08:34:57 -0400 Received: from [195.159.176.226] (port=46440 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGln3-0001c1-3N for emacs-orgmode@gnu.org; Fri, 02 Jun 2017 08:34:53 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dGlmu-0003bt-Vy for emacs-orgmode@gnu.org; Fri, 02 Jun 2017 14:34:44 +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: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Eric Abrahamsen writes: > >> Looks like a good start! My first comment is, this should definitely be >> written as a patch to `org-attach-set-directory'. It's useful >> functionality, and fits well into the whole system -- so long as you >> give users a chance to say no, I don't see why it shouldn't be part of >> the library. > > FWIW, I agree. I should have mentioned it wasn't my decision :) >> Various comments: > > [...] > >> 3. This is a good use of `copy-directory' with the COPY-CONTENTS flag, >> but I'd still recommend using `directory-files' and then looping over >> all the files with a `map-y-or-n-p'. That will give users a chance to >> selectively choose files to move. This is a matter of taste. If you >> stick with `copy-directory', at least ask the user first. >> 4. I think you're right not to delete the directory afterwards. Best not >> to assume too much. > > What about using `rename-file' so as to move the whole directory to the > new location? > > Maybe a defcustom could let the user choose between moving and copying > the attachment directory. Mostly I was thinking of two things: 1) giving the user the chance to say yea or nay on a file-by-file basis, and 2) the possibility of clobbering an existing directory. Even if the usual warnings kick in, it still makes me nervous to think of what you could lose. Plus, potentially merging directories might be useful. >> 7. Personally I'd rework things so you only call `org-attach-dir' once. >> How to handle this depends a bit on when when-let was introduced into >> Emacs, and whether Org is okay to support it. Probably safest to use >> when-let*. so: >> >> (when-let* ((attach-dir (org-attach-dir)) >> (target (read-directory-name "Move attachments to: "))) > > We cannot use `when-let*'. Besides, > > (let ((attch-dir (org-attach-dir))) > (when attach-dir > (let ((target (read-directory-name "Move attachments to: "))) > ...))) > > is fine, too, or even > > (let ((attch-dir (or (org-attach-dir) (error "No attachment directory"))) > (target (read-directory-name "Move attachments to: "))) > ...) Good to know about when-let, etc. There are indeed many ways to skin that cat. Eric