(feat): Implement ‘org-roam-insert-immediate’ (#814)

This commit is contained in:
Leo Vivier
2020-06-15 12:34:27 +02:00
committed by GitHub
parent 87403b330c
commit 7ab67436a7
4 changed files with 29 additions and 1 deletions

View File

@ -1,5 +1,14 @@
# Changelog # Changelog
## 1.2.1 (TBD)
### Breaking Changes
### Features
- [#814] Implement `org-roam-insert-immediate`
### Bugfixes
## 1.2.0 (12-06-2020) ## 1.2.0 (12-06-2020)
In this release, we improved the linking process by achieving feature parity between links to files and links to headlines. Before, we used the `file:foo::*bar` format to link to the headline `bar` in file `foo`, but this was prone to breakage upon renaming the file or modifying the headline. This is not the case anymore. Now, we use `org-id` to create IDs for those headlines, which are then stored in our database to compute the relationships and jump around. Note that this will work even if youre not using `org-id` in your global configuration for Org-mode. In this release, we improved the linking process by achieving feature parity between links to files and links to headlines. Before, we used the `file:foo::*bar` format to link to the headline `bar` in file `foo`, but this was prone to breakage upon renaming the file or modifying the headline. This is not the case anymore. Now, we use `org-id` to create IDs for those headlines, which are then stored in our database to compute the relationships and jump around. Note that this will work even if youre not using `org-id` in your global configuration for Org-mode.

View File

@ -60,7 +60,8 @@ Here's a sample configuration with using `use-package`:
("C-c n f" . org-roam-find-file) ("C-c n f" . org-roam-find-file)
("C-c n g" . org-roam-show-graph)) ("C-c n g" . org-roam-show-graph))
:map org-mode-map :map org-mode-map
(("C-c n i" . org-roam-insert)))) (("C-c n i" . org-roam-insert))
(("C-c n I" . org-roam-insert-immediate))))
``` ```
`org-roam-graph` by default expects to find the `dot` executable `org-roam-graph` by default expects to find the `dot` executable

View File

@ -106,6 +106,12 @@ applies.
inserted on initial creation (added only once). This is where inserted on initial creation (added only once). This is where
insertion of any note metadata should go.") insertion of any note metadata should go.")
(defvar org-roam-capture-immediate-template
(append (car org-roam-capture-templates) '(:immediate-finish t))
"Capture template to use for immediate captures in Org-roam.
This is a single template, so do not enclose it into a list.
See `org-roam-capture-templates' for details on templates.")
(defvar org-roam-capture-ref-templates (defvar org-roam-capture-ref-templates
'(("r" "ref" plain (function org-roam-capture--get-point) '(("r" "ref" plain (function org-roam-capture--get-point)
"" ""

View File

@ -1378,6 +1378,18 @@ If DESCRIPTION is provided, use this as the link label. See
(org-roam--with-template-error 'org-roam-capture-templates (org-roam--with-template-error 'org-roam-capture-templates
(org-roam-capture--capture)))))) (org-roam-capture--capture))))))
;;;###autoload
(defun org-roam-insert-immediate (arg &rest args)
"Find an Org-roam file, and insert a relative org link to it at point.
This variant of `org-roam-insert' inserts the link immediately by
using the template in `org-roam-capture-immediate-template'. The
interactive ARG and ARGS are forward to `org-roam-insert'.
See `org-roam-insert' for details."
(interactive "P")
(let ((args (push arg args))
(org-roam-capture-templates (list org-roam-capture-immediate-template)))
(apply #'org-roam-insert args)))
;;;###autoload ;;;###autoload
(defun org-roam-jump-to-index () (defun org-roam-jump-to-index ()
"Find the index file in `org-roam-directory'. "Find the index file in `org-roam-directory'.