summaryrefslogtreecommitdiffstats
path: root/.emacs.d/init.el
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2024-09-20 14:16:56 +0200
committerjdlugosz963 <jdlugosz963@gmail.com>2024-09-20 14:16:56 +0200
commit45bb0d11161b1c5077a1415eed6dbd0fd25ccb6a (patch)
treeb564c1c43920def6641cd482a7b4dca453dbc043 /.emacs.d/init.el
parent07dd8e37eb767c3dd6abf63e5e4a720cd778da15 (diff)
downloaddotfiles-45bb0d11161b1c5077a1415eed6dbd0fd25ccb6a.tar.gz
dotfiles-45bb0d11161b1c5077a1415eed6dbd0fd25ccb6a.zip
Change dotfiles structure, and add guix-channels declaration.
Diffstat (limited to '.emacs.d/init.el')
-rwxr-xr-x.emacs.d/init.el146
1 files changed, 0 insertions, 146 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
deleted file mode 100755
index 090592f..0000000
--- a/.emacs.d/init.el
+++ /dev/null
@@ -1,146 +0,0 @@
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)