summaryrefslogtreecommitdiffstats
path: root/files/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to 'files/.emacs.d')
-rw-r--r--files/.emacs.d/.gitignore5
-rwxr-xr-xfiles/.emacs.d/init.el146
-rwxr-xr-xfiles/.emacs.d/jd/jd-apps.el49
-rwxr-xr-xfiles/.emacs.d/jd/jd-custom.el33
-rwxr-xr-xfiles/.emacs.d/jd/jd-dev.el177
-rwxr-xr-xfiles/.emacs.d/jd/jd-exwm.el177
-rwxr-xr-xfiles/.emacs.d/jd/jd-gym.el120
-rwxr-xr-xfiles/.emacs.d/jd/jd-keys.el49
-rw-r--r--files/.emacs.d/jd/jd-misc.el34
-rwxr-xr-xfiles/.emacs.d/jd/jd-mu4e.el84
-rwxr-xr-xfiles/.emacs.d/jd/jd-org.el224
-rw-r--r--files/.emacs.d/jd/jd-sway.el18
-rwxr-xr-xfiles/.emacs.d/jd/jd-ui.el104
13 files changed, 1220 insertions, 0 deletions
diff --git a/files/.emacs.d/.gitignore b/files/.emacs.d/.gitignore
new file mode 100644
index 0000000..10f87ad
--- /dev/null
+++ b/files/.emacs.d/.gitignore
@@ -0,0 +1,5 @@
1*
2!init.el
3!jd
4!jd/*
5!.gitignore \ No newline at end of file
diff --git a/files/.emacs.d/init.el b/files/.emacs.d/init.el
new file mode 100755
index 0000000..090592f
--- /dev/null
+++ b/files/.emacs.d/init.el
@@ -0,0 +1,146 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6;; Minimize garbage collection during startup
7(setq gc-cons-threshold most-positive-fixnum)
8
9;; Lower threshold back to 8 MiB (default is 800kB)
10(add-hook 'emacs-startup-hook
11 (lambda ()
12 (setq gc-cons-threshold (expt 2 23))))
13
14(defvar jd/manifest-list
15 nil
16 "List that contain Emacs packages for GNU/Guix." )
17
18(defvar jd/exwm-p
19 (or (not (null (getenv "JD_EXWM")))
20 (and (seq-contains command-line-args "exwm" #'string-match)
21 t))
22 "Is non-nil when Emacs is run as a window manager.")
23
24(defvar jd/guix-p
25 (and (eq system-type 'gnu/linux)
26 (file-exists-p "/etc/os-release")
27 (with-temp-buffer
28 (insert-file-contents "/etc/os-release")
29 (search-forward "ID=guix" nil t))
30 t)
31 "Is non-nil when Emacs packages are installed by GNU/Guix package manager.")
32
33(defun jd/add-package-to-manifest (guix-package-name)
34 "Add GUIX-PACKAGE-NAME to jd/manifest-list."
35 (unless (member guix-package-name jd/manifest-list)
36 (setq jd/manifest-list
37 (cons guix-package-name jd/manifest-list))))
38
39(add-to-list 'load-path (concat user-emacs-directory "/jd"))
40
41(defun jd/display-startup-time ()
42 (message "Emacs loaded in %s with %d garbage collections."
43 (format "%.2f seconds"
44 (float-time
45 (time-subtract after-init-time before-init-time)))
46 gcs-done))
47
48(defun jd-emacs/startup ()
49 "This procedure will run after Emacs startup."
50 (electric-pair-mode 1)
51 (global-company-mode 1)
52 (jd/display-startup-time))
53
54(add-hook 'emacs-startup-hook #'jd-emacs/startup)
55
56(setq user-full-name "Jakub Dlugosz"
57 user-mail-address "jdlugosz963@gmail.com")
58
59(setq backup-directory-alist '(("." . "~/.cache/emacs/backup"))
60 backup-by-copying t
61 version-control t
62 delete-old-versions t
63 kept-new-versions 20
64 kept-old-versions 5
65 custom-file (concat user-emacs-directory
66 "custom.el"))
67
68;; (setq user-emacs-directory "~/.cache/emacs")
69
70(require 'package)
71(setq package-archives '(("melpa" . "https://melpa.org/packages/")
72 ("org" . "https://orgmode.org/elpa/")
73 ("gnu-devel" . "https://elpa.gnu.org/devel/")
74 ("elpa" . "https://elpa.gnu.org/packages/")))
75(package-initialize)
76
77(unless package-archive-contents
78 (package-refresh-contents))
79
80(jd/add-package-to-manifest "emacs-use-package")
81(unless jd/guix-p
82 (unless (package-installed-p 'use-package)
83 (package-install 'use-package)))
84
85(require 'use-package)
86
87(setq use-package-always-ensure (not jd/guix-p))
88
89(defun jd/generate-manifest ()
90 "Generate GNU/Guix Emacs manifest to temp-buffer."
91 (interactive)
92 (with-output-to-temp-buffer "*guix-emacs-packages-manifest.scm*"
93 (princ (concat ";; This file is auto-generated by Emacs "
94 "function: jd/manifest-generate-to-file \n"))
95 (princ `(specifications->manifest
96 '(,@(mapcar #'(lambda (guix-package-name)
97 (concat "\""
98 guix-package-name
99 "\"\n"))
100 jd/manifest-list))))))
101
102(defun use-package-normalize/:guix-package (name keyword args)
103 (use-package-as-one (symbol-name keyword) args
104 #'(lambda (_label arg)
105 (cond
106 ((consp arg) arg)
107 ((stringp arg) (list arg))
108 ((use-package-non-nil-symbolp arg) (symbol-name arg))
109 (t
110 (use-package-error
111 ":pin wants an archive name (a string)"))))))
112
113(defun use-package-handler/:guix-package
114 (name _keyword args rest state)
115 (let ((body (use-package-process-keywords name rest state)))
116 (use-package-concat
117 (when (consp args)
118 (mapcar #'(lambda (arg)
119 `(jd/add-package-to-manifest ,arg))
120 args))
121 body)))
122
123(add-to-list 'use-package-keywords ':guix-package)
124
125(jd/add-package-to-manifest "emacs")
126(jd/add-package-to-manifest "emacs-guix")
127
128(require 'jd-keys)
129(require 'jd-ui)
130(require 'jd-org)
131(require 'jd-dev)
132(require 'jd-apps)
133(require 'jd-custom)
134(require 'jd-mu4e)
135(require 'jd-misc)
136(require 'jd-sway)
137
138(when jd/exwm-p
139 (require 'jd-exwm))
140
141;; (setq gc-cons-threshold (* 2 1000 1000))
142
143;;; init.el ends here
144(put 'upcase-region 'disabled nil)
145(put 'downcase-region 'disabled nil)
146(put 'set-goal-column 'disabled nil)
diff --git a/files/.emacs.d/jd/jd-apps.el b/files/.emacs.d/jd/jd-apps.el
new file mode 100755
index 0000000..f06430b
--- /dev/null
+++ b/files/.emacs.d/jd/jd-apps.el
@@ -0,0 +1,49 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(use-package vterm
7 :guix-package "emacs-vterm"
8 :init
9 (add-to-list 'project-switch-commands '(project-vterm "Vterm") t)
10 (add-to-list 'project-kill-buffer-conditions
11 '(major-mode . vterm-mode))
12 (setq vterm-copy-exclude-prompt t)
13 :config
14 (setq vterm-buffer-name "vterm")
15 ;; (evil-set-initial-state 'vterm-mode 'emacs)
16 (setq vterm-tramp-shells
17 (append '(("ssh" "/bin/bash")) vterm-tramp-shells))
18
19 )
20
21(use-package all-the-icons-dired
22 :guix-package "emacs-all-the-icons-dired"
23 :hook (dired-mode . all-the-icons-dired-mode))
24
25(use-package dired
26 :ensure nil
27 :commands (dired dired-jump)
28 :custom ((dired-listing-switches "-agho --group-directories-first"))
29 :config
30 (setq dired-kill-when-opening-new-dired-buffer t))
31
32(use-package pdf-tools
33 :guix-package
34 "emacs-pdf-tools")
35
36(use-package password-store
37 :guix-package "emacs-password-store"
38 :bind
39 ("C-c P p" . password-store-copy)
40 ("C-c P i" . password-store-insert)
41 ("C-c P g" . password-store-generate))
42
43(use-package shell
44 :bind
45 ("C-c C-<return>" . shell))
46
47(provide 'jd-apps)
48
49;;; jd-apps.el ends here
diff --git a/files/.emacs.d/jd/jd-custom.el b/files/.emacs.d/jd/jd-custom.el
new file mode 100755
index 0000000..a634baa
--- /dev/null
+++ b/files/.emacs.d/jd/jd-custom.el
@@ -0,0 +1,33 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(setq erc-nick "bobbma"
7 erc-user-full-name "Jakub Dlugosz"
8 erc-notify-list '("akuleszaa"))
9
10(defun hipis-znc ()
11 (interactive)
12 (erc :server "195.74.91.18"
13 :port "6697"))
14
15
16;; Repair load paths when tramp try to connect to guix instances
17(require 'tramp)
18
19(connection-local-set-profile-variables
20 'guix-system
21 '((tramp-remote-path . (tramp-own-remote-path))))
22
23(connection-local-set-profiles
24 '(:application tramp :protocol "sudo" :machine "localhost")
25 'guix-system)
26
27(connection-local-set-profiles
28 '(:application tramp :protocol "ssh" :machine "jdlugosz.com")
29 'guix-system)
30
31(provide 'jd-custom)
32
33;;; jd-custom.el ends here
diff --git a/files/.emacs.d/jd/jd-dev.el b/files/.emacs.d/jd/jd-dev.el
new file mode 100755
index 0000000..12cd21b
--- /dev/null
+++ b/files/.emacs.d/jd/jd-dev.el
@@ -0,0 +1,177 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6;; (setq c-default-style "linux"
7;; c-basic-offset 8
8;; gdb-many-windows t)
9
10(use-package lsp-mode
11 :guix-package "emacs-lsp-mode"
12 :diminish t
13 :commands (lsp lsp-deferred)
14 :init
15 (setq lsp-headerline-breadcrumb-enable nil)
16 (setq lsp-diagnostics-provider :none)
17 (setq lsp-modeline-diagnostics-enable nil)
18 (setq lsp-keymap-prefix "C-c l")
19 :config
20 (lsp-enable-which-key-integration t)
21
22 (global-set-key (kbd "C-x ]")
23 #'(lambda ()
24 (interactive)
25 (forward-page)
26 (recenter-top-bottom 0)))
27
28 (global-set-key (kbd "C-x [")
29 #'(lambda ()
30 (interactive)
31 (backward-page)
32 (recenter-top-bottom 0)))
33
34 (define-key c-mode-map
35 (kbd "C-c C-c")
36 #'(lambda ()
37 (interactive)
38 (compile compile-command)))
39
40 (define-key c-mode-map
41 (kbd "C-c M-c")
42 'compile))
43
44(use-package lsp-ivy
45 :guix-package "emacs-lsp-ivy"
46 :after lsp)
47
48
49(use-package paredit
50 :guix-package "emacs-paredit")
51
52(defun jd/lisp-mode-setup ()
53 (rainbow-delimiters-mode)
54 (paredit-mode))
55
56(add-hook 'emacs-startup-hook
57 (lambda ()
58 (add-hook 'scheme-mode-hook 'jd/lisp-mode-setup)
59 (add-hook 'emacs-lisp-mode-hook 'jd/lisp-mode-setup)
60 (add-hook 'clojure-mode-hook 'jd/lisp-mode-setup)
61 (add-hook 'lisp-mode-hook 'jd/lisp-mode-setup)))
62
63(use-package rainbow-delimiters
64 :guix-package "emacs-rainbow-delimiters")
65
66(use-package sly
67 :guix-package "emacs-sly")
68
69(use-package geiser
70 :guix-package "emacs-geiser")
71
72(use-package geiser-racket
73 :guix-package "emacs-geiser-racket")
74
75(use-package racket-mode
76 :guix-package "emacs-racket-mode")
77
78(use-package geiser-guile
79 :guix-package "emacs-geiser-guile"
80 :config
81 (when jd/guix-p
82 (defun jd/guix-repl ()
83 (interactive)
84 (let ((geiser-guile-binary '("guix" "repl"))
85 (geiser-guile-load-path (cons "~/dotfiles/guix" geiser-guile-load-path)))
86 (geiser 'guile)))))
87
88(use-package pyvenv
89 :guix-package "emacs-pyvenv"
90 :after python-mode)
91
92(use-package typescript-mode
93 :guix-package "emacs-typescript-mode"
94 :mode ("\\.ts\\'")
95 :config
96 (setq typescript-indent-level 2))
97
98(use-package cider
99 :guix-package "emacs-cider")
100
101(use-package tide
102 :guix-package "emacs-tide"
103 :after (typescript-mode company web-mode))
104
105(use-package flycheck
106 :guix-package "emacs-flycheck"
107 :hook ((after-init . global-flycheck-mode)))
108
109(use-package web-mode
110 :guix-package "emacs-web-mode"
111 :mode
112 ("\\.ejs\\'" "\\.hbs\\'" "\\.html\\'" "\\.php\\'" "\\.[jt]sx?\\'")
113 :config
114 (setq web-mode-content-types-alist '(("jsx" . "\\.[jt]sx?\\'")))
115 (setq web-mode-markup-indent-offset 2)
116 (setq web-mode-css-indent-offset 2)
117 (setq web-mode-code-indent-offset 2)
118 (setq web-mode-script-padding 2)
119 (setq web-mode-block-padding 2)
120 (setq web-mode-style-padding 2)
121 (setq web-mode-enable-auto-pairing t)
122 (setq web-mode-enable-auto-closing t)
123 (setq web-mode-enable-current-element-highlight t))
124
125(use-package yaml-mode
126 :guix-package "emacs-yaml-mode")
127
128(use-package docker
129 :guix-package "emacs-docker"
130 :bind
131 ("C-c D d" . docker-containers)
132 ("C-c D D" . docker))
133
134(use-package company
135 :guix-package "emacs-company"
136 :diminish t
137 :after lsp-mode
138 :hook (lsp-mode . company-mode)
139 :bind (:map company-active-map
140 ("<tab>" . company-complete-selection))
141 (:map lsp-mode-map
142 ("<tab>" . company-indent-or-complete-common))
143 :custom
144 (company-minimum-prefix-length 1)
145 (company-idle-delay 0.0)
146 :config
147 (global-company-mode))
148
149(use-package projectile
150 :guix-package "emacs-projectile"
151 :diminish projectile-mode
152 :init
153 (when (file-directory-p "~/Documents/code")
154 (setq projectile-project-search-path '("~/Documents/code/")))
155 :custom ((projectile-Completion-system 'ivy))
156 :config
157 (setq projectile-switch-project-action #'projectile-dired)
158 (projectile-mode))
159
160(use-package magit
161 :guix-package "emacs-magit"
162 :custom
163 (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
164
165(use-package restclient
166 :guix-package "emacs-restclient")
167
168(setq sql-connection-alist
169 '(("net47-abaks"
170 (sql-product 'postgres)
171 (sql-user "kuba")
172 (sql-database "net47")
173 (sql-server "net47.abaks.pl"))))
174
175(provide 'jd-dev)
176
177;;; jd-dev.el ends here
diff --git a/files/.emacs.d/jd/jd-exwm.el b/files/.emacs.d/jd/jd-exwm.el
new file mode 100755
index 0000000..7731b01
--- /dev/null
+++ b/files/.emacs.d/jd/jd-exwm.el
@@ -0,0 +1,177 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6
7(use-package perspective
8 :guix-package "emacs-perspective")
9
10(use-package exwm
11 :guix-package "emacs-exwm"
12 :config
13 (defun jd/exwm-update-class ()
14 (exwm-workspace-rename-buffer exwm-class-name))
15
16 (defun jd-exwm/run-in-background (command)
17 (let ((command-parts (split-string command "[ ]+")))
18 (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
19
20 (defun jd-exwm/restart-process (program-name)
21 (call-process "killall" nil nil nil program-name)
22 (jd-exwm/run-in-background program-name))
23
24 (defun jd-exwm/exwm-init-hook ()
25 (jd-exwm/run-in-background "nitrogen --restore")
26 (start-process-shell-command "xinput" nil "xinput set-prop 'ETPS/2 Elantech Touchpad' 'Synaptics Tap Action' 1 1 1 2 1")
27 (start-process-shell-command "syndaemon" nil "syndaemon -i 0.8 -K -R -d")
28
29 (jd-exwm/restart-process "polybar")
30 (jd-exwm/restart-process "nm-applet")
31 (jd-exwm/restart-process "redshift-gtk -l 54.37:18.6")
32 (jd-exwm/restart-process "blueman-applet"))
33
34 (defun jd-exwm/exwm-update-title ()
35 (exwm-workspace-rename-buffer exwm-title))
36
37 (defun jd-exwm/configure-window-by-class ()
38 (interactive)
39 (pcase exwm-class-name
40 ("firefox" (exwm-workspace-move-window 2))
41 ("Brave" (exwm-workspace-move-window 2))
42 ("qutebrowser" (exwm-workspace-move-window 2))
43 ("discord" (exwm-workspace-move-window 5))
44 ("obs" (exwm-workspace-move-window 5))
45 ("Virt-manager" (exwm-workspace-move-window 4))))
46
47 (setq exwm-workspace-number 10)
48
49 ;; (add-hook 'exwm-init-hook #'jd-exwm/exwm-init-hook)
50 (add-hook 'exwm-update-class-hook #'jd/exwm-update-class)
51 (add-hook 'exwm-update-title-hook #'jd-exwm/exwm-update-title)
52 (add-hook 'exwm-manage-finish-hook #'jd-exwm/configure-window-by-class)
53
54 (require 'exwm-randr)
55 (setq exwm-randr-workspace-monitor-plist '(9 "eDP-1" 0 "eDP-1"))
56 (exwm-randr-enable)
57
58 (setq exwm-input-simulation-keys
59 '(([?\C-b] . [left])
60 ([?\C-f] . [right])
61 ([?\C-p] . [up])
62 ([?\C-n] . [down])
63 ([?\C-a] . [home])
64 ([?\C-e] . [end])
65 ([?\C-k] . [S-end delete])
66 ([?\M-w] . [C-c])
67 ([?\C-y] . [C-v])
68 ([?\C-v] . [next])
69 ([?\M-v] . [prior])
70 ))
71
72 (setq exwm-input-prefix-keys
73 '(?\C-x
74 ?\C-u
75 ?\C-h
76 ?\M-x
77 ?\M-`
78 ?\M-&
79 ?\M-!
80 ?\C-g
81 ?\M-:
82 ?\C-\M-j
83 ?\C-\ ))
84
85 (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
86 (exwm-input-set-key (kbd "s-p") 'counsel-linux-app)
87
88 (setq exwm-input-global-keys
89 `(([?\s-R] . exwm-reset)
90
91
92 ([?\s-r] . (lambda (command)
93 (interactive (list (read-shell-command "$ ")))
94 (start-process-shell-command command nil command)))
95
96 ([?\s-W] . exwm-workspace-move-window)
97 ([?\s-w] . exwm-workspace-switch)
98
99 ,@(mapcar (lambda (i)
100 `(,(kbd (format "s-%d" i)) .
101 (lambda ()
102 (interactive)
103 (exwm-workspace-switch-create ,i))))
104 (number-sequence 0 9))))
105
106 (exwm-enable)
107 (require 'exwm-systemtray)
108 (exwm-systemtray-enable))
109
110(use-package desktop-environment
111 :guix-package "emacs-desktop-environment"
112 :after exwm
113 :custom
114 (desktop-environment-brightness-small-increment "2%+")
115 (desktop-environment-brightness-small-decrement "2%-")
116 (desktop-environment-brightness-normal-increment "5%+")
117 (desktop-environment-brightness-normal-decrement "5%-")
118
119 :config
120 (defun jd/dunst-show-history ()
121 (interactive)
122 (start-process-shell-command "dunstctl" nil "dunstctl history-pop"))
123 (global-set-key (kbd "C-c N h") #'jd/dunst-show-history)
124
125 (defun jd/dunst-close ()
126 (interactive)
127 (start-process-shell-command "dunstctl" nil "dunstctl close"))
128 (global-set-key (kbd "C-c N c") #'jd/dunst-close)
129
130 (defun jd/dunst-close-all ()
131 (interactive)
132 (start-process-shell-command "dunstctl" nil "dunstctl close-all"))
133 (global-set-key (kbd "C-c N a") #'jd/dunst-close-all)
134
135 (desktop-environment-mode))
136
137;; (set-frame-parameter (selected-frame) 'alpha '(90 . 90))
138;; (add-to-list 'default-frame-alist `(alpha . (90 . 90)))
139;; (set-frame-parameter (selected-frame) 'fullscreen 'maximized)
140;; (add-to-list 'default-frame-alist '(fullscreen . maximized))
141
142(defun jd-exwm/get-color (ATTRIBUTE)
143 (face-attribute 'default ATTRIBUTE))
144
145(defun theme-to-xresources ()
146 (interactive)
147 (require 'term)
148 (with-temp-buffer
149 (insert "! Generated by theme-to-xresources\n")
150 (dolist (spec
151 '(("emacs.background" :background "E6")
152 ("emacs.foreground" :foreground "")))
153 (let ((color (jd-exwm/get-color (cadr spec))))
154 (insert (format "%s: #%s%s\n"
155 (car spec)
156 (caddr spec)
157 (string-remove-prefix "#" color))))
158 jd
159 (write-region (point-min) (point-max) "~/.Xresources")))
160 (call-process "xrdb" nil nil nil "-merge" (expand-file-name "~/.Xresources")))
161
162(defun jd/theme-sync ()
163 (interactive)
164 (theme-to-xresources)
165 (setq org-confirm-babel-evaluate nil)
166 (org-babel-tangle-file "~/dotfiles/Desktop.org")
167 (setq org-confirm-babel-evaluate 't)
168 (call-process "killall" nil nil nil "dunst") ;; TODO: prevent clear notification history
169 (jd-exwm/restart-process "polybar"))
170
171;; (add-hook 'jd/load-theme-hook #'jd/theme-sync)
172;; (add-hook 'exwm-init-hook #'jd/theme-sync)
173
174(provide 'jd-exwm)
175
176;;; jd-exwm.el ends here
177
diff --git a/files/.emacs.d/jd/jd-gym.el b/files/.emacs.d/jd/jd-gym.el
new file mode 100755
index 0000000..581bf65
--- /dev/null
+++ b/files/.emacs.d/jd/jd-gym.el
@@ -0,0 +1,120 @@
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/files/.emacs.d/jd/jd-keys.el b/files/.emacs.d/jd/jd-keys.el
new file mode 100755
index 0000000..8c1c4cb
--- /dev/null
+++ b/files/.emacs.d/jd/jd-keys.el
@@ -0,0 +1,49 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3;; Custom keysets used in my emacs
4;;; Code:
5
6(use-package multiple-cursors
7 :guix-package "emacs-multiple-cursors"
8 :config
9 (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
10 (global-set-key (kbd "C->") 'mc/mark-next-like-this)
11 (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
12 (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this))
13
14(use-package hydra
15 :guix-package "emacs-hydra"
16 ;; :defer t
17 :config
18 (defun jd/text-scale-increase ()
19 (interactive)
20 (let ((old-face-attribute (face-attribute 'default :height)))
21 (set-face-attribute 'default nil :height (+ old-face-attribute 10))))
22
23 (defun jd/text-scale-decrease ()
24 (interactive)
25 (let ((old-face-attribute (face-attribute 'default :height)))
26 (set-face-attribute 'default nil :height (- old-face-attribute 10))))
27
28 (defhydra hydra-text-scale-global (:timeout 4)
29 "scale text"
30 ("j" jd/text-scale-increase "in")
31 ("k" jd/text-scale-decrease "out")
32 ("q" nil "finished" :exit t)) ;; TODO not working
33
34 (defhydra hydra-text-scale (:timeout 4)
35 "scale text"
36 ("j" text-scale-increase "in")
37 ("k" text-scale-decrease "out")
38 ("q" nil "finished" :exit t)))
39
40(use-package undo-tree
41 :guix-package "emacs-undo-tree"
42 :diminish
43 :config
44 (setq undo-tree-auto-save-history nil)
45 (global-undo-tree-mode 1))
46
47(provide 'jd-keys)
48
49;;; jd-keys.el ends here
diff --git a/files/.emacs.d/jd/jd-misc.el b/files/.emacs.d/jd/jd-misc.el
new file mode 100644
index 0000000..2b7d1bd
--- /dev/null
+++ b/files/.emacs.d/jd/jd-misc.el
@@ -0,0 +1,34 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(defun jd/generete-qr-from-clipboard ()
7 (interactive)
8 (let ((clipboard-value (x-get-clipboard))
9 (clipboard-file-path "/tmp/clipboard_value.txt")
10 (clipboard-out-image "/tmp/qr.png"))
11 (with-temp-file clipboard-file-path
12 (insert clipboard-value))
13 (shell-command (concat
14 "qrencode -o "
15 clipboard-out-image
16 " < "
17 clipboard-file-path))
18 (find-file clipboard-out-image)))
19
20(defun jd/dired-open-file-in-kill-ring ()
21 (interactive)
22 (let* ((last-killed (car kill-ring))
23 (exists-p (file-exists-p last-killed))
24 (dir-p (file-directory-p last-killed)))
25 (cond
26 ((not exists-p) (message "File doesn't exists!"))
27 (dir-p (dired last-killed))
28 ((not dir-p) (find-file last-killed)))))
29
30(global-set-key (kbd "C-c O") #'jd/dired-open-file-in-kill-ring)
31
32(provide 'jd-misc)
33
34;;; jd-misc.el ends here
diff --git a/files/.emacs.d/jd/jd-mu4e.el b/files/.emacs.d/jd/jd-mu4e.el
new file mode 100755
index 0000000..b388201
--- /dev/null
+++ b/files/.emacs.d/jd/jd-mu4e.el
@@ -0,0 +1,84 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(use-package htmlize
7 :guix-package "emacs-htmlize")
8
9(use-package mu4e
10 :guix-package ("mu" "isync")
11 :defer 10
12 :ensure nil
13 :bind
14 ("C-c M" . mu4e)
15 :config
16 ;a (require 'org-mu4e)
17
18 (unless jd/guix-p
19 (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
20 (setq mu4e-mu-binary "/usr/local/bin/mu"))
21
22 (setq mu4e-update-interval (* 10 60))
23 (setq mu4e-get-mail-command "mbsync -a")
24 (setq mu4e-maildir "~/Mail")
25
26 (setq mu4e-completing-read-function #'ivy-completing-read)
27
28 (setq mu4e-change-filenames-when-moving t)
29
30 (setq mu4e-contexts
31 `(,(make-mu4e-context
32 :name "Abaks"
33 :match-func (lambda (msg) (when msg
34 (string-prefix-p "/abaks" (mu4e-message-field msg :maildir))))
35 :vars '(
36 (user-full-name . "Jakub Dlugosz")
37 (user-mail-address . "jakub@abaks.pl")
38 (mu4e-sent-folder . "/abaks/Sent Items")
39 (mu4e-trash-folder . "/abaks/Trash")
40 (mu4e-drafts-folder . "/abaks/Drafts")
41 (mu4e-refile-folder . "/abaks/Archive")
42 (mu4e-sent-messages-behavior . sent)
43 (smtpmail-local-domain . "pl")
44 (smtpmail-smtp-server . "smtp.abaks.pl")
45 (smtpmail-smtp-user . "jakub@abaks.pl")))
46 ,(make-mu4e-context
47 :name "Gmail"
48 :match-func (lambda (msg) (when msg
49 (string-prefix-p "/gmail" (mu4e-message-field msg :maildir))))
50 :vars '(
51 (user-full-name . "Jakub Dlugosz")
52 (user-mail-address . "jdlugosz963@gmail.com")
53 (mu4e-sent-folder . "/gmail/\[Gmail\]/Wys\&AUI-ane")
54 (mu4e-trash-folder . "/gmail/\[Gmail\]/Kosz")
55 (mu4e-drafts-folder . "/gmail/\[Gmail\]/Wersje\ robocze")
56 (mu4e-refile-folder . "/gmail/Archive")
57 (smtpmail-local-domain . "com")
58 (smtpmail-smtp-server . "smtp.gmail.com")
59 (smtpmail-smtp-user . "jdlugosz963@gmail.com")
60 (mu4e-sent-messages-behavior . sent)))))
61
62 (setq mail-user-agent 'mu4e-user-agent
63 mail-host-address nil
64 message-send-mail-function 'smtpmail-send-it
65 smtpmail-smtp-service 465
66 smtpmail-stream-type 'ssl
67 smtpmail-servers-requiring-authorization ".*")
68
69 (setq mu4e-compose-signature (concat
70 "Pozdrawiam,\n"
71 "Jakub Długosz"))
72
73 (mu4e t)
74 (mu4e-modeline-mode nil))
75
76(use-package mu4e-alert
77 :guix-package "emacs-mu4e-alert"
78 :defer 20
79 :config
80 (mu4e-alert-set-default-style 'libnotify)
81 (mu4e-alert-enable-mode-line-display)
82 (mu4e-alert-enable-notifications))
83
84(provide 'jd-mu4e)
diff --git a/files/.emacs.d/jd/jd-org.el b/files/.emacs.d/jd/jd-org.el
new file mode 100755
index 0000000..400d00c
--- /dev/null
+++ b/files/.emacs.d/jd/jd-org.el
@@ -0,0 +1,224 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(defvar jd/org-home "~/Notes")
7(defvar jd/org-roam-home (concat jd/org-home "/roam"))
8(defvar jd/org-sync (concat jd/org-home "/sync"))
9(defvar jd/org-roam-daily-home (concat jd/org-roam-home "/daily"))
10
11(defun jd/org-mode-init ()
12 (org-indent-mode)
13 (variable-pitch-mode 1)
14 (visual-line-mode 1))
15
16(defun jd-emacs/org-insert-date (&optional date)
17 (org-insert-time-stamp (org-read-date nil t (or date "+0d"))))
18
19(use-package org-pomodoro
20 :guix-package "emacs-org-pomodoro")
21
22(use-package org-caldav
23 :guix-package "emacs-org-caldav"
24 :config
25 (setq org-caldav-url "http://caldav.jdlugosz.com/radicale/admin/"
26 org-caldav-files nil
27 org-icalendar-timezone "Europe/Warsaw")
28
29 (defun jd/caldav-calendar-sync ()
30 (interactive)
31 (let ((org-caldav-calendar-id "0c54a523-c7aa-2f26-2c18-a12b69c2bc86")
32 (org-caldav-inbox (concat jd/org-sync
33 "/calendar.org")))
34 (org-caldav-sync)))
35
36 (defun jd/caldav-journal-sync ()
37 (interactive)
38 (let ((org-caldav-calendar-id "3cc70419-a787-5f84-28c6-96f15fc606d9")
39 (org-caldav-inbox (concat jd/org-sync
40 "/journal.org")))
41 (org-caldav-sync)))
42
43 (defun jd/caldav-tasks-sync ()
44 (interactive)
45 (let ((org-caldav-calendar-id "372cbbb3-14f7-fc15-9f7b-cae04114920c")
46 (org-caldav-inbox (concat jd/org-sync
47 "/tasks.org")))
48 (org-caldav-sync))))
49
50(use-package org
51 :guix-package "emacs-org"
52 :pin org
53 :commands (org-capture org-agenda)
54 :hook (org-mode . jd/org-mode-init)
55 :bind
56 ("C-c o c" . #'org-capture)
57 ("C-c o p" . #'org-mobile-pull)
58 ("C-c o P" . #'org-mobile-push)
59 ("C-c o a" . #'org-agenda)
60 :config
61 (defun jd/org-mode-file (file-name) (concat org-directory "/" file-name ".org"))
62 (setq org-directory (file-truename "~/Notes")
63 org-mobile-directory (concat org-directory "/Mobile")
64 org-mobile-inbox-for-pull (concat org-directory "/flagged.org") ;; TODO: ??
65
66 org-refile-targets '((org-agenda-files :maxlevel . 1))
67 org-outline-path-complete-in-steps nil
68 org-refile-use-outline-path t
69 org-agenda-files '("Personal.org" "Work.org" "Inbox.org")
70 org-ellipsis " ▾"
71 org-agenda-start-with-log-mode t
72 org-log-done 'time
73 org-log-into-drawer t
74 org-return-follows-link t
75 org-latex-listings 'minted
76 org-latex-packages-alist '(("" "minted"))
77
78 org-agenda-custom-commands
79 `(("p" "Planning"
80 ((tags-todo "+planning"
81 ((org-agenda-overriding-header "Planning Tasks")))
82 (tags-todo "-{.*}"
83 ((org-agenda-overriding-header "Untagged Tasks")))
84 (todo "*" ((org-agenda-files '(,(jd/org-mode-file "Inbox")))
85 (org-agenda-overriding-header "Unprocessed Inbox Items")))))
86
87 ("d" "Daily Agenda"
88 ((agenda "" ((org-agenda-span 'day)
89 (org-deadline-warning-days 7)))
90 (tags-todo "+PRIORITY=\"A\""
91 ((org-agenda-overriding-header "High Priority Tasks")))))
92
93 ("w" "Weekly Review"
94 ((agenda ""
95 ((org-agenda-overriding-header "Completed Tasks")
96 (org-agenda-skip-function '(org-agenda-skip-entry-if 'nottodo 'done))
97 (org-agenda-span 'week)))
98
99 (agenda ""
100 ((org-agenda-overriding-header "Unfinished Scheduled Tasks")
101 (org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
102 (org-agenda-span 'week))))))
103
104 org-capture-templates
105 `(("i" "Capture to Inbox" entry (file+olp ,(jd/org-mode-file "Inbox") "Inbox")
106 "* TODO %?\n %t\n" :empty-lines 1))
107
108 org-latex-pdf-process
109 '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
110 "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
111
112 (require 'org-tempo)
113
114 (defun jd/org-font-setup ()
115 ;; Replace list hyphen with dot
116 ;; (font-lock-add-keywords 'org-mode
117 ;; '(("^ *\\([.]\\) "
118 ;; (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-"))))))
119
120 ;; Set faces for heading levels
121 (dolist (face '((org-level-1 . 1.3)
122 (org-level-2 . 1.2)
123 (org-level-3 . 1.1)
124 (org-level-4 . 1.0)
125 (org-level-5 . 1.0)
126 (org-level-6 . 1.0)
127 (org-level-7 . 1.0)
128 (org-level-8 . 1.0)))
129 (set-face-attribute (car face) nil :font "Terminus" :weight 'Bold :height (cdr face)))
130
131 ;; Ensure that anything that should be fixed-pitch in Org files appears that way
132 (set-face-attribute 'org-block nil :font "Terminus" :inherit 'fixed-pitch :height 100)
133 (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
134 (set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
135 (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
136 (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
137 (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
138 (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
139 (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
140 (set-face-attribute 'line-number nil :inherit 'fixed-pitch)
141 (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch))
142
143 (with-eval-after-load 'org (jd/org-font-setup))
144
145 (defun jd-emacs/org-timer-stop ()
146 (start-process-shell-command "notify-send" nil "notify-send Zakonczono odliczanie"))
147
148 (add-hook 'org-timer-stop-hook #'jd-emacs/org-timer-stop)
149
150 (defun jd/org-tempo-setup ()
151 (dolist (template '(("s" . "src")
152 ("sql" . "src sql")
153 ("sh" . "src sh")
154 ("el" . "src emacs-lisp")
155 ("li" . "src lisp")
156 ("sc" . "src scheme")
157 ("ts" . "src typescript")
158 ("py" . "src python")
159 ("go" . "src go")
160 ("yaml" . "src yaml")))
161 (add-to-list 'org-structure-template-alist template)))
162
163 (with-eval-after-load 'org-tempo (jd/org-tempo-setup))
164
165 (org-babel-do-load-languages
166 'org-babel-load-languages
167 '((emacs-lisp . t)
168 (python . t)
169 (shell . t))))
170
171(use-package org-superstar
172 :guix-package "emacs-org-superstar"
173 :hook (org-mode . org-superstar-mode)
174 :init
175 (setq org-superstar-special-todo-items t)
176 (setq org-superstar-remove-leading-stars t)
177 (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●")))
178
179(use-package org-roam
180 :guix-package "emacs-org-roam"
181 :custom
182 (org-roam-directory (file-truename jd/org-roam-home))
183 :bind (("C-c n l" . org-roam-buffer-toggle)
184 ("C-c n f" . org-roam-node-find)
185 ("C-c n g" . org-roam-graph)
186 ("C-c n i" . org-roam-node-insert)
187 ("C-c n c" . org-roam-capture)
188 ;; Dailies
189 ("C-c n j" . org-roam-dailies-capture-today))
190 :bind-keymap
191 ("C-c n d" . org-roam-dailies-map)
192 :config
193 (require 'org-roam-dailies)
194
195 (defun jd/org-roam-filter-by-tag (tag-name)
196 (lambda (node)
197 (member tag-name (org-roam-node-tags node))))
198
199 (defun jd/org-roam-list-notes-by-tag (tag-name)
200 (mapcar #'org-roam-node-file
201 (seq-filter
202 (jd/org-roam-filter-by-tag tag-name)
203 (org-roam-node-list))))
204
205 (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
206 (setq org-roam-capture-templates
207 '(("d" "default" plain "%?"
208 :target (file+head
209 "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n* ${title}\n %?") ;; TODO: point cursor to the end of the file, it should be: `%?`
210 :unnarrowed t)
211 ;; ("n" "insert node" plain (file "~/Documents/roam/study/templates/research.org")
212 ;; :target (file+head "study/%<%Y%m%d%H%M%S>-${slug}.org"
213 ;; "#+title: ${title}\n")
214 ;; :unnarrowed t)
215 ))
216
217 (org-roam-db-autosync-mode))
218
219(use-package ox-pandoc
220 :guix-package "emacs-ox-pandoc")
221
222(provide 'jd-org)
223
224;;; jd-org.el ends here
diff --git a/files/.emacs.d/jd/jd-sway.el b/files/.emacs.d/jd/jd-sway.el
new file mode 100644
index 0000000..cdfb667
--- /dev/null
+++ b/files/.emacs.d/jd/jd-sway.el
@@ -0,0 +1,18 @@
1;;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(defun use-package-normalize/:diminish (name keyword args)
7 (use-package-as-one (symbol-name keyword) args
8 (apply-partially #'use-package-normalize-diminish name) t))
9
10(use-package shackle
11 :guix-package "emacs-shackle")
12
13(use-package sway
14 :guix-package "emacs-sway")
15
16(provide 'jd-sway)
17
18;;; jd-sway.el ends here
diff --git a/files/.emacs.d/jd/jd-ui.el b/files/.emacs.d/jd/jd-ui.el
new file mode 100755
index 0000000..4e388c9
--- /dev/null
+++ b/files/.emacs.d/jd/jd-ui.el
@@ -0,0 +1,104 @@
1;; Dotfiles --- Jakub Dlugosz emacs config
2;;; Commentary:
3
4;;; Code:
5
6(setq inhibit-startup-message t)
7(setq visible-bell t)
8(scroll-bar-mode -1)
9(tool-bar-mode -1)
10(tooltip-mode -1)
11(menu-bar-mode -1)
12(set-fringe-mode 10)
13
14;; (set-frame-parameter (selected-frame) 'alpha '(92 . 92))
15;; (add-to-list 'default-frame-alist '(alpha . (92 . 92)))
16
17(let ((height (if (string-equal (system-name)
18 "berserker")
19 175
20 125)))
21 (custom-set-faces
22 `(default ((t (:inherit nil :height ,height :family "Terminus"))))
23 `(line-number ((t (:inherit nil :height ,height :family "Terminus"))))
24 `(line-number-current-line ((t (:inherit nil :height ,height :family "Terminus"))))))
25
26(add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative)
27
28(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
29
30(global-prettify-symbols-mode 1)
31
32(defalias 'yes-or-no-p 'y-or-n-p)
33
34(require 'diminish)
35
36(use-package doom-modeline
37 :guix-package "emacs-doom-modeline"
38 :config
39 (doom-modeline-mode))
40
41(use-package solarized-theme
42 :guix-package "emacs-solarized-theme"
43 :config
44 (load-theme 'solarized-dark-high-contrast t))
45
46
47(use-package diminish
48 :guix-package "emacs-diminish")
49
50(use-package hl-todo
51 :guix-package "emacs-hl-todo"
52 :init
53 (setq hl-todo-keyword-faces
54 '(("TODO" . "#FF0000")
55 ("FIXME" . "#FF0000")
56 ("DEBUG" . "#A020F0")))
57 :config
58 (global-hl-todo-mode 1))
59
60(defvar jd/load-theme-hook nil)
61(defun jd/load-theme ()
62 (interactive)
63 (counsel-load-theme)
64 (run-hooks 'jd/load-theme-hook))
65
66(use-package ivy
67 :guix-package "emacs-ivy"
68 :diminish
69 :bind
70 (("C-s" . swiper))
71 :config
72 (ivy-mode 1))
73
74(use-package counsel
75 :guix-package "emacs-counsel"
76 :diminish t
77 :config
78 (counsel-mode 1))
79
80(use-package which-key
81 :guix-package "emacs-which-key"
82 :diminish
83 :config
84 (which-key-mode)
85 (setq which-key-idle-delay 0.3))
86
87(use-package all-the-icons
88 :guix-package "emacs-all-the-icons")
89
90(use-package beacon
91 :guix-package "emacs-beacon"
92 :config
93 (beacon-mode 1))
94
95(setq display-time-string-forms
96 '(" " 24-hours ":" minutes " "))
97
98(when jd/exwm-p
99 (display-battery-mode)
100 (display-time-mode))
101
102(provide 'jd-ui)
103
104;;; jd-ui.el ends here