mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): fix link outline extraction (#1085)
This commit is contained in:
84
org-roam.el
84
org-roam.el
@ -581,48 +581,48 @@ it as FILE-PATH."
|
|||||||
(require 'org-ref nil t)
|
(require 'org-ref nil t)
|
||||||
(unless file-path
|
(unless file-path
|
||||||
(setq file-path (file-truename (buffer-file-name))))
|
(setq file-path (file-truename (buffer-file-name))))
|
||||||
(let (links)
|
(save-excursion
|
||||||
(org-element-map (org-element-parse-buffer) 'link
|
(let (links)
|
||||||
(lambda (link)
|
(org-element-map (org-element-parse-buffer) 'link
|
||||||
(let* ((type (org-element-property :type link))
|
(lambda (link)
|
||||||
(path (org-element-property :path link))
|
(goto-char (org-element-property :begin link))
|
||||||
(element (save-excursion
|
(let* ((type (org-element-property :type link))
|
||||||
(goto-char (org-element-property :begin link))
|
(path (org-element-property :path link))
|
||||||
(org-element-at-point)))
|
(element (org-element-at-point))
|
||||||
(begin (or (org-element-property :content-begin element)
|
(begin (or (org-element-property :content-begin element)
|
||||||
(org-element-property :begin element)))
|
(org-element-property :begin element)))
|
||||||
(content (or (org-element-property :raw-value element)
|
(content (or (org-element-property :raw-value element)
|
||||||
(buffer-substring-no-properties
|
(buffer-substring-no-properties
|
||||||
begin
|
begin
|
||||||
(or (org-element-property :content-end element)
|
(or (org-element-property :content-end element)
|
||||||
(org-element-property :end element)))))
|
(org-element-property :end element)))))
|
||||||
(content (string-trim content))
|
(content (string-trim content))
|
||||||
(content (org-roam--expand-links content file-path))
|
(content (org-roam--expand-links content file-path))
|
||||||
(properties (list :outline (mapcar (lambda (path)
|
(properties (list :outline (mapcar (lambda (path)
|
||||||
(org-roam--expand-links path file-path))
|
(org-roam--expand-links path file-path))
|
||||||
(org-roam--get-outline-path))
|
(org-roam--get-outline-path))
|
||||||
:content content
|
:content content
|
||||||
:point begin))
|
:point begin))
|
||||||
(names (pcase type
|
(names (pcase type
|
||||||
("id"
|
("id"
|
||||||
(list (car (org-roam-id-find path))))
|
(list (car (org-roam-id-find path))))
|
||||||
((pred (lambda (typ)
|
((pred (lambda (typ)
|
||||||
(and (boundp 'org-ref-cite-types)
|
(and (boundp 'org-ref-cite-types)
|
||||||
(-contains? org-ref-cite-types typ))))
|
(-contains? org-ref-cite-types typ))))
|
||||||
(setq type "cite")
|
(setq type "cite")
|
||||||
(org-ref-split-and-strip-string path))
|
(org-ref-split-and-strip-string path))
|
||||||
("fuzzy" (list path))
|
("fuzzy" (list path))
|
||||||
(_ (if (file-remote-p path)
|
(_ (if (file-remote-p path)
|
||||||
(list path)
|
(list path)
|
||||||
(let ((file-maybe (file-truename
|
(let ((file-maybe (file-truename
|
||||||
(expand-file-name path (file-name-directory file-path)))))
|
(expand-file-name path (file-name-directory file-path)))))
|
||||||
(if (f-exists? file-maybe)
|
(if (f-exists? file-maybe)
|
||||||
(list file-maybe)
|
(list file-maybe)
|
||||||
(list path))))))))
|
(list path))))))))
|
||||||
(dolist (name names)
|
(dolist (name names)
|
||||||
(when name
|
(when name
|
||||||
(push (vector file-path name type properties) links))))))
|
(push (vector file-path name type properties) links))))))
|
||||||
links))
|
links)))
|
||||||
|
|
||||||
(defun org-roam--extract-headlines (&optional file-path)
|
(defun org-roam--extract-headlines (&optional file-path)
|
||||||
"Extract all headlines with IDs within the current buffer.
|
"Extract all headlines with IDs within the current buffer.
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
(pcase (benchmark-run 1 (org-roam-db-build-cache t))
|
(pcase (benchmark-run 1 (org-roam-db-build-cache t))
|
||||||
(`(,time ,gcs ,time-in-gc)
|
(`(,time ,gcs ,time-in-gc)
|
||||||
(message "Elapsed time: %fs (%fs in %d GCs)" time time-in-gc gcs)
|
(message "Elapsed time: %fs (%fs in %d GCs)" time time-in-gc gcs)
|
||||||
(expect time :to-be-less-than 70))))
|
(expect time :to-be-less-than 90))))
|
||||||
(it "builds quickly without change"
|
(it "builds quickly without change"
|
||||||
(pcase (benchmark-run 1 (org-roam-db-build-cache))
|
(pcase (benchmark-run 1 (org-roam-db-build-cache))
|
||||||
(`(,time ,gcs ,time-in-gc)
|
(`(,time ,gcs ,time-in-gc)
|
||||||
|
Reference in New Issue
Block a user