summaryrefslogtreecommitdiffstats
path: root/.config/emacs/jd
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2023-07-02 15:07:07 +0200
committerjdlugosz963 <jdlugosz963@gmail.com>2023-07-02 15:07:07 +0200
commit6156f86dd5797de5ea4f912b70d38963c6cf4ad4 (patch)
treed578204262209695d995e3f639076e91dcb85354 /.config/emacs/jd
parentef565a486511cbbb86e0d1f80264b3b57d2ac88a (diff)
downloaddotfiles-6156f86dd5797de5ea4f912b70d38963c6cf4ad4.tar.gz
dotfiles-6156f86dd5797de5ea4f912b70d38963c6cf4ad4.zip
New Emacs config and change location of Emacs home dir.
Diffstat (limited to '.config/emacs/jd')
-rw-r--r--.config/emacs/jd/jd-gym.el120
-rw-r--r--.config/emacs/jd/jd-mu4e.el76
2 files changed, 0 insertions, 196 deletions
diff --git a/.config/emacs/jd/jd-gym.el b/.config/emacs/jd/jd-gym.el
deleted file mode 100644
index 2602e3e..0000000
--- a/.config/emacs/jd/jd-gym.el
+++ /dev/null
@@ -1,120 +0,0 @@
1;;; jd-gym.el --- Gym workout manager.
2;;; Commentary:
3;; It will be a gym workout manager in the future.
4;;; code:
5
6(require 'emacsql-sqlite)
7
8(defconst jd-gym/db--tables-schema
9 '((workout-plans
10 [(id integer :primary-key :autoincrement)
11 (name text)])
12
13 (workouts
14 [(id integer :primary-key :autoincrement)
15 (workout-plan-id integer :not-null)
16 (day integer :not-null)
17 (month integer :not-null)
18 (year integer :not-null)]
19 (:foreign-key [workout-plan-id] :references workout-plans [id] :on-delete :cascade))
20
21 (muscle-part
22 [(id integer :primary-key :autoincrement)
23 (name text :not-null)])
24
25 (exercises
26 [(id integer :primary-key :autoincrement)
27 (name text :not-null)
28 (muscle-part-id integer :not-null)]
29 (:foreign-key [muscle-part-id] :references muscle-part [id] :on-delete :cascade))
30
31 (workout-plan-exercise-map
32 [(id integer :primary-key :autoincrement)
33 (week-day integer :not-null)
34 (workout-plan-id integer :not-null)
35 (exercise-id integer :not-null)]
36 (:foreign-key [workout-plan-id] :references workout-plans [id] :on-delete :cascade)
37 (:foreign-key [exercise-id] :references exercises [id] :on-delete :cascade))
38
39 (workout-sets
40 [(id integer :primary-key :autoincrement)
41 (reps integer :not-null)
42 (weight integer :not-null)
43 (workout-plan-exercise-map-id integer :not-null)
44 (comment text)]
45 (:foreign-key [workout-plan-exercise-map-id] :references workout-plan-exercise-map [id] :on-delete :cascade))))
46
47(defconst jd-gym/db--test-data
48 '((workout-plans
49 ([nil "Push pull"]))
50 (workouts
51 ([nil 1 3 1 2023]))
52 (muscle-part
53 ([nil "glutes"]
54 [nil "chest"]))
55 (exercises
56 ([nil "Bench press" 2]
57 [nil "RDL" 1]))
58 (workout-plan-exercise-map
59 ([nil 0 1 1] ; Monday, Push pull, Bench press
60 [nil 1 1 2] ; Tuesday, Push pull, RDL
61 [nil 3 1 1] ; Thursday, Push pull, Bench press
62 [nil 4 1 2] ; Friday, Push pull, RDL
63 ))
64 (workout-sets
65 ([nil 7 70 1 "New PR!"]
66 [nil 8 110 2 "It was hard!"]))))
67
68(defun jd-gym/db--test-data-insert ()
69 "Insert test data to jd-gym database."
70 (mapc (lambda (table)
71 (let ((table-name (car table))
72 (table-data (cdr table)))
73 (emacsql jd-gym/db--conn [:insert :into $i1
74 :values $v2]
75 table-name table-data)))
76 jd-gym/db--test-data))
77
78(defvar jd-gym/db-path "~/Documents/Gym/gym.sqlite"
79 "Path can be relative or absolute.")
80
81(defvar jd-gym/db--conn nil
82 "Store connection to jd-gym database.")
83
84(defun jd-gym/db--conn-p ()
85 "Check if jd-gym is connected to db."
86 (and (emacsql-sqlite-connection-p jd-gym/db--conn)
87 (emacsql-live-p jd-gym/db--conn)))
88
89(defun jd-gym/db--connect ()
90 "Connect to db if there is no connection yet."
91 (unless (jd-gym/db--conn-p)
92 (setq jd-gym/db--conn (emacsql-sqlite jd-gym/db-path))))
93
94(defun jd-gym/db--close ()
95 "Close db connection."
96 (when (jd-gym/db--conn-p)
97 (emacsql-close jd-gym/db--conn)))
98
99(defun jd-gym/db--init ()
100 "Initialize database structure."
101 (when (jd-gym/db--conn-p)
102 (emacsql jd-gym/db--conn [:pragma (= foreign_keys ON)])
103 (emacsql jd-gym/db--conn "PRAGMA foreign_keys=ON")
104 (mapc (lambda (table)
105 (let ((table-name (car table))
106 (table-schema (cdr table)))
107 (emacsql jd-gym/db--conn [:create-table $i1 $S2] table-name table-schema)))
108 jd-gym/db--tables-schema)))
109
110(defun jd-gym/db ()
111 "Entrypoint to jd-gym db."
112 (unless (file-exists-p jd-gym/db-path)
113 (jd-gym/db--close)
114 (jd-gym/db--connect) ; Restart connection
115 (jd-gym/db--init)))
116
117
118(provide 'jd-gym)
119
120;;; jd-gym.el ends here
diff --git a/.config/emacs/jd/jd-mu4e.el b/.config/emacs/jd/jd-mu4e.el
deleted file mode 100644
index 0f45f15..0000000
--- a/.config/emacs/jd/jd-mu4e.el
+++ /dev/null
@@ -1,76 +0,0 @@
1(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
2
3(use-package org-msg)
4
5(use-package mu4e
6 :defer 10
7 :ensure nil
8 :config
9 (require 'org-mu4e)
10
11 (setq mu4e-mu-binary "/usr/local/bin/mu")
12 (setq mu4e-update-interval (* 10 60))
13 (setq mu4e-get-mail-command "mbsync -a")
14 (setq mu4e-maildir "~/Mail")
15
16 (setq mu4e-completing-read-function #'ivy-completing-read)
17
18 (setq mu4e-change-filenames-when-moving t)
19
20 (setq mu4e-contexts
21 `(,(make-mu4e-context
22 :name "Abaks"
23 :match-func (lambda (msg) (when msg
24 (string-prefix-p "/abaks" (mu4e-message-field msg :maildir))))
25 :vars '(
26 (user-full-name . "Jakub Dlugosz")
27 (user-mail-address . "jakub@abaks.pl")
28 (mu4e-sent-folder . "/abaks/Sent Items")
29 (mu4e-trash-folder . "/abaks/Trash")
30 (mu4e-drafts-folder . "/abaks/Drafts")
31 (mu4e-refile-folder . "/abaks/Archive")
32 (smtpmail-local-domain . "pl")
33 (smtpmail-smtp-server . "smtp.abaks.pl")
34 (mu4e-sent-messages-behavior . sent)
35 ))
36 ,(make-mu4e-context
37 :name "Gmail"
38 :match-func (lambda (msg) (when msg
39 (string-prefix-p "/gmail" (mu4e-message-field msg :maildir))))
40 :vars '(
41 (user-full-name . "Jakub Dlugosz")
42 (user-mail-address . "jdlugosz963@gmail.com")
43 (mu4e-sent-folder . "/gmail/\[Gmail\]/Wys\&AUI-ane")
44 (mu4e-trash-folder . "/gmail/\[Gmail\]/Kosz")
45 (mu4e-drafts-folder . "/gmail/\[Gmail\]/Wersje\ robocze")
46 (mu4e-refile-folder . "/gmail/Archive")
47 (smtpmail-local-domain . "com")
48 (smtpmail-smtp-server . "smtp.gmail.com")
49 (mu4e-sent-messages-behavior . sent)
50 ))))
51
52 (setq mail-user-agent 'mu4e-user-agent
53 mail-host-address nil
54 message-send-mail-function 'smtpmail-send-it
55 smtpmail-smtp-service 465
56 smtpmail-stream-type 'ssl)
57
58 (setq mu4e-compose-signature (concat
59 "Pozdrawiam,\n"
60 "Jakub Długosz"))
61
62 (mu4e t))
63
64(use-package mu4e-alert
65 :defer 20
66 :config
67 (mu4e-alert-set-default-style 'libnotify)
68 (mu4e-alert-enable-mode-line-display)
69 (mu4e-alert-enable-notifications))
70
71(jd/leader-key-def
72 "m" '(:ignore t :which-key "mail")
73 "mm" 'mu4e
74 "mc" 'mu4e-compose-new)
75
76(provide 'jd-mu4e)