I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1323 lines
40 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #+TITLE: Dotfiles
  2. #+SUBTITLE: I showed you my source code, pls respond
  3. #+AUTHOR: Christopher James Hayward
  4. #+EMAIL: chris@chrishayward.xyz
  5. #+ROAM_KEY: https://github.com/chayward1/dotfiles/
  6. #+ATTR_ORG: :width 420px
  7. #+ATTR_HTML: :width 420px
  8. #+ATTR_LATEX: :width 420px
  9. [[./docs/images/desktop-alt.png]]
  10. Immutable GNU Emacs dotfiles. Built for Life, Liberty, and the Open Road.
  11. + 100% Literate
  12. + 100% Immutable
  13. + 100% Reproducible
  14. Heavily inspired by [[https://github.com/hlissner/doom-emacs][Doom Emacs]] and [[https://youtube.com/c/SystemCrafters][System Crafters]].
  15. * Init
  16. :PROPERTIES:
  17. :header-args: :tangle init.el
  18. :END:
  19. Although later versions of Emacs introduce =early-init.el=, it's not used in this configuration for two reasons:
  20. + It's not required due to the modularity
  21. + Maintaining support for older versions
  22. Assuming you have completed all of the following tasks prior to proceeding further:
  23. 1. Imported the =secrets=
  24. 2. Initialized the =passwords=
  25. 3. Defined the =host= file
  26. 4. Created all required symbolic links
  27. Launch emacs: ~emacs -mm --debug-init~
  28. ** Options
  29. Here's a complete list of all of the options configurable for each host, and their default values. If a host configuration does not exist, these values will be used in place.
  30. Configure the system font with a single ~font-family~ and define the size, of which variations to the font size are relative to this value.
  31. #+begin_src emacs-lisp
  32. (defvar dotfiles/font
  33. "Fira Code"
  34. "Unified system font family, used on all font faces.")
  35. #+end_src
  36. #+begin_src emacs-lisp
  37. (defvar dotfiles/font-size
  38. 96
  39. "Unified font size, of which all variations are relative to.")
  40. #+end_src
  41. Used by the desktop module to find the appropriate browser.
  42. #+begin_src emacs-lisp
  43. (defvar dotfiles/browser
  44. (getenv "BROWSER")
  45. "The default browser used by the system.")
  46. #+end_src
  47. All of the available modules are defined in the ~dotfiles/modules-available~ constant.
  48. #+begin_src emacs-lisp
  49. (defconst dotfiles/modules-available
  50. '(core desktop writing projects interface)
  51. "All of the available modules for hosts to load.")
  52. #+end_src
  53. Add the modules you want to initialize to the ~dotfiles/modules~ variable.
  54. #+begin_src emacs-lisp
  55. (defvar dotfiles/modules
  56. dotfiles/modules-available
  57. "Enabled modules, modify this in your host configuration.")
  58. #+end_src
  59. Specify the emacs home, and the cache directory.
  60. #+begin_src emacs-lisp
  61. (defvar dotfiles/home
  62. user-emacs-directory
  63. "Original value of `user-emacs-directory'.")
  64. #+end_src
  65. Used to seperate the immutable configuration from the stateful package files.
  66. #+begin_src emacs-lisp
  67. (defvar dotfiles/cache
  68. (expand-file-name "~/.cache/emacs")
  69. "Where `user-emacs-directory' will be redirected.")
  70. #+end_src
  71. Functionality like =completion= and =hints= can be delayed to avoid popups for common manuevers.
  72. #+begin_src emacs-lisp
  73. (defvar dotfiles/idle
  74. 0.0
  75. "Length of time to wait before offering completions.")
  76. #+end_src
  77. Required for the all powerful leader key.
  78. #+begin_src emacs-lisp
  79. (defvar dotfiles/leader-key
  80. "SPC"
  81. "Custom leader key for custom actions.")
  82. #+end_src
  83. The desktop module requires the global leader key to be set.
  84. #+begin_src emacs-lisp
  85. (defvar dotfiles/leader-key-global
  86. (concat "C-" dotfiles/leader-key)
  87. "Global leader key available everywhere.")
  88. #+end_src
  89. Define where the source repositories are stored, for integration with the *Projects* module.
  90. #+begin_src emacs-lisp
  91. (defvar dotfiles/projects
  92. (expand-file-name "~/.local/source/")
  93. "Location where source code projects are stored.")
  94. #+end_src
  95. Where the password store is located.
  96. #+begin_src emacs-lisp
  97. (defvar dotfiles/passwords
  98. (expand-file-name "~/.password-store/")
  99. "Directory containing the password store.")
  100. #+end_src
  101. ** Startup
  102. The host configuration is loaded (if it exist) using the systems name.
  103. #+begin_src emacs-lisp
  104. ;; Load the host configuration.
  105. (let ((host-file (concat dotfiles/home "/hosts/" system-name ".el")))
  106. (when (file-exists-p host-file)
  107. (load-file host-file)))
  108. #+end_src
  109. Load all of the enabled modules:
  110. #+begin_src emacs-lisp
  111. ;; Load the enabled modules.
  112. (dolist (m dotfiles/modules)
  113. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".el")))
  114. (when (file-exists-p mod-file)
  115. (load-file mod-file))))
  116. #+end_src
  117. * Hosts
  118. Each host system that runs Emacs has a file defined in the =hosts/= sub directory, following the pattern of ~$HOSTNAME.el~. All of the configurations are defined within this file, the values of which are read from by the other modules during startup and installation. This does *not* cover hosts that are controlled via =TRAMP=, as that will be covered in another section.
  119. ** Example (Ubuntu)
  120. :PROPERTIES:
  121. :header-args: :tangle hosts/ubuntu.el
  122. :END:
  123. The first configuration, which was built using the Ubuntu 20.04 LTS server edition. I decided to incorporate =flatpaks= into this build.
  124. #+begin_src emacs-lisp
  125. (setq dotfiles/browser "flatpak run org.mozilla.firefox")
  126. #+end_src
  127. + Set the browser to the flatpak browser currently installed
  128. - firefox
  129. - chromium
  130. - any other browser
  131. ** Phone (Termux)
  132. :PROPERTIES:
  133. :header-args: :tangle hosts/localhost.el
  134. :END:
  135. Remove the ~desktop~ module, since we're running on android.
  136. #+begin_src emacs-lisp
  137. (delete 'desktop dotfiles/modules)
  138. #+end_src
  139. * Modules
  140. Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundemental requirement to achieve the goal of modularity. Incorporating just the =core= module on a build server to build literate programming projects is just one example of what can be achieved.
  141. ** Core
  142. :PROPERTIES:
  143. :header-args: :tangle modules/core.el :results silent
  144. :END:
  145. Minimal configuration to make Emacs usable for my own personal workflow. This does very little in the ways of improving the visuals, only removing what is included by default and not required.
  146. *** Cleanup
  147. Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory. How can we solve this issue? Shortly after initialization, before most packages are loaded, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post [[https://chrishayward.xyz/posts/immutable-emacs/][Immutable Emacs]].
  148. #+begin_src emacs-lisp
  149. (setq user-emacs-directory dotfiles/cache)
  150. #+end_src
  151. Because this project uses version-control, we can disable more unwanted features:
  152. + Lock files
  153. + Backup files
  154. #+begin_src emacs-lisp
  155. (setq create-lockfiles nil
  156. make-backup-files nil)
  157. #+end_src
  158. *** Packages
  159. Download and install packages using [[https://github.com/raxod502/straight.el][straight.el]], a functional package manager that integrates with =use-package=, giving us more control over where packages are sourced from.
  160. + Use the development branch
  161. + Integrate with ~use-package~
  162. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  163. #+begin_src emacs-lisp
  164. (setq straight-repository-branch "develop"
  165. straight-use-package-by-default t)
  166. #+end_src
  167. Bootstrap the package manager, downloading, installing, or configuring depending on the state of the configuration. All packages are downloaded and built from source, and can be pinned to specific git commit hashes.
  168. #+begin_src emacs-lisp
  169. (defvar bootstrap-version)
  170. (let ((bootstrap-file
  171. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  172. (bootstrap-version 5))
  173. (unless (file-exists-p bootstrap-file)
  174. (with-current-buffer
  175. (url-retrieve-synchronously
  176. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  177. 'silent 'inhibit-cookies)
  178. (goto-char (point-max))
  179. (eval-print-last-sexp)))
  180. (load bootstrap-file nil 'nomessage))
  181. #+end_src
  182. Complete the integration with ~use-package~ by installing it with =straight=.
  183. #+begin_src emacs-lisp
  184. (straight-use-package 'use-package)
  185. #+end_src
  186. *** Cleanup
  187. Despite having our *stateful* and *immutable* configurations seperate, it's good practice to make efforts to reduce the trash created by Emacs.
  188. Install [[https://github.com/emacscollective/no-littering][no-littering]] to reduce the files created by Emacs.
  189. #+begin_src emacs-lisp
  190. (use-package no-littering)
  191. #+end_src
  192. Emacs' default user interface is horrendous, but with less than 10 lines of code we can change that.
  193. #+begin_src emacs-lisp
  194. (setq inhibit-startup-message t)
  195. (global-prettify-symbols-mode)
  196. (when (< emacs-major-version 27)
  197. (scroll-bar-mode -1))
  198. (menu-bar-mode -1)
  199. (tool-bar-mode -1)
  200. (tooltip-mode -1)
  201. #+end_src
  202. *** Babel
  203. *Organize your plain life in plain text*
  204. [[https://orgmode.org][Org-mode]] is one of the hallmark features of Emacs, and provides the basis for my Literate Programming platform. It's essentially a markdown language with rich features for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities.
  205. + [[https://orgmode.org/worg/org-contrib/babel/languages/index.html][Babel languages]]
  206. + [[https://orgmode.org/manual/Structure-Templates.html][Structure templates]]
  207. #+begin_src emacs-lisp
  208. (use-package org
  209. :hook (org-mode . (lambda ()
  210. (org-indent-mode)
  211. (visual-line-mode 1)
  212. (variable-pitch-mode 1)))
  213. :custom (org-ellipsis " ▾")
  214. (org-log-done 'time)
  215. (org-log-into-drawer t)
  216. (org-image-actual-width nil)
  217. (org-directory dotfiles/home)
  218. (org-src-preserve-indentation t)
  219. :config (require 'org-tempo)
  220. (add-to-list 'org-structure-template-alist '("s" . "src"))
  221. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  222. (add-to-list 'org-structure-template-alist '("e" . "example"))
  223. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  224. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
  225. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)
  226. (emacs-lisp . t))))
  227. #+end_src
  228. Build all of the =org= files within a given directory.
  229. #+begin_src emacs-lisp
  230. (defun dotfiles/tangle (dir)
  231. "Recursively tangle the Org files within a directory."
  232. (interactive)
  233. (let ((org-files (directory-files-recursively dir "org")))
  234. (dolist (f org-files)
  235. (org-babel-tangle-file f))))
  236. #+end_src
  237. *** Keys
  238. Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
  239. #+begin_src emacs-lisp
  240. (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
  241. #+end_src
  242. **** Hints
  243. Download [[https://github.com/justbur/emacs-which-key][which-key]], a package that displays the current incomplete keybinding input in a mini-buffer, showing available completion options.
  244. #+begin_src emacs-lisp
  245. (use-package which-key
  246. :diminish which-key-mode
  247. :custom (which-key-idle-delay dotfiles/idle)
  248. :config (which-key-mode))
  249. #+end_src
  250. **** Leader
  251. Implement the *leader* key using [[https://github.com/noctuid/general.el][general.el]], letting us easily configure prefixed keybindings in a much cleaner manner than the default methods.
  252. #+begin_src emacs-lisp
  253. (use-package general
  254. :config
  255. (general-create-definer dotfiles/leader
  256. :states '(normal motion)
  257. :keymaps 'override
  258. :prefix dotfiles/leader-key
  259. :global-prefix dotfiles/leader-key-global))
  260. #+end_src
  261. Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
  262. #+begin_src emacs-lisp
  263. (use-package hydra)
  264. #+end_src
  265. **** Evil
  266. After a few hour with =vim= I knew it was game over, I cannot even think of another way I would feel comfortable editing text. Luckily, there exist packages to emulate this within Emacs. [[https://evil.readthedocs.io/en/latest/index.html][evil-mode]] is the extensible VI layer for Emacs.
  267. #+begin_src emacs-lisp
  268. (use-package evil
  269. :custom (evil-want-integration t) ;; Required for `evil-collection'.
  270. (evil-want-keybinding nil) ;; Same as above
  271. :config (evil-mode 1))
  272. #+end_src
  273. Unfortunately the default keybindings are *lacking*, but there is a community curated package [[https://github.com/emacs-evil/evil-collection][evil-collection]], which does a much better job implementing keybindings you would expect to find.
  274. #+begin_src emacs-lisp
  275. (use-package evil-collection
  276. :after evil
  277. :config (evil-collection-init))
  278. #+end_src
  279. Surround text with functions, quotations, and any other symbols using the [[https://github.com/emacs-evil/evil-surround][evil-surround]] package.
  280. #+begin_src emacs-lisp
  281. (use-package evil-surround
  282. :config (global-evil-surround-mode 1))
  283. #+end_src
  284. https://github.com/redguardtoo/evil-nerd-commenter
  285. + Toggle comments with =M-;=
  286. #+begin_src emacs-lisp
  287. (use-package evil-nerd-commenter
  288. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  289. #+end_src
  290. **** Shortcuts
  291. Again cherry picked from =Doom=, I want to continue utilizing the muscle memory I have developed from a year of mainlining the framework.
  292. + Close buffers with =SPC c=
  293. + Find files with =SPC . (period)=
  294. + Switch buffers with =SPC , (comma)=
  295. #+begin_src emacs-lisp
  296. (dotfiles/leader
  297. "." '(find-file :which-key "Files")
  298. "," '(switch-to-buffer :which-key "Buffers")
  299. "c" '(kill-buffer-and-window :which-key "Close"))
  300. #+end_src
  301. Run helper functions with =SPC h=.
  302. + Packages =p=
  303. + Variables =v=
  304. + Functions =f=
  305. #+begin_src emacs-lisp
  306. (dotfiles/leader
  307. "h" '(:ignore t :which-key "Help")
  308. "hp" '(describe-package :which-key "Package")
  309. "hv" '(describe-variable :which-key "Variable")
  310. "hf" '(describe-function :which-key "Function"))
  311. #+end_src
  312. Quit emacs with =SPC q=.
  313. + Saving =q=
  314. + Without =w=
  315. + Frame (daemon) =f=
  316. #+begin_src emacs-lisp
  317. (dotfiles/leader
  318. "q" '(:ignore t :which-key "Quit")
  319. "qq" '(save-buffers-kill-emacs :which-key "Save")
  320. "qw" '(kill-emacs :which-key "Now")
  321. "qf" '(delete-frame :which-key "Frame"))
  322. #+end_src
  323. Window management with =SPC w=.
  324. + Swap with =w=
  325. + Close with =c=
  326. + Motions with =h,j,k,l=
  327. + Split with =s + <MOTION>=
  328. #+begin_src emacs-lisp
  329. (dotfiles/leader
  330. "w" '(:ignore t :which-key "Window")
  331. "ww" '(window-swap-states :which-key "Swap")
  332. "wc" '(delete-window :which-key "Close")
  333. "wh" '(windmove-left :which-key "Left")
  334. "wj" '(windmove-down :which-key "Down")
  335. "wk" '(windmove-up :which-key "Up")
  336. "wl" '(windmove-right :which-key "Right")
  337. "ws" '(:ignore t :which-key "Split")
  338. "wsj" '(split-window-below :which-key "Down")
  339. "wsl" '(split-window-right :which-key "Right"))
  340. #+end_src
  341. Place runtime tweaks behind =SPC t=.
  342. #+begin_src emacs-lisp
  343. (dotfiles/leader
  344. "t" '(:ignore t :which-key "Tweaks"))
  345. #+end_src
  346. *** Git
  347. Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
  348. #+begin_src emacs-lisp
  349. (use-package magit
  350. :custom (magit-display-buffer-function
  351. #'magit-display-buffer-same-window-except-diff-v1))
  352. #+end_src
  353. Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
  354. + Requires a valid ~$GITHUB_TOKEN~
  355. #+begin_src emacs-lisp
  356. (use-package forge)
  357. #+end_src
  358. Open the *status* page for the current repository with =SPC g=.
  359. #+begin_src emacs-lisp
  360. (dotfiles/leader
  361. "g" '(magit-status :which-key "Magit"))
  362. #+end_src
  363. *** Shell
  364. While not a traditional terminal emulator, =eshell= provides me with all of the functionality I expect and require from one. Some users may be left wanting more, I would recommend they look into =vterm=.
  365. https://github.com/zwild/eshell-prompt-extras
  366. + Enable lambda shell prompt
  367. #+begin_src emacs-lisp
  368. (use-package eshell-prompt-extras
  369. :custom (eshell-highlight-prompt nil)
  370. (eshell-prompt-function 'epe-theme-lambda))
  371. #+end_src
  372. Open an =eshell= buffer with =SPC e=.
  373. #+begin_src emacs-lisp
  374. (dotfiles/leader
  375. "e" '(eshell :which-key "Shell"))
  376. #+end_src
  377. *** Files
  378. Emacs' can feel more modern when icon-fonts are installed and prioritized. I feel that this makes navigation of folders much faster, given that file types may be quickly identified by their corresponding icons.
  379. https://github.com/domtronn/all-the-icons.el
  380. + Collects various icon fonts
  381. #+begin_src emacs-lisp
  382. (use-package all-the-icons)
  383. #+end_src
  384. https://github.com/jtbm37/all-the-icons-dired
  385. + Integration with dired
  386. #+begin_src emacs-lisp
  387. (use-package all-the-icons-dired
  388. :hook (dired-mode . all-the-icons-dired-mode))
  389. #+end_src
  390. When opening =dired=, I don't want to have to press =RET= twice to navigate to the current directory. This can be avoided with ~dired-jump~, included in the =dired-x= package shipped with =dired=.
  391. #+begin_src emacs-lisp
  392. (require 'dired-x)
  393. #+end_src
  394. By default =dired= will create a new buffer everytime you press =RET= over a directory. In my workflow this leads to many unwanted =dired= buffers that have to be cleaned up manually. [[https://github.com/crocket/dired-single][Dired-single]] lets us reuse the same dired buffer.
  395. + Move up a directory with =h=
  396. + Open a single buffer with =l=
  397. #+begin_src emacs-lisp
  398. (use-package dired-single
  399. :config (evil-collection-define-key 'normal 'dired-mode-map
  400. "h" 'dired-single-up-directory
  401. "l" 'dired-single-buffer))
  402. #+end_src
  403. Open a dired buffer with =SPC d=.
  404. #+begin_src emacs-lisp
  405. (dotfiles/leader
  406. "d" '(dired-jump :which-key "Dired"))
  407. #+end_src
  408. ** Desktop
  409. :PROPERTIES:
  410. :header-args: :tangle modules/desktop.el :results silent
  411. :END:
  412. I use Emacs as a Desktop Environment with the [[https://github.com/ch11ng/exwm][exwm]] package. It allows Emacs to function as a complete tiling window manager for =X11=. My workflow includes launching the window manager with =xinitrc=, without the use of a display manager, controlling *everything* within Emacs.
  413. #+begin_src conf :tangle config/xinitrc
  414. exec dbus-launch --exit-with-session emacs -mm --debug-init
  415. #+end_src
  416. *** Email
  417. Plain text email delivered via mu, mu4e and mbsync. I run my own email server, so your configuration may differ from mine. This is the ~mbsyncrc~ file I use to synchronize my local mail with my server. This is required for mu4e in Emacs.
  418. #+begin_src conf :tangle config/mbsyncrc
  419. IMAPStore xyz-remote
  420. Host mail.chrishayward.xyz
  421. User chris@chrishayward.xyz
  422. PassCmd "pass chrishayward.xyz/chris"
  423. SSLType IMAPS
  424. MaildirStore xyz-local
  425. Path ~/.cache/mail/
  426. Inbox ~/.cache/mail/inbox
  427. SubFolders Verbatim
  428. Channel xyz
  429. Master :xyz-remote:
  430. Slave :xyz-local:
  431. Patterns * !Archives
  432. Create Both
  433. Expunge Both
  434. SyncState *
  435. #+end_src
  436. The system typically expects to find this file at ~$HOME/.mbsyncrc~, but you may also specify a custom path if launching the command using arguments. I chose to symlink the default location to my repository.
  437. #+begin_src shell :tangle no
  438. mbsync -a
  439. mu index --maildir="~/.cache/mail"
  440. #+end_src
  441. Once the mail is being synchronized, and the mail has been indexed with =mu=, it's time to install the required packages for Emacs.
  442. + Update every 5 minutes
  443. + Scale text for all devices
  444. + Sign outbound mail with GPG key
  445. + Configure mail account(s)
  446. #+begin_src emacs-lisp
  447. (use-package mu4e
  448. :load-path "/usr/share/emacs/site-lisp/mu4e"
  449. :custom (mu4e-maildir "~/.cache/mail")
  450. (mu4e-update-interval (* 5 60))
  451. (mu4e-get-mail-command "mbsync -a")
  452. (mu4e-compose-format-flowed t)
  453. (mu4e-change-filenames-when-moving t)
  454. (message-send-mail-function 'smtpmail-send-it)
  455. (mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  456. (mu4e-compose-signature (concat "Chris Hayward\n"
  457. "https://chrishayward.xyz\n"))
  458. :config
  459. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  460. (setq mu4e-contexts
  461. (list
  462. ;; Main
  463. ;; chris@chrishayward.xyz
  464. (make-mu4e-context
  465. :name "Main"
  466. :match-func
  467. (lambda (msg)
  468. (when msg
  469. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  470. :vars
  471. '((user-full-name . "Christopher James Hayward")
  472. (user-mail-address . "chris@chrishayward.xyz")
  473. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  474. (smtpmail-smtp-service . 587)
  475. (smtpmail-stream-type . starttls))))))
  476. #+end_src
  477. Use [[https://github.com/iqbalansari/mu4e-alert][mu4e-alert]] to give us desktop notifications about incoming mail.
  478. #+begin_src emacs-lisp
  479. (use-package mu4e-alert
  480. :custom (mu4e-alert-set-default-style 'libnotify)
  481. :config (mu4e-alert-enable-notifications)
  482. (mu4e-alert-enable-mode-line-display))
  483. #+end_src
  484. Create a keybinding to open the mail dashboard with =SPC m=.
  485. #+begin_src emacs-lisp
  486. (dotfiles/leader
  487. "m" '(mu4e :which-key "Mail"))
  488. #+end_src
  489. *** Browser
  490. Write out the ~$BROWSER~ environment variable.
  491. #+begin_src emacs-lisp
  492. (setenv "BROWSER" dotfiles/browser)
  493. #+end_src
  494. Launch a browser with =SPC b=.
  495. #+begin_src emacs-lisp
  496. ;; (dotfiles/leader
  497. ;; "b" '(dotfiles/run-in-background dotfiles/browser :which-key "Browser"))
  498. #+end_src
  499. *** Startup
  500. When launching into a session, if the display server is not running then =startx= should be invoked, to run the window manager.
  501. #+begin_src sh :tangle config/profile
  502. if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
  503. exec startx
  504. fi
  505. #+end_src
  506. *** Methods
  507. Define a method to run an external process, allowing us to launch any application on a new process without interferring with Emacs.
  508. #+begin_src emacs-lisp
  509. (defun dotfiles/run (command)
  510. "Run an external process."
  511. (interactive (list (read-shell-command "λ ")))
  512. (start-process-shell-command command nil command))
  513. #+end_src
  514. Some methods must be called and applied to the current call process in order to function correctly with Emacs hooks.
  515. #+begin_src emacs-lisp
  516. (defun dotfiles/run-in-background (command)
  517. (let ((command-parts (split-string command "[ ]+")))
  518. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  519. #+end_src
  520. + Run shell commands with =SPC x=
  521. + Run async shell commands with =SPC z=
  522. #+begin_src emacs-lisp
  523. (dotfiles/leader
  524. "x" '(dotfiles/run :which-key "Run")
  525. "z" '(async-shell-command :which-key "Async"))
  526. #+end_src
  527. *** Displays
  528. When the window manager first launches the ~init-hook~ will be called, this allows us to define some custom logic when it's initialized.
  529. + Display time and date
  530. + Display battery info (if available)
  531. In my personal configuration, I do not want the battery or time displayed within Emacs when it's not running as desktop environment because that information is typically already available.
  532. #+begin_src emacs-lisp
  533. (defun dotfiles/init-hook ()
  534. (exwm-workspace-switch-create 1)
  535. (setq display-time-and-date t)
  536. (display-battery-mode 1)
  537. (display-time-mode 1))
  538. #+end_src
  539. Using =autorandr= with pre configured profiles, switching screens (AKA hot plugging) is also handled through a hook.
  540. #+begin_src emacs-lisp
  541. (defun dotfiles/update-display ()
  542. (dotfiles/run-in-background "autorandr --change --force"))
  543. #+end_src
  544. *** Configuration
  545. Connect our custom hooks and configure the input keys, a custom layer for defining which keys are captured by Emacs, and which are passed through to =X= applications.
  546. + Enable =randr= support
  547. + Pass through to Emacs
  548. + =M-x= to Emacs
  549. + =C-g= to Emacs
  550. + =C-SPC= to Emacs
  551. + Bindings with =S= (Super / Win)
  552. + Reset =S-r=
  553. + Launch =S-&=
  554. + Workspace =S-[1..9]=
  555. #+begin_src emacs-lisp
  556. (use-package exwm
  557. :custom (exwm-input-prefix-keys
  558. '(?\M-x
  559. ?\C-g
  560. ?\C-\ ))
  561. (exwm-input-global-keys
  562. `(([?\s-r] . exwm-reset)
  563. ,@(mapcar (lambda (i)
  564. `(,(kbd (format "s-%d" i)) .
  565. (lambda ()
  566. (interactive)
  567. (exwm-workspace-switch-create ,i))))
  568. (number-sequence 1 9))))
  569. :config (require 'exwm-randr)
  570. (exwm-randr-enable)
  571. (add-hook 'exwm-init-hook #'dotfiles/init-hook)
  572. (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
  573. (dotfiles/update-display)
  574. (exwm-enable))
  575. #+end_src
  576. ** Writing
  577. :PROPERTIES:
  578. :header-args: :tangle modules/writing.el :results silent
  579. :END:
  580. I am using [[https://orgmode.org][Org-mode]] extensively for writing projects for different purposes. Most of the improvements are done in the *Core* module for the Literate programming configuration. [[https://github.com/integral-dw/org-superstar-mode][Org-superstar-mode]] for making headline stars more *super*.
  581. #+begin_src emacs-lisp
  582. (use-package org-superstar
  583. :hook (org-mode . org-superstar-mode))
  584. #+end_src
  585. I use [[https://gohugo.io][Hugo]] for my personal [[https://chrishayward.xyz][website]], which I write in =Org-mode= before compiling to =hugo-markdown=. [[https://github.com/kaushalmodi/ox-hugo][Ox-hugo]], configured for =one-post-per-file= is my technique for managing my blog.
  586. #+begin_src emacs-lisp
  587. (use-package ox-hugo
  588. :after ox)
  589. #+end_src
  590. Produce high quality presentations that work anywhere with =HTML/JS= and the [[https://revealjs.com][Reveal.js]] package. [[https://github.com/hexmode/ox-reveal][Ox-reveal]], configured to use a =cdn= allows us to produce ones that are not dependent on a local version of =Reveal.js=.
  591. #+begin_src emacs-lisp
  592. (use-package ox-reveal
  593. :after ox
  594. :custom (org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"))
  595. #+end_src
  596. *** Roam
  597. Download and install [[https://orgroam.com][org-roam]], a plain text knowledge management system for Emacs.
  598. #+begin_src emacs-lisp
  599. (use-package org-roam
  600. :hook (after-init . org-roam-mode)
  601. :custom (org-roam-directory org-directory)
  602. (org-roam-encrypt-files t))
  603. #+end_src
  604. Visualize the org-roam database with the server, available when the editor is running at http://localhost:8080
  605. #+begin_src emacs-lisp
  606. (use-package org-roam-server
  607. :hook (org-roam-mode . org-roam-server-mode))
  608. #+end_src
  609. Place keybindings behind =SPC r=.
  610. + Find with =f=
  611. + Toggle buffer with =b=
  612. + Dailies with =d=
  613. + Arbitrary date with =d=
  614. + Today with =t=
  615. + Tomorrow with =m=
  616. + Yesterday with =y=
  617. #+begin_src emacs-lisp
  618. (dotfiles/leader
  619. "r" '(:ignore t :which-key "Roam")
  620. "rf" '(org-roam-find-file :which-key "Find")
  621. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  622. "rd" '(:ignore t :which-key "Dailies")
  623. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  624. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  625. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  626. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  627. #+end_src
  628. Organize the capture templates, this allows me to quickly dictate where each new item should be placed.
  629. + ~posts/~ contains blog posts
  630. + ~notes/~ contains cited notes on others' work
  631. + ~slides/~ contains presentations / screencasts
  632. #+begin_src emacs-lisp
  633. (setq org-roam-capture-templates
  634. '(("p" "Posts" plain (function org-roam-capture--get-point)
  635. "%?"
  636. :file-name "docs/posts/${slug}"
  637. :unnarrowed t
  638. :head
  639. "
  640. ,#+TITLE: ${title}
  641. ,#+AUTHOR: Christopher James Hayward
  642. ,#+DATE: %<%Y-%m-%d>
  643. ,#+EXPORT_FILE_NAME: ${slug}
  644. ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  645. ,#+HUGO_BASE_DIR: ../../website/
  646. ,#+HUGO_AUTO_SET_LASTMOD: t
  647. ,#+HUGO_SECTION: posts
  648. ,#+HUGO_DRAFT: true
  649. ")
  650. ("n" "Notes" plain (function org-roam-capture--get-point)
  651. "%?"
  652. :file-name "docs/notes/${slug}"
  653. :unnarrowed t
  654. :head
  655. "
  656. ,#+TITLE: ${title}
  657. ,#+AUTHOR: Christopher James Hayward
  658. ,#+EXPORT_FILE_NAME: ${slug}
  659. ,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/
  660. ,#+HUGO_BASE_DIR: ../../website
  661. ,#+HUGO_AUTO_SET_LASTMOD: t
  662. ,#+HUGO_SECTION: notes
  663. ,#+HUGO_DRAFT: true
  664. ")
  665. ("s" "Slides" plain (function org-roam-capture--get-point)
  666. "%?"
  667. :file-name "docs/slides/${slug}"
  668. :unnarrowed t
  669. :head
  670. "
  671. ,#+TITLE: ${title}
  672. ,#+AUTHOR: Christopher James Hayward
  673. ,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
  674. ")))
  675. #+end_src
  676. By default I want my daily notes to live in ~daily/~ relative to my dotfiles.
  677. #+begin_src emacs-lisp
  678. (setq org-roam-dailies-capture-templates
  679. '(("d" "Default" entry (function org-roam-capture--get-point)
  680. "* %?"
  681. :file-name "docs/daily/%<%Y-%m-%d>"
  682. :head
  683. "
  684. ,#+TITLE: %<%Y-%m-%d>
  685. ,#+AUTHOR: Christopher James Hayward
  686. ")))
  687. #+end_src
  688. *** Agenda
  689. Override ~org-agenda-file-regexp~ to include =.org.gpg= files.
  690. #+begin_src emacs-lisp
  691. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  692. (setq org-agenda-file-regexp
  693. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  694. org-agenda-file-regexp)))
  695. #+end_src
  696. Configure agenda sources.
  697. #+begin_src emacs-lisp
  698. (setq org-agenda-files '("~/.emacs.d/docs/"
  699. "~/.emacs.d/docs/daily/"))
  700. #+end_src
  701. Open an agenda buffer with =SPC a=.
  702. #+begin_src emacs-lisp
  703. (dotfiles/leader
  704. "a" '(org-agenda :which-key "Agenda"))
  705. #+end_src
  706. *** Images
  707. Create screencasts with =one-frame-per-action= GIF recording via [[https://github.com/takaxp/emacs-gif-screencast][emacs-gif-screencast]].
  708. + Can be paused / resumed
  709. + High quality images
  710. + Optimized size
  711. It requires the installation of ~scrot~, ~gifsicle~, and ~convert~ from the =ImageMagick= library.
  712. #+begin_src emacs-lisp
  713. (use-package gif-screencast
  714. :custom (gif-screencast-output-directory (concat dotfiles/home "docs/images/")))
  715. #+end_src
  716. Screencast controls behind =SPC s=.
  717. + Start / stop with =s=
  718. + Pause with =t=
  719. #+begin_src emacs-lisp
  720. (dotfiles/leader
  721. "s" '(:ignore t :which-key "Screencast")
  722. "ss" '(gif-screencast-start-or-stop :which-key "Start / Stop")
  723. "sp" '(gif-screencast-toggle-pause :which-key "Pause"))
  724. #+end_src
  725. ** Projects
  726. :PROPERTIES:
  727. :header-args: :tangle modules/projects.el :results silent
  728. :END:
  729. An IDE like experience (or better) can be achieved in Emacs using two *Microsoft* open source initiatives.
  730. Turn Emacs into an *IDE* (or better) with the [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]], an open source initiative from *Microsoft* for the *VSCode* editor.
  731. [[https://emacs-lsp.github.io/lsp-mode/][Lsp-mode]] brings support for language servers into Emacs.
  732. #+begin_src emacs-lisp
  733. (use-package lsp-mode
  734. :custom (gc-cons-threshold 1000000000)
  735. (lsp-idle-delay 0.500))
  736. #+end_src
  737. https://emacs-lsp.github.io/lsp-ui/
  738. + UI improvements for =lsp-mode=
  739. #+begin_src emacs-lisp
  740. (use-package lsp-ui
  741. :custom (lsp-ui-doc-position 'at-point)
  742. (lsp-ui-doc-delay 0.500))
  743. #+end_src
  744. *** Management
  745. Configure [[https://projectile.mx][projectile]], a project interaction library for Emacs. It provides a nice set of features for operating on a project level without introducing external dependencies.
  746. #+begin_src emacs-lisp
  747. (use-package projectile
  748. :custom (projectile-project-search-path '("~/.local/source"))
  749. :config (projectile-mode))
  750. #+end_src
  751. *** Passwords
  752. Pass makes managing passwords extremely easy, encrypring them in a file structure and providing easy commands for generating, modify, and copying passwords. =password-store.el= provides a wrapper for the functionality within Emacs.
  753. #+begin_src emacs-lisp
  754. (use-package password-store
  755. :custom (password-store-dir dotfiles/passwords))
  756. #+end_src
  757. Configure keybindings behind =SPC p=.
  758. + Copy with =p=
  759. + Rename with =r=
  760. + Generate with =g=
  761. #+begin_src emacs-lisp
  762. (dotfiles/leader
  763. "p" '(:ignore t :which-key "Passwords")
  764. "pp" '(password-store-copy :which-key "Copy")
  765. "pr" '(password-store-rename :which-key "Rename")
  766. "pg" '(password-store-generate :which-key "Generate"))
  767. #+end_src
  768. *** Debugging
  769. Handled through the [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]], an open source initiative from *Microsoft* for the *VSCode* editor.
  770. [[https://emacs-lsp.github.io/dap-mode/][Dap-mode]] adds support for the protocol to Emacs.
  771. #+begin_src emacs-lisp
  772. (use-package dap-mode)
  773. #+end_src
  774. *** Completion
  775. Text completion framework via =company= aka *Complete Anything*.
  776. http://company-mode.github.io/
  777. + Integrate with =lsp-mode=
  778. #+begin_src emacs-lisp
  779. (use-package company)
  780. (use-package company-lsp)
  781. #+end_src
  782. *** Languages
  783. Support for individual languages are implemented here.
  784. **** C/C++
  785. Install the [[https://github.com/MaskRay/ccls][ccls]] language server, and allow us to create a new structure template for C/C++ with ~<cc~.
  786. #+begin_src emacs-lisp
  787. (use-package ccls
  788. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  789. (lambda ()
  790. (require 'ccls)
  791. (lsp)))
  792. :config (add-to-list 'org-structure-template-alist '("cc" . "src cc")))
  793. #+end_src
  794. **** Python
  795. Install the =pyls= language server.
  796. #+begin_src shell :tangle no
  797. pip install --user "python-language-server[all]"
  798. #+end_src
  799. [[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python-mode]] is an Emacs built in mode.
  800. + Load the babel language module for Python
  801. + Add a python source code block structure template with ~<py~
  802. #+begin_src emacs-lisp
  803. (use-package python-mode
  804. :hook (python-mode . lsp)
  805. :config (require 'dap-python)
  806. (add-to-list 'org-src-lang-modes '("python" . python))
  807. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  808. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  809. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  810. (dap-python-executable "python3") ;; Same as above.
  811. (dap-python-debugger 'debugpy))
  812. #+end_src
  813. **** PlantUML
  814. Download and install [[https://plantuml.com][PlantUML]], a text-based markup language for creating UML diagrams.
  815. + Load the babel language module for PlantUML
  816. + Create a structure template with ~<pl~
  817. #+begin_src emacs-lisp
  818. (use-package plantuml-mode
  819. :custom (plantuml-default-exec-mode 'jar)
  820. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  821. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  822. (org-startup-with-inline-images t)
  823. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  824. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  825. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
  826. #+end_src
  827. Toggle inline images with =SPC t i=.
  828. #+begin_src emacs-lisp
  829. (dotfiles/leader
  830. "ti" '(org-display-inline-images :which-key "Images"))
  831. #+end_src
  832. **** Go
  833. Install the =gopls= language server.
  834. #+begin_src sh :tangle no
  835. GO111MODULE=on go get golang.org/x/tools/gopls@latest
  836. #+end_src
  837. Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
  838. #+begin_src emacs-lisp
  839. (setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
  840. #+end_src
  841. Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
  842. #+begin_src emacs-lisp
  843. (setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
  844. #+end_src
  845. Finally we can include the =go-mode= package, integrating it with =lsp=.
  846. #+begin_src emacs-lisp
  847. (use-package go-mode
  848. :hook (go-mode . lsp))
  849. #+end_src
  850. Apply some custom behaviour before saving:
  851. + Format buffer
  852. + Organize imports
  853. #+begin_src emacs-lisp
  854. (defun dotfiles/go-hook ()
  855. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  856. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  857. #+end_src
  858. #+begin_src emacs-lisp
  859. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  860. #+end_src
  861. Add a golang source code block structure template with ~<go~:
  862. #+begin_src emacs-lisp
  863. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  864. #+end_src
  865. ** Interface
  866. :PROPERTIES:
  867. :header-args: :tangle modules/interface.el :results silent
  868. :END:
  869. *Bring Emacs out of the eighties*
  870. *** Fonts
  871. Write out to all *3* of Emacs' default font faces.
  872. #+begin_src emacs-lisp
  873. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  874. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  875. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  876. #+end_src
  877. Define a transient keybinding for scaling the text.
  878. #+begin_src emacs-lisp
  879. (defhydra hydra-text-scale (:timeout 4)
  880. "Scale"
  881. ("j" text-scale-increase "Increase")
  882. ("k" text-scale-decrease "Decrease")
  883. ("f" nil "Finished" :exit t))
  884. #+end_src
  885. Increase the font size in buffers with =SPC t f=.
  886. + Increase =j=
  887. + Decrease =k=
  888. + Finish =f=
  889. #+begin_src emacs-lisp
  890. (dotfiles/leader
  891. "tf" '(hydra-text-scale/body :which-key "Font"))
  892. #+end_src
  893. *** Lines
  894. Relative line numbers are important when using =VI= emulation keys. You can prefix most commands with a *number*, allowing you to jump up / down by a line count.
  895. #+begin_example
  896. 5:
  897. 4:
  898. 3:
  899. 2:
  900. 1:
  901. 156: << CURRENT LINE >>
  902. 1:
  903. 2:
  904. 3:
  905. 4:
  906. 5:
  907. #+end_example
  908. https://github.com/emacsmirror/linum-relative
  909. + Integrate with ~display-line-numbers-mode~ for performance
  910. #+begin_src emacs-lisp
  911. (use-package linum-relative
  912. :custom (linum-relative-backend 'display-line-numbers-mode)
  913. :config (linum-relative-global-mode))
  914. #+end_src
  915. Add line numbers to the toggles behind =SPC t l=.
  916. #+begin_src emacs-lisp
  917. (dotfiles/leader
  918. "tl" '(linum-relative-global-mode :which-key "Lines"))
  919. #+end_src
  920. https://github.com/Fanael/rainbow-delimiters
  921. + Colourize nested parenthesis
  922. #+begin_src emacs-lisp
  923. (use-package rainbow-delimiters
  924. :hook (prog-mode . rainbow-delimiters-mode))
  925. #+end_src
  926. *** Themes
  927. Cherry pick a few modules from =doom-emacs=. High quality and modern colour themes are provided in the [[https://github.com/hlissner/emacs-doom-themes][doom-themes]] package.
  928. #+begin_src emacs-lisp
  929. (use-package doom-themes
  930. :init (load-theme 'doom-moonlight t))
  931. #+end_src
  932. [[https://github.com/seagle0128/doom-modeline][doom-modeline]] provides an elegant status bar / modeline.
  933. #+begin_src emacs-lisp
  934. (use-package doom-modeline
  935. :custom (doom-modeline-height 16)
  936. :config (doom-modeline-mode 1))
  937. #+end_src
  938. Load a theme with =SPC t t=.
  939. #+begin_src emacs-lisp
  940. (dotfiles/leader
  941. "tt" '(load-theme t t :which-key "Theme"))
  942. #+end_src
  943. *** Ligatures
  944. Enable font ligatures via [[https://github.com/jming422/fira-code-mode][fira-code-mode]], perform this action *only* when ~Fira Code~ is set as the current font.
  945. #+begin_src emacs-lisp
  946. (when (display-graphic-p)
  947. (use-package fira-code-mode
  948. :hook (prog-mode org-mode)))
  949. #+end_src
  950. Toggle global ligature mode with =SPC t g=.
  951. #+begin_src emacs-lisp
  952. (dotfiles/leader
  953. "tg" '(global-fira-code-mode :which-key "Ligatures"))
  954. #+end_src
  955. *** Dashboard
  956. #+ATTR_ORG: :width 420px
  957. #+ATTR_HTML: :width 420px
  958. #+ATTR_LATEX: :width 420px
  959. [[./docs/images/desktop.png]]
  960. Present a dashboard when first launching Emacs.
  961. #+begin_src emacs-lisp
  962. (use-package dashboard
  963. :custom (dashboard-center-content t)
  964. (dashboard-set-init-info t)
  965. (dashboard-set-file-icons t)
  966. (dashboard-set-heading-icons t)
  967. (dashboard-set-navigator t)
  968. (dashboard-startup-banner 'logo)
  969. (dashboard-projects-backend 'projectile)
  970. (dashboard-items '((projects . 5)
  971. (recents . 5)
  972. (agenda . 5 )))
  973. :config (dashboard-setup-startup-hook))
  974. #+end_src
  975. Customize the buttons of the navigator:
  976. + Brain @ http://localhost:8080
  977. + Homepage @ https://chrishayward.xyz
  978. + Athabasca @ https://login.athabascau.ca/cas/login
  979. + Bookshelf @ https://online.vitalsource.com
  980. #+begin_src emacs-lisp
  981. (setq dashboard-navigator-buttons
  982. `(;; First row.
  983. ((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
  984. "Brain"
  985. "Knowledge base"
  986. (lambda (&rest _) (browse-url "http://localhost:8080"))))
  987. ;; Second row.
  988. ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
  989. "Homepage"
  990. "Personal website"
  991. (lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
  992. ;; Third row.
  993. ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
  994. "Athabasca"
  995. "Univeristy login"
  996. (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
  997. ;; Fourth row.
  998. ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
  999. "Bookshelf"
  1000. "Vitalsource bookshelf"
  1001. (lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
  1002. #+end_src
  1003. When running in *daemon* mode, ensure that the dashboard is the initial buffer.
  1004. #+begin_src emacs-lisp
  1005. (setq initial-buffer-choice
  1006. (lambda ()
  1007. (get-buffer "*dashboard*")))
  1008. #+end_src