dots

Configurations for various programs.
Log | Files | Refs | README

config.org (18604B)


      1 # -*- after-save-hook: (org-babel-tangle) -*-
      2 #+PROPERTY: header-args:emacs-lisp :exports code :results none :tangle init.el
      3 
      4 * Gabriel's Emacs configuration
      5 This is my Emacs configuration. Enjoy.
      6 
      7 Most of the setup is tangled to the file ~init.el~ itself. Some things are tangled to ~early-init.el~ instead to improve startup time.
      8 
      9 ** Lexical binding
     10 Supresses the annoying error message.
     11 
     12 #+BEGIN_SRC emacs-lisp
     13 ;;; -*- lexical-binding: t; -*-
     14 #+END_SRC
     15 
     16 Also for ~early-init.el~.
     17 
     18 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     19 ;;; -*- lexical-binding: t; -*-
     20 #+END_SRC
     21 
     22 Just supress it for whatever other package that's not supressing it themselves.
     23 
     24 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     25 (add-to-list 'warning-suppress-types '(files missing-lexbind-cookie))
     26 #+END_SRC
     27 
     28 ** Garbage collection
     29 Disables garbage collection while loading configuration, and re-enables it right afterwards.
     30 
     31 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     32 (setq gc-cons-threshold most-positive-fixnum)
     33 (add-hook 'emacs-startup-hook
     34           (lambda () (setq gc-cons-threshold (* 50 1024 1024))))
     35 #+END_SRC
     36 
     37 Inhibits startup, splash, etc.
     38 
     39 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     40 (setq inhibit-splash-screen t)
     41 (setq inhibit-startup-screen t)
     42 (setq inhibit-startup-message t)
     43 (setq inhibit-startup-buffer-menu t)
     44 #+END_SRC
     45 
     46 Increases native compilation optimization.
     47 
     48 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     49 (setq native-comp-speed 3)
     50 #+END_SRC
     51 
     52 ** Package management configuration
     53 Nowadays, Emacs already comes with ~use-package~. But we still bootstrap it here as it costs us nothing and we need to setup it anyways.
     54 
     55 #+BEGIN_SRC emacs-lisp
     56 (require 'package)
     57 
     58 (add-to-list 'package-archives
     59              '("melpa" . "https://melpa.org/packages/") t)
     60 
     61 (package-initialize)
     62 
     63 (unless (package-installed-p 'use-package)
     64   (package-refresh-contents)
     65   (package-install 'use-package))
     66 
     67 (require 'use-package)
     68 
     69 (setq use-package-always-ensure t)
     70 #+END_SRC
     71 
     72 Enables support for diminishing modes.
     73 
     74 #+BEGIN_SRC emacs-lisp
     75 (use-package diminish
     76   :init
     77   (diminish 'visual-line-mode)
     78   (diminish 'abbrev-mode))
     79 #+END_SRC
     80 
     81 ** Appearance
     82 *** Basics
     83 Unclutter the UI and stop the blinking cursor.
     84 
     85 #+BEGIN_SRC emacs-lisp :tangle early-init.el
     86 (menu-bar-mode -1)
     87 (tool-bar-mode -1)
     88 (scroll-bar-mode -1)
     89 (blink-cursor-mode -1)
     90 #+END_SRC
     91 
     92 Prettify symbols.
     93 
     94 #+BEGIN_SRC emacs-lisp
     95 (global-prettify-symbols-mode 1)
     96 #+END_SRC
     97 
     98 Make the frames open a little bigger.
     99 
    100 #+BEGIN_SRC emacs-lisp :tangle early-init.el
    101 (add-to-list 'default-frame-alist '(width . 85))
    102 (add-to-list 'default-frame-alist '(height . 35))
    103 #+END_SRC
    104 
    105 *** Theme, fonts and modeline
    106 Modus Vivendi is great: very dark, very readable, and the best: builtin. We need to be aware it resets the fonts we use.
    107 
    108 #+BEGIN_SRC emacs-lisp :tangle early-init.el
    109 (require-theme 'modus-themes)
    110 (setq modus-themes-italic-constructs t)
    111 (setq modus-themes-mixed-fonts t)
    112 (setq modus-themes-headings
    113       '((1 . (1.5))
    114         (2 . (1.3))
    115 	(3 . (1.1))))
    116 (setq modus-themes-variable-pitch-ui t)
    117 (add-hook
    118  'modus-themes-after-load-theme-hook
    119  (lambda ()
    120    (set-face-attribute 'default nil :family
    121 		       "Adwaita Mono" :height 120)
    122    (set-face-attribute 'fixed-pitch nil :family
    123 		       "Adwaita Mono" :height 120)
    124    (set-face-attribute 'variable-pitch nil :family
    125 		       "Adwaita Sans" :height 130)))
    126 (modus-themes-load-theme 'modus-vivendi)
    127 #+END_SRC
    128 
    129 Make some reading modes use variable text. Help mode variable pitch is only enabled in actual help buffers, because various modes use the help mode and they usually don't look good with variable pitch.
    130 
    131 #+BEGIN_SRC emacs-lisp
    132 (add-hook 'help-mode-hook #'variable-pitch-mode)
    133 (add-hook 'package-menu-mode-hook #'variable-pitch-mode)
    134 (add-hook 'Man-mode-hook #'variable-pitch-mode)
    135 #+END_SRC
    136 
    137 Modeline.
    138 
    139 #+BEGIN_SRC emacs-lisp
    140 (setq display-time-interval 20)
    141 (setq display-time-day-and-date t)
    142 (setq display-time-24hr-format t)
    143 (display-time-mode 1)
    144 (column-number-mode 1)
    145 #+END_SRC
    146 
    147 ** Behaviour
    148 *** Basics
    149 Short answers, fill column, don't make backups.
    150 
    151 #+BEGIN_SRC emacs-lisp
    152 (defalias 'yes-or-no-p 'y-or-n-p)
    153 (setopt use-short-answers t)
    154 
    155 (setq-default fill-column 80)
    156 
    157 (setq make-backup-files nil)
    158 #+END_SRC
    159 
    160 Move custom elsewhere.
    161 
    162 #+BEGIN_SRC emacs-lisp
    163 (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
    164 (load custom-file 'noerror)
    165 #+END_SRC
    166 
    167 Disable the audible bell.
    168 
    169 #+BEGIN_SRC emacs-lisp
    170 (setq ring-bell-function 'ignore)
    171 #+END_SRC
    172 
    173 Setup auth sources.
    174 
    175 #+BEGIN_SRC emacs-lisp
    176 (setq auth-sources '("~/.authinfo.gpg"))
    177 #+END_SRC
    178 
    179 Emacs has a very low default nesting limit that's commonly exceeded even on builtin functionality like TRAMP.
    180 
    181 #+BEGIN_SRC emacs-lisp
    182 (setq max-lisp-eval-depth 10000)
    183 #+END_SRC
    184 
    185 *** Compile mode
    186 No default command, colorize the buffer.
    187 
    188 #+BEGIN_SRC emacs-lisp
    189 (setq-default compile-command "")
    190 
    191 (require 'ansi-color)
    192 (defun colorize-compilation ()
    193   "Colorize from `compilation-filter-start' to `point'."
    194   (let ((inhibit-read-only t))
    195     (ansi-color-apply-on-region
    196      compilation-filter-start (point))))
    197 
    198 (add-hook 'compilation-filter-hook
    199           #'colorize-compilation)
    200 #+END_SRC
    201 
    202 *** Minibuffer
    203 Configures the builtin minibuffer completion so it's nicer.
    204 
    205 #+BEGIN_SRC emacs-lisp
    206 (setq completion-show-help nil)
    207 (setq completion-show-inline-help nil)
    208 (setq completions-detailed t)
    209 (setq completions-format 'one-column)
    210 (setq completions-max-height 20)
    211 (setq completions-sort 'historical)
    212 (setq completion-auto-help t)
    213 (setq completion-auto-select nil)
    214 (setq minibuffer-visible-completions t)
    215 (setq completion-eager-display t)
    216 (setq completion-eager-update t)
    217 
    218 (define-key minibuffer-local-map (kbd "C-n") #'minibuffer-next-completion)
    219 (define-key minibuffer-local-map
    220 	    (kbd "C-p") #'minibuffer-previous-completion)
    221 #+END_SRC
    222 
    223 *** Windows
    224 Move windows with meta. Makes C-v and M-v to move by half pages instead of full ones.
    225 
    226 #+BEGIN_SRC emacs-lisp
    227 (windmove-default-keybindings 'meta)
    228 
    229 (defun window-half-height ()
    230   (max 1 (/ (1- (window-height (selected-window))) 2)))
    231 
    232 (defun scroll-up-half ()
    233   (interactive)
    234   (scroll-up (window-half-height)))
    235 
    236 (defun scroll-down-half ()
    237   (interactive)
    238   (scroll-down (window-half-height)))
    239 
    240 (global-set-key (kbd "C-v") #'scroll-up-half)
    241 (global-set-key (kbd "M-v") #'scroll-down-half)
    242 #+END_SRC
    243 
    244 Prefer using frames instead of windows.
    245 
    246 #+BEGIN_SRC emacs-lisp
    247 (use-package frames-only-mode
    248   :hook (after-init . frames-only-mode)
    249   :config (frames-only-mode-remap-common-window-split-keybindings))
    250 #+END_SRC
    251 
    252 ** Editor configuration
    253 *** Basics
    254 Show trailing whitespaces, but not on some weird buffers of course. Display line numbers and fill column in all actual editing modes. Scroll nicely. Save history and recent files.
    255 
    256 #+BEGIN_SRC emacs-lisp
    257 (defun prog-and-text-mode-setup ()
    258   (display-fill-column-indicator-mode t)
    259   (setq show-trailing-whitespace t))
    260 (add-hook 'prog-mode-hook #'prog-and-text-mode-setup)
    261 (add-hook 'text-mode-hook #'prog-and-text-mode-setup)
    262 
    263 (setq scroll-step 1)
    264 (setq scroll-conservatively 100000)
    265 
    266 (savehist-mode 1)
    267 (recentf-mode 1)
    268 #+END_SRC
    269 
    270 *** Respect ~.editorconfig~ files.
    271 #+BEGIN_SRC emacs-lisp
    272 (use-package editorconfig
    273   :hook after-init)
    274 #+END_SRC
    275 
    276 *** Electric
    277 Electric, auto-fill and selection deletion.
    278 
    279 #+BEGIN_SRC emacs-lisp
    280 (electric-indent-mode t)
    281 (electric-pair-mode t)
    282 (add-hook 'text-mode-hook
    283   	  (lambda ()
    284   	    (auto-fill-mode t)))
    285 (delete-selection-mode t)
    286 #+END_SRC
    287 
    288 *** Xrefs
    289 So the editor is a little less dumb.
    290 
    291 #+BEGIN_SRC emacs-lisp
    292 (use-package dumb-jump
    293   :custom (dumb-jump-prefer-searcher 'rg)
    294   :bind (("<f1>" . xref-find-definitions-other-window)
    295 	 ("<f9>" . xref-find-references))
    296   :hook (prog-mode . (lambda ()
    297 		       (add-to-list
    298 			'xref-backend-functions
    299 			#'dumb-jump-xref-activate))))
    300 #+END_SRC
    301 
    302 *** Searching
    303 Ripgrep is fast. Also, the package automatically configures ~wgrep~ for us and other niceties.
    304 
    305 #+BEGIN_SRC emacs-lisp
    306 (use-package rg
    307   :bind (("<f7>" . rg)
    308 	 ("<f8>" . rg-literal))
    309   :config
    310   (rg-enable-default-bindings))
    311 #+END_SRC
    312 
    313 *** Bindings
    314 #+BEGIN_SRC emacs-lisp
    315 (global-set-key (kbd "<f2>") #'query-replace)
    316 (global-set-key (kbd "<f5>") #'compile)
    317 (global-set-key (kbd "<f6>") #'async-shell-command)
    318 #+END_SRC
    319 
    320 ** Utilities
    321 *** Magit
    322 The best git UI in the world.
    323 
    324 #+BEGIN_SRC emacs-lisp
    325 (use-package magit
    326   :bind (("C-x g" . magit-status))
    327   :commands (magit-status magit-dispatch magit-file-dispatch))
    328 #+END_SRC
    329 
    330 It's better to use ~forge~ than ~magit-gh~. ~forge~ is very complete.
    331 
    332 #+BEGIN_SRC emacs-lisp
    333 (use-package forge
    334   :after magit)
    335 #+END_SRC
    336 
    337 *** Dired
    338 File management.
    339 
    340 #+BEGIN_SRC emacs-lisp
    341 (setq dired-kill-when-opening-new-dired-buffer t)
    342 (setq dired-delete-by-moving-to-trash t)
    343 (setq dired-listing-switches "-lahD --group-directories-first")
    344 (setq dired-dwim-target t)
    345 (use-package async
    346   :hook (after-init . dired-async-mode))
    347 #+END_SRC
    348 
    349 Enhanced appearance.
    350 
    351 #+BEGIN_SRC emacs-lisp
    352 (use-package diredfl
    353   :hook (after-init . diredfl-global-mode))
    354 #+END_SRC
    355 
    356 *** Eat
    357 Eat is the best terminal emulator for Emacs.
    358 
    359 #+BEGIN_SRC emacs-lisp
    360 (use-package eat
    361   :commands (eat eat-other-window))
    362 #+END_SRC
    363 
    364 *** HTTPD
    365 Sometimes we need a simple web server.
    366 
    367 #+BEGIN_SRC emacs-lisp
    368 (use-package simple-httpd
    369   :commands (httpd-serve-directory httpd-start httpd-stop))
    370 #+END_SRC
    371 
    372 *** Email
    373 For reading, I use ~mu4e~. The messages are fetched via ~mbsync~. Both need to be installed system-wide. The ~mbsync~ package sometimes is called ~isync~. For sending, I use ~msmtp~. Also needed to be installed system-wide. It's symlinked to ~sendmail~.
    374 
    375 #+BEGIN_SRC emacs-lisp
    376 (use-package mu4e
    377   :ensure nil
    378   :bind (("C-c e" . mu4e))
    379   :config
    380   (setq mu4e-change-filenames-when-moving t)
    381   (setq mu4e-update-interval 600)
    382   (setq mu4e-get-mail-command "mbsync -a")
    383   (setq mu4e-maildir "~/mail")
    384   (setq mu4e-compose-signature "Please no HTML,\n~ Gabriel G. de Brito")
    385   (setq send-mail-function 'sendmail-send-it)
    386   (setq mail-user-agent 'mu4e-user-agent)
    387   (setq read-mail-command 'mu4e)
    388   (setq mail-specify-envelope-from t)
    389   (setq message-sendmail-envelope-from 'header)
    390   (setq mail-envelope-from 'header)
    391   (setq mu4e-contexts (list
    392 		  (make-mu4e-context
    393 		   :name "icloud"
    394 		   :match-func
    395 		   (lambda (msg)
    396 		     (when msg
    397 		       (string-prefix-p
    398 			"/icloud" (mu4e-message-field msg :maildir))))
    399 		   :vars '((user-mail-address . "me@gboncoffee.dev.br")
    400 			   (user-full-name . "Gabriel de Brito")
    401 			   (mu4e-drafts-folder  . "/icloud/Drafts")
    402 			   (mu4e-sent-folder  . "/icloud/Sent")
    403 			   (mu4e-trash-folder  . "/icloud/Trash")))
    404 		  (make-mu4e-context
    405 		   :name "dinf"
    406 		   :match-func
    407 		   (lambda (msg)
    408 		     (when msg
    409 		       (string-prefix-p
    410 			"/dinf" (mu4e-message-field msg :maildir))))
    411 		   :vars '((user-mail-address . "ggb23@inf.ufpr.br")
    412 			   (user-full-name . "Gabriel de Brito")
    413 			   (mu4e-drafts-folder  . "/dinf/Drafts")
    414 			   (mu4e-sent-folder  . "/dinf/Sent")
    415 			   (mu4e-trash-folder  . "/dinf/Trash")))))
    416   (setq mu4e-maildir-shortcuts
    417    '(("/icloud/inbox" . ?i)
    418      ("/dinf/inbox" . ?d)))
    419   (setq mu4e-context-policy 'pick-first)
    420   (setq mml-secure-openpgp-signers '("ABE72DFCAD2D5333FE3F8912F6C1E4A22E8C1F3D"))
    421   (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime))
    422 #+END_SRC
    423 
    424 *** Miscelaneous
    425 Better support for PDF files.
    426 
    427 #+BEGIN_SRC emacs-lisp
    428 (use-package pdf-tools
    429   :mode ("\\.pdf\\'" . pdf-view-mode))
    430 #+END_SRC
    431 
    432 Better separation of shell commands.
    433 
    434 #+BEGIN_SRC emacs-lisp
    435 (use-package shell-command-x
    436   :diminish shell-command-x
    437   :hook after-init)
    438 #+END_SRC
    439 
    440 ** Language specific configuration
    441 First let's make all languages use treesitter by default.
    442 
    443 #+BEGIN_SRC emacs-lisp
    444 (setopt treesit-enabled-modes t)
    445 (setopt treesit-auto-install-grammar 'ask)
    446 #+END_SRC
    447 
    448 *** Go
    449 Basic support.
    450 
    451 #+BEGIN_SRC emacs-lisp
    452 (use-package go-mode
    453   :mode "\\.go\\'"
    454   :hook
    455   (go-mode . (lambda ()
    456 	       (setq tab-width 4)
    457 	       (setq indent-tabs-mode t))))
    458 #+END_SRC
    459 
    460 *** C/C++
    461 #+BEGIN_SRC emacs-lisp
    462 (defun c-configs ()
    463   (setq tab-width 4)
    464   (setq indent-tabs-mode nil))
    465 (add-hook 'c-mode-hook #'c-configs)
    466 (add-hook 'cpp-mod-hook #'c-configs)
    467 (add-hook 'c-ts-mode-hook #'c-configs)
    468 (add-hook 'cpp-ts-mode-hook #'c-configs)
    469 #+END_SRC
    470 
    471 *** Pascal
    472 #+BEGIN_SRC emacs-lisp
    473 (setq-default pascal-indent-level 4)
    474 (setq-default pascal-tab-always-indent 'complete)
    475 (add-hook 'pascal-mode-hook
    476       	  (lambda ()
    477       	    (setq tab-width 4)
    478       	    (setq pascal-indent-level 4)
    479       	    (setq pascal-auto-lineup '())
    480       	    (setq indent-tabs-mode nil)))
    481 #+END_SRC
    482 
    483 *** Web
    484 #+BEGIN_SRC emacs-lisp
    485 (use-package web-mode
    486   :mode "\\.html?\\'")
    487 #+END_SRC
    488 
    489 *** Markdown
    490 #+BEGIN_SRC emacs-lisp
    491 (use-package markdown-mode
    492   :mode "\\.md\\'")
    493 #+END_SRC
    494 
    495 *** ASM
    496 #+BEGIN_SRC emacs-lisp
    497 (use-package nasm-mode
    498   :mode ("\\.asm\\'" "\\.s\\'"))
    499 #+END_SRC
    500 
    501 *** Zig
    502 #+BEGIN_SRC emacs-lisp
    503 (use-package zig-mode
    504   :mode "\\.zig\\'")
    505 #+END_SRC
    506 
    507 *** Odin
    508 #+BEGIN_SRC emacs-lisp
    509 (use-package odin-mode
    510   :mode "\\.odin\\'"
    511   :commands odin-mode
    512   :vc (:url "https://github.com/mattt-b/odin-mode.git"
    513       	    :rev :last-release)
    514   :hook (odin-mode . (lambda ()
    515 		       (setq-local indent-tabs-mode t)
    516 		       (indent-tabs-mode 1)
    517 		       (setq-local tab-width 8)
    518 		       (setq-local js-indent-level 8)
    519 		       (setq-local fill-column 100))))
    520 #+END_SRC
    521 
    522 *** Elixir
    523 #+BEGIN_SRC emacs-lisp
    524 (use-package elixir-mode
    525   :mode ("\\.ex\\'" "\\.exs\\'"))
    526 #+END_SRC
    527 
    528 Inferior mode.
    529 
    530 #+BEGIN_SRC emacs-lisp
    531 (use-package inf-elixir
    532   :after elixir-mode
    533   :hook (elixir-mode . inf-elixir-minor-mode))
    534 #+END_SRC
    535 
    536 *** Erlang
    537 #+BEGIN_SRC emacs-lisp
    538 (use-package erlang
    539   :mode "\\.erl\\'")
    540 #+END_SRC
    541 
    542 *** Haskell
    543 #+BEGIN_SRC emacs-lisp
    544 (use-package haskell-mode
    545   :mode "\\.hs\\'"
    546   :custom
    547   (haskell-stylish-on-save t))
    548 #+END_SRC
    549 
    550 *** Rust
    551 #+BEGIN_SRC emacs-lisp
    552 (use-package rust-mode
    553   :mode "\\.rs\\'")
    554 #+END_SRC
    555 
    556 *** Verilog
    557 #+BEGIN_SRC emacs-lisp
    558 (setq verilog-case-indent 2)
    559 (setq verilog-cexp-indent 2)
    560 (setq verilog-indent-level 2)
    561 (setq verilog-indent-level-module 2)
    562 (setq verilog-indent-level-directive 2)
    563 (setq verilog-indent-level-behavioral 2)
    564 (setq verilog-indent-level-declaration 2)
    565 (setq verilog-auto-lineup nil)
    566 (setq verilog-indent-lists nil)
    567 (add-hook 'verilog-mode-hook
    568 	  (lambda ()
    569 	    (indent-tabs-mode 0)
    570 	    (setq-local tab-width 2)))
    571 #+END_SRC
    572 
    573 *** Lua
    574 #+BEGIN_SRC emacs-lisp
    575 (use-package lua-mode
    576   :mode "\\.lua\\'")
    577 #+END_SRC
    578 
    579 *** Common Lisp
    580 #+BEGIN_SRC emacs-lisp
    581 (add-to-list 'auto-mode-alist '("\\.cl\\'" . lisp-mode))
    582 #+END_SRC
    583 
    584 *** Formatters for (almost) all the above
    585 #+BEGIN_SRC emacs-lisp
    586 (use-package reformatter
    587   :config
    588   (reformatter-define odin-format
    589     :program "odinfmt"
    590     :args '("-stdin"))
    591   (add-hook 'odin-mode-hook #'odin-format-on-save-mode)
    592   (reformatter-define clang-format
    593     :program "clang-format")
    594   (add-hook 'c-mode-hook #'clang-format-on-save-mode)
    595   (add-hook 'cpp-mode-hook #'clang-format-on-save-mode)
    596   (add-hook 'c-ts-mode-hook #'clang-format-on-save-mode)
    597   (add-hook 'c++-ts-mode-hook #'clang-format-on-save-mode)
    598   (reformatter-define go-format
    599     :program "gofmt")
    600   (add-hook 'go-mode-hook #'go-format-on-save-mode)
    601   (add-hook 'go-ts-mode-hook #'go-format-on-save-mode)
    602   (reformatter-define elixir-format
    603     :program "mix"
    604     :args '("format" "-"))
    605   (add-hook 'elixir-mode-hook #'elixir-format-on-save-mode)
    606   (add-hook 'elixir-ts-mode-hook #'elixir-format-on-save-mode)
    607   (reformatter-define latex-format
    608     :program "latexindent"
    609     :args '("-y=defaultIndent:'  '"))
    610   (add-hook 'latex-mode-hook #'latex-format-on-save-mode)
    611   (add-hook 'latex-ts-mode-hook #'latex-format-on-save-mode)
    612   (reformatter-define rust-format
    613     :program "rustfmt")
    614   (add-hook 'rust-mode-hook #'rust-format-on-save-mode)
    615   (add-hook 'rust-ts-mode-hook #'rust-format-on-save-mode)
    616   (reformatter-define verilog-format
    617     :program "verible-verilog-format"
    618     :args '("-"))
    619   (add-hook 'verilog-mode-hook #'verilog-format-on-save-mode)
    620   (add-hook 'verilog-ts-mode-hook #'verilog-format-on-save-mode)
    621   (reformatter-define zig-format
    622     :program "zig"
    623     :args '("fmt" "--stdin"))
    624   (add-hook 'zig-mode-hook #'zig-format-on-save-mode)
    625   (add-hook 'zig-ts-mode-hook #'zig-format-on-save-mode))
    626 #+END_SRC
    627 
    628 *** Minor languages without builtin-support
    629 #+BEGIN_SRC emacs-lisp
    630 (use-package yaml-mode
    631   :mode "\\.yaml\\'")
    632 #+END_SRC
    633 
    634 ** Org mode
    635 *** Basic
    636 Setup ~org-directory~ and ~org-agenda-files~.
    637 
    638 #+BEGIN_SRC emacs-lisp
    639 (setq org-directory "~/org")
    640 (setq org-agenda-files
    641       (list (expand-file-name "inbox.org" org-directory)))
    642 #+END_SRC
    643 
    644 *** Appearance/Indenting
    645 Visual line, indent, etc.
    646 
    647 #+BEGIN_SRC emacs-lisp
    648 (add-hook 'org-mode-hook
    649 	  (lambda ()
    650 	    (visual-line-mode 1)
    651 	    (org-indent-mode)
    652 	    (display-fill-column-indicator-mode -1)
    653 	    (variable-pitch-mode 1)
    654 	    (auto-fill-mode -1)))
    655 #+END_SRC
    656 
    657 Pretty.
    658 
    659 #+BEGIN_SRC emacs-lisp
    660 (use-package org-superstar
    661   :hook (org-mode . org-superstar-mode))
    662 #+END_SRC
    663 
    664 Hide and fontify everything.
    665 
    666 #+BEGIN_SRC emacs-lisp
    667 (setq org-highlight-latex-and-related '(latex script))
    668 (setq-default org-edit-src-content-indentation 0)
    669 (setq-default org-hide-macro-markers t)
    670 (setq-default org-hide-emphasis-markers t)
    671 (setq-default org-hide-block-startup t)
    672 (setq-default org-hide-drawer-startup t)
    673 (setq-default org-startup-folded 'fold)
    674 (setq org-hidden-keywords '(title))
    675 (setq org-superstar-leading-bullet ?\s)
    676 #+END_SRC
    677 
    678 Function to count the amount of ~.~ characters in the current line, because I write poetry and like to use it to separate syllables.
    679 
    680 #+BEGIN_SRC emacs-lisp
    681 (defun count-dots-in-line ()
    682   "Count the amount of . characters in the current line"
    683   (interactive)
    684   (save-excursion
    685     (let* ((start (line-beginning-position))
    686            (end   (line-end-position))
    687            (count (count-matches "\\." start end)))
    688       (message "%d" count))))
    689 #+END_SRC
    690 
    691 Another function to remove them.
    692 
    693 #+BEGIN_SRC emacs-lisp
    694 (defun remove-dots-in-line ()
    695   "Remove all . characters from the current line."
    696   (interactive)
    697   (save-excursion
    698     (let ((start (line-beginning-position))
    699           (end (line-end-position)))
    700       (goto-char start)
    701       (while (search-forward "." end t)
    702         (replace-match "" nil t)
    703         ;; The line became shorter, so keep END in sync.
    704         (setq end (1- end))))))
    705 #+END_SRC
    706 
    707 Bind them in Org mode.
    708 
    709 #+BEGIN_SRC emacs-lisp
    710 (with-eval-after-load 'org
    711   (define-key org-mode-map (kbd "C-c f") #'count-dots-in-line)
    712   (define-key org-mode-map (kbd "C-c d") #'remove-dots-in-line))
    713 #+END_SRC
    714 
    715 *** Beamer
    716 #+BEGIN_SRC emacs-lisp
    717 (use-package ox-beamer-lecture
    718   :defer t)
    719 #+END_SRC