mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(feat): Protect region targeted by org-roam-insert
(#974)
Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
@ -77,6 +77,28 @@ to look.
|
||||
(s-replace "\\" "\\\\")
|
||||
(s-replace "\"" "\\\"")))
|
||||
|
||||
;;; Shielding regions
|
||||
(defun org-roam-shield-region (beg end)
|
||||
"Shield REGION against modifications.
|
||||
REGION must be a cons-cell containing the marker to the region
|
||||
beginning and maximum values."
|
||||
(when (and beg end)
|
||||
(add-text-properties beg end
|
||||
'(font-lock-face org-roam-link-shielded
|
||||
read-only t)
|
||||
(marker-buffer beg))
|
||||
(cons beg end)))
|
||||
|
||||
(defun org-roam-unshield-region (beg end)
|
||||
"Unshield the shielded REGION."
|
||||
(when (and beg end)
|
||||
(let ((inhibit-read-only t))
|
||||
(remove-text-properties beg end
|
||||
'(font-lock-face org-roam-link-shielded
|
||||
read-only t)
|
||||
(marker-buffer beg)))
|
||||
(cons beg end)))
|
||||
|
||||
(provide 'org-roam-macs)
|
||||
|
||||
;;; org-roam-macs.el ends here
|
||||
|
Reference in New Issue
Block a user