From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Visher Subject: Re: File Scoped Properties? Date: Tue, 24 Mar 2020 20:57:15 -0400 Message-ID: References: <87mu8ugemp.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a402e705a1a35b39" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:60193) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGuMm-0005Wv-Q8 for emacs-orgmode@gnu.org; Tue, 24 Mar 2020 20:57:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGuMk-0003oy-SK for emacs-orgmode@gnu.org; Tue, 24 Mar 2020 20:57:56 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:39889) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGuMk-0003ns-JC for emacs-orgmode@gnu.org; Tue, 24 Mar 2020 20:57:54 -0400 Received: by mail-wr1-x434.google.com with SMTP id p10so921190wrt.6 for ; Tue, 24 Mar 2020 17:57:54 -0700 (PDT) In-Reply-To: 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: "Fraga, Eric" Cc: Emacs Org Mode mailing list --000000000000a402e705a1a35b39 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 9, 2020 at 9:24 AM Tim Visher wrote: > On Fri, Mar 6, 2020 at 9:09 AM Tim Visher wrote: > >> Thanks for the response, Eric. :) >> >> On Fri, Mar 6, 2020 at 1:51 AM Fraga, Eric wrote: >> >>> On Thursday, 5 Mar 2020 at 10:28, Tim Visher wrote: >>> > I _am_ able to get it to work by adding a file local variable like >>> > >>> > ``` >>> > # Local Variables: >>> > # org-attach-id-dir: "~/.foo/data" >>> > # End: >>> > ``` >>> > >>> > but then whenever I open the file it tells me it's possibly not safe >>> to set >>> > that. >>> >>> You've already received a more org-ish response but I'll give you an >>> Emacs response to this part of your post: Emacs is simply making sure >>> you are aware that a variable is being set when visiting a file. >>> >> >> My question was more around why I had to do it at all since based on my >> reading of the manual it seems like I should've been able to do this wit= h >> some kind of file-wide property. Specifically, I've never been able to w= rap >> my head around `(info "(org) Property Syntax")`. >> >> "Properties are key=E2=80=93value pairs. When they are associated with a= single >> entry or with a tree=E2=80=A6," for instance, seems to imply by "When th= ey are >> associated with a single entry=E2=80=A6" that they can be associated wit= h all the >> entries (or a particular tree or node). >> >> Anyway, I think between you and Gustav I finally have this sorted. >> >> 1. To set properties at the top level of a file you need to use the >> `#+PROPERTY: ` syntax. I've been tryi= ng to >> figure out how I misinterpreted that in the past and I _think_ it was >> because I assumed that the `#+PROPERTY` was actually `#+` a= s in >> `#+DIR` rather than `#+PROPERTY: DIR`. It looks like to set a file lo= cal >> property in an org file you _must_ (at least on 9.3 or earlier) use t= he >> `#+PROPERTY: ` syntax. >> >> 2. Even then by default org-attach property inheritance is set to >> `'selective` and `org-use-property-inheritance` is set to off. I've n= ow >> customized `org-use-property-inheritance` to `'("DIR")` which I belie= ve >> says that I consider the `DIR` property to be a possible candidate fo= r >> inheritance and no others. I'm a little concerned about performance >> implications as the manual gives me all kinds of scary warnings but w= e'll >> see about that. >> >> Anyway this appears to work as I expect it to. I don't have to set a >> file-local variable to anything. I'm using org properties. And >> `org-attach-dir` now returns the proper directory for this file. >> >> Thanks all! If you think I'm still misunderstanding something please >> correct me. :) >> > > I'll go ahead and correct myself. (=EF=BC=8D=E2=80=B8=E1=83=9A) > > It turns out that I wasn't understanding what the `DIR` property actually > does. If `DIR` is set, it makes that the attachment directory, period. In > other words it's different than the default `./data/` prefix directory in > that ID paths are not then suffixed upon the end of it like > `./data/XX/XXXXX-XXX-XXX/` for each entry. Instead, if you have `DIR` set= , > that headings attachment directory =3D=3D `DIR`. > > So the way to change the attachment directory prefix is just not to mess > with `DIR` at all. Instead, you must set the variable `org-attach-id-dir`= , > and if you want that to be local to a file the natural way to do that is > with a file-local variable. > > ``` > # Local Variables: > # org-attach-id-dir: "~/.foo/data" > # End: > ``` > > Cheers. :) > This ended up producing more of a learning opportunity than I had initially suspected and I wrote it up on my blog. In case anyone else is interested in the details: https://blog.twonegatives.com/post/613474532727095296/how-to-set-the-attach= -directory-prefix-for Happy Org! --000000000000a402e705a1a35b39 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Mar 9, 2020 at 9:24 AM Tim Visher= <tim.visher@gmail.com> w= rote:
On Fri, Mar 6, 2020 at 9= :09 AM Tim Visher <tim.visher@gmail.com> wrote:
T= hanks for the response, Eric. :)

