mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(feat): rename file on title change (#1073)
Adds `org-roam-title-change-hook`. This now contains two functions: 1. `org-roam--update-links-on-title-change`: updates the link description of all files that link to the current file. 2. `org-roam--update-file-name-on-title-change`: updates the current buffer's filename to reflect the updated title.
This commit is contained in:
@ -461,22 +461,24 @@ connections, nil is returned."
|
||||
(org-roam-db--insert-headlines headlines))))
|
||||
|
||||
(defun org-roam-db--update-file (&optional file-path)
|
||||
"Update Org-roam cache for FILE-PATH."
|
||||
(when (org-roam--org-roam-file-p file-path)
|
||||
(let ((buf (or (and file-path
|
||||
(find-file-noselect file-path t))
|
||||
(current-buffer))))
|
||||
(with-current-buffer buf
|
||||
(org-with-wide-buffer
|
||||
(emacsql-with-transaction (org-roam-db)
|
||||
(org-roam-db--update-meta)
|
||||
(org-roam-db--update-tags)
|
||||
(org-roam-db--update-titles)
|
||||
(org-roam-db--update-refs)
|
||||
(when org-roam-enable-headline-linking
|
||||
(org-roam-db--update-headlines))
|
||||
(org-roam-db--update-links)))
|
||||
(org-roam-buffer--update-maybe :redisplay t)))))
|
||||
"Update Org-roam cache for FILE-PATH.
|
||||
If the file does not exist anymore, remove it from the cache.
|
||||
If the file exists, update the cache with information."
|
||||
(setq file-path (or file-path
|
||||
(buffer-file-name (buffer-base-buffer))))
|
||||
(cond ((not (file-exists-p file-path))
|
||||
(org-roam-db--clear-file file-path))
|
||||
((org-roam--org-roam-file-p file-path)
|
||||
(with-current-buffer (find-file-noselect file-path t)
|
||||
(org-with-wide-buffer
|
||||
(emacsql-with-transaction (org-roam-db)
|
||||
(org-roam-db--update-meta)
|
||||
(org-roam-db--update-tags)
|
||||
(org-roam-db--update-titles)
|
||||
(org-roam-db--update-refs)
|
||||
(when org-roam-enable-headline-linking
|
||||
(org-roam-db--update-headlines))
|
||||
(org-roam-db--update-links)))))))
|
||||
|
||||
(defun org-roam-db-build-cache (&optional force)
|
||||
"Build the cache for `org-roam-directory'.
|
||||
|
Reference in New Issue
Block a user