Updated functions.org to automatically refresh agenda.
This commit is contained in:
@@ -1,8 +1,40 @@
|
||||
#+TITLE: Custom Elisp Functions
|
||||
* Org-Roam
|
||||
** Refresh Org Roam Agenda
|
||||
|
||||
As of now, I haven't added anything here, though I do expect to start adding some custom functions as I learn more about Elisp.
|
||||
Creates a function to refresh the ~org-agenda-files~ variable to be set to include all org roam notes files.
|
||||
|
||||
* Org Roam Dailies Shortcuts
|
||||
#+begin_src emacs-lisp
|
||||
(defun jm/org-roam-refresh-agenda-list ()
|
||||
(let ((directory (expand-file-name org-roam-dailies-directory org-roam-directory)))
|
||||
(setq org-agenda-files
|
||||
(seq-filter
|
||||
(lambda (file-path) (not (s-starts-with-p directory file-path)))
|
||||
(org-roam-list-files)))))
|
||||
#+end_src
|
||||
|
||||
** Custom Org-Roam Indexing Functions
|
||||
|
||||
Before getting into the main config for Org-roam, I've created a few functions for better indexing nodes stored in the org-roam database. Specifically, these functions separate the org roam dailies nodes from other nodes.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun jm/org-roam-find-filter (node)
|
||||
(let ((directory (expand-file-name org-roam-dailies-directory org-roam-directory)))
|
||||
(string= (file-name-directory (org-roam-node-file node))
|
||||
directory)))
|
||||
|
||||
(defun jm/org-roam-dailies-find ()
|
||||
(interactive)
|
||||
(org-roam-node-find nil nil #'jm/org-roam-find-filter))
|
||||
|
||||
(defun jm/org-roam-find ()
|
||||
(interactive)
|
||||
(org-roam-node-find
|
||||
nil nil
|
||||
(lambda (node) (not (jm/org-roam-find-filter node)))))
|
||||
#+end_src
|
||||
|
||||
** Org Roam Dailies Shortcuts
|
||||
|
||||
Shortcut to goto todays org-roam dailies document.
|
||||
|
||||
@@ -12,20 +44,20 @@ Shortcut to goto todays org-roam dailies document.
|
||||
(file-base (file-name-base (buffer-file-name))))
|
||||
(s-matches-p "^[0-9]+-[0-9]+-[0-9]+$" file-base)))
|
||||
|
||||
(defun jm/org-roam-capture-day ()
|
||||
(defun jm/org-roam-capture-today ()
|
||||
(interactive)
|
||||
(if (jm/dailies-file-p)
|
||||
(org-roam-dailies--capture (date-to-time (file-name-base (buffer-file-name))))
|
||||
(org-roam-dailies-capture-today)))
|
||||
(jm/org-roam-goto-day 0 t))
|
||||
|
||||
(defun jm/org-roam-goto-day (days)
|
||||
(let* ((base-time (if (and (jm/dailies-file-p) (not (eq days 0)))
|
||||
(date-to-time (file-name-base (buffer-file-name)))
|
||||
(current-time)))
|
||||
(defun jm/org-roam-goto-day (days &optional force-capture)
|
||||
(let* ((base-time
|
||||
(if (and (jm/dailies-file-p) (not (eq days 0)))
|
||||
(date-to-time (file-name-base (buffer-file-name)))
|
||||
(current-time)))
|
||||
(rel-time (time-add base-time (days-to-time days)))
|
||||
(path (format-time-string "%Y-%m-%d.org" rel-time))
|
||||
(full-path (file-name-concat org-roam-directory "daily" path)))
|
||||
(if (file-exists-p full-path)
|
||||
(jm/org-roam-refresh-agenda-list)
|
||||
(if (and (file-exists-p full-path) (not force-capture))
|
||||
(find-file full-path)
|
||||
(org-roam-dailies--capture rel-time))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user