Re: Document-level properties incorrect and/or missing based on preceding blank lines and/or comments

2023-10-12 Thread Ihor Radchenko
"Tom Alexander"  writes:

> ### Issue 1
>
> Putting a comment before it makes the value for the foo property incorrect 
> (seems to be grabbing an earlier string slice):
> 
> ### Issue 2
>
> Putting any blank lines before it makes the foo property not appear in 
> org-data at all
> ```
>
> :PROPERTIES:
> :FOO:bar
> :END:
> ```

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a52c74e96
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fba3fd56c

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



Document-level properties incorrect and/or missing based on preceding blank lines and/or comments

2023-10-11 Thread Tom Alexander
Emacs version: Emacs 29.1
Org-mode version: e1569918cc94253650781e83a09695739c93352f  (latest in git)

The org-mode syntax document[1] says that property drawers can exist in the 
zeroth section with the format:
```
BEGINNING-OF-FILE
BLANK-LINES
COMMENT
PROPERTYDRAWER
```

Using this test document:
```
:PROPERTIES:
:FOO:bar
:END:
```

I correctly get the foo property in the top-level org-data
```
(org-data
(:standard-properties
  [1 1 1 33 33 0 nil org-data nil nil nil 32 33 nil # nil nil 
nil]
  :path nil :FOO "bar" :CATEGORY nil)
```

But now there are two separate issues:

### Issue 1

Putting a comment before it makes the value for the foo property incorrect 
(seems to be grabbing an earlier string slice):
```
# baz
:PROPERTIES:
:FOO:bar
:END:
```

```
(org-data
(:standard-properties
  [1 1 1 39 39 0 nil org-data nil nil nil 38 39 nil # nil nil 
nil]
  :path nil :FOO "O: " :CATEGORY nil)
```

Interestingly, looking farther down the AST, the value for foo is properly set 
in the node-property, just not the org-data:
```
(node-property
(:standard-properties
 [20 20 nil nil 33 0 nil node-property nil nil nil nil nil nil # nil nil #2]
 :key "FOO" :value "bar"))
```

### Issue 2

Putting any blank lines before it makes the foo property not appear in org-data 
at all
```

:PROPERTIES:
:FOO:bar
:END:
```

```
(org-data
(:standard-properties
  [1 1 2 34 34 0 nil org-data nil nil nil 4 34 nil # nil nil 
nil]
  :path nil :CATEGORY nil)
```

Looking farther down the AST it seems the property-drawer became a regular 
drawer


[1] https://orgmode.org/worg/org-syntax.html#Property_Drawers

--
Tom Alexander
pgp: https://fizz.buzz/pgp.asc