mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): Fix chronology issue between renaming notes and updating links (#1517)
This commit is contained in:
@ -227,7 +227,8 @@ Template string :\n%v")
|
|||||||
:head "#+title: ${title}\n#+roam_key: ${ref}"
|
:head "#+title: ${title}\n#+roam_key: ${ref}"
|
||||||
:unnarrowed t))
|
:unnarrowed t))
|
||||||
"The Org-roam templates used during a capture from the roam-ref protocol.
|
"The Org-roam templates used during a capture from the roam-ref protocol.
|
||||||
Details on how to specify for the template is given in `org-roam-capture-templates'."
|
Details on how to specify for the template is given in
|
||||||
|
`org-roam-capture-templates'."
|
||||||
:group 'org-roam
|
:group 'org-roam
|
||||||
;; Adapted from `org-capture-templates'
|
;; Adapted from `org-capture-templates'
|
||||||
:type
|
:type
|
||||||
|
@ -101,7 +101,8 @@ so that multi-directories are updated.")
|
|||||||
Update the database immediately upon file changes.
|
Update the database immediately upon file changes.
|
||||||
|
|
||||||
`idle-timer'
|
`idle-timer'
|
||||||
Updates the database if dirty, if Emacs idles for `org-roam-db-update-idle-seconds'."
|
Updates the database if dirty, if Emacs idles for
|
||||||
|
`org-roam-db-update-idle-seconds'."
|
||||||
:type '(choice (const :tag "idle-timer" idle-timer)
|
:type '(choice (const :tag "idle-timer" idle-timer)
|
||||||
(const :tag "immediate" immediate))
|
(const :tag "immediate" immediate))
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
@ -67,7 +67,7 @@ during an `org-roam-capture'."
|
|||||||
|
|
||||||
(defface org-roam-dailies-calendar-note
|
(defface org-roam-dailies-calendar-note
|
||||||
'((t :inherit (org-roam-link) :underline nil))
|
'((t :inherit (org-roam-link) :underline nil))
|
||||||
"Face for dates with a daily-note in the calendar"
|
"Face for dates with a daily-note in the calendar."
|
||||||
:group 'org-roam-faces)
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
;;; _
|
;;; _
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
(declare-function org-roam-format-link "org-roam")
|
(declare-function org-roam-format-link "org-roam")
|
||||||
|
|
||||||
(defcustom org-roam-link-auto-replace t
|
(defcustom org-roam-link-auto-replace t
|
||||||
"When non-nil, replace Org-roam's roam links with file or id links whenever possible."
|
"When non-nil, replace Org-roam's roam links with file/id equivalents."
|
||||||
:group 'org-roam
|
:group 'org-roam
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
|
31
org-roam.el
31
org-roam.el
@ -259,7 +259,8 @@ Function should return a filename string based on title."
|
|||||||
)
|
)
|
||||||
"Characters to trim from Unicode normalization for slug.
|
"Characters to trim from Unicode normalization for slug.
|
||||||
|
|
||||||
By default, the characters are specified to remove Diacritical Marks from the Latin alphabet."
|
By default, the characters are specified to remove Diacritical
|
||||||
|
Marks from the Latin alphabet."
|
||||||
:type '(repeat character)
|
:type '(repeat character)
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
@ -305,7 +306,9 @@ The currently supported symbols are:
|
|||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
(defcustom org-roam-enable-headline-linking t
|
(defcustom org-roam-enable-headline-linking t
|
||||||
"Enable linking to headlines, which includes automatic :ID: creation and scanning of :ID:s for org-roam database."
|
"Enable linking to headlines.
|
||||||
|
This includes automatic :ID: creation and scanning of :ID:s for
|
||||||
|
org-roam database."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
@ -994,13 +997,28 @@ Return nil if the file does not exist."
|
|||||||
(file (plist-get (cdr (assoc ref completions)) :path)))
|
(file (plist-get (cdr (assoc ref completions)) :path)))
|
||||||
(org-roam--find-file file)))
|
(org-roam--find-file file)))
|
||||||
|
|
||||||
|
(defun org-roam--org-roam-buffer-p (&optional buffer)
|
||||||
|
"Return t if BUFFER is accessing a part of Org-roam system.
|
||||||
|
If BUFFER is not specified, use the current buffer."
|
||||||
|
(let ((buffer (or buffer (current-buffer)))
|
||||||
|
path)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(and (derived-mode-p 'org-mode)
|
||||||
|
(setq path (buffer-file-name (buffer-base-buffer)))
|
||||||
|
(org-roam--org-roam-file-p path)))))
|
||||||
|
|
||||||
(defun org-roam--get-roam-buffers ()
|
(defun org-roam--get-roam-buffers ()
|
||||||
"Return a list of buffers that are Org-roam files."
|
"Return a list of buffers that are Org-roam files."
|
||||||
(--filter (and (with-current-buffer it (derived-mode-p 'org-mode))
|
(--filter (org-roam--org-roam-buffer-p it)
|
||||||
(buffer-file-name it)
|
|
||||||
(org-roam--org-roam-file-p (buffer-file-name it)))
|
|
||||||
(buffer-list)))
|
(buffer-list)))
|
||||||
|
|
||||||
|
(defun org-roam--save-buffers (&optional ask update)
|
||||||
|
"Save all Org-roam buffers.
|
||||||
|
When ASK is non-nil, ask whether the buffers should be saved.
|
||||||
|
When UPDATE is non-nil, update the database after."
|
||||||
|
(save-some-buffers (not ask) #'org-roam--org-roam-buffer-p)
|
||||||
|
(when update (org-roam-db-update)))
|
||||||
|
|
||||||
;;; org-roam-backlinks-mode
|
;;; org-roam-backlinks-mode
|
||||||
(define-minor-mode org-roam-backlinks-mode
|
(define-minor-mode org-roam-backlinks-mode
|
||||||
"Minor mode for the `org-roam-buffer'.
|
"Minor mode for the `org-roam-buffer'.
|
||||||
@ -1390,7 +1408,7 @@ OLD-TITLE, and replace the link descriptions with the NEW-TITLE
|
|||||||
if applicable.
|
if applicable.
|
||||||
|
|
||||||
To be added to `org-roam-title-change-hook'."
|
To be added to `org-roam-title-change-hook'."
|
||||||
(let* ((current-path (buffer-file-name))
|
(let* ((current-path (buffer-file-name (buffer-base-buffer)))
|
||||||
(files-affected (org-roam-db-query [:select :distinct [source]
|
(files-affected (org-roam-db-query [:select :distinct [source]
|
||||||
:from links
|
:from links
|
||||||
:where (= dest $s1)]
|
:where (= dest $s1)]
|
||||||
@ -1407,6 +1425,7 @@ current filename, the new slug is computed with NEW-TITLE, and
|
|||||||
that portion of the filename is renamed.
|
that portion of the filename is renamed.
|
||||||
|
|
||||||
To be added to `org-roam-title-change-hook'."
|
To be added to `org-roam-title-change-hook'."
|
||||||
|
(org-roam--save-buffers)
|
||||||
(when org-roam-rename-file-on-title-change
|
(when org-roam-rename-file-on-title-change
|
||||||
(let* ((old-slug (funcall org-roam-title-to-slug-function old-title))
|
(let* ((old-slug (funcall org-roam-title-to-slug-function old-title))
|
||||||
(file (buffer-file-name (buffer-base-buffer)))
|
(file (buffer-file-name (buffer-base-buffer)))
|
||||||
|
Reference in New Issue
Block a user