On Fr= i, Mar 6, 2020 at 1:51 AM Fraga, Eric <e.fraga@ucl.ac.uk> wrote:
On Thurs= day,=C2=A0 5 Mar 2020 at 10:28, Tim Visher wrote:
> I _am_ able to get it to work by adding a file local variable like
>
> ```
> # Local Variables:
> # org-attach-id-dir: "~/.foo/data"
> # End:
> ```
>
> but then whenever I open the file it tells me it's possibly not sa= fe to set
> that.

You've already received a more org-ish response but I'll give you a= n
Emacs response to this part of your post: Emacs is simply making sure
you are aware that a variable is being set when visiting a file.

My question was more around why I had to do it at= all since based on my reading of the manual it seems like I should've = been able to do this with some kind of file-wide property. Specifically, I&= #39;ve never been able to wrap my head around `(info "(org) Property S= yntax")`.

"Properties are key=E2=80= =93value pairs. When they are associated with a single entry or with a tree= =E2=80=A6," for instance, seems to imply by "When they are associ= ated with a single entry=E2=80=A6" that they can be associated with al= l the entries (or a particular tree or node).

Anyw= ay, I think between you and Gustav I finally have this sorted.
  • To set properties at the top level of a file you need to use the `#+P= ROPERTY: <PROPERTY_NAME> <PROPERTY_VALUE>` syntax. I've bee= n trying to figure out how I misinterpreted that in the past and I _think_ = it was because I assumed that the `#+PROPERTY` was actually `#+<PROPERTY= >` as in `#+DIR` rather than `#+PROPERTY: DIR`. It looks like to set a f= ile local property in an org file you _must_ (at least on 9.3 or earlier) u= se the `#+PROPERTY: <PROPERTY_NAME> <PROPERTY_VALUE>` syntax.
  • Even then by default org-attach property inheritance is set = to `'selective` and `org-use-property-inheritance` is set to off. I'= ;ve now customized `org-use-property-inheritance` to `'("DIR"= )` which I believe says that I consider the `DIR` property to be a possible= candidate for inheritance and no others. I'm a little concerned about = performance implications as the manual gives me all kinds of scary warnings= but we'll see about that.
  • Anyway this appears to work as= I expect it to. I don't have to set a file-local variable to anything.= I'm using org properties. And `org-attach-dir` now returns the proper = directory for this file.

    Thanks all! If you = think I'm still misunderstanding something please correct me. :)
    <= /div>

    I'll go ahead and correct m= yself.=C2=A0(=EF=BC=8D=E2=80=B8=E1=83=9A)

    It turns= out that I wasn't understanding what the `DIR` property actually does.= If `DIR` is set, it makes that the attachment directory, period. In other = words it's different than the default `./data/` prefix directory in tha= t ID paths are not then suffixed upon the end of it like `./data/XX/XXXXX-X= XX-XXX/` for each entry. Instead, if you have `DIR` set, that headings atta= chment directory =3D=3D `DIR`.

    So the way to chang= e the attachment directory prefix is just not to mess with `DIR` at all. In= stead, you must set the variable `org-attach-id-dir`, and if you want that = to be local to a file the natural way to do that is with a file-local varia= ble.

    ```
    # Local Variables:
    # org-att= ach-id-dir: "~/.foo/data"
    # End:
    ```
    <= br>
    Cheers. :)

    = This ended up producing more of a learning opportunity than I had initially= suspected and I wrote it up on my blog. In case anyone else is interested = in the details:=C2=A0https://blog.twonega= tives.com/post/613474532727095296/how-to-set-the-attach-directory-prefix-fo= r

    Happy Org!=C2=A0
    --000000000000a402e705a1a35b39--