Re: org-attach-git don't automatically commit changes

2024-01-10 Thread Ihor Radchenko
Juan Manuel Macías  writes:

>> In any case, if you provide a patch, it will encourage the org
>> maintainers to join this discussion and proceed with changes.
>
> OK, this week I will try to propose a patch here, and bring it up for
> (possible) discussion. Thanks for the suggestions.

For the record, this appears to be fixed in df9b509a6.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Juan Manuel Macías
Ihor Radchenko  writes:

> What is more tricky is making sure that workflow for people using the
> old behaviour is not broken. Just changing to (org-attach-dir) will
> break existing git repos in org-attach-id-dir. This should also not be
> too hard (say, we can introduce a custom variable defaulting to old
> behaviour), but exact details may need to be discussed.

I agree: I think a custom variable with the current behavior by default
would be fine.

> In any case, if you provide a patch, it will encourage the org
> maintainers to join this discussion and proceed with changes.

OK, this week I will try to propose a patch here, and bring it up for
(possible) discussion. Thanks for the suggestions.

Best regards,

Juan Manuel 



Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> Do you think a possible patch could simply consist of replacing (as I
> have done) `(expand-file-name org-attach-id-dir)' by `(org-attach-dir)'
> in `org-attach-git-commit'? This would allow you to handle attachment
> dirs as individual git repos, regardless of :ID: or :DIR: properties,
> since "[(org-attach-dir)] Return the directory associated with the
> current outline node. First check for DIR property, then ID property
> [...]".

All the instances of (expand-file-name org-attach-id-dir) should be
replaced. There are 3. That's not a big deal.

What is more tricky is making sure that workflow for people using the
old behaviour is not broken. Just changing to (org-attach-dir) will
break existing git repos in org-attach-id-dir. This should also not be
too hard (say, we can introduce a custom variable defaulting to old
behaviour), but exact details may need to be discussed.

In any case, if you provide a patch, it will encourage the org
maintainers to join this discussion and proceed with changes.

Best,
Ihor



Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Juan Manuel Macías
Ihor Radchenko  writes:

> The other thing is that `org-attach-id-dir' makes much less sense from
> the time :DIR: property was introduced. So, I believe that
> org-attach-git should be updated. Probably, handling attachment dirs as
> individual git repos can be one of the ways to upgrade the current
> version. I guess, patches welcome.

Do you think a possible patch could simply consist of replacing (as I
have done) `(expand-file-name org-attach-id-dir)' by `(org-attach-dir)'
in `org-attach-git-commit'? This would allow you to handle attachment
dirs as individual git repos, regardless of :ID: or :DIR: properties,
since "[(org-attach-dir)] Return the directory associated with the
current outline node. First check for DIR property, then ID property
[...]".

Best regards,

Juan Manuel 



Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Juan Manuel Macías
Ihor Radchenko  writes:

> I think you misunderstood how org-attach-git works.
>
> org-attach-git is:
>
> ;; An extension to org-attach.  If `org-attach-id-dir' is initialized
> ;; as a Git repository, then org-attach-git will automatically commit
> ;; changes when it sees them.  Requires git-annex.
>
> So, it is not designed to work when your actual attachment directory is
> a git repo, but rather when org-attach-id-dir is a git repo (initialised
> manually).

Thanks for the explanation: it is clear that I had misinterpreted
`org-attach-id-dir'. Now it makes sense that it didn't work for me.
Anyway, I think the manual at that point is somewhat ambiguous and it
should be more precise, IMHO.

> So, I believe that org-attach-git should be updated. Probably,
> handling attachment dirs as individual git repos can be one of the
> ways to upgrade the current version.

I agree, I think this possibility makes a lot more sense.

Best regards,

Juan Manuel 



Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> But if I evaluate this, I get an 'incomplete' path:

I think you misunderstood how org-attach-git works.

org-attach-git is:

;; An extension to org-attach.  If `org-attach-id-dir' is initialized
;; as a Git repository, then org-attach-git will automatically commit
;; changes when it sees them.  Requires git-annex.

So, it is not designed to work when your actual attachment directory is
a git repo, but rather when org-attach-id-dir is a git repo (initialised
manually).

The other thing is that `org-attach-id-dir' makes much less sense from
the time :DIR: property was introduced. So, I believe that
org-attach-git should be updated. Probably, handling attachment dirs as
individual git repos can be one of the ways to upgrade the current
version. I guess, patches welcome.

Best,
Ihor





Re: org-attach-git don't automatically commit changes

2021-01-31 Thread Juan Manuel Macías
Hi Ihor,

Ihor Radchenko  writes:

> Does it mean that your attachment folder is set in :DIR: property?

No, my attachment folder is build using :ID: property. For example, in
my heading:

*   Test
:PROPERTIES:
:ID: d0e690e2-2ecd-4224-891a-b91257db5389
:END:

And if I evaluate `org-attach-dir' here, it returns the correct path:

#+begin_src emacs-lisp 
(org-attach-dir)
#+end_src


#+RESULTS:
: 
/home/juanmanuel/Documentos/docs-compartidos/org/data/d0/e690e2-2ecd-4224-891a-b91257db5389

But if I evaluate this, I get an 'incomplete' path:

