#+title: Emacs Config Defaults #+author: Evie Litherland-Smith #+email: evie@xenia.me.uk #+filetags: :emacs:config:org: #+property: header-args:emacs-lisp :tangle yes :mkdirp yes :results output silent #+begin_src emacs-lisp (setq custom-file (locate-user-emacs-file "custom.el")) (when (and custom-file (file-exists-p custom-file)) (load custom-file nil 'nomessage)) (setq user-full-name "Evie Litherland-Smith" user-mail-address "evie@xenia.me.uk" use-short-answers t load-prefer-newer t even-window-sizes t global-auto-revert-non-file-buffers t dired-auto-revert-buffer t dired-dwim-target t tab-always-indent t completion-cycle-threshold nil completions-detailed t xref-show-definitions-function #'xref-show-definitions-completing-read kill-do-not-save-duplicates t auto-window-vscroll nil fast-but-imprecise-scrolling t scroll-conservatively 101 scroll-margin 0 scroll-preserve-screen-position 1) ;; Bind normal forward/back buttons on mouse to next/previous buffer respectively (keymap-global-set "" #'previous-buffer) (keymap-global-set "" #'next-buffer) ;; Quick bind for calling `git-sync-all' (defun my/git-sync-all () "Run shell command `git-sync-all' asynchronously." (interactive) (async-shell-command "git-sync-all" "*git-sync-all*" "*git-sync-errors*") (require 'org-journal) (org-journal-invalidate-cache)) (keymap-global-set "C-c g s" #'my/git-sync-all) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (global-auto-revert-mode +1) (delete-selection-mode +1) (setopt ;; No tabs indent-tabs-mode nil ;; Only display async output buffer when there's something to show async-shell-command-display-buffer nil ;; Scroll compilation buffer output compilation-scroll-output t) ;; Make shebang (#!) file executable when saved (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) #+end_src * Auto-save file settings #+begin_src emacs-lisp :tangle yes (setq backup-directory-alist '(("." . "~/.local/state/emacs/backups")) tramp-backup-directory-alist backup-directory-alist tramp-auto-save-directory (cdr (assoc "." tramp-backup-directory-alist))) (savehist-mode +1) #+end_src * Recent files #+begin_src emacs-lisp (use-package recentf :config (run-at-time nil (* 5 60) 'recentf-save-list) (recentf-mode +1) :custom (recentf-max-saved-items 2048)) #+end_src * diminish modes #+begin_src emacs-lisp (use-package diminish :ensure t) #+end_src * Authentication #+begin_src emacs-lisp (when (require 'auth-source nil :noerror) (setq auth-sources '("secrets:Login")) (when (require 'auth-source-pass nil :noerror) (auth-source-pass-enable))) #+end_src * Helpful #+begin_src emacs-lisp ;; Make `describe-*' screens more helpful (use-package helpful :ensure t :bind ((" " . helpful-command) (" " . helpful-callable) (" " . helpful-key) (" " . helpful-symbol) (" " . helpful-variable) ("C-h F" . helpful-function) :map helpful-mode-map (" " . helpful-update))) ;; Bind extra `describe-*' commands (keymap-global-set "C-h K" #'describe-keymap) #+end_src * Spell checking #+begin_src emacs-lisp ;; turn on spell checking, if available. (use-package ispell :ensure t :diminish :custom (ispell-dictionary "en_GB")) (use-package flyspell :ensure t :diminish :hook ((text-mode . flyspell-mode) (prog-mode . flyspell-prog-mode)) :init (require 'ispell) :custom (flyspell-mode-line-string nil) (flyspell-use-meta-tab nil) :config (require 'flyspell-correct) (require 'consult-flyspell)) (use-package flyspell-correct :ensure t :diminish :after flyspell :bind ( :map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))) (use-package consult-flyspell :ensure t :diminish :after (consult flyspell) :bind ( :map flyspell-mode-map ("C-c s ;" . consult-flyspell)) :config (setq consult-flyspell-always-check-buffer t)) #+end_src * ibuffer #+begin_src emacs-lisp (use-package ibuffer :ensure t :bind (("C-c b" . ibuffer))) (use-package ibuffer-project :ensure t :after ibuffer :hook ((ibuffer . (lambda () (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups)) (unless (eq ibuffer-sorting-mode 'project-file-relative) (ibuffer-do-sort-by-project-file-relative)))))) #+end_src * Link hint keymaps #+begin_src emacs-lisp (use-package link-hint :ensure t :bind (("C-c l o" . link-hint-open-link) ("C-c l c" . link-hint-copy-link) ("C-c l C-o" . link-hint-open-all-link) ("C-c l C-c" . link-hint-copy-all-link))) #+end_src * Avy keymaps #+begin_src emacs-lisp (use-package avy :ensure t :diminish :bind (("C-c j j" . avy-goto-char-2) ("C-c j w" . avy-goto-word-0) ("C-c j c" . avy-goto-char) ("C-c j l" . avy-goto-line))) #+end_src * which-func config #+begin_src emacs-lisp (use-package which-func :ensure t :init (which-function-mode)) #+end_src * Shells and terminals #+begin_src emacs-lisp (use-package shell :bind (("C-c t s" . shell))) (use-package eshell :bind (("C-c t e" . eshell))) #+end_src * Web browser #+begin_src emacs-lisp :tangle yes (use-package eww :defer t :diminish :custom (browse-url-browser-function 'browse-url-default-browser) (browse-url-new-window-flag t) (eww-default-download-directory "~/Downloads/") (eww-auto-rename-buffer 'title) (eww-browse-url-new-window-is-tab nil)) #+end_src