mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
fix id retrieval resulting in infinite loop
Use custom `org-roam-up-heading-or-point-min` to prevent infinite looping during ID retrieval. Fixes #1452.
This commit is contained in:
@ -47,6 +47,7 @@
|
|||||||
(defvar org-roam-verbose)
|
(defvar org-roam-verbose)
|
||||||
(defvar org-agenda-files)
|
(defvar org-agenda-files)
|
||||||
|
|
||||||
|
(declare-function org-roam-id-at-point "org-roam")
|
||||||
(declare-function org-roam--org-roam-file-p "org-roam")
|
(declare-function org-roam--org-roam-file-p "org-roam")
|
||||||
(declare-function org-roam--list-all-files "org-roam")
|
(declare-function org-roam--list-all-files "org-roam")
|
||||||
(declare-function org-roam-node-at-point "org-roam-node")
|
(declare-function org-roam-node-at-point "org-roam-node")
|
||||||
@ -235,6 +236,17 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
|||||||
:values $v1]
|
:values $v1]
|
||||||
(list (vector file hash)))))
|
(list (vector file hash)))))
|
||||||
|
|
||||||
|
(defun org-roam-id-at-point ()
|
||||||
|
"Return the ID at point, if any.
|
||||||
|
Recursively traverses up the headline tree to find the
|
||||||
|
first encapsulating ID."
|
||||||
|
(let (source)
|
||||||
|
(org-with-wide-buffer
|
||||||
|
(while (and (not (setq source (org-id-get)))
|
||||||
|
(not (bobp)))
|
||||||
|
(org-roam-up-heading-or-point-min)))
|
||||||
|
source))
|
||||||
|
|
||||||
(defun org-roam-db-get-scheduled-time ()
|
(defun org-roam-db-get-scheduled-time ()
|
||||||
"Return the scheduled time at point in ISO8601 format."
|
"Return the scheduled time at point in ISO8601 format."
|
||||||
(when-let ((time (org-get-scheduled-time (point))))
|
(when-let ((time (org-get-scheduled-time (point))))
|
||||||
@ -376,11 +388,7 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
|||||||
(type (org-element-property :type link))
|
(type (org-element-property :type link))
|
||||||
(dest (org-element-property :path link))
|
(dest (org-element-property :path link))
|
||||||
(properties (list :outline (org-get-outline-path)))
|
(properties (list :outline (org-get-outline-path)))
|
||||||
source)
|
(source (org-roam-id-at-point)))
|
||||||
(save-excursion
|
|
||||||
(while (and (not (setq source (org-id-get)))
|
|
||||||
(not (bobp)))
|
|
||||||
(org-up-heading-or-point-min)))
|
|
||||||
(when source
|
(when source
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into links
|
[:insert :into links
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'org-roam-macs))
|
(require 'org-roam-macs))
|
||||||
|
|
||||||
|
(declare-function org-roam-id-at-point "org-roam")
|
||||||
(defvar org-roam-mode-sections)
|
(defvar org-roam-mode-sections)
|
||||||
|
|
||||||
;;; Section
|
;;; Section
|
||||||
@ -117,12 +118,8 @@ nodes."
|
|||||||
If ASSERT, throw an error."
|
If ASSERT, throw an error."
|
||||||
(if-let ((node (magit-section-case
|
(if-let ((node (magit-section-case
|
||||||
(org-roam-node-section (oref it node))
|
(org-roam-node-section (oref it node))
|
||||||
(t (let (id)
|
(t (when-let ((id (org-roam-id-at-point)))
|
||||||
(org-with-wide-buffer
|
(org-roam-populate (org-roam-node-create :id id)))))))
|
||||||
(while (and (not (setq id (org-id-get)))
|
|
||||||
(not (bobp)))
|
|
||||||
(org-up-heading-or-point-min))
|
|
||||||
(org-roam-populate (org-roam-node-create :id id))))))))
|
|
||||||
node
|
node
|
||||||
(when assert
|
(when assert
|
||||||
(user-error "No node at point"))))
|
(user-error "No node at point"))))
|
||||||
|
12
org-roam.el
12
org-roam.el
@ -161,6 +161,18 @@ This face is used on the region target by `org-roam-insertion'
|
|||||||
during an `org-roam-capture'."
|
during an `org-roam-capture'."
|
||||||
:group 'org-roam-faces)
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
;;;; ID Utilities
|
||||||
|
(defun org-roam-id-at-point ()
|
||||||
|
"Return the ID at point, if any.
|
||||||
|
Recursively traverses up the headline tree to find the
|
||||||
|
first encapsulating ID."
|
||||||
|
(let (source)
|
||||||
|
(org-with-wide-buffer
|
||||||
|
(while (and (not (setq source (org-id-get)))
|
||||||
|
(not (bobp)))
|
||||||
|
(org-roam-up-heading-or-point-min)))
|
||||||
|
source))
|
||||||
|
|
||||||
;;;; File functions and predicates
|
;;;; File functions and predicates
|
||||||
(defun org-roam--file-name-extension (filename)
|
(defun org-roam--file-name-extension (filename)
|
||||||
"Return file name extension for FILENAME.
|
"Return file name extension for FILENAME.
|
||||||
|
Reference in New Issue
Block a user