(fix): place cursor after inserted link for new nodes (#2109)

Special care is taken not to move the point if the original point is no
longer the same (i.e. the user moves the cursor after calling the
capture, but before finalizing it). Fixes #2108.
This commit is contained in:
Jethro Kuan
2022-02-27 12:50:45 -08:00
committed by GitHub
parent 62d311de22
commit 65ea325071
3 changed files with 8 additions and 5 deletions

View File

@ -744,9 +744,12 @@ This function is to be called in the Org-capture finalization process."
(delete-region (car region) (cdr region))
(set-marker (car region) nil)
(set-marker (cdr region) nil))
(org-with-point-at mkr
(insert (org-link-make-string (concat "id:" (org-roam-capture--get :id))
(org-roam-capture--get :link-description)))))))
(let ((link (org-link-make-string (concat "id:" (org-roam-capture--get :id))
(org-roam-capture--get :link-description))))
(if (eq (point) (marker-position mkr))
(insert link)
(org-with-point-at mkr
(insert link)))))))
;;;; Processing of the capture templates
(defun org-roam-capture--fill-template (template &optional org-capture-p newline)