Skip to content

Commit

Permalink
Org: Extend ID link support for org-transclusion (see nobiot/org-tran…
Browse files Browse the repository at this point in the history
…sclusion#237 for discussion)
  • Loading branch information
aam-at committed Jun 29, 2024
1 parent 14b5c08 commit 625a846
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions spacemacs/org-extras/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,32 @@ DAYS must be a positive integer greater than 1."
(path (substring path index)))
(insert (s-lex-format "file:~/${path}")))))))

(defun org-extras/org-transclusion-add-org-id--tofile (link &rest args)
(when (string= "id" (org-element-property :type link))
(let* ((raw-link (org-element-property :path link))
(parts (split-string raw-link "::")) ; Split the link into parts.
(id (car parts)) ; Extract the ID part.
(search (cadr parts)) ; Extract the search part.
(file-path (ignore-errors
(car (org-id-find id)))) ; define file path resolution from id
(new-link
(with-temp-buffer
(insert (format "[[file:%s" file-path))
(when search
(insert "::" search))
(insert "]]")
(beginning-of-line)
(org-element-link-parser))))
(org-transclusion-add-org-file new-link args))))


(with-eval-after-load 'org-transclusion
(add-to-list 'org-transclusion-add-functions
#'org-extras/org-transclusion-add-org-id--tofile)
(setq org-transclusion-add-functions
(remove #'org-transclusion-add-org-id
org-transclusion-add-functions)))


;; Customization for org-remark
(defun org-extras/remark-notes-file ()
Expand Down
3 changes: 2 additions & 1 deletion spacemacs/spacemacs_full
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ This function should only modify configuration layer settings."
(dash :variables
dash-docs-docset-newpath "~/.local/share/Zeal/docsets")
(elfeed :variables
elfeed-search-filter "@1-months-ago +unread"
elfeed-spacemacs-layout-name "@Elfeed"
elfeed-spacemacs-layout-binding "f"
elfeed-enable-goodies t
elfeed-enable-web-interface t
rmh-elfeed-org-files (list "~/Dropbox/Org/feeds.org")
elfeed-goodies/entry-pane-position 'bottom
url-queue-timeout 10)
Expand Down

0 comments on commit 625a846

Please sign in to comment.