Add backlink lookups

This commit is contained in:
Correl Roush 2022-06-11 21:17:07 -04:00
parent 5663580322
commit 4ca2a56b7c
2 changed files with 20 additions and 1 deletions

View file

@ -9,7 +9,7 @@
;; Version: 0.0.1 ;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp ;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/correlr/org-roam-export ;; Homepage: https://github.com/correlr/org-roam-export
;; Package-Requires: ((emacs "24.3") org-roam) ;; Package-Requires: ((emacs "24.3") org-roam s seq)
;; ;;
;; This file is not part of GNU Emacs. ;; This file is not part of GNU Emacs.
;; ;;
@ -20,6 +20,19 @@
;;; Code: ;;; Code:
(require 'org-roam) (require 'org-roam)
(require 's)
(require 'seq)
(defun org-roam-export-backlink-title (backlink)
"Get exportable title of BACKLINK."
(s-join " > "
(seq-concatenate 'list
(list (org-roam-node-title (org-roam-backlink-source-node backlink)))
(plist-get (org-roam-backlink-properties backlink) :outline))))
(defun org-roam-export-backlink-link (backlink)
"Get Org link to BACKLINK."
(concat "id:" (org-roam-node-id (org-roam-backlink-source-node backlink))))
(provide 'org-roam-export) (provide 'org-roam-export)
;;; org-roam-export.el ends here ;;; org-roam-export.el ends here

View file

@ -13,14 +13,20 @@
(require 'ert) (require 'ert)
(require 'org-roam) (require 'org-roam)
(require 'org-roam-export) (require 'org-roam-export)
(require 'seq)
(setq org-roam-directory (expand-file-name "./test-slipbox") (setq org-roam-directory (expand-file-name "./test-slipbox")
org-roam-db-location (expand-file-name "org-roam.db")) org-roam-db-location (expand-file-name "org-roam.db"))
(org-roam-update-org-id-locations)
(org-roam-db-sync) (org-roam-db-sync)
(ert-deftest simple-test () (ert-deftest simple-test ()
(should (= 1 1))) (should (= 1 1)))
(ert-deftest lorem-backlink-titles ()
(should (equal '("Ipsum > II")
(seq-map #'org-roam-export-backlink-title (org-roam-backlinks-get (org-roam-node-from-id "d12a1ce4-3199-42f4-b39b-b68c03458669") :unique t)))))
(provide 'tests) (provide 'tests)
;;; tests.el ends here ;;; tests.el ends here