Refactoring a header within a current node into a separate file-node is a very common action for me. The function org-roam-extract-subtree seems built for exactly this purpose. However, I have been encountering problems or unexpected behaviors. I will add to this thread as I observe and enumerate all the issues. Meanwhile, here is the first issue Here is the list:
First paragraph of subtree is treated strangely. The first paragraph is placed one line above #+title: in the newly-created file-node.
What template, if any, does the newly-created file-node use? For example, Iād like to insert :CREATED: in the PROPERTIES drawer of the file-node if subheader doesnāt already have this property. If subheader already has this property, Iād like to insert :MODIFIED:.
Is it possible to open the newly-created file-node in a new window (perhaps a preference variable whose value can be set by the user)? One reason I want to see it in a new window is to confirm that the file has indeed been created with the appropriate content. Often what is being refactored is precious text. Some visual feedback confirming that it has been saved in its full form can be reassuring.
When extracting a subtree from a non-roam org file, Iād like it to create the node-file in my org-roam-directory. Currently, it seems to create the node-file in the directory in which the original file is found. And, there is some strange behavior after the extraction (I havenāt fully characterized the behavior but something is off (sorry for that vague descriptionā¦ Iāll add detail when I get the chance)).
I believe Issue #1 is a problem with org-roam-promote-entire-buffer. To recreate, follow these steps:
a. Create a new .org file in your org-roam-directory and insert the following text:
* asfasdfasfsdasdfa
:PROPERTIES:
:CREATED: [2022-02-26 Sat 13:24]
:END:
asdfasdfasdggbvbx
fsdfsfsfs
I am writing my own version of extract-subtree. Below is a version that appears to address Issue 4 and, in a clunky way, Issue 1. I took chunks of code from the current version of org-roam-extract-subtree from Github. I will post again when I eventually address Issues 3 and 4. The end-product is a non-elegant patched-up solution ā good enough, I hope, until the real org-roam-extract-subtree is fixed in a future release.
Sorry for the delay on the review @jmay, I think there are a couple of issues that are inherited from the original code, Iāll write a longform comment on the issue today.