Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat)db: include self in outline #1756

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions org-roam-db.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
;;
;;; Code:
(require 'org-roam)
(defvar org-outline-path-cache)

;;; Options
(defcustom org-roam-db-location (expand-file-name "org-roam.db" user-emacs-directory)
Expand Down Expand Up @@ -312,7 +313,7 @@ If UPDATE-P is non-nil, first remove the file in the database."
(tags org-file-tags)
(refs (org-entry-get (point) "ROAM_REFS"))
(properties (org-entry-properties))
(olp (org-get-outline-path)))
(olp nil))
(org-roam-db-query!
(lambda (err)
(lwarn 'org-roam :warning "%s for %s (%s) in %s"
Expand Down Expand Up @@ -371,7 +372,7 @@ If UPDATE-P is non-nil, first remove the file in the database."
(1+ (- (point) (line-beginning-position))))
(cl-return-from org-roam-db-insert-node-data))))
(properties (org-entry-properties))
(olp (org-get-outline-path))
(olp (org-get-outline-path nil 'use-cache))
(title (org-link-display-format title)))
(org-roam-db-query!
(lambda (err)
Expand Down Expand Up @@ -425,7 +426,10 @@ If UPDATE-P is non-nil, first remove the file in the database."
(goto-char (org-element-property :begin link))
(let ((type (org-element-property :type link))
(path (org-element-property :path link))
(properties (list :outline (org-get-outline-path)))
(properties (list :outline (condition-case nil
;; This can error if link is not under any headline
(org-get-outline-path 'with-self 'use-cache)
(t nil))))
(source (org-roam-id-at-point)))
;; For Org-ref links, we need to split the path into the cite keys
(when (and (boundp 'org-ref-cite-types)
Expand Down Expand Up @@ -514,11 +518,13 @@ If the file exists, update the cache with information."
(org-roam-db-clear-file)
(org-roam-db-insert-file)
(org-roam-db-insert-file-node)
(setq org-outline-path-cache nil)
(org-roam-db-map-nodes
(list #'org-roam-db-insert-node-data
#'org-roam-db-insert-aliases
#'org-roam-db-insert-tags
#'org-roam-db-insert-refs))
(setq org-outline-path-cache nil)
(org-roam-db-map-links
(list #'org-roam-db-insert-link)))))))

Expand Down