(feat): support fuzzy links (#910)

This commit is contained in:
Jethro Kuan
2020-08-05 20:52:27 +08:00
committed by GitHub
parent f18ecd1fc3
commit da6fdd7542
5 changed files with 269 additions and 13 deletions

View File

@ -77,6 +77,19 @@ to look.
(s-replace "\\" "\\\\")
(s-replace "\"" "\\\"")))
;;; Link Utilities
(defun org-roam-replace-fuzzy-link (new-loc &optional desc)
"Replace the current fuzzy link (e.g. [[Foo]]) with a NEW-LOC.
If DESC, also replace the desc"
(save-match-data
(unless (org-in-regexp org-link-bracket-re 1)
(user-error "No link at point"))
(let ((desc (or desc (match-string-no-properties 1)))
(remove (list (match-beginning 0) (match-end 0))))
(apply #'delete-region remove)
(insert (org-link-make-string new-loc desc)))
(sit-for 0)))
;;; Shielding regions
(defun org-roam-shield-region (beg end)
"Shield REGION against modifications.