Hi folks,
I started trying to use the org-attach feature (C-c C-a) and I like
the idea that it can auto-commit attachment changes to a git repo. But
I noticed some shortcomings...
1. I like to keep the entire org-directory under version control, but
org-attach only commits if the org-attach-directory is the root of the
repo. Instead of using (file-exists-p (expand-file-name ".git" dir))
in org-attach-commit, why not just TRY the "git add" shell command in
that dir and check the return value to see whether to continue with
the commit?
2. I got the above working, but then I noticed that if you use the
ATTACH_DIR property to redirect attachments elsewhere, org-attach-
commit ignores that and still tries to synchronize the standard org-
attach-directory.
Below I have a patch to address both of these, but I don't recommend
applying it yet... if the ATTACH_DIR happens to be in a normal source
tree, users may not want to auto-commit to it, particularly with such
an unhelpful log message. So I'd like to add an ATTACH_DIR_COMMIT flag
that, when set, indicates it's okay to auto-commit the ATTACH_DIR.
Other suggestions about how to customize whether or not to commit on a
per-directory basis are welcome.. maybe a org-attach-commit-dirs
variable that's a boolean, a list or a regex, combined with the
ATTACH_DIR_COMMIT property..?
Thanks,
Chris
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5f439da..a59b2ec 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -240,11 +240,12 @@ the ATTACH_DIR property) their own attachment
directory."
(defun org-attach-commit ()
"Commit changes to git if `org-attach-directory' is properly
initialized.
This checks for the existence of a \".git\" directory in that
directory."
- (let ((dir (expand-file-name org-attach-directory)))
- (if (file-exists-p (expand-file-name ".git" dir))
+ (let ((dir (org-attach-dir)))
+ (if (and dir
+ (= 0 (shell-command
+ (concat "(cd " dir "; git add .)"))))
(shell-command
(concat "(cd " dir "; "
- " git add .; "
" git ls-files --deleted -z | xargs -0 git rm; "
" git commit -m 'Synchronized attachments')")))))
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode