aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/init.el
blob: 5d5c0c4a16a6fc4b018ec5a8dc07821936893c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
;; Debian packages: elpa-use-package elpa-fill-column-indicator fonts-hack

(require 'package)
(require 'fill-column-indicator)

;; This is only needed once, near the top of the file
(eval-when-compile
  (require 'use-package))

(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)

(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)

;; Do not persist customizations
(setq custom-file (make-temp-file "emacs-custom-"))

;; Place backups in ~/.backups/ directory, like a civilized program.
;; ------
(if (file-directory-p "~/.backup")
    (setq backup-directory-alist '(("." . "~/.backup")))
  (message "Directory does not exist: ~/.backup"))

(filesets-init)

(setq backup-by-copying t    ; Don't delink hardlinks
      delete-old-versions t  ; Clean up the backups
      version-control t      ; Use version numbers on backups,
      kept-new-versions 3    ; keep some new versions
      kept-old-versions 2)   ; and some old ones, too

;; ---------
;; Generic keybindings
;; ---------
(global-set-key (kbd "C-c d") 'diff-buffer-with-file)
(global-set-key (kbd "C-c R") 'revert-buffer)

;; compile
(global-set-key [f12] 'compile)

(defun help/insert-em-dash ()
  "Inserts an EM-DASH (not a HYPEN, not an N-DASH)"
  (interactive)
  (insert "—"))

(global-set-key (kbd "C--") #'help/insert-em-dash)

;; ------
;; General config
;; ------

(setq fill-column 79)

;; Make sure that pressing middle mouse button pastes right at point,
;; not where the mouse cursor is.
(setq mouse-yank-at-point t)

(setq column-number-mode 1)
(setq line-number-mode 1)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)

(setq-default c-basic-offset 4)

;; ------
;; Initialize environment
;; ------

(setenv "TMPDIR" (concat (getenv "HOME") "/tmp"))
(add-hook 'after-init-hook #'server-start)

;; ------
;; Helper for compilation.
;; ------
;; Close the compilation window if there was no error at all.
(defun compilation-exit-autoclose (status code msg)
  ;; If M-x compile exists with a 0
  (when (and (eq status 'exit) (zerop code))
    ;; then bury the *compilation* buffer, so that C-x b doesn't go there
    (bury-buffer)
    ;; and delete the *compilation* window
    (delete-window (get-buffer-window (get-buffer "*compilation*"))))
  ;; Always return the anticipated result of compilation-exit-message-function
  (cons msg code))

;; Specify my function (maybe I should have done a lambda function)
(setq compilation-exit-message-function 'compilation-exit-autoclose)
(setq compilation-read-command nil)

;; Themes
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")

;; Remove scratch message
(setq initial-scratch-message "")

;; Ask y or n instead of yes or no
(defalias 'yes-or-no-p 'y-or-n-p)

;; Fancier buffer selection
(global-set-key (kbd "C-x C-b") 'bs-show)

;;; Stefan Monnier <foo at acm.org>. It is the opposite of fill-paragraph
(defun unfill-paragraph (&optional region)
  "Takes a multi-line paragraph and makes it into a single line of text."
  (interactive (progn (barf-if-buffer-read-only) '(t)))
  (let ((fill-column (point-max))
        ;; This would override `fill-column' if it's an integer.
        (emacs-lisp-docstring-fill-column t))
    (fill-paragraph nil region)))

;; Handy key definition
(define-key global-map "\M-Q" 'unfill-paragraph)

;; Only flash the mode line
(setq ring-bell-function
      (lambda ()
        (let ((orig-fg (face-foreground 'mode-line)))
          (set-face-foreground 'mode-line "#F2804F")
          (run-with-idle-timer 0.1 nil
                               (lambda (fg) (set-face-foreground 'mode-line fg))
                               orig-fg))))

;; Highlight parens
(setq show-paren-delay 0)
(show-paren-mode 1)

;; Save what you enter into minibuffer prompts
(setq history-length 25)
(savehist-mode 1)

;; Remember and restore cursor information
(save-place-mode 1)

;; Desktop

;; Save the desktop session
(setq desktop-path `(,user-emacs-directory))
(setq desktop-base-file-name "desktop")
(desktop-save-mode 1)

;; Set this to t if you don't understand what it means
(setq vc-follow-symlinks nil)

;; dired
(add-hook 'dired-mode-hook #'dired-hide-details-mode)

(setq dired-guess-shell-alist-user
      '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
        ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
		(".*" "xdg-open")))

(dolist (path '("~/.emacs.d/rul-lisp/config" "~/.emacs.d/rul-lisp/packages"))
  (add-to-list 'load-path path))

(require 'rul-completion)
(require 'rul-dart)
(require 'rul-elfeed)
(require 'rul-org)
(require 'rul-org-roam)
(require 'rul-write)

(load-file "~/.emacs.d/rul-init.d/fonts.el")
(load-file "~/.emacs.d/rul-init.d/themes.el")

;; Init parts (will be deprecated in favor of packages)
(load-file "~/.emacs.d/rul-init.d/auto-fill.el")
;(load-file "~/.emacs.d/rul-init.d/doom-modeline.el")
(load-file "~/.emacs.d/rul-init.d/flycheck.el")
(load-file "~/.emacs.d/rul-init.d/flyspell.el")
(load-file "~/.emacs.d/rul-init.d/go-lang.el")
(load-file "~/.emacs.d/rul-init.d/hydra.el")
(load-file "~/.emacs.d/rul-init.d/ibuffer.el")
(load-file "~/.emacs.d/rul-init.d/imenu.el")
(load-file "~/.emacs.d/rul-init.d/latex.el")
(load-file "~/.emacs.d/rul-init.d/logos.el")
(load-file "~/.emacs.d/rul-init.d/mail-mode.el")
(load-file "~/.emacs.d/rul-init.d/markdown.el")
(load-file "~/.emacs.d/rul-init.d/magit.el")
(load-file "~/.emacs.d/rul-init.d/notmuch.el")
(load-file "~/.emacs.d/rul-init.d/projectile.el")
(load-file "~/.emacs.d/rul-init.d/tabbar.el")
(load-file "~/.emacs.d/rul-init.d/which-key.el")
(load-file "~/.emacs.d/rul-init.d/writeroom.el")
(load-file "~/.emacs.d/rul-init.d/vterm.el")

(load-file "~/.emacs.d/rul-init.d/staging.el")

(when-let* ((file (locate-user-emacs-file "rul-post-init.el"))
            ((file-exists-p file)))
  (load-file file))

;; init.el ends here
nihil fit ex nihilo