(fix)node: properly expand extraction file path (#2097)

Previously, the file-path of the new node in `org-roam-extract-subtree'
was incorrect in many circumstances.  Expanding w.r.t. the initial
prompt directory (ie, `org-roam-directory') fixes that
This commit is contained in:
Ingo Lohmar
2022-02-20 04:12:53 +01:00
committed by GitHub
parent b163c900b8
commit d20480bb8d

View File

@ -131,7 +131,8 @@ It takes a single argument REF, which is a propertized string."
:type 'boolean) :type 'boolean)
(defcustom org-roam-extract-new-file-path "%<%Y%m%d%H%M%S>-${slug}.org" (defcustom org-roam-extract-new-file-path "%<%Y%m%d%H%M%S>-${slug}.org"
"The file path to use when a node is extracted to its own file." "The file path template (relative to `org-roam-directory') to use
when a node is extracted to its own file."
:group 'org-roam :group 'org-roam
:type 'string) :type 'string)
@ -926,8 +927,11 @@ If region is active, then use it instead of the node at point."
(t (let ((r (read-from-minibuffer (format "%s: " key) default-val))) (t (let ((r (read-from-minibuffer (format "%s: " key) default-val)))
(plist-put template-info ksym r) (plist-put template-info ksym r)
r))))))) r)))))))
(file-path (read-file-name "Extract node to: " (file-path
(file-name-as-directory org-roam-directory) template nil template))) (expand-file-name
(read-file-name "Extract node to: "
(file-name-as-directory org-roam-directory) template nil template)
org-roam-directory)))
(when (file-exists-p file-path) (when (file-exists-p file-path)
(user-error "%s exists. Aborting" file-path)) (user-error "%s exists. Aborting" file-path))
(org-cut-subtree) (org-cut-subtree)