(fix)replace-link-at-point: preserve description (#1753)

Preserve descriptions (if any) when replacing `roam:` links. Fixes #1737.
This commit is contained in:
Jethro Kuan
2021-08-09 15:28:24 +08:00
committed by GitHub
parent f227c03672
commit 3c396f9e91

View File

@@ -610,6 +610,11 @@ Assumes that the cursor was put where the link is."
(let* ((link (or link (org-element-context)))
(type (org-element-property :type link))
(path (org-element-property :path link))
(desc (and (org-element-property :contents-begin link)
(org-element-property :contents-end link)
(buffer-substring-no-properties
(org-element-property :contents-begin link)
(org-element-property :contents-end link))))
node)
(goto-char (org-element-property :begin link))
(when (and (org-in-regexp org-link-any-re 1)
@@ -617,7 +622,7 @@ Assumes that the cursor was put where the link is."
(setq node (org-roam-node-from-title-or-alias path)))
(replace-match (org-link-make-string
(concat "id:" (org-roam-node-id node))
path)))))))
(or desc path))))))))
(defun org-roam-link-replace-all ()
"Replace all \"roam:\" links in buffer with \"id:\" links."