[emacs] disable EXWM
[~bandali/configs] / init.org
CommitLineData
180cab37
AB
1#+title: =aminb='s Literate Emacs Configuration
2#+author: Amin Bandali
3#+babel: :cache yes
4#+property: header-args :tangle yes
5
6* About
7:PROPERTIES:
8:CUSTOM_ID: about
9:END:
10
11This org file is my literate configuration for GNU Emacs, and is
3b98e899
AB
12tangled to [[./init.el][init.el]]. Packages are installed and managed using
13[[https://github.com/emacscollective/borg][Borg]]. Over the years, I've taken inspiration from configurations of
14many different people. Some of the configurations that I can remember
15off the top of my head are:
16
17- [[https://github.com/dieggsy/dotfiles][dieggsy/dotfiles]]: literate Emacs and dotfiles configuration, uses
18 straight.el for managing packages
19- [[https://github.com/dakra/dmacs][dakra/dmacs]]: literate Emacs configuration, using Borg for managing
20 packages
21- [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua's literate Emacs configuration]]
22- [[https://github.com/dakrone/eos][dakrone/eos]]
23- Ryan Rix's [[http://doc.rix.si/cce/cce.html][Complete Computing Environment]] ([[http://doc.rix.si/projects/fsem.html][about cce]])
24- [[https://github.com/jwiegley/dot-emacs][jwiegley/dot-emacs]]: nix-based configuration
25- [[https://github.com/wasamasa/dotemacs][wasamasa/dotemacs]]
26- [[https://github.com/hlissner/doom-emacs][Doom Emacs]]
180cab37
AB
27
28I'd like to have a fully reproducible Emacs setup (part of the reason
29why I store my configuration in this repository) but unfortunately out
30of the box, that's not achievable with =package.el=, not currently
31anyway. So, I've opted to use Borg. For what it's worth, I briefly
32experimented with [[https://github.com/raxod502/straight.el][straight.el]], but found that it added about 2 seconds
33to my init time; which is unacceptable for me: I use Emacs as my
34window manager (via EXWM) and coming from bspwm, I'm too used to
35having fast startup times.
36
3b98e899
AB
37** Installation
38
4ae2cd62
AB
39To use this config for your Emacs, first you need to clone this repo,
40then bootstrap Borg, tell Borg to retrieve package submodules, and
41byte-compiled the packages. Something along these lines should work:
42
4b4e432d 43#+begin_src sh :tangle no
4ae2cd62
AB
44git clone https://github.com/aminb/dotfiles ~/.emacs.d
45cd ~/.emacs.d
46make bootstrap-borg
47make tangle-init
48make bootstrap
49make build
50#+end_src
51
180cab37
AB
52* Contents :toc_1:noexport:
53
54- [[#about][About]]
55- [[#header][Header]]
56- [[#initial-setup][Initial setup]]
57- [[#core][Core]]
967b0a82 58- [[#post-initialization][Post initialization]]
180cab37
AB
59- [[#footer][Footer]]
60
61* Header
62:PROPERTIES:
63:CUSTOM_ID: header
64:END:
65
66** First line
67
68#+begin_src emacs-lisp :comments none
69;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t ; eval: (view-mode 1)-*-
70#+end_src
71
72Enable =view-mode=, which both makes the file read-only (as a reminder
73that =init.el= is an auto-generated file, not supposed to be edited),
74and provides some convenient key bindings for browsing through the
75file.
76
77** License
78
79#+begin_src emacs-lisp :comments none
80;; Copyright (C) 2018 Amin Bandali <amin@aminb.org>
81
82;; This program is free software: you can redistribute it and/or modify
83;; it under the terms of the GNU General Public License as published by
84;; the Free Software Foundation, either version 3 of the License, or
85;; (at your option) any later version.
86
87;; This program is distributed in the hope that it will be useful,
88;; but WITHOUT ANY WARRANTY; without even the implied warranty of
89;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90;; GNU General Public License for more details.
91
92;; You should have received a copy of the GNU General Public License
93;; along with this program. If not, see <https://www.gnu.org/licenses/>.
94#+end_src
95
96** Commentary
97
98#+begin_src emacs-lisp :comments none
99;;; Commentary:
100
101;; Emacs configuration of Amin Bandali, computer scientist and functional
102;; programmer.
103
104;; THIS FILE IS AUTO-GENERATED FROM `init.org'.
105#+end_src
106
107** Naming conventions
108
109The conventions below were inspired by [[https://github.com/hlissner/doom-emacs][Doom]]'s conventions, found
110[[https://github.com/hlissner/doom-emacs/blob/5dacbb7cb1c6ac246a9ccd15e6c4290def67757c/core/core.el#L3-L17][here]]. Naturally, I use my initials, =ab=, instead of =doom=.
111
112#+begin_src emacs-lisp :comments none
113;; Naming conventions:
114;;
115;; ab-... public variables or non-interactive functions
116;; ab--... private anything (non-interactive), not safe for direct use
117;; ab/... an interactive function; safe for M-x or keybinding
118;; ab:... an evil operator, motion, or command
119;; ab|... a hook function
120;; ab*... an advising function
121;; ab@... a hydra command
122;; ...! a macro
123#+end_src
124
125* Initial setup
126:PROPERTIES:
127:CUSTOM_ID: initial-setup
128:END:
129
130#+begin_src emacs-lisp :comments none
131;;; Code:
132#+end_src
133
134** Emacs initialization
135
136I'd like to do a couple of measurements of Emacs' startup time. First,
137let's see how long Emacs takes to start up, before even loading
138=init.el=, i.e. =user-init-file=:
139
140#+begin_src emacs-lisp
141(defvar ab--before-user-init-time (current-time)
142 "Value of `current-time' when Emacs begins loading `user-init-file'.")
143(message "Loading Emacs...done (%.3fs)"
144 (float-time (time-subtract ab--before-user-init-time
145 before-init-time)))
146#+end_src
147
148Also, temporarily increase ~gc-cons-threshhold~ and
149~gc-cons-percentage~ during startup to reduce garbage collection
150frequency. Clearing the ~file-name-handler-alist~ seems to help reduce
151startup time as well.
152
153#+begin_src emacs-lisp
154(defvar ab--gc-cons-threshold gc-cons-threshold)
155(defvar ab--gc-cons-percentage gc-cons-percentage)
156(defvar ab--file-name-handler-alist file-name-handler-alist)
157(setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB
158 gc-cons-percentage 0.6
159 file-name-handler-alist nil
160 ;; sidesteps a bug when profiling with esup
161 esup-child-profile-require-level 0)
162#+end_src
163
164Of course, we'd like to set them back to their defaults once we're
165done initializing.
166
167#+begin_src emacs-lisp
168(add-hook
169 'after-init-hook
170 (lambda ()
171 (let ((elapsed (float-time (time-subtract (current-time)
172 ab--before-user-init-time))))
173 (message "Loading %s...done (%.3fs) [after-init]"
174 user-init-file elapsed))
175 (setq gc-cons-threshold ab--gc-cons-threshold
176 gc-cons-percentage ab--gc-cons-percentage
177 file-name-handler-alist ab--file-name-handler-alist)))
178#+end_src
179
180Increase the number of lines kept in message logs (the =*Messages*=
181buffer).
182
183#+begin_src emacs-lisp
184(setq message-log-max 20000)
185#+end_src
186
187Optionally, we could suppress some byte compiler warnings like below,
188but for now I've decided to keep them enabled. See documentation for
189~byte-compile-warnings~ for more details.
190
191#+begin_src emacs-lisp
192;; (setq byte-compile-warnings
193;; '(not free-vars unresolved noruntime lexical make-local))
194#+end_src
195
196** Package management
197
198*** No =package.el=
199
200I can do all my package management things with Borg, and don't need
201Emacs' built-in =package.el=. Emacs 27 lets us disable =package.el= in
202the =early-init-file= (see [[https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b][here]]).
203
204#+begin_src emacs-lisp :tangle early-init.el
205(setq package-enable-at-startup nil)
206#+end_src
207
208But since Emacs 27 isn't out yet (Emacs 26 is just around the corner
209right now), and even when released it'll be long before most distros
210ship in their repos, I'll still put the old workaround with the
211commented call to ~package-initialize~ here anyway.
212
213#+begin_src emacs-lisp
214(setq package-enable-at-startup nil)
215;; (package-initialize)
216#+end_src
217
218*** Borg
219
220#+begin_quote
221Assimilate Emacs packages as Git submodules
222#+end_quote
223
224[[https://github.com/emacscollective/borg][Borg]] is at the heart of package management of my Emacs setup. In
225short, it creates a git submodule in =lib/= for each package, which
226can then be managed with the help of Magit or other tools.
227
228#+begin_src emacs-lisp
229(setq user-init-file (or load-file-name buffer-file-name)
230 user-emacs-directory (file-name-directory user-init-file))
231(add-to-list 'load-path
232 (expand-file-name "lib/borg" user-emacs-directory))
233(require 'borg)
234(borg-initialize)
235#+end_src
236
237*** =use-package=
238
239#+begin_quote
240A use-package declaration for simplifying your .emacs
241#+end_quote
242
243[[https://github.com/jwiegley/use-package][use-package]] is an awesome utility for managing and configuring
244packages (in our case especially the latter) in a neatly organized way
245and without compromising on performance.
246
247#+begin_src emacs-lisp
248(require 'use-package)
249(if nil ; set to t when need to debug init
250 (setq use-package-verbose t
251 use-package-expand-minimally nil
252 use-package-compute-statistics t
253 debug-on-error t)
254 (setq use-package-verbose nil
255 use-package-expand-minimally t))
256#+end_src
257
258*** Epkg
259
260#+begin_quote
261Browse the Emacsmirror package database
262#+end_quote
263
264Epkg provides access to a local copy of the [[https://emacsmirror.net][Emacsmirror]] package
265database, low-level functions for querying the database, and a
266=package.el=-like user interface for browsing the available packages.
267
268#+begin_src emacs-lisp
269(use-package epkg
270 :defer t)
271#+end_src
272
273** No littering in =~/.emacs.d=
274
275#+begin_quote
276Help keeping ~/.emacs.d clean
277#+end_quote
278
279By default, even for Emacs' built-in packages, the configuration files
280and persistent data are all over the place. Use =no-littering= to help
281contain the mess.
282
283#+begin_src emacs-lisp
284(use-package no-littering
285 :demand t
286 :config
287 (savehist-mode 1)
288 (add-to-list 'savehist-additional-variables 'kill-ring)
289 (save-place-mode 1)
290 (setq auto-save-file-name-transforms
291 `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
292#+end_src
293
180cab37
AB
294** Custom file (=custom.el=)
295
296I'm not planning on using the custom file much, but even so, I
297definitely don't want it mixing with =init.el=. So, here; let's give
298it it's own file. While at it, treat themes as safe.
299
300#+begin_src emacs-lisp
301(use-package custom
302 :no-require t
303 :config
304 (setq custom-file (no-littering-expand-etc-file-name "custom.el"))
305 (when (file-exists-p custom-file)
306 (load custom-file))
307 (setf custom-safe-themes t))
308#+end_src
309
310** Better =$PATH= handling
311
312Let's use [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] to make Emacs use the =$PATH= as set up
313in my shell.
314
315#+begin_src emacs-lisp
7538956f
AB
316(use-package exec-path-from-shell
317 :defer 1
318 :init
319 (setq exec-path-from-shell-check-startup-files nil)
320 :config
321 (exec-path-from-shell-initialize)
322 ;; while we're at it, let's fix access to our running ssh-agent
323 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
324 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
180cab37
AB
325#+end_src
326
327** Server
328
329Start server if not already running. Alternatively, can be done by
330issuing =emacs --daemon= in the terminal, which can be automated with
331a systemd service or using =brew services start emacs= on macOS. I use
332Emacs as my window manager (via EXWM), so I always start Emacs on
333login; so starting the server from inside Emacs is good enough for me.
334
335See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server][Using Emacs as a Server]].
336
337#+begin_src emacs-lisp
338(use-package server
339 :config (or (server-running-p) (server-mode)))
340#+end_src
341
e9bcfa30
AB
342** Unicode support
343
344Font stack with better unicode support, around =Ubuntu Mono= and
345=Hack=.
346
347#+begin_src emacs-lisp
348(dolist (ft (fontset-list))
349 (set-fontset-font
350 ft
351 'unicode
352 (font-spec :name "Ubuntu Mono"))
353 (set-fontset-font
354 ft
355 'unicode
356 (font-spec
357 :name "Hack")
358 nil
359 'append)
360 (set-fontset-font
361 ft
362 'unicode
363 (font-spec
364 :name "Symbola monospacified for DejaVu Sans Mono")
365 nil
366 'append))
367#+end_src
368
180cab37
AB
369* Core
370:PROPERTIES:
371:CUSTOM_ID: core
372:END:
373
374** Defaults
375
e602de37
AB
376*** Time and battery in mode-line
377
378Enable displaying time and battery in the mode-line, since I'm not
379using the Xfce panel anymore. Also, I don't need to see the load
380average on a regular basis, so disable that.
381
382#+begin_src emacs-lisp
383(use-package time
384 :ensure nil
385 :init
386 (setq display-time-default-load-average nil)
387 :config
388 (display-time-mode))
389
390(use-package battery
391 :ensure nil
392 :config
393 (display-battery-mode))
394#+end_src
395
180cab37
AB
396*** Smaller fringe
397
2f8102f0
AB
398Might want to set the fringe to a smaller value, especially if using
399EXWM. I'm fine with the default for now.
180cab37
AB
400
401#+begin_src emacs-lisp
2f8102f0 402;; (fringe-mode '(3 . 1))
4b4e432d 403(fringe-mode nil)
180cab37
AB
404#+end_src
405
406*** Disable disabled commands
407
408Emacs disables some commands by default that could persumably be
409confusing for novice users. Let's disable that.
410
411#+begin_src emacs-lisp
412(setq disabled-command-function nil)
413#+end_src
414
415*** Kill-ring
416
417Save what I copy into clipboard from other applications into Emacs'
418kill-ring, which would allow me to still be able to easily access it
419in case I kill (cut or copy) something else inside Emacs before
420yanking (pasting) what I'd originally intended to.
421
422#+begin_src emacs-lisp
423(setq save-interprogram-paste-before-kill t)
424#+end_src
425
426*** Minibuffer
427
428#+begin_src emacs-lisp
429(setq enable-recursive-minibuffers t
430 resize-mini-windows t)
431#+end_src
432
433*** Lazy-person-friendly yes/no prompts
434
435Lazy people would prefer to type fewer keystrokes, especially for yes
436or no questions. I'm lazy.
437
438#+begin_src emacs-lisp
439(defalias 'yes-or-no-p #'y-or-n-p)
440#+end_src
441
442*** Startup screen and =*scratch*=
443
444Firstly, let Emacs know that I'd like to have =*scratch*= as my
445startup buffer.
446
447#+begin_src emacs-lisp
448(setq initial-buffer-choice t)
449#+end_src
450
451Now let's customize the =*scratch*= buffer a bit. First off, I don't
452need the default hint.
453
454#+begin_src emacs-lisp
455(setq initial-scratch-message nil)
456#+end_src
457
458Also, let's use Text mode as the major mode, in case I want to
459customize it (=*scratch*='s default major mode, Fundamental mode,
460can't really be customized).
461
462#+begin_src emacs-lisp
463(setq initial-major-mode 'text-mode)
464#+end_src
465
466Inhibit the buffer list when more than 2 files are loaded.
467
468#+begin_src emacs-lisp
469(setq inhibit-startup-buffer-menu t)
470#+end_src
471
472I don't really need to see the startup screen or echo area message
473either.
474
475#+begin_src emacs-lisp
476(advice-add #'display-startup-echo-area-message :override #'ignore)
477(setq inhibit-startup-screen t
478 inhibit-startup-echo-area-message user-login-name)
479#+end_src
480
481*** More useful frame titles
482
483Show either the file name or the buffer name (in case the buffer isn't
484visiting a file). Borrowed from Emacs Prelude.
485
486#+begin_src emacs-lisp
487(setq frame-title-format
488 '("" invocation-name " - "
489 (:eval (if (buffer-file-name)
490 (abbreviate-file-name (buffer-file-name))
491 "%b"))))
492#+end_src
493
494*** Backups
495
496Emacs' default backup settings aren't that great. Let's use more
497sensible options. See documentation for the ~make-backup-file~
498variable.
499
500#+begin_src emacs-lisp
501(setq backup-by-copying t
502 version-control t)
503#+end_src
504
505** Packages
506
507The packages in this section are absolutely essential to my everyday
508workflow, and they play key roles in how I do my computing. They
509immensely enhance the Emacs experience for me; both using Emacs, and
510customizing it.
511
512*** [[https://github.com/emacscollective/auto-compile][auto-compile]]
513
514#+begin_src emacs-lisp
515(use-package auto-compile
516 :demand t
517 :config
518 (auto-compile-on-load-mode)
519 (auto-compile-on-save-mode)
520 (setq auto-compile-display-buffer nil
521 auto-compile-mode-line-counter t
522 auto-compile-source-recreate-deletes-dest t
523 auto-compile-toggle-deletes-nonlib-dest t
524 auto-compile-update-autoloads t)
525 (add-hook 'auto-compile-inhibit-compile-hook
526 'auto-compile-inhibit-compile-detached-git-head))
527#+end_src
528
529*** TODO [[https://github.com/Kungsgeten/ryo-modal][ryo-modal]]
530
531#+begin_quote
532Roll your own modal mode
533#+end_quote
534
535*** [[https://github.com/ch11ng/exwm][EXWM]] (window manager)
536
45568be1 537#+begin_src emacs-lisp :tangle no
2f8102f0
AB
538(use-package exwm
539 :demand t
540 :config
541 (require 'exwm-config)
26c45764
AB
542
543 ;; Set the initial workspace number.
544 (setq exwm-workspace-number 4)
545
546 ;; Make class name the buffer name, truncating beyond 50 characters
547 (defun exwm-rename-buffer ()
548 (interactive)
549 (exwm-workspace-rename-buffer
550 (concat exwm-class-name ":"
551 (if (<= (length exwm-title) 50) exwm-title
552 (concat (substring exwm-title 0 49) "...")))))
553 (add-hook 'exwm-update-class-hook 'exwm-rename-buffer)
554 (add-hook 'exwm-update-title-hook 'exwm-rename-buffer)
555
556 ;; 's-R': Reset
557 (exwm-input-set-key (kbd "s-R") #'exwm-reset)
558 ;; 's-\': Switch workspace
559 (exwm-input-set-key (kbd "s-\\") #'exwm-workspace-switch)
560 ;; 's-N': Switch to certain workspace
561 (dotimes (i 10)
562 (exwm-input-set-key (kbd (format "s-%d" i))
563 (lambda ()
564 (interactive)
e9bcfa30 565 (exwm-workspace-switch-create i))))
26c45764 566 ;; 's-SPC': Launch application
b46e33ae
AB
567 ;; (exwm-input-set-key
568 ;; (kbd "s-SPC")
569 ;; (lambda (command)
570 ;; (interactive (list (read-shell-command "➜ ")))
571 ;; (start-process-shell-command command nil command)))
26c45764
AB
572
573 (exwm-input-set-key (kbd "M-s-SPC") #'counsel-linux-app)
574
575 ;; Shorten 'C-c C-q' to 'C-q'
576 (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
577
578 ;; Line-editing shortcuts
579 (setq exwm-input-simulation-keys
580 '(;; movement
581 ([?\C-b] . [left])
582 ([?\M-b] . [C-left])
583 ([?\C-f] . [right])
584 ([?\M-f] . [C-right])
585 ([?\C-p] . [up])
586 ([?\C-n] . [down])
587 ([?\C-a] . [home])
588 ([?\C-e] . [end])
589 ([?\M-v] . [prior])
590 ([?\C-v] . [next])
591 ([?\C-d] . [delete])
592 ([?\C-k] . [S-end delete])
b46e33ae
AB
593 ;; cut/copy/paste
594 ;; ([?\C-w] . [?\C-x])
26c45764
AB
595 ([?\M-w] . [?\C-c])
596 ([?\C-y] . [?\C-v])
597 ;; search
598 ([?\C-s] . [?\C-f])))
599
600 ;; Enable EXWM
601 (exwm-enable)
602
603 (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame)
604
2f8102f0
AB
605 (require 'exwm-systemtray)
606 (exwm-systemtray-enable)
26c45764 607
2f8102f0 608 (require 'exwm-randr)
26c45764
AB
609 (exwm-randr-enable)
610
b46e33ae
AB
611 ;; (exwm-input-set-key
612 ;; (kbd "s-<return>")
613 ;; (lambda ()
614 ;; (interactive)
615 ;; (start-process "urxvt" nil "urxvt")))
616
617 ;; (exwm-input-set-key
618 ;; (kbd "s-SPC") ;; rofi doesn't properly launch programs when started from emacs
619 ;; (lambda ()
620 ;; (interactive)
621 ;; (start-process-shell-command "rofi-run" nil "rofi -show run -display-run '> ' -display-window ' 🗔 '")))
622
623 ;; (exwm-input-set-key
624 ;; (kbd "s-/")
625 ;; (lambda ()
626 ;; (interactive)
627 ;; (start-process-shell-command "rofi-win" nil "rofi -show window -display-run '> ' -display-window ' 🗔 '")))
628
629 ;; (exwm-input-set-key
630 ;; (kbd "M-SPC")
631 ;; (lambda ()
632 ;; (interactive)
633 ;; (start-process "rofi-pass" nil "rofi-pass")))
634
635 ;; (exwm-input-set-key
636 ;; (kbd "<XF86AudioMute>")
637 ;; (lambda ()
638 ;; (interactive)
639 ;; (start-process-shell-command "pamixer" nil "pamixer --toggle-mute")))
640
641 ;; (exwm-input-set-key
642 ;; (kbd "<XF86AudioLowerVolume>")
643 ;; (lambda ()
644 ;; (interactive)
645 ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --decrease 5")))
646
647 ;; (exwm-input-set-key
648 ;; (kbd "<XF86AudioRaiseVolume>")
649 ;; (lambda ()
650 ;; (interactive)
651 ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --increase 5")))
652
653 ;; (exwm-input-set-key
654 ;; (kbd "<XF86AudioPlay>")
655 ;; (lambda ()
656 ;; (interactive)
657 ;; (start-process-shell-command "mpc" nil "mpc toggle")))
658
659 ;; (exwm-input-set-key
660 ;; (kbd "<XF86AudioPrev>")
661 ;; (lambda ()
662 ;; (interactive)
663 ;; (start-process-shell-command "mpc" nil "mpc prev")))
664
665 ;; (exwm-input-set-key
666 ;; (kbd "<XF86AudioNext>")
667 ;; (lambda ()
668 ;; (interactive)
669 ;; (start-process-shell-command "mpc" nil "mpv next")))
670
671 (defun ab--exwm-pasystray ()
672 "A command used to start pasystray."
673 (interactive)
674 (if (executable-find "pasystray")
675 (progn
676 (message "EXWM: starting pasystray ...")
677 (start-process-shell-command "pasystray" nil "pasystray --notify=all"))
678 (message "EXWM: pasystray is not installed, abort!")))
679
680 (add-hook 'exwm-init-hook #'ab--exwm-pasystray)
681
682 (exwm-input-set-key
683 (kbd "s-t")
684 (lambda ()
685 (interactive)
686 (exwm-floating-toggle-floating)))
687
688 (exwm-input-set-key
689 (kbd "s-f")
690 (lambda ()
691 (interactive)
692 (exwm-layout-toggle-fullscreen)))
693
694 (exwm-input-set-key
695 (kbd "s-w")
696 (lambda ()
697 (interactive)
698 (kill-buffer (current-buffer))))
699
26c45764 700 (exwm-input-set-key
b46e33ae 701 (kbd "s-q")
26c45764
AB
702 (lambda ()
703 (interactive)
b46e33ae
AB
704 (exwm-manage--kill-client))))
705#+end_src
706
707**** sxhkdrc
708:PROPERTIES:
709:header-args+: :tangle ~/.config/sxhkd/sxhkdrc :mkdirp yes
710:END:
711
45568be1 712#+begin_src conf :tangle no
b46e33ae
AB
713# terminal emulator
714super + Return
715 urxvt
716
717# program launcher
718super + space
719 rofi -show run -display-run '> ' -display-window ' 🗔 '
720
721# window finder
722super + slash
723 rofi -show window -display-run '> ' -display-window ' 🗔 '
724
725# password manager
726alt + space
727 rofi-pass
728
729# make sxhkd reload its configuration files:
730super + Escape
731 pkill -USR1 -x sxhkd
732
733# volume {up,down}
734XF86Audio{Raise,Lower}Volume
735 pamixer --allow-boost --{in,de}crease 5
736
737# mute
738XF86AudioMute
739 pamixer --toggle-mute
740
741# playback control
742XF86Audio{Play,Prev,Next}
743 mpc {toggle,prev,next}
744
745# Toggle keyboard layout
746# super + F7
747# toggle-layout
748
749# Toggle Xfce presentation mode
750# XF86LaunchB
751# toggle-presentation-mode
752
753# monitor brightness
754XF86MonBrightness{Up,Down}
755 light -{A,U} 5
756
757super + apostrophe
758 rofi-light
180cab37
AB
759#+end_src
760
761*** [[https://orgmode.org/][Org mode]]
762
763#+begin_quote
764Org mode is for keeping notes, maintaining TODO lists, planning
765projects, and authoring documents with a fast and effective plain-text
766system.
767#+end_quote
768
769In short, my favourite way of life.
770
771#+begin_src emacs-lisp
772(setq org-src-tab-acts-natively t
773 org-src-preserve-indentation nil
774 org-edit-src-content-indentation 0)
775#+end_src
776
777*** [[https://magit.vc/][Magit]]
778
779#+begin_quote
780It's Magit! A Git porcelain inside Emacs.
781#+end_quote
782
783Not just how I do git, but /the/ way to do git.
784
785#+begin_src emacs-lisp
786(use-package magit
787 :defer t
788 :bind (("s-g" . magit-status)
789 ("C-x g" . magit-status)
790 ("C-x M-g" . magit-dispatch-popup))
791 :config
792 (magit-add-section-hook 'magit-status-sections-hook
793 'magit-insert-modules
794 'magit-insert-stashes
795 'append))
796#+end_src
797
798*** [[https://github.com/abo-abo/swiper][Ivy]] (and friends)
799
800#+begin_quote
801Ivy - a generic completion frontend for Emacs, Swiper - isearch with
802an overview, and more. Oh, man!
803#+end_quote
804
805There's no way I could top that, so I won't attempt to.
806
807**** Ivy
808
809#+begin_src emacs-lisp
f7752223
AB
810(use-package ivy
811 :bind
812 (:map ivy-minibuffer-map
813 ([escape] . keyboard-escape-quit)
5ad7f83a
AB
814 ;; ("C-j" . ivy-next-line)
815 ;; ("C-k" . ivy-previous-line)
f7752223
AB
816 ([S-up] . ivy-previous-history-element)
817 ([S-down] . ivy-next-history-element)
818 ("DEL" . ivy-backward-delete-char))
819 :config
f6d8e3e4 820 (setq ivy-wrap t)
f7752223 821 (ivy-mode 1))
180cab37
AB
822#+end_src
823
824**** Swiper
825
826#+begin_src emacs-lisp
f7752223
AB
827(use-package swiper
828 :bind (([remap isearch-forward] . swiper)
829 ([remap isearch-backward] . swiper)))
180cab37
AB
830#+end_src
831
832**** Counsel
833
834#+begin_src emacs-lisp
f7752223 835(use-package counsel
4ae2cd62 836 :defer 1.5
f7752223
AB
837 :bind (([remap execute-extended-command] . counsel-M-x)
838 ([remap find-file] . counsel-find-file)
839 ("s-r" . counsel-recentf)
840 :map minibuffer-local-map
841 ("C-r" . counsel-minibuffer-history))
842 :config
843 (counsel-mode 1)
844 (defalias 'locate #'counsel-locate))
180cab37
AB
845#+end_src
846
847* Borg's =layer/essentials=
848
849TODO: break this giant source block down into individual org sections.
850
851#+begin_src emacs-lisp
852(use-package dash
853 :config (dash-enable-font-lock))
854
855(use-package diff-hl
856 :config
857 (setq diff-hl-draw-borders nil)
858 (global-diff-hl-mode)
859 (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh t))
860
861(use-package dired
862 :defer t
863 :config (setq dired-listing-switches "-alh"))
864
865(use-package eldoc
866 :when (version< "25" emacs-version)
867 :config (global-eldoc-mode))
868
869(use-package help
870 :defer t
871 :config (temp-buffer-resize-mode))
872
873(progn ; `isearch'
874 (setq isearch-allow-scroll t))
875
876(use-package lisp-mode
877 :config
878 (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
879 (add-hook 'emacs-lisp-mode-hook 'reveal-mode)
880 (defun indent-spaces-mode ()
881 (setq indent-tabs-mode nil))
882 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
883
884(use-package man
885 :defer t
886 :config (setq Man-width 80))
887
888(use-package paren
889 :config (show-paren-mode))
890
891(use-package prog-mode
892 :config (global-prettify-symbols-mode)
893 (defun indicate-buffer-boundaries-left ()
894 (setq indicate-buffer-boundaries 'left))
895 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
896
897(use-package recentf
898 :demand t
899 :config (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:"))
900
901(use-package savehist
902 :config (savehist-mode))
903
904(use-package saveplace
905 :when (version< "25" emacs-version)
906 :config (save-place-mode))
907
908(use-package simple
909 :config (column-number-mode))
910
911(progn ; `text-mode'
912 (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left))
913
914(use-package tramp
915 :defer t
916 :config
917 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
918 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
919 (add-to-list 'tramp-default-proxies-alist
920 (list (regexp-quote (system-name)) nil nil)))
921
922(use-package undo-tree
923 :config
924 (global-undo-tree-mode)
925 (setq undo-tree-mode-lighter ""))
926#+end_src
927
3f0f8d01
AB
928* Programming modes
929
930** Lean mode
931
932#+begin_src emacs-lisp
e9bcfa30
AB
933(use-package lean-mode
934 :bind (:map lean-mode-map
935 ("S-SPC" . company-complete)))
3f0f8d01
AB
936#+end_src
937
180cab37
AB
938* Post initialization
939:PROPERTIES:
967b0a82 940:CUSTOM_ID: post-initialization
180cab37
AB
941:END:
942
943Display how long it took to load the init file.
944
945#+begin_src emacs-lisp
946(message "Loading %s...done (%.3fs)" user-init-file
947 (float-time (time-subtract (current-time)
948 ab--before-user-init-time)))
949#+end_src
950
951* Footer
952:PROPERTIES:
953:CUSTOM_ID: footer
954:END:
955
956#+begin_src emacs-lisp :comments none
957;;; init.el ends here
958#+end_src