emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Erik Hetzner <egh@e6h.org>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-attach.el: Get attachments from git annex
Date: Sun, 31 Jan 2016 19:32:40 -0800	[thread overview]
Message-ID: <56aed1e0.0c46620a.e568d.ffff82e2@mx.google.com> (raw)
In-Reply-To: <87r3h2ekac.fsf@gmx.us>

Hi Rasmus,

Thanks again for the feedback!

On Wed, 27 Jan 2016 14:20:59 -0800,
Rasmus <rasmus@gmx.us> wrote:
> 
> Hi Erik,
> 
> Thanks for the updated patch!
> 
> A couple of more comments follow.
> I hope I’m not being too annoying! 

Not at all, I appreciate it.

> Erik Hetzner <egh@e6h.org> writes:
> 
> > +(defcustom org-attach-annex-confirm-get-function #'y-or-n-p
> > +  "Function to call to confirm if Org should call git annex get if necessary.
> > +If t, always get, if nil, never get."
> 
> 
> Please note that the function should accept one argument cf. your code
> below.  Also, I wonder if there’s really a point in having the increased
> flexibility of a function over just: t, nil and ’ask.

This is a good point - I was following the pattern of
`org-confirm-shell-link-function' but I don’t think that in this case
it is necessary.

> > +  :group 'org-attach
> > +  :package-version '(Org . "8.3")
> > +  :type '(choice
> > +	  (const :tag "confirm with y-or-n" y-or-n-p)
> > +	  (const :tag "always get from annex if necessary" t)
> > +	  (const :tag "never get from annex" nil)))
> 
> Nitpick: package version should be org 9.  You should add :version tag as
> well.  Probably "25.1" is good.  Then we can mass-update them all when we
> are allowed to merge...

Thank you, I wasn’t sure what to use here.

> > +(defun org-attach-annex-get-maybe (path)
> > +  "Call git annex get PATH if using git annex."
> > +  (when (and (org-attach-use-annex)
> > +	     (not (string-equal "found"
> > +				(shell-command-to-string
> > +				 (format "git annex find --format=found --in=here %s" (shell-quote-argument path))))))
> > +    (if (if (functionp org-attach-annex-confirm-get-function)
> > +	    (funcall org-attach-annex-confirm-get-function (format "Run git annex get %s? " path))
> > +	  org-attach-annex-confirm-get-function)
> > +	(progn (message "Running git annex get \"%s\"." path)
> > +	       (call-process "git" nil nil nil "annex" "get" path))
> > +      (error "File %s stored in git annex but it is not available, and was not retrieved" path))))
> 
> Can’t you factor out the inner "if", e.g. to an outer let?  Shouldn’t you
> check the return of annex get and show a warning or an error if it fails?
> It seems the error is only called if the inner if fails (in which case the
> error message is not precise since we didn’t try to retrieve the file).

This has been since refactored, but the point about the error remains. The
reason I used `error' is that the user has been attempting to open the file. If
the content is unavailable, then surely the attempt to open the file will be
unsuccessful. Perhaps a more clear docstring in `org-attach-annex-get-maybe' is
in order, though.

> >  (defun org-attach-commit ()
> 
> Looks fine. 
> 
> >  cleantest:
> > +# git annex makes files 444, change to user writable so we can delete them
> > +	if [ -d $(testdir) ] ; then chmod u+w -R $(testdir) ; fi
> >  	$(RMR) $(testdir)
> 
> I wonder if it would be better to directly target the files you use?  I
> don’t think there’s a case where changing the mod of the testdir is a
> problem though....

Since it is about to be removed via =rm -rf= it doesn’t seem worth worrying
about it :)

best, Erik

> 
> > +;;; test-org-attach.el --- Tests for Org Attach
> 
> Skipped again...
> 
> -- 
> Slowly unravels in a ball of yarn and the devil collects it

  reply	other threads:[~2016-02-01  3:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05  5:09 [PATCH] org-attach.el: Fetch attachments from git annex Erik Hetzner
2016-01-05  5:30 ` Eric Abrahamsen
2016-01-05  6:11 ` Erik Hetzner
2016-01-05  6:36   ` Kyle Meyer
2016-01-05  9:56   ` Rasmus
2016-01-05 17:14     ` Kyle Meyer
2016-01-05 18:16       ` Rasmus
2016-01-05 19:30         ` Kyle Meyer
2016-01-05 21:55           ` Rasmus
2016-01-06  5:43             ` Kyle Meyer
2016-01-06  1:27     ` Erik Hetzner
2016-01-06  9:37       ` Rasmus
2016-01-05  6:21 ` Kyle Meyer
2016-01-06  1:15   ` Erik Hetzner
2016-01-25  5:24     ` Erik Hetzner
2016-01-25 21:19       ` Rasmus
2016-01-25  4:34         ` Erik Hetzner
2016-01-26  7:40           ` Kyle Meyer
2016-01-26 16:39             ` Erik Hetzner
2016-01-26 17:34               ` Kyle Meyer
2016-01-26 22:04                 ` Rasmus
2016-01-25  4:34                   ` [PATCH] org-attach.el: Get " Erik Hetzner
2016-01-27 22:20                     ` Rasmus
2016-02-01  3:32                       ` Erik Hetzner [this message]
2016-01-29  5:39                     ` Kyle Meyer
2016-01-25  4:34                       ` Erik Hetzner
2016-02-05  2:41                         ` Kyle Meyer
2016-02-06 12:18                         ` Rasmus
2016-02-07 17:15                           ` Erik Hetzner
2016-02-07 20:48                             ` Achim Gratz
2016-02-09  5:25                               ` Erik Hetzner
2016-02-09 19:40                                 ` Achim Gratz
2016-02-09 21:12                                   ` Erik Hetzner
2016-02-09 22:19                                     ` Achim Gratz
2016-02-11  2:24                                       ` Erik Hetzner
2016-02-11 18:57                                         ` Achim Gratz
2016-02-09  5:40                               ` [PATCH] testing/lisp/test-org-attach-annex.el: New file Erik Hetzner
2016-02-14 11:50                                 ` Achim Gratz
2016-01-26  5:31         ` [PATCH] org-attach.el: Fetch attachments from git annex Erik Hetzner
2016-01-26 22:10           ` Rasmus

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=56aed1e0.0c46620a.e568d.ffff82e2@mx.google.com \
    --to=egh@e6h.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /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).