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.

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