diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad1876..f11c43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ * [#103][gh-103] Change `org-roam-file-format` to a function: `org-roam-file-name-function` to allow more flexible file name customizaton. Also changes `org-roam-use-timestamp-as-filename` to `org-roam-filename-noconfirm` to better describe what it does. ### New Features -* [#87][gh-87], [#90][gh-90] Support encrypted Org files (by [@chip2n](https://github.com/chip2n/)) +* [#87][gh-87], [#90][gh-90] Support encrypted Org files +* [#110][gh-110] Add prefix to `org-roam-insert`, for inserting titles down-cased ### Bugfixes * [#86][gh-86] Fix `org-roam--parse-content` incorrect `:to` computation for nested files @@ -19,6 +20,10 @@ ### Internal * [#92][gh-92], [#105][gh-105]: Add tests for core functionality +### Contributors +* [@chip2n](https://github.com/chip2n/) +* [@l3kn](https://github.com/l3kn/) + ## 0.1.1 (2020-02-15) Mostly a documentation/cleanup release. @@ -58,6 +63,7 @@ Mostly a documentation/cleanup release. [gh-103]: https://github.com/jethrokuan/org-roam/pull/103 [gh-105]: https://github.com/jethrokuan/org-roam/pull/105 [gh-108]: https://github.com/jethrokuan/org-roam/pull/108 +[gh-110]: https://github.com/jethrokuan/org-roam/pull/110 # Local Variables: # eval: (auto-fill-mode -1) diff --git a/org-roam.el b/org-roam.el index 027929a..c8a9fee 100644 --- a/org-roam.el +++ b/org-roam.el @@ -274,9 +274,11 @@ If not provided, derive the title from the file name." (org-roam--new-file-named (format-time-string "%Y%m%d%H%M%S" (current-time)))) ;;; Inserting org-roam links -(defun org-roam-insert () - "Find an org-roam file, and insert a relative org link to it at point." - (interactive) +(defun org-roam-insert (prefix) + "Find an org-roam file, and insert a relative org link to it at point. + +If PREFIX, downcase the title before insertion." + (interactive "P") (let* ((completions (mapcar (lambda (file) (list (org-roam--get-title-or-slug file) file)) @@ -293,7 +295,9 @@ If not provided, derive the title from the file name." (insert (format "[[%s][%s]]" (concat "file:" (file-relative-name absolute-file-path current-file-path)) - (format org-roam-link-title-format title))))) + (format org-roam-link-title-format (if prefix + (downcase title) + title)))))) ;;; Finding org-roam files (defun org-roam-find-file () diff --git a/tests/test-org-roam.el b/tests/test-org-roam.el index b43362a..c3c84e8 100644 --- a/tests/test-org-roam.el +++ b/tests/test-org-roam.el @@ -122,7 +122,7 @@ (with-current-buffer buf (with-simulated-input "File SPC 1 RET" - (org-roam-insert)))) + (org-roam-insert nil)))) (expect (buffer-string) :to-match (regexp-quote "file:f1.org"))) (it "temp2 -> nested/f1" @@ -130,7 +130,7 @@ (with-current-buffer buf (with-simulated-input "Nested SPC File SPC 1 RET" - (org-roam-insert)))) + (org-roam-insert nil)))) (expect (buffer-string) :to-match (regexp-quote "file:nested/f1.org"))) (it "nested/temp3 -> f1" @@ -138,7 +138,7 @@ (with-current-buffer buf (with-simulated-input "File SPC 1 RET" - (org-roam-insert)))) + (org-roam-insert nil)))) (expect (buffer-string) :to-match (regexp-quote "file:../f1.org"))) (it "a/b/temp4 -> nested/f1" @@ -146,5 +146,5 @@ (with-current-buffer buf (with-simulated-input "Nested SPC File SPC 1 RET" - (org-roam-insert)))) + (org-roam-insert nil)))) (expect (buffer-string) :to-match (regexp-quote "file:../../nested/f1.org"))))