Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

PROPERTIES drawer is deleted before inserting snippet #89

Open stefan2904 opened 1 year ago

stefan2904 commented 1 year ago

When I expand a snippet, the PROPERTIES drawer is gone (even when :props: is not set).

Behavior:

1) Create yankpad snippet with PROPERTIES (as part of snippet), without the props tag (or the remove-props flag) 2) yankpad-reaload and expand that snippet

Expected:

3) Snippet gets expanded including the PROPERTIES drawer

Actual:

3) Snippet gets expanded & inserted, but without the PROPERTIES drawer


I have a yankpad file like this:

* org-mode
** yankpad testing

*** Some snippet with properties 

\** Foo heading
:PROPERTIES:
:FOO: bla1
:bar:  bla2
:END:

no properties.

\** Bar heading
:properties:
:bar2:   bla
:end:

also no properties here.

When I expand it, I get:

** Foo heading

no properties.

** Bar heading

also no properties here.

If I inspect the value of yankpad--active-snippets:

(("Some snippet with properties" nil nil "\\** Foo heading\n\n\nno properties.\n\n\\** Bar heading\n\n\nalso no properties here." nil)

stefan2904 commented 1 year ago

Hm, I think I got a bit confused here.

It works when I add the snippet directly in the category subtree:

* org-mode

** Some snippet with properties 

\** Foo heading
:PROPERTIES:
:FOO: bla1
:bar:  bla2
:END:

no properties.

\** Bar heading
:PROPERTIES:
:bar2:   bla
:END:

also no properties here.

But according to the README, organizing of snippets in subtrees should be possible:

You can organize your snippets inside a category by using subtrees, like
this one. Only headings without children are considered as snippets.

But it does not, since those headings are then parsed with remove-props set:

https://github.com/Kungsgeten/yankpad/blob/927e6d26956ac7219b8a69d641acf486854fba16/yankpad.el#L647

m2habert commented 2 days ago

workaround: https://github.com/Kungsgeten/yankpad/issues/78#issuecomment-864444040

Drawers are preserved all right this way.