feat(emacs): add more info to org-journal

This commit is contained in:
Pavel Korytov 2023-01-14 23:39:07 +03:00
parent 86798c2875
commit 0c6c2e6acf
2 changed files with 54 additions and 6 deletions

View file

@ -745,9 +745,14 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
:states '(insert normal)
"C-y" 'counsel-yank-pop)
(defun my/swiper-isearch ()
(interactive)
(if current-prefix-arg
(swiper-all)
(swiper-isearch)))
(my-leader-def "SPC SPC" 'ivy-resume)
(my-leader-def "s" 'swiper-isearch
"S" 'swiper-all)
(my-leader-def "s" 'my/swiper-isearch)
(general-define-key
:keymaps '(ivy-minibuffer-map swiper-map)
@ -3221,6 +3226,21 @@ skip exactly those headlines that do not match."
(message "Got error: %S" error-thrown)))))
my/weather-value)
(defun my/get-mood ()
(let* ((crm-separator " ")
(crm-local-completion-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map crm-local-completion-map)
(define-key map " " 'self-insert-command)
map))
(ivy-prescient-sort-commands nil))
(mapconcat
#'identity
(completing-read-multiple
"How do you feel: "
my/mood-list)
" ")))
(defun my/set-journal-header ()
(org-set-property "Emacs" emacs-version)
(org-set-property "Hostname" system-name)
@ -3246,7 +3266,9 @@ skip exactly those headlines that do not match."
(when title
(setq string (concat string title)))
(when (> (length string) 0)
(org-set-property "EMMS_Track" string)))))))
(org-set-property "EMMS_Track" string))))))
(when-let (mood (my/get-mood))
(org-set-property "Mood" mood)))
(add-hook 'org-journal-after-entry-create-hook
#'my/set-journal-header)

View file

@ -1227,9 +1227,14 @@ Setting up quick access to various completions.
:states '(insert normal)
"C-y" 'counsel-yank-pop)
(defun my/swiper-isearch ()
(interactive)
(if current-prefix-arg
(swiper-all)
(swiper-isearch)))
(my-leader-def "SPC SPC" 'ivy-resume)
(my-leader-def "s" 'swiper-isearch
"S" 'swiper-all)
(my-leader-def "s" 'my/swiper-isearch)
(general-define-key
:keymaps '(ivy-minibuffer-map swiper-map)
@ -4491,12 +4496,31 @@ Also, I want to add some extra information to the journal. Here's a functionalit
my/weather-value)
#+end_src
Let's also try to log the current mood:
#+begin_src emacs-lisp
(defun my/get-mood ()
(let* ((crm-separator " ")
(crm-local-completion-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map crm-local-completion-map)
(define-key map " " 'self-insert-command)
map))
(ivy-prescient-sort-commands nil))
(mapconcat
#'identity
(completing-read-multiple
"How do you feel: "
my/mood-list)
" ")))
#+end_src
And here's a function that creates a drawer with such information. At the moment, it's:
- Emacs version
- Hostname
- Location
- Weather
- Current EMMS track
- Current mood
#+begin_src emacs-lisp
(defun my/set-journal-header ()
@ -4524,7 +4548,9 @@ And here's a function that creates a drawer with such information. At the moment
(when title
(setq string (concat string title)))
(when (> (length string) 0)
(org-set-property "EMMS_Track" string)))))))
(org-set-property "EMMS_Track" string))))))
(when-let (mood (my/get-mood))
(org-set-property "Mood" mood)))
(add-hook 'org-journal-after-entry-create-hook
#'my/set-journal-header)