(feature): insert link as downcased title with org-roam-insert (#110)

This commit is contained in:
Jethro Kuan
2020-02-17 23:15:27 +08:00
committed by GitHub
parent 883eed0a5e
commit 2d206134fd
3 changed files with 19 additions and 9 deletions

View File

@ -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)

View File

@ -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 ()

View File

@ -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"))))