-
Notifications
You must be signed in to change notification settings - Fork 2
/
org-roam-lite.el
39 lines (31 loc) · 1.42 KB
/
org-roam-lite.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;;; org-roam-lite.el -*- lexical-binding: t; -*-
;; https://stackoverflow.com/questions/66574715/how-to-get-org-mode-file-title-and-other-file-level-properties-from-an-arbitra
(defun ndk/get-keyword-key-value (kwd)
(let ((data (cadr kwd)))
(list (plist-get data :key)
(plist-get data :value))))
(defun ndk/org-current-buffer-get-title ()
(nth 1
(assoc "TITLE"
(org-element-map (org-element-parse-buffer 'greater-element)
'(keyword)
#'ndk/get-keyword-key-value))))
(defun ndk/org-file-get-title (file)
(with-current-buffer (find-file-noselect file)
(ndk/org-current-buffer-get-title)))
(setq org-roam-lite-file-path (concat org-file-path "notes/"))
(defun jparcill/org-roam-lite-new-note ()
(interactive)
(let ((note-name (read-string "Name of note:")))
(find-file (concat org-roam-lite-file-path (format-time-string "%Y%m%d%H%M%S" (current-time)) "-" note-name ".org"))
)
)
(defun jparcill/org-roam-lite-search-org ()
(interactive)
(let ((search-text (read-string "Search: ")))
(grep (concat "grep --color=auto -r -niH --include=\*.org --null \"" search-text "\" " org-file-path))))
(defun jparcill/org-roam-lite-link-note (file-name)
(interactive
(list (read-file-name "File Name: " org-file-path)))
(progn (message (concat "inserted " file-name))
(insert "[[file:" file-name "][" (ndk/org-file-get-title file-name) "]]")))