[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] org-attach.el: Fetch attachments from git annex

From: Rasmus
Subject: Re: [O] [PATCH] org-attach.el: Fetch attachments from git annex
Date: Tue, 5 Jan 2016 09:56:39 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hi Erik,

> I couldn’t figure out how to add a comment to my patch, so here is a 
little more
> commentary.

For long prose like this I'd just export the patch (git format-patch)
and attach it to an email like this.  But this is also fine...  Perhaps
Kyle's method is more pro.

> Right now, if you use git to sync your Org files and git annex to 
manage your
> (large) attachments, and are on a different computer from the one you 
were using
> when you added the attachment, you will typically have a dangling 
symlink to
> your attachment until you call =get annex get PATH=. (This is how git 
annex is
> intended to work.)
> This patch automatically calls =git annex get PATH= when you open the 
> from Org, if the file has not been fetched already.

This is a good idea.  Though really this sounds like something that
should be done by the git annex assistant rather than per application.

Has Joey spoken for or against automatic fetching of content when

> (It would be nice to have Org do the same thing when exporting to HTML 
as well,
> if the git annex file is an image that is being exported as an 
embedded image
> link, but I can’t figure out how to do that.)

A stronger argument for for first figuring out whether it 

> +(defun org-attach-use-annex ()
> +  "Return true if we should use git annex for attachments."
> +  (let* ((dir (expand-file-name org-attach-directory))
> +      (git-dir (vc-git-root dir)))
> +    (and org-attach-git-annex-cutoff
> +         (or (file-exists-p (expand-file-name "annex" git-dir))
> +             (file-exists-p (expand-file-name ".git/annex" git-

As Kyle points out there should be a defcustom as well to decide whether
annex should be used.

since you call (org-attach-use-annex) you should probably check this
variable here.

>  (defun org-attach-commit ()
>    "Commit changes to git if `org-attach-directory' is properly 
>  This checks for the existence of a \".git\" directory in that 
>  <at>  <at>  -279,20 +287,16  <at>  <at>  This checks for the 
existence of a \".git\" directory in that directory."
>      (when (and git-dir (executable-find "git"))
>        (with-temp-buffer
>       (cd dir)
> -     (let ((have-annex
> -            (and org-attach-git-annex-cutoff
> -                 (or (file-exists-p (expand-file-name "annex" git-
> -                     (file-exists-p (expand-file-name ".git/annex" 
> -       (dolist (new-or-modified
> -                (split-string
> -                 (shell-command-to-string
> -                  "git ls-files -zmo --exclude-standard") "\0" t))
> -         (if (and have-annex
> -                  (>= (nth 7 (file-attributes new-or-modified))
> -                      org-attach-git-annex-cutoff))
> -             (call-process "git" nil nil nil "annex" "add" new-or-
> -           (call-process "git" nil nil nil "add" new-or-modified))
> -         (incf changes)))
> +        (dolist (new-or-modified
> +                 (split-string
> +                  (shell-command-to-string
> +                   "git ls-files -zmo --exclude-standard") "\0" t))
> +          (if (and (org-attach-use-annex)

> +                   (>= (nth 7 (file-attributes new-or-modified))
> +                       org-attach-git-annex-cutoff))

IMO we should get rid of org-attach-git-annex-cutoff and point to
preferred content:


E.g. I might have a small mp3 file.  There's no point in storing it with
git rather than git annex.

When preferred content is set up, I think git annex add will do the
right thing.

> +              (call-process "git" nil nil nil "annex" "add" new-or-
> +            (call-process "git" nil nil nil "add" new-or-modified))
> +         (incf changes))
>       (dolist (deleted
>                (split-string
>                 (shell-command-to-string "git ls-files -z --deleted") 
"\0" t))
>  <at>  <at>  -465,8 +469,13  <at>  <at>  If IN-EMACS is non-nil, force 
opening in Emacs."
>        (file (if (= (length files) 1)
>                  (car files)
>                (org-icompleting-read "Open attachment: "
> -                                    (mapcar 'list files) nil t))))
> -    (org-open-file (expand-file-name file attach-dir) in-emacs)))
> +                                    (mapcar 'list files) nil t)))
> +         (path (expand-file-name file attach-dir)))
> +    (if (and (file-symlink-p path)
> +             (org-attach-use-annex)
> +             (not (file-exists-p (file-symlink-p path))))

Can you ask annex if it's an annexed file?  A symlink in an annexed 
to a usb disk that is not attached would pass this test.  But the 
indication would be wrong.

> +        (call-process "git" nil nil nil "annex" "get" path))
> +    (org-open-file path in-emacs)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]