diff options
Diffstat (limited to '.emacs.d/init.el')
-rwxr-xr-x | .emacs.d/init.el | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el new file mode 100755 index 0000000..d4fc30a --- /dev/null +++ b/.emacs.d/init.el | |||
@@ -0,0 +1,122 @@ | |||
1 | ;;; Dotfiles --- Jakub Dlugosz emacs config | ||
2 | ;;; Commentary: | ||
3 | |||
4 | ;;; Code: | ||
5 | |||
6 | (setq gc-cons-threshold (* 50 1000 1000)) | ||
7 | |||
8 | (defvar jd/manifest-list | ||
9 | nil | ||
10 | "List that contain Emacs packages for GNU/Guix." ) | ||
11 | |||
12 | (defvar jd/exwm-p | ||
13 | (or (not (null (getenv "JD_EXWM"))) | ||
14 | (and (seq-contains command-line-args "exwm" #'string-match) | ||
15 | t)) | ||
16 | "Is non-nil when Emacs is run as a window manager.") | ||
17 | |||
18 | (defvar jd/guix-p | ||
19 | (and (eq system-type 'gnu/linux) | ||
20 | (file-exists-p "/etc/os-release") | ||
21 | (with-temp-buffer | ||
22 | (insert-file-contents "/etc/os-release") | ||
23 | (search-forward "ID=guix" nil t)) | ||
24 | t) | ||
25 | "Is non-nil when Emacs packages are installed by GNU/Guix package manager.") | ||
26 | |||
27 | (defun jd/add-package-to-manifest (guix-package-name) | ||
28 | "Add GUIX-PACKAGE-NAME to jd/manifest-list." | ||
29 | (unless (member guix-package-name jd/manifest-list) | ||
30 | (setq jd/manifest-list | ||
31 | (cons guix-package-name jd/manifest-list)))) | ||
32 | |||
33 | (add-to-list 'load-path (concat user-emacs-directory "/jd")) | ||
34 | |||
35 | (defun jd/display-startup-time () | ||
36 | (message "Emacs loaded in %s with %d garbage collections." | ||
37 | (format "%.2f seconds" | ||
38 | (float-time | ||
39 | (time-subtract after-init-time before-init-time))) | ||
40 | gcs-done)) | ||
41 | |||
42 | (defun jd-emacs/startup () | ||
43 | "This procedure will run after Emacs startup." | ||
44 | (electric-pair-mode 1) | ||
45 | (global-company-mode 1) | ||
46 | (jd/display-startup-time)) | ||
47 | |||
48 | (add-hook 'emacs-startup-hook #'jd-emacs/startup) | ||
49 | |||
50 | (setq user-full-name "Jakub Dlugosz" | ||
51 | user-mail-address "jdlugosz963@gmail.com") | ||
52 | |||
53 | (setq backup-directory-alist '(("." . "~/.cache/emacs/backup")) | ||
54 | backup-by-copying t | ||
55 | version-control t | ||
56 | delete-old-versions t | ||
57 | kept-new-versions 20 | ||
58 | kept-old-versions 5) | ||
59 | |||
60 | ;; (setq user-emacs-directory "~/.cache/emacs") | ||
61 | |||
62 | (require 'package) | ||
63 | (setq package-archives '(("melpa" . "https://melpa.org/packages/") | ||
64 | ("org" . "https://orgmode.org/elpa/") | ||
65 | ("gnu-devel" . "https://elpa.gnu.org/devel/") | ||
66 | ("elpa" . "https://elpa.gnu.org/packages/"))) | ||
67 | (package-initialize) | ||
68 | |||
69 | (unless package-archive-contents | ||
70 | (package-refresh-contents)) | ||
71 | |||
72 | (jd/add-package-to-manifest "emacs-use-package") | ||
73 | (unless jd/guix-p | ||
74 | (unless (package-installed-p 'use-package) | ||
75 | (package-install 'use-package))) | ||
76 | |||
77 | (require 'use-package) | ||
78 | |||
79 | (setq use-package-always-ensure (not jd/guix-p)) | ||
80 | |||
81 | (defmacro jd/use-package (package-name | ||
82 | guix-package-name | ||
83 | &rest body) | ||
84 | `(progn | ||
85 | ,(when guix-package-name | ||
86 | `(jd/add-package-to-manifest ,guix-package-name)) | ||
87 | (use-package ,package-name ,@body))) | ||
88 | |||
89 | (defun jd/manifest-generate-to-file (file-name) | ||
90 | "Generate GNU/Guix Emacs manifest to output file provided in: FILE-NAME." | ||
91 | (interactive | ||
92 | (list (read-from-minibuffer "Output file: " ))) | ||
93 | (with-temp-file file-name | ||
94 | (insert | ||
95 | (with-temp-buffer | ||
96 | (insert (format ";; This file is auto-generated by Emacs function: jd/manifest-generate-to-file\n%s" | ||
97 | `(specifications->manifest | ||
98 | '(,@(mapcar #'(lambda (guix-package-name) | ||
99 | (concat "\"" | ||
100 | guix-package-name | ||
101 | "\"\n")) | ||
102 | jd/manifest-list))))) | ||
103 | (pp-buffer) | ||
104 | (buffer-string))))) | ||
105 | |||
106 | (jd/add-package-to-manifest "emacs") | ||
107 | (jd/add-package-to-manifest "emacs-guix") | ||
108 | |||
109 | (require 'jd-keys) | ||
110 | (require 'jd-ui) | ||
111 | (require 'jd-org) | ||
112 | (require 'jd-dev) | ||
113 | (require 'jd-apps) | ||
114 | (require 'jd-custom) | ||
115 | (require 'jd-mu4e) | ||
116 | |||
117 | (when jd/exwm-p | ||
118 | (require 'jd-exwm)) | ||
119 | |||
120 | (setq gc-cons-threshold (* 2 1000 1000)) | ||
121 | |||
122 | ;;; init.el ends here | ||