Added shortcuts for org-roam dailies and better dynamic habits
This commit is contained in:
parent
818f1395e3
commit
19be781b8b
@ -2,10 +2,31 @@
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
* Org Roam Shortcuts
|
||||||
|
|
||||||
|
Shortcut to goto todays org-roam dailies document.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun jm/org-roam-goto-day (days)
|
||||||
|
(let* ((rel-time (+ (time-convert (current-time) 'integer) (* days 86400)))
|
||||||
|
(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)
|
||||||
|
(find-file full-path)
|
||||||
|
(org-roam-dailies--capture rel-time))))
|
||||||
|
|
||||||
|
(jm/leader-keys
|
||||||
|
"op" '((lambda () (interactive) (jm/org-roam-goto-day -1)) :which-key "Open/create yesterday's daily notes file")
|
||||||
|
"ot" '((lambda () (interactive) (jm/org-roam-goto-day 0)) :which-key "Open/create today's daily notes file")
|
||||||
|
"on" '((lambda () (interactive) (jm/org-roam-goto-day 1)) :which-key "Open/create tomorrow's daily notes file"))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Capture Template Functions
|
* Capture Template Functions
|
||||||
|
|
||||||
These functions are for my org roam daily capture template.
|
These functions are for my org roam daily capture template.
|
||||||
|
|
||||||
|
** Helper Functions
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun jm/dt-filter-tasks (helper query)
|
(defun jm/dt-filter-tasks (helper query)
|
||||||
(let ((entries (org-map-entries helper query 'agenda)))
|
(let ((entries (org-map-entries helper query 'agenda)))
|
||||||
@ -17,7 +38,11 @@ These functions are for my org roam daily capture template.
|
|||||||
(car (org-property-values "ID")))))
|
(car (org-property-values "ID")))))
|
||||||
(when (stringp item-id)
|
(when (stringp item-id)
|
||||||
(format "%s [[id:%s][%s]]" prefix item-id item-name))))
|
(format "%s [[id:%s][%s]]" prefix item-id item-name))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Queries
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
(defun jm/dt-get-priority (priority &optional prompt)
|
(defun jm/dt-get-priority (priority &optional prompt)
|
||||||
(jm/dt-filter-tasks
|
(jm/dt-filter-tasks
|
||||||
(lambda () (when (equal priority (org-entry-get nil "PRIORITY"))
|
(lambda () (when (equal priority (org-entry-get nil "PRIORITY"))
|
||||||
@ -35,9 +60,21 @@ These functions are for my org roam daily capture template.
|
|||||||
(defun jm/dt-get-status (status &optional prompt)
|
(defun jm/dt-get-status (status &optional prompt)
|
||||||
(jm/dt-filter-tasks (lambda () (jm/dt-format-link (or prompt "- [ ]")))
|
(jm/dt-filter-tasks (lambda () (jm/dt-format-link (or prompt "- [ ]")))
|
||||||
(concat "TODO=\"" status "\"")))
|
(concat "TODO=\"" status "\"")))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
(defun jm/dt-dynamic-habits (habit week-days)
|
** Dynamic Habits
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun jm/dt-habit (habit)
|
||||||
(let* ((org-date (or (org-capture-get :default-time) (current-time)))
|
(let* ((org-date (or (org-capture-get :default-time) (current-time)))
|
||||||
(today (downcase (format-time-string "%a" org-date))))
|
(today (downcase (format-time-string "%a" org-date))))
|
||||||
(when (seq-contains-p week-days today) habit)))
|
(when (seq-contains-p (cdr habit) today)
|
||||||
|
(car habit))))
|
||||||
|
|
||||||
|
(defun jm/dt-habits (habits)
|
||||||
|
(let ((out-list '()))
|
||||||
|
(dolist (habit habits out-list)
|
||||||
|
(when-let (out (jm/dt-habit habit))
|
||||||
|
(push out out-list)))
|
||||||
|
(mapconcat #'identity out-list "\n")))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -13,16 +13,6 @@ This installs the org package and creates a setup function to enable/disable cer
|
|||||||
(visual-line-mode 1)
|
(visual-line-mode 1)
|
||||||
(add-to-list 'org-link-frame-setup '(file . find-file))) ; Open link in current window not other window.
|
(add-to-list 'org-link-frame-setup '(file . find-file))) ; Open link in current window not other window.
|
||||||
|
|
||||||
|
|
||||||
;; Shortcut to goto todays org-roam dailies document.
|
|
||||||
(defun jm/org-roam-goto-today ()
|
|
||||||
(interactive)
|
|
||||||
(let* ((path (format-time-string "%Y-%m-%d.org" ))
|
|
||||||
(full-path (file-name-concat org-roam-directory "daily" path)))
|
|
||||||
(if (file-exists-p full-path)
|
|
||||||
(find-file full-path)
|
|
||||||
(org-roam-dailies-capture-today))))
|
|
||||||
|
|
||||||
(use-package org
|
(use-package org
|
||||||
:hook (org-mode . jm/org-mode-setup)
|
:hook (org-mode . jm/org-mode-setup)
|
||||||
:config
|
:config
|
||||||
@ -40,8 +30,7 @@ This installs the org package and creates a setup function to enable/disable cer
|
|||||||
org-time-stamp-custom-formats '("%m-%d-%y %a" . "%m-%d-%y %a %I:%M %p"))
|
org-time-stamp-custom-formats '("%m-%d-%y %a" . "%m-%d-%y %a %I:%M %p"))
|
||||||
|
|
||||||
(jm/leader-keys
|
(jm/leader-keys
|
||||||
"oa" '(org-agenda :which-key "Org agenda")
|
"oa" '(org-agenda :which-key "Org agenda")))
|
||||||
"ot" '(jm/org-roam-goto-today :which-key "Open/create daily notes file")))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Evil Org
|
* Evil Org
|
||||||
|
Loading…
x
Reference in New Issue
Block a user