#+begin_src emacs-lisp 
(expand-file-name org-attach-id-dir)
#+end_src

#+RESULTS:
: /home/juanmanuel/Documentos/docs-compartidos/org/data/

So if I replace `(expand-file-name org-attach-id-dir)' with
`(org-attach-dir)' in `(org-attach-git-commit)' [line 7, the `dir'
variable], it works fine when I run 'C-c C-a z'.

Best regards

Juan Manuel 

>
> I suspect that it is a leftover from the major changes in org-attach
> when :DIR: property was introduced. The org-attach-git presumes that all
> the attachments in current file are stored in sub-directories located
> inside org-attach-id-dir, which is no longer guaranteed. In fact, the
> existing approach to treat all the attachments to all headings in
> current file as files in a single git repo cannot be used. I can see two
> possible fixes:
> 1. Treat each attachment dir as individual git repo (breaking change for
>those who are using :ID: property to build the attachment dirs)
> 2. Treat attachment dirs defined by :DIR: property individually and
>leave the :ID:-defined attachments as they were treated before
>(inconsistent).
>
> I am in favour of the first approach since I do not like the idea of
> keeping all the attachments in the whole file in a single git repo.
> I think feedback from other is needed to decide what we need to do here.
>
> P.S. Marking this as a bug.
>
> Best,
> Ihor
>




Re: org-attach-git don't automatically commit changes

2021-01-30 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> The default value of `org-attach-id-dir' is "data/", and if I evaluate
> `(expand-file-name org-attach-id-dir)' on my current node, it returns a
> wrong path to the attached folder. `org-attach-sync' only works for me
> if I set in `org-attach-git-commit' the variable like this:

Does it mean that your attachment folder is set in :DIR: property?

> #+begin_src emacs-lisp
> ;; ...
>   (let* ((dir (expand-file-name org-attach-id-dir))
> ;; ...
> #+end_src

I suspect that it is a leftover from the major changes in org-attach
when :DIR: property was introduced. The org-attach-git presumes that all
the attachments in current file are stored in sub-directories located
inside org-attach-id-dir, which is no longer guaranteed. In fact, the
existing approach to treat all the attachments to all headings in
current file as files in a single git repo cannot be used. I can see two
possible fixes:
1. Treat each attachment dir as individual git repo (breaking change for
   those who are using :ID: property to build the attachment dirs)
2. Treat attachment dirs defined by :DIR: property individually and
   leave the :ID:-defined attachments as they were treated before
   (inconsistent).

I am in favour of the first approach since I do not like the idea of
keeping all the attachments in the whole file in a single git repo.
I think feedback from other is needed to decide what we need to do here.

P.S. Marking this as a bug.

Best,
Ihor





Re: org-attach-git don't automatically commit changes

2021-01-30 Thread Juan Manuel Macías
Hi Ihor,

Ihor Radchenko  writes:

> Note that org "sees" changes in the attachment dir only when you use
> M-x org-attach command to manage the attachments. Directly changing the
> attachment directory will not be noticed. You can force org-mode to
> check for changes in attachment dir by running "C-c C-a z".

Thanks for the explanation. It seems that I had misinterpreted
what the manual said :-)

Anyway, in my case, it still doesn't work (?). I think it's for a path
problem. In `org-attach-git-commit' there is this variable:

#+begin_src emacs-lisp
;; ...
  (let* ((dir (expand-file-name org-attach-id-dir))
;; ...
#+end_src

The default value of `org-attach-id-dir' is "data/", and if I evaluate
`(expand-file-name org-attach-id-dir)' on my current node, it returns a
wrong path to the attached folder. `org-attach-sync' only works for me
if I set in `org-attach-git-commit' the variable like this:

#+begin_src emacs-lisp
;; ...
  (let* ((dir (org-attach-dir)) ;; <
;; ...
#+end_src

In that case, it does recognize the path correctly. Again, I don't
know if I'm missing something...

Best regards,

Juan Manuel 



Re: org-attach-git don't automatically commit changes

2021-01-29 Thread Ihor Radchenko
Juan Manuel Macías  writes:

> I don't see that org-attach "automatically commit changes when it sees
> them". Only when I run in the attached directory `M-:
> (org-attach-git-commit) RET' it works fine.

Note that org "sees" changes in the attachment dir only when you use
M-x org-attach command to manage the attachments. Directly changing the
attachment directory will not be noticed. You can force org-mode to
check for changes in attachment dir by running "C-c C-a z".

I guess using something like inotify might be a good new feature to
make org detect changes automatically.

Best,
Ihor




org-attach-git don't automatically commit changes

2021-01-29 Thread Juan Manuel Macías
Hi,

I don't know if this is a bug or if I am doing something wrong...

According to the manual:

#+begin_quote
If the directory attached to an outline node is a Git
repository, Org can be configured to automatically commit changes to
that repository when it sees them.

To make Org mode take care of versioning of attachments for you, add the
following to your Emacs config:

(require 'org-attach-git)
#+end_quote

I don't see that org-attach "automatically commit changes when it sees
them". Only when I run in the attached directory `M-:
(org-attach-git-commit) RET' it works fine.

`org-attach-after-change-hook' is set to `(org-attach-git-commit)'.

Regards,

Juan Manuel