Closed Hxppdv closed 2 years ago
Having read through this, my inclination is against merging this change without further planning[^1], but I've pushed a change that re-introduces a hook I accidentally deleted which is called when you do a rename. org-roam-rewrite-node-renamed-hook
should be the extension point you were looking for. :)
;; Warning--not tested.
(defun my-rename-node-file-handler ()
(when-let* ((node (org-roam-node-at-point))
(file (org-roam-node-file node))
(new-name
;; However you want to compute this. Probably something like:
(concat (org-roam-node-slug node) ".org"))
(dest (expand-file-name new-name (file-name-directory file))))
(magit-file-rename file dest)
;; Tell org-roam that files changed on disk.
(org-roam-db-sync)))
(add-hook 'org-roam-rewrite-node-renamed-hook #'my-rename-node-file-handler)
[^1]: The name of a node is determined by its capture template, which is not necessarily a slug (human-readable title). It's not unusual to use opaque timestamps or UUIDs as file names in org-roam since you wouldn't normally browse notes in the filesystem directly.
Thank you for the suggestion. This is just a test feature that only fits a specific use case, and I'm aware of a lot of possible issues, I just don't have a good way to take into account various use cases without making a lot of changes. Maybe I can spend more time improving it afterwards, I'll close pr for now, thanks.
Hi there! Would you mind describing this changeset and what the use case is?