diff --git a/README.org b/README.org index 693f4f6..29df31b 100644 --- a/README.org +++ b/README.org @@ -2,220 +2,2032 @@ #+AUTHOR: Christopher James Hayward #+EMAIL: chris@chrishayward.xyz -#+PROPERTY: header-args :results silent :eval no-export +#+NAME: description +#+BEGIN_SRC text +Immutable NixOS dotfiles. +#+END_SRC -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil +Built for Life, Liberty, and the Open Road. -#+ATTR_ORG: :width 420px -#+ATTR_HTML: :width 420px -#+ATTR_LATEX: :width 420px -[[./docs/images/desktop-example.png]] ++ 100% Immutable ++ 100% Declarative ++ 100% Reproducible -Portable *GNU/Emacs*[fn:1] dotfiles. Built for Life, Liberty, and the Open Road. +* Introduction -+ 100% Reproducible -+ 100% Immutable -+ 100% Literate +This is my personal configuration(s) for GNU/Linux[fn:1] systems. It enables a consistent experience and computing environment across all of my machines. This project is written with GNU/Emacs[fn:2], leveraging its capabilities for Literate Programming[fn:3], a technique where programs are written in a natural language, such as English, interspersed with snippets of code to describe a software project. + +#+NAME: file-warning +#+BEGIN_SRC text +This file is controlled by /etc/dotfiles/README.org +#+END_SRC + +** Getting Started + +1) Download the latest version of NixOS https://nixos.org/download.html +2) Partition drives and mount the file system https://nixos.org/manual/nixos/stable/#sec-installation-partitioning +3) Clone the project to =/etc/dotfiles= ~git clone git@git.chrishayward.xyz:chris/dotfiles /etc/dotfiles~ +4) Load the default shell environment ~nix-shell /etc/dotfiles~ +5) Install the default system ~sudo nixos-rebuild switch --flake /etc/dotfiles#nixos~ +6) Reboot and login, start a graphical system with ~startx~ + +* Operating System + +NixOS[fn:4] is a purely functional Linux distribution built on top of the Nix[fn:5] package manager. It uses a declarative configuration language to define entire computer systems, and allows reliable system upgrades and rollbacks. NixOS[fn:4] also has tool dedicated to DevOps and deployment tasks, and makes it trivial to share development environments. + +#+BEGIN_SRC nix :noweb yes :tangle flake.nix +# <> +{ + description = "<>"; + + inputs = { + <> + <> + <> + <> + }; + + outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: { + nixosConfigurations = { + <> + <> + }; + }; +} +#+END_SRC + +** Nixpkgs + +Nixpkgs[fn:6] is a collection of over 60,000 software packages that can be installed with the Nix[fn:5] package manager. Two main branches are offered: + +1) The current stable release +2) The Unstable branch following the latest development + +#+NAME: os-nixpkgs +#+BEGIN_SRC nix +nixpkgs.url = "nixpkgs/nixos-unstable"; +nixpkgs-unstable.url = "nixpkgs/master"; +#+END_SRC + +** Home Manager + +Home Manager[fn:7] provides a basic system for managing user environments using the Nix[fn:5] package manager together with the Nix libraries found in Nixpkgs[fn:6]. It allows declarative configuration of user specific (non-global) packages and files. + +#+NAME: os-home-manager +#+BEGIN_SRC nix +home-manager.url = "github:nix-community/home-manager"; +home-manager.inputs.nixpkgs.follows = "nixpkgs"; +#+END_SRC + +** Emacs Overlay + +Adding the Emacs Overlay[fn:8] extends the GNU/Emacs[fn:2] package set to contain the latest versions, and daily generations from popular package sources, including the needed dependencies to run GNU/Emacs[fn:2] as a Window Manager. + +#+NAME: os-emacs-overlay +#+BEGIN_SRC nix +emacs-overlay.url = "github:nix-community/emacs-overlay"; +#+END_SRC + +** NixOS Hardware + +NixOS Hardware[fn:9] is a collection of NixOS[fn:4] modules covering specific hardware quirks. Unlike the channel, this will update the git repository on a rebuild. However, it's easy to pin particular revisions for more stability. + +#+NAME: os-nixos-hardware +#+BEGIN_SRC nix +nixos-hardware.url = "github:nixos/nixos-hardware"; +#+END_SRC + +* Host Configurations + +NixOS[fn:4] typically stores the current machine configuration in =/etc/nixos/configuration.nix=. In this project, this file is stored in =/etc/dotfiles/hosts/$HOSTNAME/...=, and imported, along with the generated hardware configurations. This ensures that multiple host machines can share the same modules, and generating new host definitions is trivial. + +** Default + +The default host, built using QEMU[fn:10], a free and open-source emulator that can perform hardware virtualization. It features a lightweight system optimized for development, running GNU/Emacs[fn:2] + EXWM[fn:11] as the graphical environment. + +#+NAME: host-default +#+BEGIN_SRC nix :noweb yes +nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./hosts/nixos + <> + <> + <> + <> + ]; +}; +#+END_SRC + +Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixos~. + +#+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix +# <> +{ ... }: + +{ + imports = [ + ./configuration.nix + ./hardware.nix + ]; +} +#+END_SRC + +*** Configuration + +This configuration can function independently from the rest of the project. If you wish to install a specific host without including the entire flake, you can create a symbolic link from =/etc/nixos= to =/etc/dotfiles/hosts/=. This configuration also handles a few requirements that must occur /outside/ of the Home Manager[fn:7] integration: + +1) It imports the Emacs Overlay[fn:8] +2) It installs the unstable version of Nix[fn:5] + +#+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/configuration.nix +# <> +{ config, pkgs, inputs, ... }: + +{ + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.device = "/dev/sda"; + + time.timeZone = "America/Toronto"; + + networking.hostName = "nixos"; + networking.useDHCP = false; + networking.firewall.enable = false; + networking.interfaces.ens3.useDHCP = true; + + programs.mtr.enable = true; + programs.fish.enable = true; + programs.gnupg.agent.enable = true; + + users.users.chris = { + shell = pkgs.fish; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; +} +#+END_SRC + +*** Hardware + +The file system for this host is a single 24GB QCOW file, a format for disk images used by QEMU[fn:10]. The file can be recreated easily by following the steps listed in the NixOS[fn:4] installation manual, specifically the section on disk formatting. + +#+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/hardware.nix +# <> +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "floppy" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/fddc37ff-a442-41fa-afc4-abf878be7c5a"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/5fc0e3df-e796-4fe2-8482-c6acaed9d36f"; } + ]; +} +#+END_SRC + +** TODO Acernitro + +My gaming laptop, the model is an Acer Nitro AN-515-53[fn:12]. The Nitro 5 has more in common with the mid-range notebooks rather than the gaming models due to its cooling design, chassis, and overall construction. + +Here are the specs: + +| Slot | Component | +|---------+---------------------------------------| +| CPU | Intel Core i5-8300H | +| GPU | NVIDIA GeForce GTX 1050Ti (4GB GDDR5) | +| RAM | 16GB DDR4 | +| Display | 15.6" Full HD (1920 x 1080), IPS | +| Storage | 1000GB HDD | +| Weight | 2.48kg (5.5 lbs) | + +#+NAME: host-acernitro +#+BEGIN_SRC nix :noweb yes +# NOTE: Work In Progress! +# acernitro = nixpkgs.lib.nixosSystem { +# system = "x86_64-linux"; +# specialArgs = { inherit inputs; }; +# modules = [ +# ./hosts/acernitro +# <> +# <> +# <> +# <> +# ]; +# }; +#+END_SRC + +Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#acernitro~. + +#+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/default.nix +# <> +{ ... }: + +{ + imports = [ + ./configuration.nix + ./hardware.nix + ]; +} +#+END_SRC + +*** TODO Configuration + +*** TODO Hardware + +* Module Definitions + +Modules are files combined by NixOS[fn:4] to produce the full system configuration. Modules wre introduced to allow extending NixOS[fn:4] without modifying its source code. They also allow splitting up =configuration.nix=, making the system configuration easier to maintain and use. + +** X11 + +#+NAME: module-x11 +#+BEGIN_SRC nix +./modules/x11.nix +#+END_SRC + +X11, or X[fn:13] is the generic name for the X Window System Display Server. All graphical GNU/Linux[fn:1] applications connect to an X-Window[fn:13] (or Wayland[fn:14]) to display graphical data on the monitor of a computer. Its a program that acts as the interface between graphical applications and the graphics subsystem of the computer. + +#+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix +# <> +{ config, pkgs, ... }: + +{ + services.xserver.enable = true; + services.xserver.layout = "us"; + services.xserver.libinput.enable = true; + services.xserver.displayManager.startx.enable = true; + + environment = { + systemPackages = with pkgs; [ + pkgs.sqlite + ]; + extraInit = '' + export XAUTHORITY=/tmp/Xauthority + [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" + ''; + }; + + services.picom.enable = true; + services.openssh.enable = true; + services.printing.enable = true; + + fonts.fonts = with pkgs; [ + iosevka + emacs-all-the-icons-fonts + ]; +} +#+END_SRC + +** Flakes + +#+NAME: module-flakes +#+BEGIN_SRC nix +./modules/flakes.nix +#+END_SRC + +Nix Flakes[fn:15] are an upcoming feature of the Nix package manager[fn:5]. They allow you to specify your codes dependencies in a declarative way, simply by listing them inside of a ~flake.nix~ file. Each dependency is then pinned to a specific git-hash. Flakes[fn:15] replace the =nix-channels= command and things like ~builtins.fetchGit~, keeping dependencies at the top of the tree, and channels always in sync. Currently, Flakes[fn:15] are not available unless explicitly enabled. + +#+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix +# <> +{ config, pkgs, inputs, ... }: + +{ + nix = { + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + nixpkgs = { + config = { allowUnfree = true; }; + overlays = [ inputs.emacs-overlay.overlay ]; + }; +} +#+END_SRC + +** Cachix + +#+NAME: module-cachix +#+BEGIN_SRC nix +./modules/cachix.nix +#+END_SRC + +Cachix[fn:16] is a Command line client for Nix[fn:5] binary cache hosting. This allows downloading and usage of pre-compiled binaries for applications on /nearly/ every available system architecture. This speeds up the time it takes to rebuild configurations. + +#+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix +# <> +{ config, ... }: + +{ + nix = { + binaryCaches = [ + "https://nix-community.cachix.org" + ]; + binaryCachePublicKeys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; +} +#+END_SRC + +** Home Manager + +Home Manager includes a =flake.nix= file for compatibility with Nix Flakes, a feature utilized heavily in this project. When using flakes, switching to a new configuration is done /only/ for the entire system, using the command ~nixos-rebuild switch --flake ~, instead of ~nixos-rebuild~, and ~home-manager~ seperately. + +#+NAME: module-home-manager +#+BEGIN_SRC nix :noweb yes +inputs.home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.chris = { + imports = [ + <> + <> + <> + <> + <> + ]; + }; +} +#+END_SRC + +** Git + +#+NAME: module-git +#+BEGIN_SRC nix +./modules/git.nix +#+END_SRC + +Git[fn:17] is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn, has a tiny footprint, and lighting fast performance. It outclasses every other version control tool such as: SCM, Subversion, CVS, ClearCase, with features like cheap local branching, convinient staging areas, and multiple workflows. + +#+BEGIN_SRC nix :noweb yes :tangle modules/git.nix +# <> +{ pkgs, ... }: + +{ + programs.git = { + enable = true; + userName = "Christopher James Hayward"; + userEmail = "chris@chrishayward.xyz"; + + signing = { + key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F"; + signByDefault = true; + }; + }; +} +#+END_SRC + +** Gpg + +#+NAME: module-gpg +#+BEGIN_SRC nix +./modules/gpg.nix +#+END_SRC + +GNU Privacy Guard[fn:18] is a free-software replacement for Symantec's PGP cryptographic software suite. It is compliant with RFC 4880, the IETF standards-track specification of OpenPGP. Modern versions of PGP are interoperable with GnuPG and other OpenPGP-compliant systems. + +#+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix +# <> +{ pkgs, ... }: + +{ + services.gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + pinentryFlavor = "gtk2"; + }; +} +#+END_SRC + +** Vim + +#+NAME: module-vim +#+BEGIN_SRC nix +./modules/vim.nix +#+END_SRC + +Neovim[fn:19] is a project that seeks to aggressively refactor Vim in order to: + ++ Simplify maintenance and encourage contributions ++ Split the work between multiple developers ++ Enable advanced UIs without core modification ++ Maximize extensibility + +#+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix +# <> +{ pkgs, ... }: + +{ + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + extraConfig = '' + set number relativenumber + set nobackup + ''; + extraPackages = [ + pkgs.nixfmt + ]; + plugins = with pkgs.vimPlugins; [ + vim-nix + vim-airline + vim-polyglot + ]; + }; +} +#+END_SRC + +** GTK + +#+NAME: module-gtk +#+BEGIN_SRC nix +./modules/gtk.nix +#+END_SRC + +GTK[fn:20] is a free and open-source, cross-platform widget toolkit for graphical user interfaces. It's one of the most popular toolkits for the Wayland[fn:14] and X11[fn:13] windowing systems. + +#+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix +# <> +{ pkgs, ... }: + +{ + home.packages = [ + pkgs.nordic + pkgs.lxappearance + ]; + + home.file.".gtkrc-2.0" = { + text = '' + gtk-theme-name="Nordic-bluish-accent" + gtk-icon-theme-name="Adwaita" + gtk-font-name="Sans 10" + gtk-cursor-theme-size=0 + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR + gtk-button-images=0 + gtk-menu-images=0 + gtk-enable-event-sounds=1 + gtk-enable-input-feedback-sounds=1 + gtk-xft-antialias=1 + gtk-xft-hinting=1 + gtk-xft-hintstyle="hintmedium" + ''; + }; +} +#+END_SRC -* Setup -:PROPERTIES: -:header-args: :tangle early-init.el -:END: +* Development Shells -These is my personal configuration(s) for *GNU/Linux*[fn:2], and *GNU/Emacs*[fn:1] software. It enables a consistent experience and computing environment across all of my machines. The entire experience is controlled with *GNU/Emacs*[fn:1], leveraging it's capabilities for *Literate Programming*[fn:3]. +The command ~nix-shell~[fn:21] will build the dependencies of the specified derivation, but not the derivation itself. It will then start an interactive shell in which all environment variables defined by the derivation /path/ have been set to their corresponding values. -#+begin_src emacs-lisp -;; This file is controlled by README.org -;; Please make any modifications there. -#+end_src +Import this shell with ~nix-shell /etc/dotfiles~. -** Cleanup +#+BEGIN_SRC nix :noweb yes :tangle shell.nix +# <> +{ pkgs ? import { } }: -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. To solve this issue, before most of the packages have loaded, I change the value, a method I detail in this post[fn:4]. +with pkgs; -#+begin_src emacs-lisp -;; The original value of `user-emacs-directory' prior to redirection. -(defconst dotfiles/home - (or (getenv "DOTFILES_HOME") - (expand-file-name user-emacs-directory))) +let + nixBin = writeShellScriptBin "nix" '' + ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@" + ''; -;; The redirection target of `user-emacs-directory' during initialization. -(defconst dotfiles/cache - (or (getenv "DOTFILES_CACHE") - (expand-file-name "~/.cache/emacs"))) +in mkShell { + buildInputs = [ + git + ]; + shellHook = '' + export FLAKE=$(pwd) + export PATH=$FLAKE/bin:${nixBin}/bin:$PATH" + ''; +} +#+END_SRC -;; Make sure `dotfiles/cache' is a valid directory. -(unless (file-exists-p dotfiles/cache) - (make-directory dotfiles/cache t)) +** Go -;; Redirect the value of `user-emacs-directory'. -(setq user-emacs-directory dotfiles/cache) +Go[fn:22] is an open-source programming language that makes it easy to build simple, reliable, and efficient software. It's statically typed and compiled programming language. It's syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency. -;; Remove the eln-cache subdirectory. -(delete (expand-file-name "eln-cache" dotfiles/home) comp-eln-load-path) +Import this shell with ~nix-shell /etc/dotfiles/shells/go~ -;; Add a new eln-cache folder. -(add-to-list 'comp-eln-load-path (expand-file-name "eln-cache" dotfiles/cache)) +#+BEGIN_SRC nix :noweb yes :tangle shells/go.nix +# <> +{ pkgs ? import { } }: -;; Disable error messages for packages that don't support native-comp. -(setq comp-async-report-warnings-errors nil) +with pkgs; +mkShell { + buildInputs = [ + go + gopls + protoc-gen-go-grpc + ]; + shellHook = '' + export GO111MODULE=on + export GOPATH=$HOME/.go/ + export PATH=$GOPATH/bin:$PATH + ''; +} +#+END_SRC +** gRPC + +gRPC[fn:23] is a modern open-source, high-performance Remote Procedure Call (RPC) framework that can run in any environment. It can efficiently connect services in and across data centres with pluggable support for load balancing, tracing, health checking, and authentication. + +Import this shell with ~nix-shell /etc/dotfiles/shells/grpc~ + +#+BEGIN_SRC nix :noweb yes :tangle shells/grpc.nix +# <> +{ pkgs ? import { } }: + +with pkgs; +mkShell { + buildInputs = [ + grpc + grpc-tools + grpcui + grpcurl + ]; + shellHook = '' + ''; +} +#+END_SRC + +** C/C++ + +C[fn:24] is a general-purpose, procedural computer programming language support structured programming, lexical variable scope, and recursion. It has a static type system, and by design provides constructs that map efficiently to typical machine instructions. C++[fn:25] is a general-purpose programming language created as an extension of the C[fn:24] programming language. + +Import this shell with ~nix-shell /etc/dotfiles/shells/cc~ + +#+BEGIN_SRC nix :noweb yes :tangle shells/cc.nix +# <> +{ pkgs ? import { } }: + +with pkgs; +mkShell { + buildInputs = [ + ccls + gnumake + libstdcxx5 + gcc-unwrapped + ]; + shellHook = '' + ''; +} +#+END_SRC + +** Python + +Python[fn:26] is an interpreted high-level, general-purpose programming language. Its design philosophy emphasizes code readability, with its notable use of significant indentation. Its language constructs, as well as its object-oriented approach aim to help programmers write clear, logical, code for small and large projects. + +Import this shell with ~nix-shell /etc/dotfiles/shells/python~ + +#+BEGIN_SRC nix :noweb yes :tangle shells/python.nix +# <> +{ pkgs ? import { } }: + +with pkgs; +mkShell { + buildInputs = [ + python39Packages.pip + python39Packages.pip-tools + python39Packages.pyls-mypy + python39Packages.pyls-isort + python39Packages.pyls-black + ]; + shellHook = '' + ''; +} +#+END_SRC + +* Emacs Configuration + +#+NAME: module-emacs +#+BEGIN_SRC nix +./modules/emacs.nix +#+END_SRC + +GNU/Emacs[fn:2] is an extensible, customizable, free/libre text editor -- and more. At its core is an interpreter for Emacs Lisp[fn:18], a dialect of the Lisp programming language with extensions to support text editing. Other features include: + ++ Highly customizable ++ Full Unicopde support ++ Content-aware editing modes ++ Complete built-in documentation ++ Wide range of functionality beyond text editing + +#+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix +# <> +{ pkgs, ... }: + +let + myEmacs = pkgs.emacsWithPackagesFromUsePackage { + config = ../README.org; + package = <> + alwaysEnsure = true; + alwaysTangle = true; + extraEmacsPackages = epkgs: [ + # Required packages... + <> + <> + <> + <> + + # Optional packages. + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + <> + ]; + }; + +in { + home.packages = [ + <> + <> + <> + <> + <> + <> + <> + ]; + + programs.emacs = { + enable = true; + package = myEmacs; + }; + + <> + <> + <> +} +#+END_SRC + +When Emacs is started, it normally tries to load a Lisp program from an ititialization file, or /init/ file. This file, if it exists, specifies how to initialize and configure Emacs. + +#+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/init.el +;; <> + +;; Required inputs. +<> +<> +<> +<> + +;; Optional inputs. +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> + +;; User interface. +<> +<> +<> +#+END_SRC + +It's somtimes desirable to have customization that takes effect during Emacs startup earlier than the normal init file. Place these configurations in =~/.emacs.d/early-init.el=. Most customizations should be put in the normal init file =~/.emacs.d/init.el=. + +#+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/early-init.el +;; <> +<> +<> +<> +<> +#+END_SRC + +** Disable UI + +Emacs[fn:2] has been around since the 1980s, and it's painfully obvious when you're greeted with the default user interface. Disable some unwanted features to clean it up, and bring the appearance to something closer to a modern editor. + +#+NAME: emacs-disable-ui-elisp +#+BEGIN_SRC emacs-lisp +;; Disable unwanted UI elements. +(tooltip-mode -1) +(menu-bar-mode -1) +(tool-bar-mode -1) +(scroll-bar-mode -1) + +;; Fix the scrolling behaviour. +(setq scroll-conservatively 101) + +;; Fix mouse-wheel scrolling behaviour. +(setq mouse-wheel-follow-mouse t + mouse-wheel-progressive-speed t + mouse-wheel-scroll-amount '(3 ((shift) . 3))) +#+END_SRC + +** Native Comp + +#+NAME: emacs-native-comp-package +#+BEGIN_SRC nix +pkgs.emacsGcc; +#+END_SRC + +Native Comp, also known as GccEmacs, refers to the ~--with-native-compilation~ configuration option when building GNU/Emacs[fn:2]. It adds support for compiling Emacs Lisp to native code using ~libgccjit~. All of the Emacs Lisp packages shipped with Emacs are native-compiled, providing a noticable performance iomprovement out-of-the-box. + +#+NAME: emacs-native-comp-elisp +#+BEGIN_SRC emacs-lisp +;; Silence warnings from packages that don't support `native-comp'. +(setq comp-async-report-warnings-errors nil ;; Emacs 27.2 ... + native-comp-async-report-warnings-errors nil) ;; Emacs 28+ ... +#+END_SRC + +** Backup Files + +Emacs[fn:2] makes a backup for a file only the first time the file is saved from a buffer. No matter how many times the file is subsequently written to, the backup remains unchanged. For files managed by a version control system, backup files are redundant since the previous versions are already stored. + +#+NAME: emacs-backup-files-elisp +#+BEGIN_SRC emacs-lisp ;; Disable unwanted features. (setq make-backup-files nil create-lockfiles nil) -#+end_src - -** Packages - -Download and install packages using ~straight.el~[fn:5], a fully functional package manager for Emacs that integrates with ~use-package~, a popular way of installing packages for Emacs. - -#+begin_src emacs-lisp -;; Apply the configurations prior to bootstrapping the package manager. -(setq straight-repository-branch "master" - straight-use-package-by-default t - package-enable-at-startup nil) - -;; BUGFIX https://github.com/raxod502/straight.el/issues/757 -(defvar native-comp-deferred-compilation-deny-list ()) -#+end_src - -Bootstrap the package manager by loading the bootstrap-file, downloading it when it doesn't exist on a new system. This operation may take some time on a new system. - -#+begin_src emacs-lisp -;; Bootstrap the package manager. -(defvar bootstrap-version) -(let ((bootstrap-file - (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) - (bootstrap-version 5)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) - -;; Integrate with `use-package' by installing it via `straight'. -(straight-use-package 'use-package) - -;; Specify core package sources. -(straight-use-package 'no-littering) -(straight-use-package '(org :local-repo nil)) -#+end_src - -** Options - -All of the options are defined early in the config, this is for two reasons: The first being to allow the possibility of sharing between modules, the values which are set early in the configuration. The second reason, related to the first, is to allow machine specific overrides depending on the context where Emacs is running. - -#+begin_src emacs-lisp -;; All of the modules available sorted in their default load order. -(defconst dotfiles/modules-p - '(trash keys org evil dired magit shell - emms mu4e elfeed eshell vterm gpg pass - x11 exwm roam agenda spelling grammar - reveal hugo capture projects docker - lsp dap cc go uml conf python fonts - nix ivy themes modeline dashboard)) - -;; All of the enabled modules. -(defvar dotfiles/modules dotfiles/modules-p) - -;; The default system language. -(defvar dotfiles/language (getenv "LANG")) - -;; Configure a unified system font. -(defvar dotfiles/font "Fira Code") - -;; Default system font size. -(defvar dotfiles/font-size 96) - -;; Delay time before offering suggestions and completions. -(defvar dotfiles/idle 0.0) - -;; The all powerful leader key. -(defvar dotfiles/leader-key "SPC") - -;; Global prefix for the leader key under X11 windows. -(defvar dotfiles/leader-key-global - (concat "C-" dotfiles/leader-key)) - -;; The location on disk of source code projects. -(defvar dotfiles/projects - (or (getenv "DOTFILES_PROJECTS") - (expand-file-name "~/.local/source"))) - -;; The location on disk of the local copy of the password store. -(defvar dotfiles/passwords - (or (getenv "DOTFILES_PASSWORDS") - (expand-file-name "~/.password-store"))) - -;; The public GPG key to encrpyt files, and emails for / to / with. -(defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F") -#+end_src - -** Methods - -Define two methods that will be used in the next phase of startup: The first method will load a machine-specific (host) configuration file, and the second method will load a custom module definition. - -#+begin_src emacs-lisp -;; Load a host configuration. -(defun dotfiles/load-host (host-name) - "Load the host configuration file for the system `host-name'." - (interactive) - (let ((host-file (concat dotfiles/home "/hosts/" host-name ".org"))) - (when (file-exists-p host-file) - (org-babel-load-file host-file)))) - -;; Load a module definition. -(defun dotfiles/load-modules (modules) - "Load the `modules' in sequential order." - (interactive) - (dolist (m modules) - (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org"))) - (when (file-exists-p mod-file) - (org-babel-load-file mod-file))))) -#+end_src - -* Config -:PROPERTIES: -:header-args: :tangle init.el -:END: - -Once the early-init phase as completed, there are only two remaining tasks to complete before the system is fully initialized. - -#+begin_src emacs-lisp -;; This file is controlled by README.org -;; Please make any modifications there. -#+end_src +#+END_SRC + +** Shell Commands + +Define some methods for interaction between GNU/Emacs[fn:2], and the systems underyling shell: + +1) Method to run an external process, launching any application on a new process without interferring with Emacs[fn:2] +2) Method to apply commands to the curren call process, effecting the running instance of Emacs[fn:2] + +#+NAME: emacs-shell-commands-elisp +#+BEGIN_SRC emacs-lisp +;; Define a method to run an external process. +(defun dotfiles/run (cmd) + "Run an external process." + (interactive (list (read-shell-command "λ "))) + (start-process-shell-command cmd nil cmd)) + +;; Define a method to run a background process. +(defun dotfiles/run-in-background (cmd) + (let ((command-parts (split-string cmd "[ ]+"))) + (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) +#+END_SRC + +** Nix Mode + +#+NAME: emacs-nix-mode-extras +#+BEGIN_SRC nix +pkgs.nixfmt +#+END_SRC + +Nix-mode[fn:27] is an Emacs[fn:2] major mode for editing Nix[fn:5] expressions. This provides basic handling of =.nix= files. Syntax highlighting and indentation support using =SMIE= are provided. + +#+NAME: emacs-nix-mode-package +#+BEGIN_SRC nix +epkgs.nix-mode +#+END_SRC + +** Evil Mode + +Evil[fn:12] is an extensible VI layer for GNU/Emacs[fn:2]. It emulates the main features of Vim[fn:19], turning GNU/Emacs[fn:2] into a modal editor. + +#+NAME: emacs-evil-package +#+BEGIN_SRC nix +epkgs.evil +epkgs.evil-collection +epkgs.evil-surround +epkgs.evil-nerd-commenter +#+END_SRC + +The next time Emacs[fn:2] is started, it will come up in /normal state/, denoted by == in the modeline. This is where the main ~vi~ bindings are defined. Like Emacs[fn:2] in general, Evil[fn:12] is extensible in Emacs Lisp[fn:18]. + +#+NAME: emacs-evil-elisp +#+BEGIN_SRC emacs-lisp +;; Enable the Extensible VI Layer for Emacs. +(setq evil-want-integration t ;; Required for `evil-collection.' + evil-want-keybinding nil) ;; Same as above. +(evil-mode +1) + +;; Configure `evil-collection'. +(evil-collection-init) + +;; Configure `evil-surround'. +(global-evil-surround-mode +1) + +;; Configure `evil-nerd-commenter'. +(global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines) +#+END_SRC + +** EXWM + +#+NAME: emacs-exwm-package +#+BEGIN_SRC nix +epkgs.exwm +#+END_SRC + +EXWM (Emacs X Window Manager)[fn:11] is a full-featured tiling X window manager for GNU/Emacs[fn:2] built on-top of XELB. It features: + ++ Fully keyboard-driven operations ++ Hybrid layout modes (tiling & stacking) ++ Dynamic workspace support ++ ICCM/EWMH compliance + +#+NAME: emacs-exwm-extras +#+BEGIN_SRC nix +pkgs.arandr +pkgs.autorandr +#+END_SRC + +I wanted to leave ~(exwm-enable)~ out of my Emacs configuration (which does no harm anyways). This can be called when using the daemon to start EXWM[fn:11]. + +#+NAME: emacs-exwm-config +#+BEGIN_SRC nix +xsession = { + enable = true; + windowManager.command = '' + ${myEmacs}/bin/emacs --daemon -f exwm-enable + ${myEmacs}/bin/emacsclient -c + ''; +}; +#+END_SRC + +EXWM[fn:11] cannot make an X window manager by itself, this is by design; You must tell X to do it. Override the =~/.xinitrc= file to start the =xsession=. + +#+NAME: emacs-exwm-xinitrc +#+BEGIN_SRC nix +home.file.".xinitrc" = { + text = '' + exec ./.xsession + ''; +}; +#+END_SRC + +#+NAME: emacs-exwm-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `exwm'. +(setq exwm-worspace-show-all-buffers t) +(setq exwm-input-prefix-keys + '(?\M-x + ?\C-g + ?\C-\ )) +(setq exwm-input-global-keys + `(([?\s-r] . exwm-reset) + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 1 9)))) + +;; Configure `exwm-randr'. +(require 'exwm-randr) +(exwm-randr-enable) + +;; Configure custom hooks. +(setq display-time-and-date t) +(add-hook 'exwm-init-hook + (lambda () + (display-battery-mode +1) ;; Display battery info (if available). + (display-time-mode +1))) ;; Display the time in the modeline. + +;; Setup buffer display names. +(add-hook 'exwm-update-class-hook + (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) ;; Use the system class name. + +;; Configure monitor hot-swapping. +(add-hook 'exwm-randr-screen-change-hook + (lambda () + (dotfiles/run-in-background "autorandr --change --force"))) ;; Swap to the next screen config. +#+END_SRC + +** General + +#+NAME: emacs-general-package +#+BEGIN_SRC nix +epkgs.general +#+END_SRC + +General[fn:28] provides a more convenient method for binding keys in Emacs[fn:2], providing a unified interface for key definitions. Its primary purpose is to build on /existing/ functionality to make key definitions more clear and concise. + +#+NAME: emacs-general-elisp +#+BEGIN_SRC emacs-lisp +;; Use as a leader key via `general.el'. +(general-create-definer dotfiles/leader + :states '(normal motion) + :keymaps 'override + :prefix "SPC" + :global-prefix "C-SPC") + +;; Find files with ... +;; Switch buffers with ... +(dotfiles/leader + "." '(find-file :which-key "File") + "," '(switch-to-buffer :which-key "Buffer") + "c" '(kill-buffer-and-window :which-key "Close")) + +;; Add keybindings for executing shell commands. +(dotfiles/leader + "r" '(:ignore t :which-key "Run") + "rr" '(dotfiles/run :which-key "Run") + "ra" '(async-shell-command :which-key "Async")) + +;; Add keybindings for quitting Emacs. +(dotfiles/leader + "q" '(:ignore t :which-key "Quit") + "qq" '(save-buffers-kill-emacs :which-key "Save") + "qw" '(kill-emacs :which-key "Now") + "qf" '(delete-frame :which-key "Frame")) + +;; Add keybindings for toggles / tweaks. +(dotfiles/leader + "t" '(:ignore t :which-key "Toggle / Tweak")) + +;; Add keybindings for working with frames to replace +;; the C-x method of bindings, which is awful. +(dotfiles/leader + "w" '(:ignore t :which-key "Windows") + "ww" '(window-swap-states :which-key "Swap") + "wc" '(delete-window :which-key "Close") + "wh" '(windmove-left :which-key "Left") + "wj" '(windmove-down :which-key "Down") + "wk" '(windmove-up :which-key "Up") + "wl" '(windmove-right :which-key "Right") + "ws" '(:ignore t :which-key "Split") + "wsj" '(split-window-below :which-key "Below") + "wsl" '(split-window-right :which-key "Right")) +#+END_SRC + +** Which Key + +Which-key[fn:29] is a minor mode for Emacs[fn:2] that displays the key bindings following your currently entered incomplete command (prefix) in a popup or mini-buffer. + +#+NAME: emacs-which-key-package +#+BEGIN_SRC nix +epkgs.which-key +#+END_SRC + +#+NAME: emacs-which-key-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `which-key' to see keyboard bindings in the +;; mini-buffer and when using M-x. +(setq which-key-idle-delay 0.0) +(which-key-mode +1) +#+END_SRC + +** EWW + +The Emacs Web Wowser[fn:30] is a Web browser written in Emacs Lisp[fn:18] based on the ~shr.el~ library. It's my primary browser when it comes to text-based browsing. + ++ Use ~eww~ as the default browser ++ Don't use any special fonts or colours + +#+NAME: emacs-eww-elisp +#+BEGIN_SRC emacs-lisp +;; Set `eww' as the default browser. +(setq browse-url-browser-function 'eww-browse-url) + +;; Configure the `shr' rendering engine. +(setq shr-use-fonts nil + shr-use-colors nil) +#+END_SRC + +** Dired + +#+NAME: emacs-dired-package +#+BEGIN_SRC nix +epkgs.dired-single +#+END_SRC + +Dired[fn:31] shows a directory listing inside of an Emacs[fn:2] buffer that can be used to perform various file operations on files and subdirectories. THe operations you can perform are numerous, from creating subdirectories, byte-compiling files, searching, and editing files. Dired-Extra[fn:32] provides extra functionality for Dired[fn:31]. + +#+NAME: emacs-dired-elisp +#+BEGIN_SRC emacs-lisp +;; Include `dired-x' for the `jump' method. +(require 'dired-x) + +;; Configure `dired-single' to support `evil' keys. +(evil-collection-define-key 'normal 'dired-mode-map + "h" 'dired-single-up-directory + "l" 'dired-single-buffer) + +;; Setup `all-the-icons' and the `dired' extension. + +;; Configure keybindings for `dired'. +(dotfiles/leader + "d" '(dired-jump :which-key "Dired")) +#+END_SRC + +** Icons + +#+NAME: emacs-icons-package +#+BEGIN_SRC nix +epkgs.all-the-icons +epkgs.all-the-icons-dired +#+END_SRC + +All The Icons[fn:33] is a utility package to collect various Icon Fonts and prioritize them within GNU/Emacs[fn:2]. + +#+NAME: emacs-icons-elisp +#+BEGIN_SRC emacs-lisp +;; Setup `all-the-icons-dired'. +(add-hook 'dired-mode-hook 'all-the-icons-dired-mode) + +;; Display default font ligatures. +(global-prettify-symbols-mode +1) +#+END_SRC + +** Emojis + +#+NAME: emacs-emoji-package +#+BEGIN_SRC nix +epkgs.emojify +#+END_SRC + +Emojify[fn:34] is an Emacs[fn:2] extension to display Emojis. It can display GitHub style Emojis like :smile: or plain ascii ones such as :). It tries to be as efficient as possible, while also providing flexibility. -** Hosts +#+NAME: emacs-emoji-elisp +#+BEGIN_SRC emacs-lisp +;; Setup `emojify'. +(add-hook 'after-init-hook 'global-emojify-mode) +#+END_SRC -The first task involves loading a machine-specific (host) configuration file. This gives the oppertunity for a host to intervene in the module loading process, adding or removing modules before the next stage has begun. This is accomplished by modifying the list of modules in ~dotfiles/modules~. +** EShell -#+begin_src emacs-lisp -;; Load the host configuration. -(dotfiles/load-host system-name) -#+end_src +#+NAME: emacs-eshell-package +#+BEGIN_SRC nix +epkgs.eshell-prompt-extras +#+END_SRC -** Modules +EShell [fn:35] is a shell-like command interpreter for GNU/Emacs[fn:2] implemented in Emacs Lisp[fn:18]. It invokes no external processes except for those requested by the user. It's intended to be an alternative for IELM, and a full REPL envionment for Emacs[fn:2]. -After the host configuration file has loaded, the value of ~dotfiles/modules~ is used to load all of the enabled modules. They're loaded in sequential order, and an error in any module will end this process. +#+NAME: emacs-eshell-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `eshell'. +(setq eshell-highlight-prompt nil + eshell-prefer-lisp-functions nil) -#+begin_src emacs-lisp -;; Load the enabled modules. -(dotfiles/load-modules dotfiles/modules) -#+end_src +;; Configure the lambda prompt. +(autoload 'epe-theme-lambda "eshell-prompt-extras") +(setq eshell-prompt-function 'epe-theme-lambda) + +;; Configure keybindings for `eshell'. +(dotfiles/leader + "e" '(eshell :which-key "EShell")) +#+END_SRC + +** VTerm + +Emacs Libvterm (VTerm)[fn:36] is a fully-fledged terminal emulator inside GNU/Emacs[fn:2] based on Libvterm[fn:37], a blazing fast C library used in Neovim[fn:19]. As a result of using compiled code (instead of Emacs Lisp[fn:18]), VTerm[fn:36] is capable, fast, and it can seamlessly handle large outputs. + +#+NAME: emacs-vterm-package +#+BEGIN_SRC nix +epkgs.vterm +#+END_SRC + +#+NAME: emacs-vterm-elisp +#+BEGIN_SRC emacs-lisp +;; Add keybindings for interacting with the shell(s). +(dotfiles/leader + "v" '(vterm :which-key "VTerm")) +#+END_SRC + +** Magit + +Magit[fn:38] is an interface to the Git[fn:17] version control system, implemented as a GNU/Emacs[fn:2] package written in Elisp[fn:18]. It fills the glaring gap between the Git[fn:17] command line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks within a few mnemonic key presses. + +#+NAME: emacs-magit-package +#+BEGIN_SRC nix +epkgs.magit +#+END_SRC + +| Key | Description | +|-----+--------------------------------------| +| gg | Check the status of a repository | +| gc | Clone a remote repository | +| gf | Fetch the contents of the repository | +| gp | Pull the remotes of the repository | + +#+NAME: emacs-magit-elisp +#+BEGIN_SRC emacs-lisp +;; Add keybindings for working with `magit'. +(dotfiles/leader + "g" '(:ignore t :which-key "Git") + "gg" '(magit-status :which-key "Status") + "gc" '(magit-clone :which-key "Clone") + "gf" '(magit-fetch :which-key "Fetch") + "gp" '(magit-pull :which-key "Pull")) +#+END_SRC + +** Fonts + +#+NAME: emacs-fonts-elisp +#+BEGIN_SRC emacs-lisp +;; Configure the font when running as `emacs-server'. +(custom-set-faces + '(default ((t (:inherit nil :height 96 :family "Iosevka"))))) + +;; Set all three of Emacs' font faces. +;; NOTE: This only works without `emacs-server'. +;; (set-face-attribute 'default nil :font "Iosevka" :height 96) +;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 96) +;; (set-face-attribute 'variable-pitch nil :font "Iosevka" :height 96) +#+END_SRC + +** Elfeed + +#+NAME: emacs-elfeed-package +#+BEGIN_SRC nix +epkgs.elfeed +#+END_SRC + +Elfeed[fn:39] is an extensible web feed reader for GNU/Emacs[fn:2], support both =Atom= and =RSS=. It requires =Emacs 24.3+= and is available for download from the standard repositories. + +| Key | Command | +|-----+---------| +| l | Open | +| u | Update | + +#+NAME: emacs-elfeed-elisp +#+BEGIN_SRC emacs-lisp +;; Add custom feeds for `elfeed' to fetch. +(setq elfeed-feeds (quote + (("https://hexdsl.co.uk/rss.xml") + ("https://lukesmith.xyz/rss.xml") + ("https://friendo.monster/rss.xml") + ("https://chrishayward.xyz/index.xml") + ("https://protesilaos.com/codelog.xml")))) + +;; Add custom keybindings for `elfeed'. +(dotfiles/leader + "l" '(:ignore t :which-key "Elfeed") + "ll" '(elfeed :which-key "Open") + "lu" '(elfeed-update :which-key "Update")) +#+END_SRC + +** Org Mode + +#+NAME: emacs-org-package +#+BEGIN_SRC nix +epkgs.org +#+END_SRC + +Org-mode[fn:40] is a document editing and organizing mode, designed for notes, planning, and authoring within the free software text editor GNU/Emacs[fn:2]. The name is used to encompass plain text files (such as this one) that include simple marks to indicate levels of a hierarchy, and an editor with functions that can read the markup and manipulate the hierarchy elements. + +#+NAME: emacs-org-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `org-mode' source blocks. +(setq org-src-fontify-natively t ;; Make source blocks prettier. + org-src-tab-acts-natively t ;; Use TAB indents within source blocks. + org-src-preserve-indentation t) ;; Stop `org-mode' from formatting blocks. + +;; Add an `org-mode-hook'. +(add-hook 'org-mode-hook + (lambda () + (org-indent-mode) + (visual-line-mode))) + +;; Remove the `Validate XHTML 1.0' message from HTML export. +(setq org-export-html-validation-link nil + org-html-validation-link nil) + +;; TODO: Configure default structure templates. +;; (require 'org-tempo) + +;; Apply custom keybindings. +(dotfiles/leader + "o" '(:ignore t :which-key "Org") + "oe" '(org-export-dispatch :which-key "Export") + "ot" '(org-babel-tangle :which-key "Tangle") + "of" '(:ignore t :which-key "Footnotes") + "ofn" '(org-footnote-normalize :which-key "Normalize")) +#+END_SRC + +** Org Roam + +#+NAME: emacs-org-roam-package +#+BEGIN_SRC nix +epkgs.org-roam +epkgs.org-roam-server +#+END_SRC + +Org Roam[fn:41] is a plain-text knowledge management system. It borrows principles from the Zettelkasten method[fn:42], providing a solution for non-hierarchical note-taking. It should also work as a plug-and-play solution for anyone already using Org Mode[fn:40] for their personal wiki (me). Org Roam Server[fn:43] is a Web application to visualize the Org Roam[fn:41] database. Although it should automatically reload if there's a change in the database, it can be done so manually by clicking the =reload= button on the Web interface. + +#+NAME: emacs-org-roam-elisp +#+BEGIN_SRC emacs-lisp +;; Setup `org-roam' hooks. +(add-hook 'after-init-hook + (lambda () + (org-roam-mode) + (org-roam-server-mode))) + +;; Configure `org-roam'. +(setq org-roam-encrypt-files t + org-roam-directory (expand-file-name "/etc/dotfiles") + org-roam-capture-templates '() + org-roam-dailies-capture-templates '()) + +;; Encrypt files with the public key. +(setq epa-file-select-keys 2 + epa-file-encrypt-to "37AB1CB72B741E478CA026D43025DCBD46F81C0F" + epa-cache-passphrase-for-symmetric-encryption t) + +;; Define a new `title-to-slug' function to override the default `org-roam-title-to-slug' function. +;; This is done to change the replacement character from "_" to "-". +(require 'cl-lib) +(defun dotfiles/title-to-slug (title) + "Convert TITLE to a filename-suitable slug." + (cl-flet* ((nonspacing-mark-p (char) + (eq 'Mn (get-char-code-property char 'general-category))) + (strip-nonspacing-marks (s) + (apply #'string (seq-remove #'nonspacing-mark-p + (ucs-normalize-NFD-string s)))) + (cl-replace (title pair) + (replace-regexp-in-string (car pair) (cdr pair) title))) + (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric. + ("--*" . "-") ;; Remove sequential dashes. + ("^-" . "") ;; Remove starting dashes. + ("-$" . ""))) ;; Remove ending dashes. + (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs))) + (downcase slug)))) +(setq org-roam-title-to-slug-function #'dotfiles/title-to-slug) + +;; Configure capture templates. +;; Standard document. +(add-to-list 'org-roam-capture-templates + '("d" "Default" entry (function org-roam-capture--get-point) + "%?" + :file-name "docs/${slug}" + :unnarrowed t + :head +" +,#+TITLE: ${title} +,#+AUTHOR: Christopher James Hayward +,#+EMAIL: chris@chrishayward.xyz +")) + +;; Course document. +(add-to-list 'org-roam-capture-templates + '("c" "Course" plain (function org-roam-capture--get-point) + "%?" + :file-name "docs/courses/${slug}" + :unnarrowed t + :head +" +,#+TITLE: ${title} +,#+SUBTITLE: +,#+AUTHOR: Christopher James Hayward +,#+EMAIL: chris@chrishayward.xyz + +,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil +,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil +")) + +;; Daily notes. +(add-to-list 'org-roam-dailies-capture-templates + '("d" "Default" entry (function org-roam-capture--get-point) + "* %?" + :file-name "docs/daily/%<%Y-%m-%d>" + :head +" +,#+TITLE: %<%Y-%m-%d> +,#+AUTHOR: Christopher James Hayward + +,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil +,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil +")) + +;; Apply custom keybindings. +(dotfiles/leader + "or" '(:ignore t :which-key "Roam") + "ori" '(org-roam-insert :which-key "Insert") + "orf" '(org-roam-find-file :which-key "Find") + "orc" '(org-roam-capture :which-key "Capture") + "orb" '(org-roam-buffer-toggle-display :which-key "Buffer")) + +;; Apply custom keybindings for dailies. +(dotfiles/leader + "ord" '(:ignore t :which-key "Dailies") + "ordd" '(org-roam-dailies-find-date :which-key "Date") + "ordt" '(org-roam-dailies-find-today :which-key "Today") + "ordm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow") + "ordy" '(org-roam-dailies-find-yesterday :which-key "Yesterday")) +#+END_SRC + +** Org Drill + +#+NAME: emacs-org-drill-package +#+BEGIN_SRC nix +epkgs.org-drill +#+END_SRC + +Org Drill[fn:44] is an extension for Org Mode[fn:40] that uses a spaced repition algorithm to conduct interactive /Drill Sessions/ using Org files as sources of facts to be memorized. + +#+NAME: emacs-org-drill-elisp +#+BEGIN_SRC emacs-lisp +;; Configure keybindings for `org-drill'. +(dotfiles/leader + "od" '(:ignore t :which-key "Drill") + "odd" '(org-drill :which-key "Drill") + "odc" '(org-drill-cram :which-key "Cram") + "odr" '(org-drill-resume :which-key "Resume")) +#+END_SRC + +** Org Agenda + +The way Org Mode[fn:40] works, TODO items, time-stamped items, and tagged headlines can be scattered throughout a file, or even a number of files. To get an overview of open action items, or of events that are important for a particular date, this information must be collected, sorted, and displayed in an organized way. + +#+NAME: emacs-org-agenda-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `org-agenda' to use the project files. +(setq org-agenda-files '("/etc/dotfiles/" + "/etc/dotfiles/docs/" + "/etc/dotfiles/docs/courses/" + "/etc/dotfiles/docs/daily/" + "/etc/dotfiles/docs/notes/" + "/etc/dotfiles/docs/posts/" + "/etc/dotfiles/docs/slides/")) + +;; Include files encrypted with `gpg'. +(require 'org) +(unless (string-match-p "\\.gpg" org-agenda-file-regexp) + (setq org-agenda-file-regexp + (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?" + org-agenda-file-regexp))) + +;; Open an agenda buffer with SPC o a. +(dotfiles/leader + "oa" '(org-agenda :which-key "Agenda")) +#+END_SRC + +** Org Pomodoro + +#+NAME: emacs-pomodoro-package +#+BEGIN_SRC nix +epkgs.org-pomodoro +#+END_SRC + +Org Pomodoro[fn:45] adds basic support for the Pomodoro Technique[fn:46] in GNU/Emacs[fn:2]. It can be started for the task at point, or the last task time was clocked for. Each session starts a timer of 25 minutes, finishing with a break of 5 minutes. After 4 sessions, ther will be a break of 20 minutes. All values are customizable. + +#+NAME: emacs-pomodoro-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `org-pomodor' with the overtime workflow. +(setq org-pomodoro-manual-break t + org-pomodoro-keep-killed-time t) + +;; Configure keybindings. +(dotfiles/leader + "op" '(org-pomodoro :which-key "Pomodoro")) +#+END_SRC + +** Writegood Mode + +#+NAME: emacs-writegood-package +#+BEGIN_SRC nix +epkgs.writegood-mode +#+END_SRC + +Writegood Mode[fn:47] is an Emacs[fn:2] minor mode to aid in finding common writing problems. It highlights the text based on the following criteria: + ++ Weasel Words ++ Passive Voice ++ Duplicate Words + +#+NAME: emacs-writegood-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `writegood-mode'. +(dotfiles/leader + "tg" '(writegood-mode :which-key "Grammar")) +#+END_SRC + +** Aspell + +#+NAME: emacs-aspell-extras +#+BEGIN_SRC nix +pkgs.aspell +pkgs.aspellDicts.en +pkgs.aspellDicts.en-science +pkgs.aspellDicts.en-computers +#+END_SRC + +GNU Aspell[fn:48] is a Free and Open Source spell checker designed to replace ISpell. It can be used as a library, or an independent spell checker. Its main feature is that it does a superior job of suggesting possible replacements for mis-spelled words than any other spell checker for the English language. + +#+NAME: emacs-aspell-elisp +#+BEGIN_SRC emacs-lisp +;; Use `aspell' as a drop-in replacement for `ispell'. +(setq ispell-program-name "aspell" + ispell-eextra-args '("--sug-mode=fast")) + +;; Configure the built-in `flyspell-mode'. +(dotfiles/leader + "ts" '(flyspell-mode :which-key "Spelling")) +#+END_SRC + +** Hugo + +#+NAME: emacs-hugo-extras +#+BEGIN_SRC nix +pkgs.hugo +#+END_SRC + +Hugo[fn:49] is one of the most popular open-source static site generators. + +#+NAME: emacs-hugo-package +#+BEGIN_SRC nix +epkgs.ox-hugo +#+END_SRC + +Ox-Hugo[fn:50] is an Org-Mode[fn:40] exporter for Hugo[fn:49] compabile markdown. I post nonsense on my Personal Blog[fn:51], and share my notes on various textbooks, articles, and software Here[fn:52]. + +#+NAME: emacs-hugo-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `ox-hugo' as an `org-mode-export' backend. +(require 'ox-hugo) + +;; Capture templates. +;; Personal blog post. +(add-to-list 'org-roam-capture-templates + '("p" "Post" plain (function org-roam-capture--get-point) + "%?" + :file-name "docs/posts/${slug}" + :unnarrowed t + :head +" +,#+TITLE: ${title} +,#+AUTHOR: Christopher James Hayward +,#+DATE: %<%Y-%m-%d> + +,#+OPTIONS: num:nil todo:nil tasks:nil + +,#+EXPORT_FILE_NAME: ${slug} +,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/ + +,#+HUGO_BASE_DIR: ../ +,#+HUGO_AUTO_SET_LASTMOD: t +,#+HUGO_SECTION: posts +,#+HUGO_DRAFT: true +")) + +;; Shared notes. +(add-to-list 'org-roam-capture-templates + '("n" "Notes" plain (function org-roam-capture--get-point) + "%?" + :file-name "docs/notes/${slug}" + :unnarrowed t + :head +" +,#+TITLE: ${title} +,#+AUTHOR: Christopher James Hayward + +,#+OPTIONS: num:nil todo:nil tasks:nil +,#+EXPORT_FILE_NAME: ${slug} +,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/ + +,#+HUGO_BASE_DIR: ../ +,#+HUGO_AUTO_SET_LASTMOD: t +,#+HUGO_SECTION: notes +,#+HUGO_DRAFT: true +")) +#+END_SRC + +** Reveal + +#+NAME: emacs-reveal-package +#+BEGIN_SRC nix +epkgs.ox-reveal +#+END_SRC + +Reveal.js[fn:53] is an open source HTML presentation framework. It enables anyone with a web browser to create fully-featured and beautiful presentations for free. Presentations with Reveal.js[fn:53] are built on open web technologies. That means anything you can do on the web, you can do in your presentation. Ox Reveal[fn:54] is an Org Mode[fn:40] export backend. + +#+NAME: emacs-reveal-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `ox-reveal' as an `org-mode-export' backend. +(require 'ox-reveal) + +;; Don't rely on any local software. +(setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js") + +;; Create a capture template. +(add-to-list 'org-roam-capture-templates + '("s" "Slides" plain (function org-roam-capture--get-point) + "%?" + :file-name "docs/slides/${slug}" + :unnarrowed t + :head +" +,#+TITLE: ${title} +,#+AUTHOR: Christopher James Hayward +,#+EMAIL: chris@chrishayward.xyz + +,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js +,#+REVEAL_THEME: serif + +,#+EXPORT_FILE_NAME: ${slug} + +,#+OPTIONS: reveal_title_slide:nil +,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil +,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil +")) +#+END_SRC + +** Passwords + +#+NAME: emacs-pass-extras +#+BEGIN_SRC nix +pkgs.pass +#+END_SRC + +With Pass[fn:55], each password lives inside of an encrypted =gpg= file, whose name is the title of the website or resource that requires the password. These encrypted files may be organized into meaningful folder hierarchies, compies from computer to computer, and in general, manipulated using standard command line tools. + +#+NAME: emacs-pass-package +#+BEGIN_SRC nix +epkgs.password-store +#+END_SRC + +Configure keybindings for passwords behind =SPC p=: + +| Key | Description | +|-----+---------------------| +| p | Copy a password | +| r | Rename a password | +| g | Generate a password | + +#+NAME: emacs-pass-elisp +#+BEGIN_SRC emacs-lisp +;; Set the path to the password store. +(setq password-store-dir (expand-file-name "~/.password-store")) + +;; Apply custom keybindings. +(dotfiles/leader + "p" '(:ignore t :which-key "Passwords") + "pp" '(password-store-copy :which-key "Copy") + "pr" '(password-store-rename :which-key "Rename") + "pg" '(password-store-generate :which-key "Generate")) +#+END_SRC + +** MU4E + +#+NAME: emacs-mu4e-extras +#+BEGIN_SRC nix +pkgs.mu +pkgs.isync +#+END_SRC + +#+NAME: emacs-mu4e-package +#+BEGIN_SRC nix +epkgs.mu4e-alert +#+END_SRC + +#+NAME: emacs-mu4e-config +#+BEGIN_SRC nix +home.file.".mbsyncrc" = { + text = '' + IMAPStore xyz-remote + Host mail.chrishayward.xyz + User chris@chrishayward.xyz + PassCmd "pass chrishayward.xyz/chris" + SSLType IMAPS + + MaildirStore xyz-local + Path ~/.cache/mail/ + Inbox ~/.cache/mail/inbox + SubFolders Verbatim + + Channel xyz + Far :xyz-remote: + Near :xyz-local: + Patterns * !Archives + Create Both + Expunge Both + SyncState * + ''; +}; +#+END_SRC + +#+BEGIN_SRC sh +mbsync -a +mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz" +mu index +#+END_SRC + +#+NAME: emacs-mu4e-elisp +#+BEGIN_SRC emacs-lisp +;; Add the `mu4e' shipped with `mu' to the load path. +(add-to-list 'load-path "/etc/profiles/per-user/chris/share/emacs/site-lisp/mu4e/") +(require 'mu4e) + +;; Confiugure `mu4e'. +(setq mu4e-maildir "~/.cache/mail" + mu4e-update-interval (* 5 60) + mu4e-get-mail-command "mbsync -a" + mu4e-compose-format-flowed t + mu4e-change-filenames-when-moving t + mu4e-compose-signature (concat "Chris Hayward\n" + "chris@chrishayward.xyz")) + +;; Sign all outbound email with GPG. +(add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime) +(setq message-send-mail-function 'smtpmail-send-it + mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F")) + +;; Setup `mu4e' accounts. +(setq mu4e-contexts + (list + ;; Main + ;; chris@chrishayward.xyz + (make-mu4e-context + :name "Main" + :match-func + (lambda (msg) + (when msg + (string-prefix-p "/Main" (mu4e-message-field msg :maildir)))) + :vars + '((user-full-name . "Christopher James Hayward") + (user-mail-address . "chris@chrishayward.xyz") + (smtpmail-smtp-server . "mail.chrishayward.xyz") + (smtpmail-smtp-service . 587) + (smtpmail-stream-type . starttls))))) + +;; Setup `mu4e-alert'. +(setq mu4e-alert-set-default-style 'libnotify) +(mu4e-alert-enable-notifications) +(mu4e-alert-enable-mode-line-display) + +;; Open the `mu4e' dashboard. +(dotfiles/leader + "m" '(mu4e :which-key "Mail")) +#+END_SRC + +** Projectile + +#+NAME: emacs-projectile-package +#+BEGIN_SRC nix +epkgs.projectile +#+END_SRC + +Projectile[fn:56] is a project interaction library for GNU/Emacs[fn:2]. Its goal is to provide a nice set of features operating on a project level, without introducing external dependencies. + +#+NAME: emacs-projectile-elisp +#+BEGIN_SRC emacs-lisp +;; Configure the `projectile-project-search-path'. +(setq projectile-project-search-path '("~/.local/source")) +(projectile-mode +1) +#+END_SRC + +** LSP Mode + +#+NAME: emacs-lsp-package +#+BEGIN_SRC nix +epkgs.lsp-mode +epkgs.lsp-ui +#+END_SRC + +The Language Server Protocol (LSP)[fn:57] defines the protocol used between an Editor or IDE, and a language server that provides features like: + ++ Auto Complete ++ Go To Defintion ++ Find All References + +#+NAME: emacs-lsp-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `lsp-mode'. +(setq lsp-idle-delay 0.5 + lsp-prefer-flymake t) + +;; Configure `lsp-ui'. +(setq lsp-ui-doc-position 'at-point + lsp-ui-doc-delay 0.5) +#+END_SRC + +** Company Mode + +#+NAME: emacs-company-package +#+BEGIN_SRC nix +epkgs.company +#+END_SRC + +Company[fn:58] is a text completion framework for GNU/Emacs[fn:2]. The name stands for =Complete Anything=. It uses pluggable back-ends and front-ends to retieve and display completion candidates. + +#+NAME: emacs-company-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `company-mode'. +(setq company-backend 'company-capf + lsp-completion-provider :capf) + +;; Enable it globally. +(global-company-mode +1) +#+END_SRC + +** Go Mode + +#+NAME: emacs-golang-package +#+BEGIN_SRC nix +epkgs.go-mode +#+END_SRC + +Go Mode[fn:59] is a major mode for editing Golang[fn:22] source code in GNU/Emacs[fn:2]. + +#+NAME: emacs-golang-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `go-mode' to work with `lsp-mode'. +(defun dotfiles/go-hook () + (add-hook 'before-save-hook #'lsp-format-buffer t t) + (add-hook 'before-save-hook #'lsp-organize-imports t t)) + +;; Configure a custom `before-save-hook'. +(add-hook 'go-mode-hook #'dotfiles/go-hook) +#+END_SRC + +** Python Mode + +#+NAME: emacs-python-package +#+BEGIN_SRC nix +epkgs.pretty-mode +#+END_SRC + +The built in Python Mode[fn:60] has a nice feature set for working with Python[fn:26] code in GNU/Emacs[fn:2]. It is complimented with the addition of an LSP[fn:57] server. These tools are included in the Development Shell[fn:21] for Python[fn:26]. + +#+NAME: emacs-python-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `pretty-mode' to work with `python-mode'. +(add-hook 'python-mode-hook + (lambda () + (turn-on-pretty-mode))) +#+END_SRC + +** PlantUML + +#+NAME: emacs-plantuml-extras +#+BEGIN_SRC nix +pkgs.plantuml +#+END_SRC + +PlantUML[fn:61] is an open-source tool allowing users to create diagrams from a plain-text language. Besides various UML diagrams, PlantUML[fn:61] has support for various other software developmented related formats, as well as visualizations of =JSON= and =YAML= files. + +#+NAME: emacs-plantuml-package +#+BEGIN_SRC nix +epkgs.plantuml-mode +#+END_SRC + +PlantUML Mode[fn:62] is a major mode for editing PlantUML[fn:61] sources in GNU/Emacs[fn:2]. + +#+NAME: emacs-plantuml-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `plantuml-mode'. +(setq plantuml-default-exec-mode 'executable) +#+END_SRC + +** Swiper + +#+NAME: emacs-swiper-package +#+BEGIN_SRC nix +epkgs.ivy +epkgs.counsel +epkgs.ivy-rich +epkgs.ivy-posframe +epkgs.ivy-prescient +#+END_SRC + +Ivy (Swiper)[fn:: https://github.com/abo-abo/swiper] is a generic completion mechanism for GNU/Emacs[fn:2]. While operating similarily to other completion schemes like =icomplete-mode=, it aims to be more efficient, smaller, simpler, and smoother to use, while remaining highly customizable. + +#+NAME: emacs-swiper-elisp +#+BEGIN_SRC emacs-lisp +;; Configure `ivy'. +(setq counsel-linux-app-format-function + #'counsel-linux-app-format-function-name-only) +(ivy-mode +1) +(counsel-mode +1) + +;; Configure `ivy-rich'. +(ivy-rich-mode +1) + +;; Configure `ivy-posframe'. +(setq ivy-posframe-parameters '((parent-frame nil)) + ivy-posframe-display-functions-alist '((t . ivy-posframe-display))) +(ivy-posframe-mode +1) + +;; Configure `ivy-prescient'. +(setq ivy-prescient-enable-filtering nil) +(ivy-prescient-mode +1) +#+END_SRC + +** Doom Themes + +#+NAME: emacs-doom-themes-package +#+BEGIN_SRC nix +epkgs.doom-themes +#+END_SRC + +Doom Themes[fn:63] is a theme megapack for GNU/Emacs[fn:2], inspired by community favourites. + +#+NAME: emacs-doom-themes-elisp +#+BEGIN_SRC emacs-lisp +;; Include modern themes from `doom-themes'. +(setq doom-themes-enable-bold t + doom-themes-enable-italic t) + +;; Load the `doom-moonlight' theme. +(load-theme 'doom-moonlight t) +(doom-modeline-mode +1) +#+END_SRC + +** Doom Modeline + +#+NAME: emacs-doom-modeline-package +#+BEGIN_SRC nix +epkgs.doom-modeline +#+END_SRC + +Doom Modeline[fn:64] is a fancy and fast modeline inspired by minimalism design. It's integrated into Centaur Emacs, Doom Emacs, and Spacemacs. + +#+NAME: emacs-doom-modeline-elisp +#+BEGIN_SRC emacs-lisp +;; Add the `doom-modeline' after initialization. +(add-hook 'after-init-hook 'doom-modeline-mode) +(setq doom-modeline-height 16 + doom-modeline-icon t) +#+END_SRC * Footnotes -[fn:1] https://gnu.org/software/emacs/ +[fn:1] https://gnu.org + +[fn:2] https://gnu.org/software/emacs/ + +[fn:3] https://literateprogramming.com/knuthweb.pdf + +[fn:4] https://nixos.org/manual/nixos/stable + +[fn:5] https://nixos.org/manual/nix/stable + +[fn:6] https://nixos.org/manual/nixpkgs/stable + +[fn:7] https://github.com/nix-community/home-manager + +[fn:8] https://github.com/nix-community/emacs-overlay + +[fn:9] https://github.com/nixos/nixos-hardware + +[fn:10] https://qemu.org + +[fn:11] https://github.com/ch11ng/exwm + +[fn:12] https://evil.readthedocs.io/en/latest/overview.html + +[fn:13] https://x.org/wiki/ + +[fn:14] https://wayland.freedesktop.org + +[fn:15] https://nixos.wiki/wiki/Flakes + +[fn:16] https://nix-community.cachix.org + +[fn:17] https://git-scm.com + +[fn:18] https://emacswiki.org/emacs/LearnEmacsLisp + +[fn:19] https://neovim.io + +[fn:20] https://gtk.org + +[fn:21] https://nixos.org/manual/nix/unstable/command-ref/nix-shell.html + +[fn:22] https://golang.org + +[fn:23] https://grpc.io + +[fn:24] https://iso.org/standard/74528.html + +[fn:25] https://en.wikipedia.org/wiki/C++ + +[fn:26] https://python.org + +[fn:27] https://github.com/nixos/nix-mode + +[fn:28] https://github.com/noctuid/general.el + +[fn:29] https://github.com/justbur/emacs-which-key + +[fn:30] https://emacswiki.org/emacs/eww + +[fn:31] https://emacswiki.org/emacs/DiredMode + +[fn:32] https://emacswiki.org/emacs/DiredExtra#Dired_X + +[fn:33] https://github.com/domtronn/all-the-icons.el + +[fn:34] https://github.com/iqbalansari/emacs-emojify + +[fn:35] https://gnu.org/software/emacs/manual/html_mono/eshell.html + +[fn:36] https://github.com/akermu/emacs-libvterm + +[fn:37] https://github.com/neovim/libvterm + +[fn:38] https://magit.vc + +[fn:39] https://github.com/skeeto/elfeed + +[fn:40] https://orgmode.org + +[fn:41] https://github.com/org-roam/org-roam + +[fn:42] https://zettelkasten.de + +[fn:43] https://github.com/org-roam/org-roam-server + +[fn:44] https://orgmode.org/worg/org-contrib/org-drill.html + +[fn:45] https://marcinkoziej/org-pomodoro + +[fn:46] https://en.wikipedia.org/wiki/Pomodoro_Technique + +[fn:47] https://github.com/bnbeckwith/writegood-mode + +[fn:48] https://aspell.net + +[fn:49] https://gohugo.io + +[fn:50] https://oxhugo.scripter.co + +[fn:51] https://chrishayward.xyz/posts/ + +[fn:52] https://chrishayward.xyz/notes/ + +[fn:53] https://revealjs.com + +[fn:54] https://github.com/hexmode/ox-reveal + +[fn:55] https://password-store.org + +[fn:56] https://projectile.mx + +[fn:57] https://microsoft.github.io/language-server-protocol + +[fn:58] https://company-mode.github.io + +[fn:59] https://emacswiki.org/emacs/GoMode + +[fn:60] https://emacswiki.org/emacs/PythonProgrammingInEmacs + +[fn:61] https://plantuml.com -[fn:2] https://gnu.org/distros/free-distros.html +[fn:62] https://github.com/skuro/plantuml-mode -[fn:3] https://chrishayward.xyz/notes/literate-programming/ +[fn:63] https://github.com/hlissner/emacs-doom-themes -[fn:4] https://chrishayward.xyz/posts/immutable-emacs/ +[fn:64] https://github.com/seagle0128/doom-modeline -[fn:5] https://github.com/raxod502/straight.el +[fn:65] https://laptopmedia.com/laptop-specs/acer-nitro-5-an515-53-2 diff --git a/config/authinfo.gpg b/config/authinfo.gpg deleted file mode 100644 index f1e2cb1..0000000 Binary files a/config/authinfo.gpg and /dev/null differ diff --git a/config/git b/config/git deleted file mode 100644 index fbfdec5..0000000 --- a/config/git +++ /dev/null @@ -1,5 +0,0 @@ -[user] - email = chris@chrishayward.xyz - name = Christopher James Hayward -[github] - user = chayward1 diff --git a/config/gpg-agent.conf b/config/gpg-agent.conf deleted file mode 100644 index 24d3cab..0000000 --- a/config/gpg-agent.conf +++ /dev/null @@ -1,2 +0,0 @@ -allow-emacs-pinentry -allow-loopback-pinentry diff --git a/config/mbsyncrc b/config/mbsyncrc deleted file mode 100644 index 4ea1560..0000000 --- a/config/mbsyncrc +++ /dev/null @@ -1,26 +0,0 @@ -# Sync -# :PROPERTIES: -# :header-args: :tangle ../config/mbsyncrc :comments org -# :END: - -# This is the *mbsyncrc*[fn:3] file I use to synchronize my local mail with my server. - - -IMAPStore xyz-remote -Host mail.chrishayward.xyz -User chris@chrishayward.xyz -PassCmd "pass chrishayward.xyz/chris" -SSLType IMAPS - -MaildirStore xyz-local -Path ~/.cache/mail/ -Inbox ~/.cache/mail/inbox -SubFolders Verbatim - -Channel xyz -Master :xyz-remote: -Slave :xyz-local: -Patterns * !Archives -Create Both -Expunge Both -SyncState * diff --git a/config/mpd.conf b/config/mpd.conf deleted file mode 100644 index e7141e0..0000000 --- a/config/mpd.conf +++ /dev/null @@ -1,6 +0,0 @@ -music_directory "~/.local/share/media/music" - -playlist_directory "~/.local/share/media/playlists" - -bind_to_address "localhost" -port "6600" diff --git a/config/profile b/config/profile deleted file mode 100644 index 8ca4b94..0000000 --- a/config/profile +++ /dev/null @@ -1,22 +0,0 @@ -# Force colours - -# Manually set the terminal type to ~xterm-256color~ for better colours on TTY Emacs. - - -export TERM=xterm-256color - -# Setting up the $PATH - -# Ensure ~~/.local/bin~ added to the =$PATH= environment variable. - - -export PATH=$PATH:~/.local/bin - -# Starting Emacs by default on TTY1 - -# When launching into a new session on ~TTY1~, if the display server is not running, run *StartX*[fn:3]. This will launch the window manager. - - -if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then - exec startx -fi diff --git a/config/xinitrc b/config/xinitrc deleted file mode 100644 index 8fcf0a0..0000000 --- a/config/xinitrc +++ /dev/null @@ -1,11 +0,0 @@ -# Config -# :PROPERTIES: -# :header-args: :tangle ../config/xinitrc :comments org -# :END: - -# My workflow includes launching Emacs under X11[fn:1] without the use of a display manager, controlling everything within Emacs, while still providing the functionality of a desktop environment. - - -compton & -xss-lock -- slock & -exec dbus-launch --exit-with-session emacs -mm --debug-init diff --git a/config/xmodmap b/config/xmodmap deleted file mode 100644 index 49a8a9a..0000000 --- a/config/xmodmap +++ /dev/null @@ -1,7 +0,0 @@ -clear lock -clear control - -keycode 66 = Control_L - -add control = Control_L -add Lock = Control_R diff --git a/hosts/acernitro.org b/hosts/acernitro.org deleted file mode 100644 index d5eec14..0000000 --- a/hosts/acernitro.org +++ /dev/null @@ -1,31 +0,0 @@ -#+TITLE: Acernitro -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle acernitro.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -The first real hardware to deploy this configuration on. It's an [[https://www.amazon.com/Acer-Nitro-AN515-Laptop-i5-8300H/dp/B07C715KNT][Acer Nitro AN-515]][fn:1] with the [[https://7thzero.com/blog/switch-hybrid-graphics-mode-nvidia-and-intel][NVIDIA / Intel Hybrid GPU]] [fn:2], which is honestly a pain in the ass to deal with. Due to the issues I encountered with this hardware setup, I opted for *easy mode* and installed [[https://ubuntu.com][Ubuntu]][fn:3], setting up the drivers, and then ripping away everything I didn't need. - -* Options - -+ Set the browser manually -+ Set the language to Canadian english -+ Increase the font size for the high DPI screen - -#+begin_src emacs-lisp -(setq dotfiles/browser "firefox" - dotfiles/language "en_CA" - dotfiles/font-size 112) -#+end_src - -* Footnotes - -[fn:1] https://www.amazon.com/Acer-Nitro-AN515-Laptop-i5-8300H/dp/B07C715KNT - -[fn:2] https://7thzero.com/blog/switch-hybrid-graphics-mode-nvidia-and-intel - -[fn:3] https://ubuntu.com diff --git a/modules/agenda.org b/modules/agenda.org deleted file mode 100644 index 774b121..0000000 --- a/modules/agenda.org +++ /dev/null @@ -1,38 +0,0 @@ -#+TITLE: Agenda -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle agenda.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Agenda integrations for ~org-mode~. - -* Config - -Integrate the ~org-agenda~ with the ~org-roam~ database, and the rest of the ~org-mode~ contexts throughout the repository: - -#+begin_src emacs-lisp -(setq org-agenda-files '("~/.emacs.d/" - "~/.emacs.d/docs/" - "~/.emacs.d/docs/courses/" - "~/.emacs.d/docs/daily/" - "~/.emacs.d/docs/notes/" - "~/.emacs.d/docs/posts/" - "~/.emacs.d/docs/slides/" - "~/.emacs.d/hosts/" - "~/.emacs.d/modules/")) -#+end_src - -* Shortcuts - -Open an agenda buffer with =SPC a=: - -#+begin_src emacs-lisp -(dotfiles/leader - "a" '(org-agenda :which-key "Agenda")) -#+end_src - -* Footnotes diff --git a/modules/capture.org b/modules/capture.org deleted file mode 100644 index 1368b2f..0000000 --- a/modules/capture.org +++ /dev/null @@ -1,56 +0,0 @@ -#+TITLE: Capture -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle capture.el :comments org -#+PROPERTY: header-args :results silent :eval no-export - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Capturing images, screencasts, screenshots or live-streaming. It's defined in this file. - -* Screenshots - -Download *screenshot.el*[fn:1] for taking screenshots of highlighted regions or entire buffers. - -#+begin_src emacs-lisp -(straight-use-package - '(screenshot - :type git - :host github - :repo "tecosaur/screenshot")) -#+end_src - -* Screencasts - -Create screencasts with =one-frame-per-action= GIF recording via *Emacs gif screencast*[fn:2]. - -+ Pause / Resume -+ High Quality -+ Optimized - -#+begin_src emacs-lisp -(use-package gif-screencast - :commands (gif-screencast-start-or-stop gif-screencast-toggle-pause) - :custom (gif-screencast-output-directory (concat dotfiles/home "docs/images/"))) -#+end_src - -* Keybindings - -+ Place keybindings for capturing the screen behind =SPC s=. - * Screenshot with =s= - * Screencast with =c= - -#+begin_src emacs-lisp -(dotfiles/leader - "s" '(:ignore t :which-key "Screen") - "ss" '(screenshot :which-key "Screenshot") - "sc" '(gif-screencast-start-or-stop :which-key "Screencast")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/tecosaur/screenshot - -[fn:2] https://github.com/takaxp/emacs-gif-screencast diff --git a/modules/cc.org b/modules/cc.org deleted file mode 100644 index ab133f8..0000000 --- a/modules/cc.org +++ /dev/null @@ -1,45 +0,0 @@ -#+TITLE: C/C++ -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle cc.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -#+begin_quote -The goal of C++ is productivity, this comes in many ways, but the language is designed to aid you as much as possible whiole hindering you as little as possible with arbitrary rules or requirements. - --- Bruce Eckel, Thinking in C++[fn:1] -#+end_quote - -* Setup - -Make sure all of the required components are installed, and the ~lsp~ and ~dap~ modules have loaded before loading this module. - -#+begin_src shell -RUN apt install -y gcc gdb ccls libstdc++ -#+end_src - -* Config - -Use the ~ccls~[fn:2] language server, and the respective Emacs package to interact with the server inside of Emacs. Load the ~babel~ language module and add structure templates for creating C/C++ code blocks inside ~org-mode~. - -#+begin_src emacs-lisp -(use-package ccls - :hook ((c-mode c++-mode objc-mode cuda-mode) . - (lambda () - (require 'ccls) - (lsp-deferred))) - :config (add-to-list 'org-structure-template-alist '("cc" . "src C")) - (add-to-list 'org-structure-template-alist '("cpp" . "src C++")) - (org-babel-do-load-languages 'org-babel-load-languages '((C . t)))) -#+end_src - -* Footnotes - -[fn:1] https://chrishayward.xyz/notes/thinking-in-cpp/ - -[fn:2] https://github.com/MaskRay/ccls diff --git a/modules/conf.org b/modules/conf.org deleted file mode 100644 index 7bddda7..0000000 --- a/modules/conf.org +++ /dev/null @@ -1,55 +0,0 @@ -#+TITLE: Conf -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle conf.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Support for different configuration languages. - -* Config - -Add support for different configuration languages, or other modules that don't fit in their own module (yet). - -** HTTP - -Interact with ~HTTP~ endpoints using the ~ob-http~[fn:1] package. You can see how it works in my post here[fn:2]. It adds interactive ~HTTP~ blocks that can output their results in place, within an ~org-mode~ buffer. - -#+begin_src emacs-lisp -(use-package ob-http - :after org - :config (org-babel-do-load-languages - 'org-babel-load-languages '((http . t)))) -#+end_src - -** YAML - -Support for YAML[fn:3] files. - -#+begin_src emacs-lisp -(use-package yaml-mode) -#+end_src - -** gRPC - -Support for gRPC[fn:4] protocol buffer definition files. - -#+begin_src emacs-lisp -(use-package protobuf-mode - :after org - :config (add-to-list 'org-structure-template-alist '("pb" . "src protobuf"))) -#+end_src - -* Footnotes - -[fn:1] https://github.com/zweifisch/ob-http - -[fn:2] https://chrishayward.xyz/posts/kanye-as-a-service/ - -[fn:3] https://emacswiki.org/emacs/YamlMode - -[fn:4] https://github.com/protocolbuffers/protobuf/blob/master/editors/protobuf-mode.el diff --git a/modules/dap.org b/modules/dap.org deleted file mode 100644 index d842cb2..0000000 --- a/modules/dap.org +++ /dev/null @@ -1,33 +0,0 @@ -#+TITLE: Debug Adapter Protocol -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle dap.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -The Debug Adapter Protocol (DAP) defines the abstract protocol used between a development tool (Emacs) and a debugger[fn:1]. - -* Config - -Use the package ~dap-mode~[fn:2] to add support for the Debug Adapter Protocol[fn:1] inside of Emacs. It has been tested against the following language servers: - -+ Java -+ Ruby -+ Python -+ Elixir -+ LLDB (C/C++/Obj-C/Swift) - -#+begin_src emacs-lisp -(use-package dap-mode - :commands (dap-debug)) -#+end_src - -* Footnotes - -[fn:1] https://microsoft.github.io/debug-adapter-protocol/ - -[fn:2] https://github.com/emacs-lsp/dap-mode diff --git a/modules/dashboard.org b/modules/dashboard.org deleted file mode 100644 index fbb49c6..0000000 --- a/modules/dashboard.org +++ /dev/null @@ -1,89 +0,0 @@ -#+TITLE: Dashboard -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle dashboard.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -#+ATTR_ORG: :width 420px -#+ATTR_HTML: :width 420px -#+ATTR_LATEX: :width 420px -[[../docs/images/desktop-example.png]] - -Present a *Dashboard*[fn:1] when first launching Emacs. Customize the buttons of the navigator. - -* Configuration - -Goal of this module is to provide an easily customizable dashboard buffer to display when launching Emacs. I also want it to include some custom links. These are hard coded right now but I want to move them to [[file:../README.org][Options]]. - -+ Brain @ http://localhost:8080 -+ Homepage @ https://chrishayward.xyz -+ Athabasca @ https://login.athabascau.ca/cas/login -+ Bookshelf @ https://online.vitalsource.com - -#+begin_src emacs-lisp -(use-package dashboard - :custom (dashboard-center-content t) - (dashboard-set-init-info t) - (dashboard-set-file-icons t) - (dashboard-set-heading-icons t) - (dashboard-set-navigator t) - (dashboard-startup-banner (expand-file-name "~/.emacs.d/docs/images/emacs.png")) - (dashboard-projects-backend 'projectile) - (dashboard-items '((projects . 10) (recents . 10) (agenda . 10))) - (dashboard-navigator-buttons - `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0) - "Brain" "Knowledge base" - (lambda (&rest _) (browse-url "http://localhost:8080")))) - ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0) - "Homepage" "Personal website" - (lambda (&rest _) (browse-url "https://chrishayward.xyz")))) - ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0) - "Athabasca" "Univeristy login" - (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login")))) - ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0) - "Bookshelf" "Vitalsource bookshelf" - (lambda (&rest _) (browse-url "https://online.vitalsource.com")))))) - :config (dashboard-setup-startup-hook)) -#+end_src - -** Default buffer - -Ensure that the dashboard is the initial buffer. - -#+begin_src emacs-lisp -(with-eval-after-load 'dashboard - (setq initial-buffer-choice - (lambda () - (get-buffer "*dashboard*")))) -#+end_src - -** Keybinding - -Quickly navigate to the dashboard with =SPC SPC=. - -#+begin_src emacs-lisp -(dotfiles/leader - "SPC" '((lambda () - (interactive) - (switch-to-buffer "*dashboard*")) - :which-key "Dashboard")) -#+end_src - -Navigate to the scratch buffer with =SPC C-SPC=. - -#+begin_src emacs-lisp -(dotfiles/leader - "C-SPC" '((lambda () - (interactive) - (switch-to-buffer "*scratch*")) - :which-key "Scratch")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/emacs-dashboard/emacs-dashboard diff --git a/modules/dired.org b/modules/dired.org deleted file mode 100644 index fac631f..0000000 --- a/modules/dired.org +++ /dev/null @@ -1,52 +0,0 @@ -#+TITLE: Dired -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle dired.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Emacs has a built-in directory editor. - -* Config - -Emacs has some really amazing built-in packages, and ~dired~[fn:1] is one of them. It completly coveres everything you would expect from a file manager, but it's not perfect out of the box. - -** Current directory - -I don't want to press =RET= twice to navigate to the current directory. There's a way to get around this problem with ~jump~, included in the ~dired-x~ package, included with Emacs. - -#+begin_src emacs-lisp -(require 'dired-x) -#+end_src - -** Reusing the same buffer - -By default, ~dired~[fn:1] will create a new buffer each time you press =RET= over a directory. This leads to unwanted buffers all over the place. Avoid this behaviour with ~dired-single~[fn:2], reusing the same ~dired~ buffer. - -+ Move up a directory with =h= -+ Open a single buffer with =l= - -#+begin_src emacs-lisp -(use-package dired-single - :config (evil-collection-define-key 'normal 'dired-mode-map - "h" 'dired-single-up-directory - "l" 'dired-single-buffer)) -#+end_src - -* Shortcuts - -Open a new dired buffer using the ~jump~ command with =SPC d=. - -#+begin_src emacs-lisp -(dotfiles/leader - "d" '(dired-jump :which-key "Dired")) -#+end_src - -* Footnotes - -[fn:1] https://en.wikipedia.org/wiki/Dired - -[fn:2] https://github.com/crocket/dired-single diff --git a/modules/docker.org b/modules/docker.org deleted file mode 100644 index 11fe81a..0000000 --- a/modules/docker.org +++ /dev/null @@ -1,44 +0,0 @@ -#+TITLE: Docker -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle docker.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Interact with Docker[fn:1] inside of Emacs. - -* Setup - -Make sure you have the required components installed on your system before loading the module. - -#+begin_src shell -RUN apt install -y docker docker-compose -#+end_src - -* Config - -It's possible to interact with Docker[fn:1] inside of Emacs through the ~docker.el~[fn:2] plugin. It provides rich support for working with containers, images, compose networks, and has bindings for using machine. - -#+begin_src emacs-lisp -(use-package docker - :commands (docker)) -#+end_src - -* Shortcuts - -Open the container management screen with =SPC k=. - -#+begin_src emacs-lisp -(dotfiles/leader - "k" '(docker :which-key "Docker")) -#+end_src - -* Footnotes - -[fn:1] https://docker.com - -[fn:2] https://github.com/Silex/docker.el diff --git a/modules/elfeed.org b/modules/elfeed.org deleted file mode 100644 index 4724417..0000000 --- a/modules/elfeed.org +++ /dev/null @@ -1,58 +0,0 @@ -#+TITLE: Elfeed -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle elfeed.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -Setup a news feed inside of Emacs using ~elfeed~[fn:1], an Emacs web feeds client. - -* Setup - -+ Add the feed for my website[fn:2] to make sure the RSS feeds are updating correctly -+ Add some subreddits, mostly about ~linux~, ~emacs~ and ~org-mode~ - -#+begin_src emacs-lisp -(use-package elfeed - :commands (elfeed elfeed-update) - :custom (elfeed-feeds (quote - (("https://hexdsl.co.uk/rss.xml") - ("https://lukesmith.xyz/rss.xml") - ("https://friendo.monster/rss.xml") - ("https://chrishayward.xyz/index.xml") - ("https://protesilaos.com/codelog.xml"))))) -#+end_src - -** Goodies - -Extend ~elfeed~[fn:1] with the ~elfeed-goodies~[fn:3] package. - -#+begin_src emacs-lisp -(use-package elfeed-goodies - :after elfeed - :custom (elfeed-goodies/entry-pane-size 0.5) - :config (elfeed-goodies/setup)) -#+end_src - -* Shortcuts - -Configure ~elfeed~[fn:1] keybindings behind =SPC l=: - -+ Open with =l= -+ Update with =u= - -#+begin_src emacs-lisp -(dotfiles/leader - "l" '(:ignore t :which-key "Elfeed") - "ll" '(elfeed :which-key "Open") - "lu" '(elfeed-update :which-key "Update")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/skeeto/elfeed - -[fn:2] https://chrishayward.xyz/index.xml - -[fn:3] https://github.com/algernon/elfeed-goodies diff --git a/modules/emms.org b/modules/emms.org deleted file mode 100644 index 35b53ba..0000000 --- a/modules/emms.org +++ /dev/null @@ -1,86 +0,0 @@ -#+TITLE: EMMS -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle emms.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp: nil - -EMMS[fn:1] is Emacs as a multimedia player. - -* Setup - -Make sure you install the required packages on your system before loading the module. - -#+begin_src shell -RUN apt install -y mpc mpd mpv -#+end_src - -** Music player daemon -:PROPERTIES: -:header-args: :tangle ../config/mpd.conf -:END: - -MPD[fn:2] uses a simple text configuration file. Most options only accept a string in " quotes ". The most important option to configure is the ~music_directory~. This is where all of the music ~mpd~[fn:2] will serve exists. It will read the directory recursively. - -#+begin_src conf -music_directory "~/.local/share/media/music" -#+end_src - -You can configure where ~mpd~[fn:2] will look for playlists. You may want to configure this option if you share your playlists between devices. - -#+begin_src conf -playlist_directory "~/.local/share/media/playlists" -#+end_src - -It's possible to serve ~mpd~[fn:2] over the network by configuring it to listen on =0.0.0.0=, or by the systems host name. For a local setup, leave it as =localhost=. - -#+begin_src conf -bind_to_address "localhost" -port "6600" -#+end_src - -*** Deploy the configuration - -MPD[fn:2] will look for its configuration in =~/.config/mpd/mpd.conf=, and =/etc/mpd.conf= respectively. - -#+begin_src emacs-lisp -(let ((mpd-dir "~/.config/mpd")) - (unless (file-exists-p mpd-dir) - (make-directory mpd-dir t)) - (dotfiles/symlink "~/.emacs.d/config/mpd.conf" - (concat mpd-dir "/mpd.conf"))) -#+end_src - -* Config - -Displays and play multimedia from within Emacs with ~emms~[fn:1], using a variety of external players from different sources. It can run as a minimalist player and controlled with commands, or a fully fledged interactive media browser. It can display album art, play streaming media, tag files, search lyrics, and provide ~mpd~[fn:2] connectivity. - -#+begin_src emacs-lisp -(use-package emms - :custom (emms-player-mpd-server-name "localhost") - (emms-player-mpd-server-port "6600") - :config (require 'emms-setup) - (require 'emms-player-mpd) - (emms-all) - (emms-default-players) - (add-to-list 'emms-info-functions 'emms-info-mpd) - (add-to-list 'emms-player-list 'emms-player-mpd)) -#+end_src - -* Shortcuts - -Place bindings for ~emms~[fn:1] behind =SPC u=: - -#+begin_src emacs-lisp -(dotfiles/leader - "u" '(:ignore t :which-key "EMMS")) -#+end_src - -* Footnotes - -[fn:1] https://gnu.org/software/emms/ - -[fn:2] https://musicpd.org diff --git a/modules/eshell.org b/modules/eshell.org deleted file mode 100644 index 571b74a..0000000 --- a/modules/eshell.org +++ /dev/null @@ -1,45 +0,0 @@ -#+TITLE: EShell -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle eshell.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -EShell is a fully POSIX compliant shell written entirely in Emacs Lisp, included with Emacs. - -* Config - -While not a traditional terminal emulator, it provides a native REPL for Emacs Lisp code, with everything in your configuration available in the environment. Make some slight configurations: - -+ Don't highlight the prompt -+ Favour use of system utilities - -#+begin_src emacs-lisp -(setq eshell-highlight-prompt nil - eshell-prefer-lisp-functions nil) -#+end_src - -* Extras - -Implement the lambda prompt for aesthetic purposes with the ~eshell-prompt-extras~ package. Here's an example of what that looks like: - -#+begin_example -~/.emacs.d/modules:main*? λ -#+end_example - -#+begin_src emacs-lisp -(use-package eshell-prompt-extras - :custom (eshell-prompt-function 'epe-theme-lambda)) -#+end_src - -* Shortcuts - -Open ~eshell~ in the current buffer with =SPC e=: - -#+begin_src emacs-lisp -(dotfiles/leader - "e" '(eshell :which-key "EShell")) -#+end_src diff --git a/modules/evil.org b/modules/evil.org deleted file mode 100644 index 823cc21..0000000 --- a/modules/evil.org +++ /dev/null @@ -1,100 +0,0 @@ -#+TITLE: Evil -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle evil.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Transform Emacs into Vim. - -* Config - -Emacs has some strange default keybindings, which given the age of the project, is not surprising. To overcome this nearly show-stopping hurdle, we transform Emacs into Vim with ~evil~[fn:1], the Extensible VI Layer for Emacs. - -#+begin_src emacs-lisp -(use-package evil - :custom (evil-want-integration t) ;; Required for `evil-collection'. - (evil-want-keybinding nil) ;; Same as above - :config (evil-mode +1)) -#+end_src - -** Improvements - -While covering substantial ground towards the goal, the default keybindings implemented in ~evil~[fn:1] alone are lacking compared to what you would expect from Vim. There's a community curated package ~evil-collection~[fn:2] that does a much better job implementing the proper keybindings. - -#+begin_src emacs-lisp -(use-package evil-collection - :after evil - :config (evil-collection-init)) -#+end_src - -** Surround text - -Quickly and efficiently surround text with ~evil-surround~[fn:3]. Highlight blocks of text with function definitions, quotations, or any symbol you can input from your keyboard. - -#+begin_src emacs-lisp -(use-package evil-surround - :after evil - :config (global-evil-surround-mode 1)) -#+end_src - -** Line numbering - -Relative line numbers are important when using VI emulation keys. You can prefix commands with a number, allowing you to perform that action that number of times. Useful when navigating around pages that are hundreds, or even thousands of lines long. - -#+begin_example - 5: - 4: - 3: - 2: - 1: -156: << CURRENT LINE >> - 1: - 2: - 3: - 4: - 5: -#+end_example - -This behaviour is implemented with ~linum-relative~[fn:4], hooking into the ~display-line-number-mode~ as the backend for good performance in the GUI or TTY. - -#+begin_src emacs-lisp -(use-package linum-relative - :commands (linum-relative-global-mode) - :custom (linum-delay t) - (linum-relative-backend 'display-line-numbers-mode)) -#+end_src - -** Toggle comments - -Toggle comments in a language agnostic manner with ~evil-nerd-commenter~[fn:5]. Add a custom binding to =M-;= to mimmic the behaviour in other popular Emacs configuration frameworks. What is =M-?= Called the *Meta* key in Emacs, it typically refers to =Alt=. - -#+begin_src emacs-lisp -(use-package evil-nerd-commenter - :after evil - :bind ("M-;" . evilnc-comment-or-uncomment-lines)) -#+end_src - -* Shortcuts - -Toggle relative line numbers with =SPC t l=. - -#+begin_src emacs-lisp -(dotfiles/leader - "tl" '(linum-relative-global-mode :which-key "Lines")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/emacs-evil/evil-mode - -[fn:2] https://github.com/emacs-evil/evil-collection - -[fn:3] https://github.com/emacs-evil/evil-surround - -[fn:4] https://github.com/emacsmirror/linum-relative - -[fn:5] https://github.com/redguardtoo/evil-nerd-commenter diff --git a/modules/exwm.org b/modules/exwm.org deleted file mode 100644 index 39eed6b..0000000 --- a/modules/exwm.org +++ /dev/null @@ -1,72 +0,0 @@ -#+TITLE: EXWM -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle exwm.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Emacs can run as a complete tiling window manager for X11. - -* Setup - -Load the ~x11~ module before loading this module. - -* Config - -When ~exwm~[fn:1] first launches the ~init-hook~ is executed, allowing us to define some custom logic inside of a hook. Display the time and date, and the battery information, if any is available. I add this here because when I'm running Emacs without ~exwm~[fn:1], information such as the batter and time is typically already available. - -#+begin_src emacs-lisp -(defun dotfiles/init-hook () - (exwm-workspace-switch-create 1) - (setq display-time-and-date t) - (display-battery-mode 1) - (display-time-mode 1)) -#+end_src - -** Display detection - -Enable hot plugging by forcing a profile change with ~autorandr~. - -#+begin_src emacs-lisp -(defun dotfiles/update-display () - "Update the displays by forcing a change through autorandr." - (dotfiles/run-in-background "autorandr --change --force")) -#+end_src - -** Window manager - -Connect all of the custom hooks and configure the input keys, a custom layer for key captures when Emacs us running as a window manager. Enable ~randr~ support, to function with ~autorandr~, and apply some default bindings. - -#+begin_src emacs-lisp -(use-package exwm - :when (window-system) - :custom (exwm-workspace-show-all-buffers t) - (exwm-input-prefix-keys - '(?\M-x - ?\C-g - ?\C-\ )) - (exwm-input-global-keys - `(([?\s-r] . exwm-reset) - ,@(mapcar (lambda (i) - `(,(kbd (format "s-%d" i)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,i)))) - (number-sequence 1 9)))) - :config (require 'exwm-randr) - (exwm-randr-enable) - (add-hook 'exwm-init-hook #'dotfiles/init-hook) - (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display) - (add-hook 'exwm-update-class-hook (lambda () (exwm-workspace-rename-buffer exwm-class-name))) - (dotfiles/update-display) - (dotfiles/run-in-background "nitrogen --restore") ;; Update the wallpaper. - (dotfiles/run-in-background "xmodmap") ;; Rebind CTRL and CAPS. - (exwm-enable)) -#+end_src - -* Footnotes - -[fn:1] https://github.com/ch11ng/exwm diff --git a/modules/fonts.org b/modules/fonts.org deleted file mode 100644 index d943eb1..0000000 --- a/modules/fonts.org +++ /dev/null @@ -1,123 +0,0 @@ -#+TITLE: Fonts -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle fonts.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Unified system font across Emacs. - -* Setup - -Install the required ~firacode~[fn:1] font before loading the module: - -#+begin_src shell -RUN apt install -y fonts-firacode -#+end_src - -* Config - -Write out the value of ~dotfiles/font~ to all of the available font faces supported by Emacs. By default, this uses ~firacode~[fn:1] for its readability and ligature support. All of the heights are configured to ~dotfiles/font-size~ by default, with further configuration based on the given size possible. - -#+begin_src emacs-lisp -(set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size) -(set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size) -(set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size) -#+end_src - -** Icons - -Emacs feels more modern with prioritized icon fonts, available in the ~all-the-icons~[fn:2] package. This makes navigation and visually parsing directories much faster, given that the file types are quickly identified by their corresponding icons. - -#+begin_src emacs-lisp -(use-package all-the-icons) -#+end_src - -Integration with the built-in ~dired~ package is available in the ~all-the-icons-dired~[fn:3] package. - -#+begin_src emacs-lisp -(use-package all-the-icons-dired - :hook (dired-mode . all-the-icons-dired-mode)) -#+end_src - -** Emojis - -It's finally here, first class support for Emojis in Emacs via the ~emacs-emojify~[fn:4] package. Have we finally gone too far? - -#+begin_src emacs-lisp -(use-package emojify - :when (window-system) - :hook (after-init . global-emojify-mode)) -#+end_src - -** Scrolling - -Emacs' default scrolling behaviour is annoying. The sudden half-page jumps and the variable scroll-speed can be fixed with a few simple commands. - -#+begin_src emacs-lisp -(setq scroll-conservatively 101 ;; Values >= 100 fix page jumping. - mouse-wheel-scroll-amount '(3 ((shift) . 3)) ;; Control the number of lines per jump. - mouse-wheel-progressive-speed t ;; Accelerate scrolling with the mouse wheel. - mouse-wheel-follow-mouse t) ;; Scroll the window under the mouse. -#+end_src - -** Ligatures - -Enable ~firacode~[fn:1] font ligatures with the ~fira-code-mode~[fn:5] package. Only perform this action when ~firacode~[fn:1] is the current font, and Emacs isn't running on the TTY. - -#+begin_src emacs-lisp -(use-package fira-code-mode - :when (and (window-system) - (equal dotfiles/font "Fira Code")) - :hook (prog-mode org-mode)) -#+end_src - -** Parenthesis - -Colourize nested parenthesis with ~rainbow-delimeters~[fn:4], a mandatory life-jacked to keep you from drowning in the sea of them in Lisp. - -#+begin_src emacs-lisp -(use-package rainbow-delimiters - :hook (prog-mode . rainbow-delimiters-mode)) -#+end_src - -** Text scaling - -Define a transient keybinding for scaling the text. One caveat to this, it only works when Emacs is running as a GUI application, and has no effect in the terminal. - -#+begin_src emacs-lisp -(defhydra hydra-text-scale (:timeout 4) - "Scale" - ("j" text-scale-increase "Increase") - ("k" text-scale-decrease "Decrease") - ("f" nil "Finished" :exit t)) -#+end_src - -* Shortcuts - -Scale the text inside of buffers using the custom transient binding, behind =SPC t f=: - -+ Increase with =j= -+ Decrease with =k= -+ Finish with =f= - -#+begin_src emacs-lisp -(dotfiles/leader - "tf" '(hydra-text-scale/body :which-key "Font")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/tonsky/FiraCode - -[fn:2] [[https://github.com/domtronn/all-the-icons.el]] - -[fn:3] https://github.com/jtbm37/all-the-icons-dired - -[fn:4] https://github.com/Fanael/rainbow-delimiters - -[fn:5] https://github.com/jming422/fira-code-mode diff --git a/modules/go.org b/modules/go.org deleted file mode 100644 index f716819..0000000 --- a/modules/go.org +++ /dev/null @@ -1,75 +0,0 @@ -#+TITLE: Go -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle go.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Go is an open source programming language that makes it easy to build simple, reliable, and efficient software[fn:1] - -* Setup - -Install ~golang~[fn:1] on your system, and configure your environment prior to loading this module. - -#+begin_src shell -RUN apt install -y golang -#+end_src - -** Language server - -Get started by installing the ~gopls~[fn:2] language server. - -#+begin_src shell -GO111MODULE=on go get golang.org/x/tools/gopls@latest -#+end_src - -** Setup the environment - -Make some modifications to the environment. Set the =$GOPATH= variable prior to loading, allowing modification of the default value. Include the =bin= subdirectory of the =$GOPATH= in the =$PATH= variable, adding compiled golang applications to the system path. - -#+begin_src emacs-lisp -(setenv "GOPATH" (concat (getenv "HOME") "/.go/")) -(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH"))) -#+end_src - -* Config - -Use the ~go-mode~[fn:3] package for integration with ~lsp-mode~, manually setting the path to ~gopls~[fn:2] before loading. - -#+begin_src emacs-lisp -(use-package go-mode - :hook (go-mode . lsp) - :custom (lsp-go-gopls-server-path "~/.go/bin/gopls")) -#+end_src - -** Before save hooks - -Apply some custom behaviour when saving ~golang~[fn:1] buffers. Format and organize the imports before saving. - -#+begin_src emacs-lisp -(defun dotfiles/go-hook () - (add-hook 'before-save-hook #'lsp-format-buffer t t) - (add-hook 'before-save-hook #'lsp-organize-imports t t)) - -(add-hook 'go-mode-hook #'dotfiles/go-hook) -#+end_src - -** Babel structure templates - -Configure the ~babel~ engine to support ~golang~[fn:1] source blocks. - -#+begin_src emacs-lisp -(add-to-list 'org-structure-template-alist '("go" . "src go")) -#+end_src - -* Footnotes - -[fn:1] https://golang.org - -[fn:2] https://pkg.go.dev/golang.org/x/tools/gopls - -[fn:3] https://emacswiki.org/emacs/GoMode diff --git a/modules/gpg.org b/modules/gpg.org deleted file mode 100644 index 64c3609..0000000 --- a/modules/gpg.org +++ /dev/null @@ -1,68 +0,0 @@ -#+TITLE: GPG -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle gpg.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Handle GPG[fn:1] pinentry within Emacs. - -* Setup -:PROPERTIES: -:header-args: :tangle ../config/gpg-agent.conf -:END: - -When the ~gpg-agent~[fn:1] loads it will read the configuration at =~/.gnupg/gpg-agent.conf=. Override the default settings to allow Emacs to function as the Pinentry application. - -#+begin_src conf -allow-emacs-pinentry -allow-loopback-pinentry -#+end_src - -You may need to restart the ~gpg-agent~[fn:1] to load the configuration without rebooting. - -#+begin_src shell :tangle nil -gpgconf --reload gpg-agent -#+end_src - -* Config - -Create the symbolic link to the configuration file. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/gpg-agent.conf" - "~/.gnupg/gpg-agent.conf") -#+end_src - -With the ~pinentry~[fn:2] package for Emacs prompts will now appear in the minibuffer. Increase the minimum prime bit size to increase performance during symmetric encryption. - -#+begin_src emacs-lisp -(use-package pinentry - :custom (epa-file-select-keys 2) - (gnutls-min-prime-bits 4096) - (epa-pinentry-mode 'loopback) - (epa-file-encrypt-to dotfiles/public-key) - (epa-file-cache-passphrase-for-symmetric-encryption t) - :config (pinentry-start)) -#+end_src - -** Including agenda files - -Override ~org-agenda-file-regexp~ to include =.org.gpg= files. - -#+begin_src emacs-lisp -(unless (string-match-p "\\.gpg" org-agenda-file-regexp) - (setq org-agenda-file-regexp - (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?" - org-agenda-file-regexp))) -#+end_src - -* Footnotes - -[fn:1] https://gnupg.org - -[fn:2] https://elpa.gnu.org/packages/pinentry.html diff --git a/modules/grammar.org b/modules/grammar.org deleted file mode 100644 index 7942ce5..0000000 --- a/modules/grammar.org +++ /dev/null @@ -1,30 +0,0 @@ -#+TITLE: Grammar -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle grammar.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Real time checking and one-shot methods to check and correct common grammatical errors. - -* Config - -Use ~writegood-mode~ to find common writing problems such as cliches, and poor wording. Grammarly for the peons! - -#+begin_src emacs-lisp -(use-package writegood-mode - :after org - :config (writegood-mode)) -#+end_src - -* Shortcuts - -Toggle ~writegood-mode~ with =SPC t w=: - -#+begin_src emacs-lisp -(dotfiles/leader - "tw" '(writegood-mode :which-key "Grammar")) -#+end_src diff --git a/modules/hugo.org b/modules/hugo.org deleted file mode 100644 index 82dd89d..0000000 --- a/modules/hugo.org +++ /dev/null @@ -1,100 +0,0 @@ -#+TITLE: Hugo -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle hugo.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Create entire websites with Emacs. - -* Setup - -Download and install ~hugo~[fn:1] on your system before loading the module: - -#+begin_src shell -RUN apt install -y hugo -#+end_src - -* Config - -It's possible to export ~org-mode~ into ~hugo~[fn:1] specific markdown[fn:2] using the ~ox-hugo~[fn:3] package. I have my setup configured for one-post-per-file, despite it not being the suggested method. The option will appear in the default export menu inside of an ~org-mode~ buffer, accessible by pressing =C-c C-e=. - -#+begin_src emacs-lisp -(use-package ox-hugo - :after ox) -#+end_src - -* Shortcuts - -Create capture templates for creating new blog posts, and creating publicly shared notes on various topics, and other peoples published works. - -** Posts - -I post nonsense on my personal blog, available here[fn:4]. This template makes sure the file ends up going to the right location, with the configuration pre-applied. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-capture-templates - '("p" "Post" plain (function org-roam-capture--get-point) - "%?" - :file-name "docs/posts/${slug}" - :unnarrowed t - :head -" -,#+TITLE: ${title} -,#+AUTHOR: Christopher James Hayward -,#+DATE: %<%Y-%m-%d> - -,#+OPTIONS: num:nil todo:nil tasks:nil - -,#+EXPORT_FILE_NAME: ${slug} -,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/ - -,#+HUGO_BASE_DIR: ../ -,#+HUGO_AUTO_SET_LASTMOD: t -,#+HUGO_SECTION: posts -,#+HUGO_DRAFT: true -"))) -#+end_src - -** Notes - -Read my notes on various textbooks, artciles, and other un-categorized nonsense here[fn:5]. This template makes sure the file ends up going to the right location, with the configuration pre-applied. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-capture-templates - '("n" "Notes" plain (function org-roam-capture--get-point) - "%?" - :file-name "docs/notes/${slug}" - :unnarrowed t - :head -" -,#+TITLE: ${title} -,#+AUTHOR: Christopher James Hayward - -,#+OPTIONS: num:nil todo:nil tasks:nil -,#+EXPORT_FILE_NAME: ${slug} -,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/ - -,#+HUGO_BASE_DIR: ../ -,#+HUGO_AUTO_SET_LASTMOD: t -,#+HUGO_SECTION: notes -,#+HUGO_DRAFT: true -"))) -#+end_src - -* Footnotes - -[fn:1] https://gohugo.io - -[fn:2] https://markdownguide.org/tools/hugo - -[fn:3] https://github.com/kaushalmodi/ox-hugo - -[fn:4] https://chrishayward.xyz/posts/ - -[fn:5] https://chrishayward.xyz/notes/ diff --git a/modules/ivy.org b/modules/ivy.org deleted file mode 100644 index 7135aa6..0000000 --- a/modules/ivy.org +++ /dev/null @@ -1,80 +0,0 @@ -#+TITLE: Ivy -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle ivy.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Bring Emacs out of the eighties. - -* Config - -There's a lot of occasions where Emacs asks you to input text to match a file name in a directory, or of a potential buffer selection. The family of packages ~ivy/swiper~[fn:1] work together toward this common goal of improving the default completion menu system. - -#+begin_src emacs-lisp -(use-package ivy - :diminish - :config (ivy-mode 1)) -#+end_src - -** Replacements - -Include ~counsel~[fn:2], a customized set of commands to replace the built-in completion buffers. This will provide an experience similar to what you've maybe experienced on ~doom~ or ~spacemacs~. - -#+begin_src emacs-lisp -(use-package counsel - :after ivy - :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only) - :config (counsel-mode 1)) -#+end_src - -** Additional details - -Provide more information about each item in the completion menu with ~ivy-rich~[fn:3]. This will include snippets from any available documentation, or active buffers. - -#+begin_src emacs-lisp -(use-package ivy-rich - :after counsel - :init (ivy-rich-mode 1)) -#+end_src - -** Popup selection frame - -Display ~ivy~[fn:1] completions in a popup buffer with the ~ivy-posframe~[fn:4] package. I prefer to use this since the menu appears in the center of my screen, stopping my from having to tilt my head to look down at the default completion menu appearing in the mini-buffer. - -#+begin_src emacs-lisp -(use-package ivy-posframe - :after ivy - :when (window-system) - :custom (ivy-posframe-display-functions-alist '((t . ivy-posframe-display))) - (ivy-posframe-parameters '((parent-frame nil))) - :config (ivy-posframe-mode 1)) -#+end_src - -** Candidate selection sorting - -Sort completion candidates based on how recently or frequently they're selected with ~prescient.el~[fn:5]. This can be helpful when using =M-x= to run commands that aren't bound to specific key-strokes. - -#+begin_src emacs-lisp -(use-package ivy-prescient - :after counsel - :custom (ivy-prescient-enable-filtering nil) - :config (prescient-persist-mode 1) - (ivy-prescient-mode 1)) -#+end_src - -* Footnotes - -[fn:1] https://github.com/abo-abo/swiper - -[fn:2] https://libraries.io/emacs/counsel - -[fn:3] https://github.com/Yevgnen/ivy-rich - -[fn:4] https://github.com/tumashu/ivy-posframe - -[fn:5] https://github.com/raxod502/prescient.el diff --git a/modules/keys.org b/modules/keys.org deleted file mode 100644 index 281a15b..0000000 --- a/modules/keys.org +++ /dev/null @@ -1,137 +0,0 @@ -#+TITLE: Keys -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle keys.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Improve the keyboard experience within Emacs. - -* Config - -Some of the default keybindings in Emacs really do leave you wondering, for example, when you want to exit a prompt you have to use =C-g=. Offer =ESC= as an alternative to quit (most) prompts, which I have muscle memory for already from literally every program created since 1990. - -#+begin_src emacs-lisp -(global-set-key (kbd "") 'keyboard-escape-quit) -#+end_src - -** Hints - -Since Emacs is keyboard driven software, there are a lot of keybindings. Sometimes it's useful to start pressing well-known key combinations, and view the available completions. This behaviour is implemented in the third-party package ~which-key~[fn:1]. It displays the current incomplete keybinding input in a mini-buffer. It also works in the other direction, showing the corresponding keybindings for each command when you run =M-x=. - -#+begin_src emacs-lisp -(use-package which-key - :diminish which-key-mode - :custom (which-key-idle-delay dotfiles/idle) - :config (which-key-mode)) -#+end_src - -** Leader - -If like myself, you started using Emacs using a framework such as ~doom~[fn:2] or ~spacemacs~[fn:3], you probably have a considerable amount of muscle memory developed for using =SPC= as a leader key. In both of the previously mentioned frameworks, the package ~general.el~[fn:4] is used to implement this behaviour. It's a major improvement to the default way of creating custom keybindings in Emacs. - -#+begin_src emacs-lisp -(use-package general - :config - (general-create-definer dotfiles/leader - :states '(normal motion) - :keymaps 'override - :prefix dotfiles/leader-key - :global-prefix dotfiles/leader-key-global)) -#+end_src - -** Transient - -Create transient keybindings with a shared prefix through ~hydra~[fn:5]. This is also used by a number of third-party packages as a completion system. An implementation example is used to scale the font size. - -#+begin_src emacs-lisp -(use-package hydra - :defer t) -#+end_src - -* Shortcuts - -Implement some shortcut bindings, with a significant portion of them cherry picked from ~doom~[fn:2]: - -+ Close buffers with =SPC c= -+ Find files with =SPC . (period)= -+ Switch buffers with =SPC , (comma)= -+ Kill buffers with =SPC / (slash)= - -#+begin_src emacs-lisp -(dotfiles/leader - "." '(find-file :which-key "Files") - "," '(switch-to-buffer :which-key "Buffers") - "c" '(kill-buffer-and-window :which-key "Close")) -#+end_src - -** Quitting Emacs - -Customize the behaviour of exiting emacs, with keybindings behind =SPC q=: - -+ Save and quit =q= -+ Quit without saving =w= -+ Exit the Frame (daemon) =f= - -#+begin_src emacs-lisp -(dotfiles/leader - "q" '(:ignore t :which-key "Quit") - "qq" '(save-buffers-kill-emacs :which-key "Save") - "qw" '(kill-emacs :which-key "Now") - "qf" '(delete-frame :which-key "Frame")) -#+end_src - -** Managing windows - -Screen space is divided into Frames inside of Emacs, manage them behind =SPC w=: - -+ Swap with =w= -+ Close with =c= -+ Delete with =d= -+ Move with =h,j,k,l= -+ Split with =s - = - -#+begin_src emacs-lisp -(dotfiles/leader - "w" '(:ignore t :which-key "Window") - "ww" '(window-swap-states :which-key "Swap") - "wc" '(delete-window :which-key "Close") - "wh" '(windmove-left :which-key "Left") - "wj" '(windmove-down :which-key "Down") - "wk" '(windmove-up :which-key "Up") - "wl" '(windmove-right :which-key "Right") - "ws" '(:ignore t :which-key "Split") - "wsj" '(split-window-below :which-key "Down") - "wsl" '(split-window-right :which-key "Right")) -#+end_src - -** Helper Functions - -Use the built-in ~describe-*~ functionality of Emacs to quickly access documentation for packages, variables, and functions. Run helper functions with =SPC h=: - -+ Packages =p= -+ Variables =v= -+ Functions =f= - -#+begin_src emacs-lisp -(dotfiles/leader - "h" '(:ignore t :which-key "Help") - "hp" '(describe-package :which-key "Package") - "hv" '(describe-variable :which-key "Variable") - "hf" '(describe-function :which-key "Function")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/justbur/emacs-which-key/ - -[fn:2] https://github.com/hlissner/doom-emacs/ - -[fn:3] https://spacemacs.org - -[fn:4] https://github.com/noctuid/general.el - -[fn:5] https://github.com/abo-abo/hydra diff --git a/modules/lsp.org b/modules/lsp.org deleted file mode 100644 index be5d36c..0000000 --- a/modules/lsp.org +++ /dev/null @@ -1,76 +0,0 @@ -#+TITLE: Language Server Protocol -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle lsp.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -The Language Server Protocol (LSP) defines the protocol used between an editor, or IDE, and a language server that provides language features like auto-complete, go-to-definition, find-all-references, etc[fn:1] - -* Config - -Support for the Language Server Protocol[fn:1] is available through the ~lsp-mode~[fn:2] package. Configure an immutable delay of =.5= to ensure it doesn't attack the current language server and overload it with requests. - -#+begin_src emacs-lisp -(use-package lsp-mode - :commands (lsp lsp-deferred) - :custom (lsp-idle-delay 0.5) - (lsp-prefer-flymake t)) -#+end_src - -** Code snippets - -Download ~yasnippet~[fn:4], used by a number of ~lsp-mode~[fn:2] extensions to provide smart completion functionality. - -#+begin_src emacs-lisp -(use-package yasnippet - :ensure t) -#+end_src - -** UI integration - -Download ~lsp-ui~[fn:3] to provide user interface improvements for ~lsp-mode~[fn:2] over the defaults. - -#+begin_src emacs-lisp -(use-package lsp-ui - :after lsp - :custom (lsp-ui-doc-position 'at-point) - (lsp-ui-doc-delay 0.500)) -#+end_src - -** Code completion - -Text completion provided by ~company~[fn:5], AKA Complete Anything. Make sure it's integrated with ~lsp-mode~[fn:2] to provide completion candidates through the Language Server Protocol[fn:1]. - -#+begin_src emacs-lisp -(use-package company - :after lsp) -#+end_src - -Specify the repository for ~company-lsp~ using straight to make sure we're getting the most recent version from GitHub, instead of the typically outdated versions in the Emacs package repositories. - -#+begin_src emacs-lisp -(use-package company-lsp - :after (lsp company) - :custom (company-lsp-async t) - (company-backend 'company-lsp) - :straight (company-lsp :type git - :host github - :repo "tigersoldier/company-lsp")) -#+end_src - -* Footnotes - -[fn:1] https://microsoft.github.io/language-server-protocol/ - -[fn:2] https://emacs-lsp.github.io/lsp-mode/ - -[fn:3] https://emacs-lsp.github.io/lsp-ui/ - -[fn:4] https://github.com/joaotavora/yasnippet - -[fn:5] https://company-mode.github.io/ diff --git a/modules/magit.org b/modules/magit.org deleted file mode 100644 index 902c7ad..0000000 --- a/modules/magit.org +++ /dev/null @@ -1,62 +0,0 @@ -#+TITLE: Magit -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle magit.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Handle all of the git interactions inside of Emacs. - -* Setup - -Deploy the global configuration file for ~git~[fn:1], by default it reads from =$HOME/.gitconfig=. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/git" - "~/.gitconfig") -#+end_src - -* Config - -Another hallmark feature of Emacs is ~magit~[fn:2]. It's a complete git porcelain inside of Emacs. The developer has stressed that it's most unfortunate name was meant to be pronounced like *magic* but with *git*. Despire his best efforts a lot of people have taken to pronouncing it *maggot*, which keeps him awake at night (probably). - -#+begin_src emacs-lisp -(use-package magit - :commands magit-status - :custom (magit-display-buffer-function - #'magit-display-buffer-same-window-except-diff-v1)) -#+end_src - -** Forge integration - -It's possible to interact with forges from Github / Gitlab using ~forge~[fn:3]. It requires the respective =$TOKEN= to be configured, or an alternative form of authentication. This enables working with pull-requests, code-reviews, and issues from inside of Emacs. - -#+begin_src emacs-lisp -(use-package forge - :after magit) -#+end_src - -* Shortcuts - -Interact with ~magit~[fn:2] behind =SPC g=: - -+ Clone with =c= -+ Status with =g= - -#+begin_src emacs-lisp -(dotfiles/leader - "g" '(:ignore t :which-key "Magit") - "gc" '(magit-clone :which-key "Clone") - "gg" '(magit-status :which-key "Status")) -#+end_src - -* Footnotes - -[fn:1] https://git-scm.com - -[fn:2] https://github.com/magit/magit - -[fn:3] https://github.com/magit/forge diff --git a/modules/modeline.org b/modules/modeline.org deleted file mode 100644 index bc81828..0000000 --- a/modules/modeline.org +++ /dev/null @@ -1,19 +0,0 @@ -#+TITLE: Modeline -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -Extend the usability of the Emacs modeline. - -* Config - -Implement and elegant and modern status bar, fully customizable and compatible with our themes with the ~doom-modeline~[fn:1] package. - -#+begin_src emacs-lisp -(use-package doom-modeline - :custom (doom-modeline-height 16) - :config (doom-modeline-mode 1)) -#+end_src - -* Footnotes - -[fn:1] https://github.com/seagle0128/doom-modeline diff --git a/modules/mu4e.org b/modules/mu4e.org deleted file mode 100644 index bd80952..0000000 --- a/modules/mu4e.org +++ /dev/null @@ -1,150 +0,0 @@ -#+TITLE: Mu4e -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle mu4e.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Plain-text email inside of Emacs. - -* Setup - -Make sure the following dependencies are installed on your system before loading the module. I would recommend against using any distributions pre-packaged version of ~mu4e~[fn:1], and instead build it yourself which I detail in this post[fn:2]: - -#+begin_src shell -RUN apt install -y isync libgmime-3.0-dev libxapian-dev -#+end_src - -** Setting up mbsync -:PROPERTIES: -:header-args: :tangle ../config/mbsyncrc :comments org -:END: - -The program that actually synchronizes the emails with the server is ~mbsync~[fn:3]. Create the configuration file, this is for my personal mail server[fn:4], which I host myself, so make sure you write your own. - -#+begin_src conf -IMAPStore xyz-remote -Host mail.chrishayward.xyz -User chris@chrishayward.xyz -PassCmd "pass chrishayward.xyz/chris" -SSLType IMAPS - -MaildirStore xyz-local -Path ~/.cache/mail/ -Inbox ~/.cache/mail/inbox -SubFolders Verbatim - -Channel xyz -Master :xyz-remote: -Slave :xyz-local: -Patterns * !Archives -Create Both -Expunge Both -SyncState * -#+end_src - -** Create symbolic links - -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. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/mbsyncrc" - "~/.mbsyncrc") -#+end_src - -This repository also contains my personal encrypted auth info, this is required by ~mbsync~[fn:3] to sign all of the outbound messages. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/authinfo.gpg" - "~/.authinfo.gpg") -#+end_src - -** First time indexing - -Before you can use ~mu4e~[fn:1] inside of Emacs, you need to synchronize the mail database, and index it using ~mu~[fn:5], the library used by ~mu4e~[fn:1] under the hood. Execute these commands in your terminal before loading the module, after that you can do everything inside of Emacs: - -#+begin_src shell -RUN mbsync -a -RUN mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz" -RUN mu index -#+end_src - -* Config - -After syncing and indexing, the mail is ready for Emacs. Include ~mu4e~[fn:1] in the configuration by adding the custom built version to the load path, and configure the mail account. - -+ Update every 5 minutes -+ Configure mail account(s) -+ Scale text for all devices -+ Sign outbound mail with GPG key - -#+begin_src emacs-lisp -(use-package mu4e - :load-path "~/.local/source/mu/mu4e/" - :custom (mu4e-maildir "~/.cache/mail") - (mu4e-update-interval (* 5 60)) - (mu4e-get-mail-command "mbsync -a") - (mu4e-compose-format-flowed t) - (mu4e-change-filenames-when-moving t) - (message-send-mail-function 'smtpmail-send-it) - (mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F")) - (mu4e-compose-signature (concat "Chris Hayward\n" - "https://chrishayward.xyz\n")) - :config - (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime) - (setq mu4e-contexts - (list - ;; Main - ;; chris@chrishayward.xyz - (make-mu4e-context - :name "Main" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/Main" (mu4e-message-field msg :maildir)))) - :vars - '((user-full-name . "Christopher James Hayward") - (user-mail-address . "chris@chrishayward.xyz") - (smtpmail-smtp-server . "mail.chrishayward.xyz") - (smtpmail-smtp-service . 587) - (smtpmail-stream-type . starttls)))))) -#+end_src - -** Desktop notifications - -Receive desktop notifications when new mail arrives with the ~mu4e-alert~[fn:6] package. - -#+begin_src emacs-lisp -(use-package mu4e-alert - :after mu4e - :custom (mu4e-alert-set-default-style 'libnotify) - :config (mu4e-alert-enable-notifications) - (mu4e-alert-enable-mode-line-display)) -#+end_src - -* Shortcuts - -Open the ~mu4e~[fn:1] dashboard with =SPC m=. - -#+begin_src emacs-lisp -(dotfiles/leader - "m" '(mu4e :which-key "Mu4e")) -#+end_src - -* Footnotes - -[fn:1] https://emacswiki.org/emacs/mu4e - -[fn:2] https://chrishayward.xyz/posts/installing-mu-mu4e-from-source/ - -[fn:3] https://isync.sourceforge.io - -[fn:4] mailto:chris@chrishayward.xyz - -[fn:5] https://codewith.mu/en/download - -[fn:6] https://github.com/iqbalansari/mu4e-alert diff --git a/modules/nix.org b/modules/nix.org deleted file mode 100644 index 1166200..0000000 --- a/modules/nix.org +++ /dev/null @@ -1,27 +0,0 @@ -#+TITLE: Nix -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle nix.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks: nil tags:nil -#+OPTIONS: skip:nil author:nil emacs:nil creator:nil timestamp:nil - -* Setup - -*Nix*[fn:1] is a package manager for Linux that uses functional configuration language to build reproducible package deployments. *NixOS*[fn:2] is an extension of the Nix package manager to the entire operating system. - -* Config - -Download and install ~nix-mode~ for working with *Nix* language buffers. - -#+begin_src emacs-lisp -(use-package nix-mode) -#+end_src - -* Footnotes - -[fn:1] https://nixos.org - -[fn:2] https://nixos.org diff --git a/modules/org.org b/modules/org.org deleted file mode 100644 index a20a1d5..0000000 --- a/modules/org.org +++ /dev/null @@ -1,160 +0,0 @@ -#+TITLE: Org -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle org.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Organize your plain-life in plain-text. The hallmark feature of Emacs, ~org-mode~[fn:1] is the king of markup languages. It has rich feature support for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities. - -* Setup - -Define a custom hook when ~org-mode~[fn:1] is enabled to customize the experience: - -+ Enable ~org-indent-mode~ to indent and align text with the parent heading -+ Enable ~visual-line-mode~ to allow text to overflow and wrap to the next visual line -+ Enable ~variable-pitch-mode~ to support multiple font-pitches and monospaced fonts - -#+begin_src emacs-lisp -(defun dotfiles/org-mode-hook () - (org-indent-mode) ;; Indent and align text. - (visual-line-mode 1) ;; Allow text to overflow line. - (variable-pitch-mode 1)) ;; Enable monospaced fonts. -#+end_src - -* Config - -Force ~straight~ to ignore the local version of ~org-mode~[fn:1], instead downloading the most recent version available. - -#+begin_src emacs-lisp -(straight-use-package '(org :local-repo nil)) -#+end_src - -Setup the default babel languages and structure templates, and apply customizations: - -+ Setup ~org-mode-hook~ with our custom hook -+ Setup ~org-ellipsis~ to show headlines with hidden contents -+ Setup ~org-log-*~ for event logging -+ Setup ~org-src-*~ for source blocks -+ Setup ~org-todo-keyword~ sequence - -#+begin_src emacs-lisp -(use-package org - :hook (org-mode . dotfiles/org-mode-hook) - :custom (org-ellipsis " ▾") - (org-log-done 'time) - (org-log-into-drawer t) - (org-return-follows-link t) - (org-image-actual-width nil) - (org-directory dotfiles/home) - (org-src-fontify-natively t) - (org-src-tab-acts-natively t) - (org-src-preserve-indentation t) - (org-confirm-babel-evaluate nil) - (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE"))) - :config (require 'org-tempo) ;; Required for structure templates. - (add-to-list 'org-structure-template-alist '("s" . "src")) - (add-to-list 'org-structure-template-alist '("q" . "quote")) - (add-to-list 'org-structure-template-alist '("e" . "example")) - (add-to-list 'org-structure-template-alist '("sh" . "src shell")) - (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) - (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) - (emacs-lisp . t)))) -#+end_src - -** Pomodoro - -Adds support for the Pomodoro workflow in Emacs through the ~org-pomodoro~[fn:4] package. Some workflows benefit from thje option to work a few minutes of *overtime* to finish a task before taking a break. With this workflow, a break notification is sent at the end of the pomodoro timer, but the break starts when calling =M-x org-pomodoro=. - -#+begin_src emacs-lisp -(use-package org-pomodoro - :after org - :custom (org-pomodoro-manual-break t) ;; Enable the 'overtime' workflow. - (org-pomodoro-keep-killed-time t)) ;; Track abandoned timers. -#+end_src - -** Flashcards - -Create study flashcards using ~org-drill~[fn:2], an extension for ~org-mode~. It uses a spaced repititon algorithm to conduct interactive drill sesslions using ~org-mode~ buffers as sources of facts to be memorized. Each drill can be restricted to topics in the current buffer, one of several, all agenda files, or a single topic across all buffers. - -#+begin_src emacs-lisp -(use-package org-drill - :after org) -#+end_src - -** Headline stars - -Make the headline stars a bit more *super* with ~org-superstar-mode~[fn:3]. Only enable this inside of a window system, as the effect can be distracting on the TTY. - -#+begin_src emacs-lisp -(use-package org-superstar - :when (window-system) - :after org - :hook (org-mode . org-superstar-mode)) -#+end_src - -* Methods - -Define some custom methods for use in the rest of the configuration. - -** Tangle directory - -Build all of the ~org~ files within a given directory, recursively. This is used in CI. - -#+begin_src emacs-lisp -(defun dotfiles/tangle (dir) - "Recursively tangle the Org files within a directory." - (interactive) - (let ((org-files (directory-files-recursively dir "org"))) - (dolist (f org-files) - (org-babel-tangle-file f)))) -#+end_src - -** Force symbolic links - -Function that takes in a system and configuration file path, checks to see if the system file doesn't exist, or doesn't point to the configuration file, deleting it for the latter, then creating a symbolic link to the configuration file in place. - -#+begin_src emacs-lisp -(defun dotfiles/symlink (src tgt) - "Forces a symlink from `src' to `tgt'." - (interactive) - (let ((sys-file (expand-file-name tgt)) - (dot-file (expand-file-name src))) - (when (or (not (file-exists-p sys-file)) - (not (equal (file-symlink-p sys-file) dot-file))) - (delete-file sys-file) - (make-symbolic-link dot-file sys-file)))) -#+end_src - - -* Shortcuts - -Place ~org-mode~[fn:1] extension bindings behind =SPC o=. - -+ Drill with =d= - + Drill with =d= - + Resume with =r= -+ Pomodoro with =p= - -#+begin_src emacs-lisp -(dotfiles/leader - "o" '(:ignore t :which-key "Org") - "od" '(:ignore t :which-key "Drill") - "odd" '(org-drill :which-key "Drill") - "odc" '(org-drill-cram :which-key "Cram") - "odr" '(org-drill-resume :which-key "Resume") - "op" '(org-pomodoro :which-key "Pomodoro")) -#+end_src - -* Footnotes - -[fn:1] https://orgmode.org - -[fn:2] https://orgmode.org/worg/org-contrib/org-drill.html - -[fn:3] https://github.com/integral-dw/org-superstar-mode - -[fn:4] https://github.com/marcinkoziej/org-pomodoro diff --git a/modules/pass.org b/modules/pass.org deleted file mode 100644 index e05b539..0000000 --- a/modules/pass.org +++ /dev/null @@ -1,51 +0,0 @@ -#+TITLE: Pass -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle pass.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Password management inside of Emacs. - -* Setup - -Install ~pass~[fn:1] on the system before loading the module. - -#+begin_src shell -RUN apt install -y pass -#+end_src - -* Config - -Encrypted passwords are stored inside files, in a file structure providing easy commands for generating, modifying, and copying passwords. ~password-store.el~[fn:2] provides a wrapper for the functionality within Emacs. - -#+begin_src emacs-lisp -(use-package password-store - :custom (password-store-dir dotfiles/passwords)) -#+end_src - -* Shortcuts - -Configure keybindings behind =SPC p=: - -+ Copy with =p= -+ Rename with =r= -+ Generate with =g= - -#+begin_src emacs-lisp -(dotfiles/leader - "p" '(:ignore t :which-key "Passwords") - "pp" '(password-store-copy :which-key "Copy") - "pr" '(password-store-rename :which-key "Rename") - "pg" '(password-store-generate :which-key "Generate")) -#+end_src - -* Footnotes - -[fn:1] https://passwordstore.org - -[fn:2] https://github.com/NicolasPetton/pass diff --git a/modules/projects.org b/modules/projects.org deleted file mode 100644 index 446961b..0000000 --- a/modules/projects.org +++ /dev/null @@ -1,136 +0,0 @@ -#+TITLE: Projects -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle projects.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -#+ATTR_ORG: :width 420px -#+ATTR_HTML: :width 420px -#+ATTR_LATEX: :width 420px -[[../docs/images/2021-02-13-example-ccls.gif]] - -An *IDE*[fn:1] like experience or better can be achieved within Emacs using two *Microsoft*[fn:2] open-source initiatives: - -+ *Debug Adapter Protocol*[fn:3] -+ *Language Server Protocol*[fn:4] - -* Code snippets - -#+begin_src emacs-lisp -(use-package yasnippet - :ensure t) -#+end_src - -* Debug adapters - -*Dap mode*[fn:5] provides support for the *Debug Adapter Protocol*[fn:3] inside of Emacs. - -#+begin_src emacs-lisp -(use-package dap-mode - :commands (dap-debug)) -#+end_src - -* Language servers - -Support for the *Language Server Protocol*[fn:4] is added to Emacs through the *Lsp mode*[fn:6] package. - -#+begin_src emacs-lisp -(use-package lsp-mode - :commands (lsp lsp-deferred) - :custom (lsp-idle-delay (* 5 dotfiles/idle)) - (lsp-prefer-flymake t)) -#+end_src - -** UI integration - -*Lsp ui*[fn:7] provides user interface improvements for *Lsp mode*[fn:6]. - -#+begin_src emacs-lisp -(use-package lsp-ui - :after lsp - :custom (lsp-ui-doc-position 'at-point) - (lsp-ui-doc-delay 0.500)) -#+end_src - -** Code completion - -Text completion via *Company*[fn:8] =AKA= *Complete Anything*. - -#+begin_src emacs-lisp -(use-package company - :after lsp) -#+end_src - -Integrate with *Lsp mode*[fn:6] to provide completion candidates through the *Language Server Protocol*[fn:4]. - -+ Specify the repository -+ Use asynchronous completion - -#+begin_src emacs-lisp -(use-package company-lsp - :after (lsp company) - :custom (company-lsp-async t) - (company-backend 'company-lsp) - :straight (company-lsp :type git - :host github - :repo "tigersoldier/company-lsp")) -#+end_src - -* Docker containers - -Manage *Docker*[fn:9] containers with *Docker.el*[fn:10]. - -#+begin_src emacs-lisp -(use-package docker - :commands (docker)) -#+end_src - -Open the container management screen with =SPC k=. - -#+begin_src emacs-lisp -(dotfiles/leader - "k" '(docker :which-key "Docker")) -#+end_src - -* Project management - -Configure *Projectile*[fn:11], a project interaction library for Emacs. It provides a nice set of features for operating on a project level without introducing external dependencies. - -#+begin_src emacs-lisp -(use-package projectile - :custom (projectile-project-search-path '("~/.local/source")) - :config (projectile-mode)) -#+end_src - -* Footnotes - -[fn:1] https://en.wikipedia.org/wiki/Integrated_development_environment - -[fn:2] https://en.wikipedia.org/wiki/Microsoft_and_open_source - -[fn:3] https://microsoft.github.io/debug-adapter-protocol - -[fn:4] https://microsoft.github.io/language-server-protocol - -[fn:5] https://emacs-lsp.github.io/dap-mode/ - -[fn:6] https://emacs-lsp.github.io/lsp-mode/ - -[fn:7] https://emacs-lsp.github.io/lsp-ui/ - -[fn:8] https://company-mode.github.io/ - -[fn:9] https://docker.com - -[fn:10] https://github.com/Silex/docker.el - -[fn:11] https://projectile.mx - -[fn:12] https://git.zx2c4.com/password-store/tree/contrib/emacs - -[fn:13] https://passwordstore.org diff --git a/modules/python.org b/modules/python.org deleted file mode 100644 index 677613d..0000000 --- a/modules/python.org +++ /dev/null @@ -1,67 +0,0 @@ -#+TITLE: Python -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle python.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Python is an interpreted high-level general-purpose programming language[fn:1]. - -* Setup - -Ensure ~python3~[fn:1] is installed on the system, and the ~lsp~ and ~dap~ modules have been loaded before loading this module. - -#+begin_src shell -RUN apt install -y python3 python3-pip -#+end_src - -** Install the language server - -Install the ~pyls~[fn:2] language server. - -#+begin_src shell -RUN pip3 install --user "python-lsp-server[all]" -#+end_src - -* Config - -Add support for ~python3~[fn:1], including ~dap~ and ~lsp~ integration. The built-in Emacs mode ~python-mode~[fn:3] handles the rest of the integration. - -#+begin_src emacs-lisp -(use-package python-mode - :hook (python-mode . lsp-deferred) - :config (require 'dap-python) - (add-to-list 'org-src-lang-modes '("python" . python)) - (add-to-list 'org-structure-template-alist '("py" . "src python")) - (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) - :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3. - (org-babel-python-command "python3") ;; Same as above. - (dap-python-executable "python3") ;; Same as above. - (lsp-pyls-server-command "pylsp") - (dap-python-debugger 'debugpy)) -#+end_src - -** Code symbols - -Programming buffers can be made prettier with ~pretty-mode~[fn:4], this is complimentary to ~prettify-symbols-mode~[fn:5], a built-in package containing similar (but lacking) functionality. - -#+begin_src emacs-lisp -(use-package pretty-mode - :hook (python-mode . turn-on-pretty-mode)) -#+end_src - -* Footnotes - -[fn:1] https://python.org - -[fn:2] https://pypi.org/project/python-language-server/ - -[fn:3] https://emacswiki.org/emacs/PythonProgrammingInEmacs - -[fn:4] https://emacswiki.org/emacs/pretty-mode.el - -[fn:5] https://emacswiki.org/emacs/PrettySymbol diff --git a/modules/reveal.org b/modules/reveal.org deleted file mode 100644 index 45b39ad..0000000 --- a/modules/reveal.org +++ /dev/null @@ -1,55 +0,0 @@ -#+TITLE: Reveal -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle reveal.el :comments org -#+PROPERTY: header-args :results silent :eval no-export - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Create high-quality, portably presentations with ~reveal.js~[fn:1]. - -* Config - -Integrate ~reveal.js~[fn:1] with Emacs using the ~ox-reveal~[fn:2] package. Configure it to use a CDN to produce presentations that are not dependent on any locally installed software. An important caveat here is that the paths to images must be absolute URLs. I get around this by hosting all of the images myself, meaning I can load the presentations in any web browser. - -#+begin_src emacs-lisp -(use-package ox-reveal - :after ox - :custom (org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")) -#+end_src - -* Shortcuts - -Add a capture tempalte for quickly creating slide presentations with the desired markup and configuration already applied. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-capture-templates - '("s" "Slides" plain (function org-roam-capture--get-point) - "%?" - :file-name "docs/slides/${slug}" - :unnarrowed t - :head -" -,#+TITLE: ${title} -,#+AUTHOR: Christopher James Hayward -,#+EMAIL: chris@chrishayward.xyz - -,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js -,#+REVEAL_THEME: serif - -,#+EXPORT_FILE_NAME: ${slug} - -,#+OPTIONS: reveal_title_slide:nil -,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil -"))) -#+end_src - -* Footnotes - -[fn:1] https://revealjs.com - -[fn:2] https://github.com/hexmode/ox-reveal diff --git a/modules/roam.org b/modules/roam.org deleted file mode 100644 index b8e5015..0000000 --- a/modules/roam.org +++ /dev/null @@ -1,175 +0,0 @@ -#+TITLE: Roam -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle roam.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Plain-text knowledge management system. - -* Setup - -Make sure ~sqlite~ is available on your system: - -#+begin_src shell -RUN apt install sqlite -#+end_src - -* Config - -Configure ~org-roam~[fn:1], a plain-text knowledge management system for Emacs built on top of ~org-mode~. Here's a quick recap of the main principles: - -+ Notes can be arbitrarily referened -+ Contexts created by linking topics and notes - -#+begin_src emacs-lisp -(use-package org-roam - :hook (after-init . org-roam-mode) ;; Lauch roam at startup, big performance cost. - :custom (org-roam-encrypt-files t) ;; Encrypt all roam captures. - (org-roam-directory org-directory) - (org-roam-capture-templates '()) - (org-roam-dailies-capture-templates '())) -#+end_src - -** Files - -The default behaviour of ~org-roam~[fn:1] when creating a title slug is to replace any non alpha numerical (whitespace) to ~_~. I wanted to change this to use ~_~ and have done so here in my own definition. The only substantial difference from the original definition is the character used. - -+ Define a new ~title-to-slug~ function -+ Override ~org-roam-title-to-slug-function~ - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (require 'cl-lib) - (defun dotfiles/title-to-slug (title) - "Convert TITLE to a filename-suitable slug." - (cl-flet* ((nonspacing-mark-p (char) - (eq 'Mn (get-char-code-property char 'general-category))) - (strip-nonspacing-marks (s) - (apply #'string (seq-remove #'nonspacing-mark-p - (ucs-normalize-NFD-string s)))) - (cl-replace (title pair) - (replace-regexp-in-string (car pair) (cdr pair) title))) - (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric. - ("--*" . "-") ;; Remove sequential dashes. - ("^-" . "") ;; Remove starting dashes. - ("-$" . ""))) ;; Remove ending dashes. - (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs))) - (downcase slug)))) - (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug)) -#+end_src - -** Visualizer - -Use the ~org-roam-server~[fn:2] web application to visualize the ~org-roam~[fn:1] database. It's available whenever the editor is running at http://localhost:8080. - -#+begin_src emacs-lisp -(use-package org-roam-server - :after org-roam - :hook (org-roam-mode . org-roam-server-mode)) -#+end_src - -* Templates - -Collection of capture templates for various contexts. Here is one for a generic document. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-capture-templates - '("d" "Default" entry (function org-roam-capture--get-point) - "%?" - :file-name "docs/${slug}" - :unnarrowed t - :head -" -,#+TITLE: ${title} -,#+AUTHOR: Christopher James Hayward -,#+EMAIL: chris@chrishayward.xyz -"))) -#+end_src - -** Course - -Capture template for a new course. Capture with =SPC r c c=. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-capture-templates - '("c" "Course" plain (function org-roam-capture--get-point) - "%?" - :file-name "docs/courses/${slug}" - :unnarrowed t - :head -" -,#+TITLE: ${title} -,#+SUBTITLE: -,#+AUTHOR: Christopher James Hayward -,#+EMAIL: chris@chrishayward.xyz - -,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil -"))) -#+end_src - -** Dailies - -Use the ~daily~ note feature of ~org-roam~[fn:1] to capture daily notes. Create the default capture template with some preconfigured headers. - -#+begin_src emacs-lisp -(with-eval-after-load 'org-roam - (add-to-list 'org-roam-dailies-capture-templates - '("d" "Default" entry (function org-roam-capture--get-point) - "* %?" - :file-name "docs/daily/%<%Y-%m-%d>" - :head -" -,#+TITLE: %<%Y-%m-%d> -,#+AUTHOR: Christopher James Hayward - -,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil -"))) -#+end_src - -* Shortcuts - -Configure custom keybindings for ~org-roam~[fn:1] behind =SPC r=: - -+ Find with =f= -+ Insert with =i= -+ Buffer with =b= -+ Capture with =c= - -#+begin_src emacs-lisp -(dotfiles/leader - "r" '(:ignore t :which-key "Roam") - "ri" '(org-roam-insert :which-key "Insert") - "rf" '(org-roam-find-file :which-key "Find") - "rc" '(org-roam-capture :which-key "Capture") - "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")) -#+end_src - -Place keybindings for daily notes behind =SPC r d=: - -+ Date with =d= -+ Today with =t= -+ Tomorrow with =m= -+ Yesterday with =y= - -#+begin_src emacs-lisp -(dotfiles/leader - "rd" '(:ignore t :which-key "Dailies") - "rdd" '(org-roam-dailies-find-date :which-key "Date") - "rdt" '(org-roam-dailies-find-today :which-key "Today") - "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow") - "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday")) -#+end_src - -* Footnotes - -[fn:1] https://github.com/org-roam/org-roam - -[fn:2] https://github.com/org-roam/org-roam-server diff --git a/modules/shell.org b/modules/shell.org deleted file mode 100644 index bf98500..0000000 --- a/modules/shell.org +++ /dev/null @@ -1,98 +0,0 @@ -#+TITLE: Shell -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle shell.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Shell environment integration. - -* Setup -:PROPERTIES: -:header-args: :tangle ../config/profile :comments org -:END: - -Override the default behaviour of the Shell environment to integrate with Emacs. - -** Force colours - -When using Emacs on the TTY, the colours sometimes will default to 16 or 8 colours, making it look horrible. It's possible to override this behaviour on every platform by manually set the terminal type to =xterm-256color=. - -#+begin_src shell -export TERM=xterm-256color -#+end_src - -** Setting up the $PATH - - Ensure =~/.local/bin= has been added to the ~$PATH~ environment variable, this location is used frequently to deploy local binaries. - -#+begin_src shell -export PATH=$PATH:~/.local/bin -#+end_src - -** Starting Emacs by default on TTY1 - -When launching into a new session on TTY1, if the display server is not running, run ~startx~[fn:1]. This will launch the window manager. - -#+begin_src shell -if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then - exec startx -fi -#+end_src - -** Creating symbolic links - -The system looks for the default shell profile under ~bash~[fn:2] at =~/.profile=. Creating a symbolic link from this location to our configuration will override the startup behaviour. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/profile" - "~/.profile") -#+end_src - -* Methods - -Define methods for interaction between Emacs and the underlying shell environment. - -** Run an external process - -Define a method to run an external process, launching any application on a new process without interferring with Emacs. - -#+begin_src emacs-lisp -(defun dotfiles/run (cmd) - "Run an external process." - (interactive (list (read-shell-command "λ "))) - (start-process-shell-command cmd nil cmd)) -#+end_src - -** Apply command to call process - -Define a method to apply commands to the current call process, this is to avoid issues with hooks but can impact the performance of Emacs. - -#+begin_src emacs-lisp -(defun dotfiles/run-in-background (cmd) - (let ((command-parts (split-string cmd "[ ]+"))) - (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) -#+end_src - -* Shortcuts - -Place keybindings for executing shell commands behind =SPC x=: - -+ Run shell commands with =x= -+ Run async shell commands with =z= - -#+begin_src emacs-lisp -(dotfiles/leader - "x" '(:ignore t :which-key "Run") - "xx" '(dotfiles/run :which-key "Run") - "xz" '(async-shell-command :which-key "Async")) -#+end_src - -* Footnotes - -[fn:1] https://x.org - -[fn:2] https://gnu.org/software/bash/ diff --git a/modules/spelling.org b/modules/spelling.org deleted file mode 100644 index 25e7da9..0000000 --- a/modules/spelling.org +++ /dev/null @@ -1,36 +0,0 @@ -#+TITLE: Spelling -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle spelling.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Real time checking and one-shot methods to check and correct common spelling mistakes. - -* Config - -Configure ~ispell~[fn:1] as a back-end with ~flyspell~[fn:2] for real-time checking and highlighting of spelling mistakes. - -#+begin_src emacs-lisp -(use-package ispell - :after org - :custom (ispell-dictionary dotfiles/lang)) -#+end_src - -* Shortcuts - -Toggle highlighting within buffer specific contexts with =SPC t s=: - -#+begin_src emacs-lisp -(dotfiles/leader - "ts" '(flyspell-buffer :which-key "Spelling")) -#+end_src - -* Footnotes - -[fn:1] https://gnu.org/software/ispell/ - -[fn:2] https://emacswiki.org/emacs/FlySpell diff --git a/modules/themes.org b/modules/themes.org deleted file mode 100644 index ecd58c4..0000000 --- a/modules/themes.org +++ /dev/null @@ -1,48 +0,0 @@ -#+TITLE: Themes -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle themes.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Configure a unified look and feel across the system with modern themes. - -* Setup - -Easily swap between system themes using the ~lxappearance~[fn:1] tool. I tend to default to the ~arc-theme~[fn:2] as it looks really good with most themes. - -#+begin_src shell -RUN apt install -y lxappearance -#+end_src - -* Config - -High quality and modern colour themes are provides inside of Emacs via the ~doom-themes~[fn:3] package. Some of the themes can be further configured, see the documentation for more details. - -#+begin_src emacs-lisp -(use-package doom-themes - :init (load-theme 'doom-moonlight t) - :custom (doom-themes-enable-bold t) - (doom-themes-enable-italic t)) -#+end_src - -* Shortcuts - -Create a custom keybinding for loading a theme with =SPC t t=: - -#+begin_src emacs-lisp -(dotfiles/leader - "tt" '(counsel-load-theme t t :which-key "Theme")) -#+end_src - -* Footnotes - -[fn:1] https://packages.debian.org/sid/lxappearance - -[fn:2] https://packages.debian.org/sid/arc-theme - -[fn:3] https://github.com/hlissner/emacs-doom-themes diff --git a/modules/trash.org b/modules/trash.org deleted file mode 100644 index f3217ba..0000000 --- a/modules/trash.org +++ /dev/null @@ -1,38 +0,0 @@ -#+TITLE: Trash -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle trash.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Keep the system clean of debris. - -* Setup - -Despite having the stateful and immutable configuration seprated, and the entire project under version control, it's still good practice to make efforts to reduce the trash created by Emacs. The package ~no-littering~ helps us achieve just that. - -+ Disable ~tooltip-mode~ -+ Disable ~tool-bar-mode~ -+ Disable ~menu-bar-mode~ -+ Disable ~scroll-bar-mode~ -+ Inhibit the startup message -# + Defer ~native-comp~ compilation -+ Clear the scratch buffer instructions -+ Increase the garbage collector threshold - -#+begin_src emacs-lisp -(use-package no-littering - :custom (inhibit-startup-message t) - (initial-scratch-message "") - ;; (comp-deferred-compilation t) - (gc-cons-threshold most-positive-fixnum) - :config (tooltip-mode -1) - (tool-bar-mode -1) - (menu-bar-mode -1) - (scroll-bar-mode -1)) -#+end_src - -* Footnotes diff --git a/modules/uml.org b/modules/uml.org deleted file mode 100644 index f73aa19..0000000 --- a/modules/uml.org +++ /dev/null @@ -1,55 +0,0 @@ -#+TITLE: UML -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle uml.el :comments org -#+PROPERTY: header-args:shell :tangle no -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -Draw UML[fn:1] diagrams inside Emacs. - -* Setup - -Make sure all of the required components are installed on your system before loading the module. - -#+begin_src shell -RUN apt install -y default-jre -#+end_src - -* Config - -Download and install ~PlantUML~[fn:2], a text-based markup language for creating UML[fn:1] diagrams. You can read my notes about using the software here[fn:3]. Support for Emacs is added through the ~plantuml-mode~[fn:4] package. Configure the ~babel~ language module and structure templates to write diagrams in ~org-mode~ buffers. - -#+begin_src emacs-lisp -(use-package plantuml-mode - :after org - :custom (plantuml-default-exec-mode 'jar) - (plantuml-jar-path "~/.local/bin/plantuml.jar") - (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar")) - (org-startup-with-inline-images t) - :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml)) - (add-to-list 'org-structure-template-alist '("pl" . "src plantuml")) - (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))) -#+end_src - -* Shortcuts - -Toggle inline imagines with =SPC t i=. - -#+begin_src emacs-lisp -(dotfiles/leader - "ti" '(org-toggle-inline-images :which-key "Images")) -#+end_src - -* Footnotes - -[fn:1] https://tutorialspoint.com/uml/uml_standard_diagrams.htm - -[fn:2] https://plantuml.com - -[fn:3] https://chrishayward.xyz/notes/plantuml/ - -[fn:4] https://github.com/skuro/plantuml-mode diff --git a/modules/vterm.org b/modules/vterm.org deleted file mode 100644 index 75d0384..0000000 --- a/modules/vterm.org +++ /dev/null @@ -1,43 +0,0 @@ -#+TITLE: VTerm -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle vterm.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -VTerm is an implementation of libvterm for Emacs. - -* Setup - -Install the dependencies before loading the module. - -#+begin_src shell -RUN apt install -y cmake libtool libtool-bin -#+end_src - -* Config - -I noticed ~eshell~ wasn't enough when needing interactivity from the terminal. Going through [[https://chrishayward.xyz/notes/thinking-in-cpp/][Thinking in C++]] for one of my courses required lots of terminal interaction which ~eshell~ was unable to handle. Since ~vterm~ is based on ~libvterm~, an external C library, it's blazing fast and fully interactive. Add a few configurations: - -+ Always compile the module -+ Install the required packages on *Debian/Ubuntu* - -#+begin_src emacs-lisp -(use-package vterm - :commands (vterm) - :custom (vterm-always-compile-module t)) -#+end_src - -* Shortcuts - -Open a new ~vterm~ buffer with =SPC v=: - -#+begin_src emacs-lisp -(dotfiles/leader - "v" '(vterm-other-window :which-key "VTerm")) -#+end_src - -* Footnotes diff --git a/modules/x11.org b/modules/x11.org deleted file mode 100644 index 8f1d72b..0000000 --- a/modules/x11.org +++ /dev/null @@ -1,165 +0,0 @@ -#+TITLE: X11 -#+AUTHOR: Christopher James Hayward -#+EMAIL: chris@chrishayward.xyz - -#+PROPERTY: header-args:emacs-lisp :tangle x11.el :comments org -#+PROPERTY: header-args :results silent :eval no-export :comments org - -#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil -#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil - -X11[fn:1] is a graphical display manager. - -* Setup - -Install the required software on your system before loading the module. Installing X11[fn:1] without any install recommends may not include all of the packages you need on your system. Make sure you don't need any GNOME software utilities before using this example. - -#+begin_src shell -RUN apt install -y xserver-xorg-core \ - --no-install-recommends \ - --no-install-suggests -#+end_src - -** Displays - -Setup ~autorandr~[fn:2] with pre-configured profiles for screen size and display output. - -#+begin_src shell -RUN apt install autorandr -y -#+end_src - -** Screen locking - -If you want to be able to lock and unlock your screen when you're away from your machine, install ~xss-lock~[fn:3]. By default, it will show a blue screen, turning red if you input your password incorrectly, and returning to your previous screen when successful. - -#+begin_src shell -RUN apt install -y xss-lock slock -#+end_src - -** Desktop compositor - -Download and install ~compton~[fn:4], a desktop compositor for X11[fn:1] that adds shadows, fading, translucency, and implements window frame opacity controls, inactive window transparency, and more. - -#+begin_src shell -RUN apt install -y compton -#+end_src - -** Desktop notifications - -Make sure ~dbus~[fn:5] is installed to receive desktop notifications, it's an IPC system used by lots of utilities. - -#+begin_src shell -RUN apt install -y dbus -#+end_src - -* Config -:PROPERTIES: -:header-args: :tangle ../config/xinitrc :comments org -:END: - -My workflow includes launching Emacs under X11[fn:1] without the use of a display manager, controlling everything within Emacs, while still providing the functionality of a desktop environment. - -#+begin_src conf -compton & -xss-lock -- slock & -exec dbus-launch --exit-with-session emacs -mm --debug-init -#+end_src - -** Create symbolic link - -By default ~xinit~[fn:1] will read the configuration file at =$HOME/.xinitrc=. Override this location with a link to the custom configuration. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/xinitrc" - "~/.xinitrc") -#+end_src - -** Desktop environment - -Use the ~desktop-environment~[fn:6] package to automatically bind well-known programs for controlling the volume, brightness, media playback, and many other XF86 functionality bindings. - -#+begin_src emacs-lisp -(use-package desktop-environment - :after exwm - :custom (desktop-environment-brightness-small-increment "2%+") - (desktop-environment-brightness-small-decrement "2%-") - (desktop-environment-brightness-normal-decrement "5%-") - (desktop-environment-brightness-normal-decrement "5%-") - (desktop-environment-volume-small-increment "2%+") - (desktop-environment-volume-small-decrement "2%-") - (desktop-environment-volume-normal-increment "5%+") - (desktop-environment-volume-normal-decrement "5%-") - :config (desktop-environment-mode)) -#+end_src - -** Swapping CAPS and CTRL -:PROPERTIES: -:header-args: conf :tangle ../config/xmodmap -:END: - -Use ~Xmodmap~[fn:7] to swap CapsLock and Ctrl to keep common bindings on the home row. - -#+begin_src conf -clear lock -clear control - -keycode 66 = Control_L - -add control = Control_L -add Lock = Control_R -#+end_src - -Override the configuration file. - -#+begin_src emacs-lisp -(dotfiles/symlink "~/.emacs.d/config/xmodmap" - "~/.Xmodmap") -#+end_src - -** Frame transparency - -Emacs supports frame transparency when running under the X Window System[fn:1]. - -#+begin_src emacs-lisp -(defun dotfiles/toggle-transparency () - (interactive) - (let ((alpha (frame-parameter nil 'alpha))) - (set-frame-parameter nil 'alpha - (if (eql (cond ((numberp alpha) alpha) - ((numberp (cdr alpha)) (cdr alpha)) - ((numberp (cadr alpha)) (cadr alpha))) - 100) - '(85 . 80) '(100 . 100))))) -#+end_src - -Enable frame transparency by default. - -#+begin_src emacs-lisp -(set-frame-parameter (selected-frame) 'alpha '(85 . 80)) -(add-to-list 'default-frame-alist '(alpha . (85 . 80))) -#+end_src - -* Shortcuts - -Toggle frame transparency with =SPC t r=. - -#+begin_src emacs-lisp -(dotfiles/leader - "tr" '(dotfiles/toggle-transparency :which-key "Transparency")) -#+end_src - -* Footnotes - -[fn:1] https://en.wikipedia.org/wiki/X_Window_System - -[fn:2] https://github.com/phillipberndt/autorandr - -[fn:3] https://man.archlinux.org/man/xss-lock.1 - -[fn:4] https://github.com/chjj/compton - -[fn:5] https://packages.debian.org/stretch/dbus-x11 - -[fn:6] https://github.com/DamienCassou/desktop-environment - -[fn:7] https://wiki.archlinux.org/title/Xmodmap