Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -27,6 +27,7 @@
- [#2060](https://github.com/org-roam/org-roam/pull/2060) node: added double acute accent normalization for Unicode characters in titles
- [#2040](https://github.com/org-roam/org-roam/pull/2040) completions: fix completions display-width for Helm users
- [#2025](https://github.com/org-roam/org-roam/pull/2025) chore: removed the dependencies on f.el and s.el
- [#2109](https://github.com/org-roam/org-roam/pull/2109) capture: `org-roam-node-insert` places cursor after inserted link where appropriate

## 2.2.0
### Added
Expand Down
9 changes: 6 additions & 3 deletions org-roam-capture.el
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions org-roam-node.el
Expand Up @@ -698,8 +698,7 @@ The INFO, if provided, is passed to the underlying `org-roam-capture-'."
:props (append
(when (and beg end)
(list :region (cons beg end)))
(list :insert-at (point-marker)
:link-description description
(list :link-description description
:finalize 'insert-link))))))
(deactivate-mark)))

Expand Down