From 2ece7032558cd0be673d65237a01c5e6ffe625f1 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 19 Nov 2022 15:21:44 +0000 Subject: Move to a GNU Stow config --- afew/.config/afew/config | 72 ++ afew/config | 72 -- alacritty/.config/alacritty/alacritty.yml | 143 +++ alacritty/alacritty.yml | 143 --- bspwm/.config/bspwmrc/bspwmrc | 16 + bspwm/bspwmrc | 16 - compton/.config/compton/compton.conf | 69 ++ compton/compton.conf | 69 -- doom/.config/doom/abbrev-defs | 9 + doom/.config/doom/config.org | 1409 +++++++++++++++++++++++++++++ doom/.config/doom/init.el | 188 ++++ doom/.config/doom/packages.el | 75 ++ doom/abbrev-defs | 9 - doom/config.org | 1409 ----------------------------- doom/init.el | 188 ---- doom/packages.el | 75 -- emacs/.config/emacs/init.el | 19 + emacs/.config/emacs/loader.org | 1268 ++++++++++++++++++++++++++ emacs/init.el | 19 - emacs/loader.org | 1268 -------------------------- firefox/.config/firefox/userChrome.css | 1 + firefox/userChrome.css | 1 - fish/.config/fish/config.fish | 36 + fish/config.fish | 36 - i3/.config/i3/config | 226 +++++ i3/.config/i3/i3exit | 30 + i3/config | 226 ----- i3/i3exit | 30 - mpd/.config/mpd/mpd.conf | 29 + mpd/mpd.conf | 29 - msmtp/.config/msmtp/config | 27 + msmtp/config | 27 - ncmpcpp/.config/ncmpcpp/bindings | 559 ++++++++++++ ncmpcpp/.config/ncmpcpp/config | 11 + ncmpcpp/bindings | 559 ------------ ncmpcpp/config | 11 - polybar/.config/polybar/config | 490 ++++++++++ polybar/.config/polybar/launch.sh | 13 + polybar/config | 490 ---------- polybar/launch.sh | 13 - rofi/.config/rofi/config | 5 + sway/.config/sway/config | 226 +++++ sway/config | 226 ----- sxhkd/.config/sxhkd/sxhkdrc | 159 ++++ sxhkd/sxhkdrc | 159 ---- termite/.config/termite/config | 117 +++ termite/config | 117 --- vim/.config/vim/init.vim | 5 + vim/init.vim | 5 - zathura/.config/zathura/zathurarc | 28 + zathura/zathurarc | 28 - 51 files changed, 5230 insertions(+), 5225 deletions(-) create mode 100644 afew/.config/afew/config delete mode 100644 afew/config create mode 100644 alacritty/.config/alacritty/alacritty.yml delete mode 100644 alacritty/alacritty.yml create mode 100755 bspwm/.config/bspwmrc/bspwmrc delete mode 100755 bspwm/bspwmrc create mode 100644 compton/.config/compton/compton.conf delete mode 100644 compton/compton.conf create mode 100644 doom/.config/doom/abbrev-defs create mode 100644 doom/.config/doom/config.org create mode 100644 doom/.config/doom/init.el create mode 100644 doom/.config/doom/packages.el delete mode 100644 doom/abbrev-defs delete mode 100644 doom/config.org delete mode 100644 doom/init.el delete mode 100644 doom/packages.el create mode 100644 emacs/.config/emacs/init.el create mode 100644 emacs/.config/emacs/loader.org delete mode 100644 emacs/init.el delete mode 100644 emacs/loader.org create mode 100644 firefox/.config/firefox/userChrome.css delete mode 100644 firefox/userChrome.css create mode 100644 fish/.config/fish/config.fish delete mode 100644 fish/config.fish create mode 100644 i3/.config/i3/config create mode 100755 i3/.config/i3/i3exit delete mode 100644 i3/config delete mode 100755 i3/i3exit create mode 100644 mpd/.config/mpd/mpd.conf delete mode 100644 mpd/mpd.conf create mode 100644 msmtp/.config/msmtp/config delete mode 100644 msmtp/config create mode 100644 ncmpcpp/.config/ncmpcpp/bindings create mode 100644 ncmpcpp/.config/ncmpcpp/config delete mode 100644 ncmpcpp/bindings delete mode 100644 ncmpcpp/config create mode 100644 polybar/.config/polybar/config create mode 100755 polybar/.config/polybar/launch.sh delete mode 100644 polybar/config delete mode 100755 polybar/launch.sh create mode 100644 rofi/.config/rofi/config create mode 100644 sway/.config/sway/config delete mode 100644 sway/config create mode 100644 sxhkd/.config/sxhkd/sxhkdrc delete mode 100644 sxhkd/sxhkdrc create mode 100644 termite/.config/termite/config delete mode 100644 termite/config create mode 100644 vim/.config/vim/init.vim delete mode 100644 vim/init.vim create mode 100644 zathura/.config/zathura/zathurarc delete mode 100644 zathura/zathurarc diff --git a/afew/.config/afew/config b/afew/.config/afew/config new file mode 100644 index 0000000..9f08b39 --- /dev/null +++ b/afew/.config/afew/config @@ -0,0 +1,72 @@ +[MailMover] +folders = mailbox/Inbox mailbox/Trash mailbox/Spam +rename = True +max_age = 15 +mailbox/Inbox = 'not tag:inbox or tag:archive':mailbox/Archive 'tag:spam':mailbox/Spam 'tag:deleted':mailbox/Trash +mailbox/Trash = 'not tag:deleted and tag:inbox':mailbox/Inbox 'not tag:deleted and tag:spam':mailbox/Spam 'not tag:deleted and tag:archive':mailbox/Archive +mailbox/Spam = 'not tag:spam and tag:inbox':mailbox/Inbox 'not tag:spam and tag:deleted':mailbox/Trash 'not tag:spam and tag:archive':mailbox/Archive + +[SpamFilter] + +[KillThreadsFilter] + +[ListMailsFilter] + +[ArchiveSentMailsFilter] + +[FolderNameFilter] +folder_transforms = "Sent Items":sent "Archive1":archive "Deleted Items":deleted Trash:deleted +maildir_separator = / +folder_lowercases = True + +[HeaderMatchingFilter.1] +header = To +pattern = (?P[a-zA-Z.]*)@ymhg\.org +tags = +{name} + +[HeaderMatchingFilter.2] +header = To +pattern = +tags = -inbox;-new;+git;+langproc + +[Filter.1] +message = Remove temporary Anacron messages. +query = from:"anacron" or from:"cron daemon" +tags = -new;-inbox;+cron + +[Filter.2] +message = Remove call for paper spam. +query = (subject:call and (subject:"papers?" or subject:"sessions?")) or from:saiconference.com +tags = -new;-inbox;+callforpaper + +[Filter.3] +message = Remove IEEE messages. +query = from:"^IEEE" +tags = -new;-inbox;+ieee + +[Filter.4] +message = Imperial noise. +query = from:"library notices" or from:"Fownes, Joanna" or from:"Victoria Scott" or from:"Graduate School " or from:"ACM Learning Center" or from:"CGCU Secretary" or from:"DoCSoc" or subject:"^[HiPEAC Members]" or (subject:"^Your Casual pay form for" or subject:"^claim for") or from:"email.teams.microsoft.com" +tags = -new;-inbox;+imperial-noise + +[Filter.5] +message = Clean up mailbox. +query = tag:sircmpwn-public-inbox +tags = -sircmpwn-public-inbox;+lists;+lists/~sircmpwn/public-inbox + +[Filter.6] +message = New Yorker clean up +query = from:"newyorker@newsletter.newyorker.com" +tags = -new;-inbox;+newyorker + +[Filter.7] +message = Clean up clutter. +query = tag:postmaster or tag:amazon.co.uk or tag:shopping +tags = -inbox;-new;-unread;+clutter + +[Filter.8] +message = Clean up mailing lists from inbox +query = tag:lists +tags = -inbox;-new + +[InboxFilter] diff --git a/afew/config b/afew/config deleted file mode 100644 index 9f08b39..0000000 --- a/afew/config +++ /dev/null @@ -1,72 +0,0 @@ -[MailMover] -folders = mailbox/Inbox mailbox/Trash mailbox/Spam -rename = True -max_age = 15 -mailbox/Inbox = 'not tag:inbox or tag:archive':mailbox/Archive 'tag:spam':mailbox/Spam 'tag:deleted':mailbox/Trash -mailbox/Trash = 'not tag:deleted and tag:inbox':mailbox/Inbox 'not tag:deleted and tag:spam':mailbox/Spam 'not tag:deleted and tag:archive':mailbox/Archive -mailbox/Spam = 'not tag:spam and tag:inbox':mailbox/Inbox 'not tag:spam and tag:deleted':mailbox/Trash 'not tag:spam and tag:archive':mailbox/Archive - -[SpamFilter] - -[KillThreadsFilter] - -[ListMailsFilter] - -[ArchiveSentMailsFilter] - -[FolderNameFilter] -folder_transforms = "Sent Items":sent "Archive1":archive "Deleted Items":deleted Trash:deleted -maildir_separator = / -folder_lowercases = True - -[HeaderMatchingFilter.1] -header = To -pattern = (?P[a-zA-Z.]*)@ymhg\.org -tags = +{name} - -[HeaderMatchingFilter.2] -header = To -pattern = -tags = -inbox;-new;+git;+langproc - -[Filter.1] -message = Remove temporary Anacron messages. -query = from:"anacron" or from:"cron daemon" -tags = -new;-inbox;+cron - -[Filter.2] -message = Remove call for paper spam. -query = (subject:call and (subject:"papers?" or subject:"sessions?")) or from:saiconference.com -tags = -new;-inbox;+callforpaper - -[Filter.3] -message = Remove IEEE messages. -query = from:"^IEEE" -tags = -new;-inbox;+ieee - -[Filter.4] -message = Imperial noise. -query = from:"library notices" or from:"Fownes, Joanna" or from:"Victoria Scott" or from:"Graduate School " or from:"ACM Learning Center" or from:"CGCU Secretary" or from:"DoCSoc" or subject:"^[HiPEAC Members]" or (subject:"^Your Casual pay form for" or subject:"^claim for") or from:"email.teams.microsoft.com" -tags = -new;-inbox;+imperial-noise - -[Filter.5] -message = Clean up mailbox. -query = tag:sircmpwn-public-inbox -tags = -sircmpwn-public-inbox;+lists;+lists/~sircmpwn/public-inbox - -[Filter.6] -message = New Yorker clean up -query = from:"newyorker@newsletter.newyorker.com" -tags = -new;-inbox;+newyorker - -[Filter.7] -message = Clean up clutter. -query = tag:postmaster or tag:amazon.co.uk or tag:shopping -tags = -inbox;-new;-unread;+clutter - -[Filter.8] -message = Clean up mailing lists from inbox -query = tag:lists -tags = -inbox;-new - -[InboxFilter] diff --git a/alacritty/.config/alacritty/alacritty.yml b/alacritty/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..5eb81a8 --- /dev/null +++ b/alacritty/.config/alacritty/alacritty.yml @@ -0,0 +1,143 @@ +font: + size: 11 + normal: + family: Iosevka YMHG + style: Medium + bold: + family: Iosevka YMHG + style: Bold + italic: + family: Iosevka YMHG + style: Italic + +window: + decorations: none + padding: + x: 10 + y: 10 + +schemes: + modus-operandi: &light + # Default colors + primary: + background: '#ffffff' + foreground: '#000000' + + dim_foreground: '#282828' + bright_foreground: '#505050' + dim_background: '#f8f8f8' + bright_background: '#f0f0f0' + + # Cursor colors + cursor: + text: '#ffffff' + cursor: '#721045' + + # Normal colors + normal: + black: '#000000' + red: '#a60000' + green: '#005e00' + yellow: '#813e00' + blue: '#0030a6' + magenta: '#721045' + cyan: '#00538b' + white: '#ffffff' + + # Bright colors + bright: + black: '#505050' + red: '#972500' + green: '#315b00' + yellow: '#70480f' + blue: '#223fbf' + magenta: '#8f0075' + cyan: '#30517f' + white: '#f0f0f0' + + # Dim colors + dim: + black: '#282828' + red: '#a0132f' + green: '#145c33' + yellow: '#863927' + blue: '#0000bb' + magenta: '#5317ac' + cyan: '#005a5f' + white: '#f8f8f8' + + modus-vivendi: &dark + # Default colors + primary: + background: '#000000' + foreground: '#ffffff' + + dim_foreground: '#e0e6f0' + bright_foreground: '#a8a8a8' + dim_background: '#110b11' + bright_background: '#181a20' + + # Cursor colors + cursor: + text: '#000000' + cursor: '#feacd0' + + # Normal colors + normal: + black: '#ffffff' + red: '#ff8059' + green: '#44bc44' + yellow: '#eecc00' + blue: '#29aeff' + magenta: '#feacd0' + cyan: '#00d3d0' + white: '#000000' + + # Bright colors + bright: + black: '#a8a8a8' + red: '#f4923b' + green: '#80d200' + yellow: '#cfdf30' + blue: '#72a4ff' + magenta: '#f78fe7' + cyan: '#4ae8fc' + white: '#181a20' + + # Dim colors + dim: + black: '#e0e6f0' + red: '#ff9977' + green: '#00cd68' + yellow: '#f0ce43' + blue: '#00bdfa' + magenta: '#b6a0ff' + cyan: '#6ae4b9' + white: '#110b11' + +colors: *dark + +key_bindings: +- { key: A, mods: Command, chars: "\x1ba" } +- { key: B, mods: Command, chars: "\x1bb" } +- { key: D, mods: Command, chars: "\x1bd" } +- { key: E, mods: Command, chars: "\x1be" } +- { key: F, mods: Command, chars: "\x1bf" } +- { key: G, mods: Command, chars: "\x1bg" } +- { key: H, mods: Command, chars: "\x1bh" } +- { key: I, mods: Command, chars: "\x1bi" } +- { key: J, mods: Command, chars: "\x1bj" } +- { key: K, mods: Command, chars: "\x1bk" } +- { key: L, mods: Command, chars: "\x1bl" } +- { key: M, mods: Command, chars: "\x1bm" } +- { key: N, mods: Command, chars: "\x1bn" } +- { key: O, mods: Command, chars: "\x1bo" } +- { key: P, mods: Command, chars: "\x1bp" } +- { key: R, mods: Command, chars: "\x1br" } +- { key: S, mods: Command, chars: "\x1bs" } +- { key: T, mods: Command, chars: "\x1bt" } +- { key: U, mods: Command, chars: "\x1bu" } +- { key: W, mods: Command, chars: "\x1bw" } +- { key: X, mods: Command, chars: "\x1bx" } +- { key: Y, mods: Command, chars: "\x1by" } +- { key: Z, mods: Command, chars: "\x1bz" } diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml deleted file mode 100644 index 5eb81a8..0000000 --- a/alacritty/alacritty.yml +++ /dev/null @@ -1,143 +0,0 @@ -font: - size: 11 - normal: - family: Iosevka YMHG - style: Medium - bold: - family: Iosevka YMHG - style: Bold - italic: - family: Iosevka YMHG - style: Italic - -window: - decorations: none - padding: - x: 10 - y: 10 - -schemes: - modus-operandi: &light - # Default colors - primary: - background: '#ffffff' - foreground: '#000000' - - dim_foreground: '#282828' - bright_foreground: '#505050' - dim_background: '#f8f8f8' - bright_background: '#f0f0f0' - - # Cursor colors - cursor: - text: '#ffffff' - cursor: '#721045' - - # Normal colors - normal: - black: '#000000' - red: '#a60000' - green: '#005e00' - yellow: '#813e00' - blue: '#0030a6' - magenta: '#721045' - cyan: '#00538b' - white: '#ffffff' - - # Bright colors - bright: - black: '#505050' - red: '#972500' - green: '#315b00' - yellow: '#70480f' - blue: '#223fbf' - magenta: '#8f0075' - cyan: '#30517f' - white: '#f0f0f0' - - # Dim colors - dim: - black: '#282828' - red: '#a0132f' - green: '#145c33' - yellow: '#863927' - blue: '#0000bb' - magenta: '#5317ac' - cyan: '#005a5f' - white: '#f8f8f8' - - modus-vivendi: &dark - # Default colors - primary: - background: '#000000' - foreground: '#ffffff' - - dim_foreground: '#e0e6f0' - bright_foreground: '#a8a8a8' - dim_background: '#110b11' - bright_background: '#181a20' - - # Cursor colors - cursor: - text: '#000000' - cursor: '#feacd0' - - # Normal colors - normal: - black: '#ffffff' - red: '#ff8059' - green: '#44bc44' - yellow: '#eecc00' - blue: '#29aeff' - magenta: '#feacd0' - cyan: '#00d3d0' - white: '#000000' - - # Bright colors - bright: - black: '#a8a8a8' - red: '#f4923b' - green: '#80d200' - yellow: '#cfdf30' - blue: '#72a4ff' - magenta: '#f78fe7' - cyan: '#4ae8fc' - white: '#181a20' - - # Dim colors - dim: - black: '#e0e6f0' - red: '#ff9977' - green: '#00cd68' - yellow: '#f0ce43' - blue: '#00bdfa' - magenta: '#b6a0ff' - cyan: '#6ae4b9' - white: '#110b11' - -colors: *dark - -key_bindings: -- { key: A, mods: Command, chars: "\x1ba" } -- { key: B, mods: Command, chars: "\x1bb" } -- { key: D, mods: Command, chars: "\x1bd" } -- { key: E, mods: Command, chars: "\x1be" } -- { key: F, mods: Command, chars: "\x1bf" } -- { key: G, mods: Command, chars: "\x1bg" } -- { key: H, mods: Command, chars: "\x1bh" } -- { key: I, mods: Command, chars: "\x1bi" } -- { key: J, mods: Command, chars: "\x1bj" } -- { key: K, mods: Command, chars: "\x1bk" } -- { key: L, mods: Command, chars: "\x1bl" } -- { key: M, mods: Command, chars: "\x1bm" } -- { key: N, mods: Command, chars: "\x1bn" } -- { key: O, mods: Command, chars: "\x1bo" } -- { key: P, mods: Command, chars: "\x1bp" } -- { key: R, mods: Command, chars: "\x1br" } -- { key: S, mods: Command, chars: "\x1bs" } -- { key: T, mods: Command, chars: "\x1bt" } -- { key: U, mods: Command, chars: "\x1bu" } -- { key: W, mods: Command, chars: "\x1bw" } -- { key: X, mods: Command, chars: "\x1bx" } -- { key: Y, mods: Command, chars: "\x1by" } -- { key: Z, mods: Command, chars: "\x1bz" } diff --git a/bspwm/.config/bspwmrc/bspwmrc b/bspwm/.config/bspwmrc/bspwmrc new file mode 100755 index 0000000..d27a070 --- /dev/null +++ b/bspwm/.config/bspwmrc/bspwmrc @@ -0,0 +1,16 @@ +#!/bin/sh + +bspc monitor DP-1 -d term web code music +bspc monitor DP-2 -d 5 6 7 +bspc monitor DVI-1-0 -d 8 9 + +bspc config border_width 0 +bspc config window_gap 5 + +bspc config split_ratio 0.52 +bspc config borderless_monocle true +bspc config gapless_monocle true + +bspc rule -a Emacs state=tiled + +$HOME/.config/polybar/launch.sh diff --git a/bspwm/bspwmrc b/bspwm/bspwmrc deleted file mode 100755 index d27a070..0000000 --- a/bspwm/bspwmrc +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -bspc monitor DP-1 -d term web code music -bspc monitor DP-2 -d 5 6 7 -bspc monitor DVI-1-0 -d 8 9 - -bspc config border_width 0 -bspc config window_gap 5 - -bspc config split_ratio 0.52 -bspc config borderless_monocle true -bspc config gapless_monocle true - -bspc rule -a Emacs state=tiled - -$HOME/.config/polybar/launch.sh diff --git a/compton/.config/compton/compton.conf b/compton/.config/compton/compton.conf new file mode 100644 index 0000000..8829cae --- /dev/null +++ b/compton/.config/compton/compton.conf @@ -0,0 +1,69 @@ +shadow = false; +no-dnd-shadow = true; +no-dock-shadow = false; +clear-shadow = true; +shadow-radius = 0; +shadow-offset-x = -7; +shadow-offset-y = -7; +shadow-opacity = 0.7; +shadow-red = 0.0; +shadow-green = 0.0; +shadow-blue = 0.0; +shadow-exclude = [ "name = 'Notification'", "class_g = 'Conky'", "class_g ?= 'Notify-osd'", "class_g = 'Cairo-clock'" ]; +shadow-ignore-shaped = false; +menu-opacity = 0.8; +inactive-opacity = 1.0; +active-opacity = 1.0; +frame-opacity = 0.3; +inactive-opacity-override = false; +alpha-step = 0.06; +inactive-dim = 0.0; +#blur-kern = "3x3box"; +resize-damage = 10; +blur-background-exclude = [ "window_type = 'desktop'" ]; +fading = false; +fade-in-step = 0.3; +fade-out-step = 0.3; +fade-exclude = [ ]; +backend = "glx"; +mark-wmwin-focused = true; +mark-ovredir-focused = true; +detect-rounded-corners = true; +detect-client-opacity = true; +refresh-rate = 0; +vsync = "none"; +dbe = false; +paint-on-overlay = true; +focus-exclude = [ "class_g = 'Cairo-clock'" ]; +detect-transient = true; +detect-client-leader = true; +invert-color-include = [ ]; +glx-copy-from-front = false; +glx-swap-method = "undefined"; +glx-no-stencil= true; +wintypes : +{ + tooltip : + { + fade = true; + shadow = false; + opacity = 0.75; + focus = true; + }; +}; +blur-background = true; +blur-background-frame = true; +blur-method = "kawase"; +blur-strength = 15; +opacity-rule = [ + "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'", + "0:_NET_WM_STATE@[1]:32a = '_NET_WM_STATE_HIDDEN'", + "0:_NET_WM_STATE@[2]:32a = '_NET_WM_STATE_HIDDEN'", + "0:_NET_WM_STATE@[3]:32a = '_NET_WM_STATE_HIDDEN'", + "0:_NET_WM_STATE@[4]:32a = '_NET_WM_STATE_HIDDEN'", + "50:class_g *?= 'Rofi'", + "70:class_g *?= 'XTerm'", + "50:class_g *?= 'Polybar'", + "70:class_g *?= 'st-256color'", + "99:class_g = 'mpv'" +]; diff --git a/compton/compton.conf b/compton/compton.conf deleted file mode 100644 index 8829cae..0000000 --- a/compton/compton.conf +++ /dev/null @@ -1,69 +0,0 @@ -shadow = false; -no-dnd-shadow = true; -no-dock-shadow = false; -clear-shadow = true; -shadow-radius = 0; -shadow-offset-x = -7; -shadow-offset-y = -7; -shadow-opacity = 0.7; -shadow-red = 0.0; -shadow-green = 0.0; -shadow-blue = 0.0; -shadow-exclude = [ "name = 'Notification'", "class_g = 'Conky'", "class_g ?= 'Notify-osd'", "class_g = 'Cairo-clock'" ]; -shadow-ignore-shaped = false; -menu-opacity = 0.8; -inactive-opacity = 1.0; -active-opacity = 1.0; -frame-opacity = 0.3; -inactive-opacity-override = false; -alpha-step = 0.06; -inactive-dim = 0.0; -#blur-kern = "3x3box"; -resize-damage = 10; -blur-background-exclude = [ "window_type = 'desktop'" ]; -fading = false; -fade-in-step = 0.3; -fade-out-step = 0.3; -fade-exclude = [ ]; -backend = "glx"; -mark-wmwin-focused = true; -mark-ovredir-focused = true; -detect-rounded-corners = true; -detect-client-opacity = true; -refresh-rate = 0; -vsync = "none"; -dbe = false; -paint-on-overlay = true; -focus-exclude = [ "class_g = 'Cairo-clock'" ]; -detect-transient = true; -detect-client-leader = true; -invert-color-include = [ ]; -glx-copy-from-front = false; -glx-swap-method = "undefined"; -glx-no-stencil= true; -wintypes : -{ - tooltip : - { - fade = true; - shadow = false; - opacity = 0.75; - focus = true; - }; -}; -blur-background = true; -blur-background-frame = true; -blur-method = "kawase"; -blur-strength = 15; -opacity-rule = [ - "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'", - "0:_NET_WM_STATE@[1]:32a = '_NET_WM_STATE_HIDDEN'", - "0:_NET_WM_STATE@[2]:32a = '_NET_WM_STATE_HIDDEN'", - "0:_NET_WM_STATE@[3]:32a = '_NET_WM_STATE_HIDDEN'", - "0:_NET_WM_STATE@[4]:32a = '_NET_WM_STATE_HIDDEN'", - "50:class_g *?= 'Rofi'", - "70:class_g *?= 'XTerm'", - "50:class_g *?= 'Polybar'", - "70:class_g *?= 'st-256color'", - "99:class_g = 'mpv'" -]; diff --git a/doom/.config/doom/abbrev-defs b/doom/.config/doom/abbrev-defs new file mode 100644 index 0000000..b9b6d7e --- /dev/null +++ b/doom/.config/doom/abbrev-defs @@ -0,0 +1,9 @@ +;;-*-coding: utf-8;-*- +(define-abbrev-table 'global-abbrev-table + '( + ("alth" "although" nil :count 1) + ("bc" "because" nil :count 0) + ("th" "though" nil :count 0) + ("vc" "Vericert" nil :count 0) + )) + diff --git a/doom/.config/doom/config.org b/doom/.config/doom/config.org new file mode 100644 index 0000000..6b9534b --- /dev/null +++ b/doom/.config/doom/config.org @@ -0,0 +1,1409 @@ +#+title: Org configuration +#+property: header-args:emacs-lisp :tangle config.el + +* Top-Level Configuration + +#+begin_src emacs-lisp +(setq doom-font (font-spec :family "Iosevka YMHG Medium" :size 16)) +(when (eq system-type 'darwin) + (setq doom-variable-pitch-font (font-spec :family "Alegreya" :size 20)) + (setq doom-serif-font (font-spec :family "Alegreya" :size 20))) +#+end_src + +#+begin_src emacs-lisp +(setq org-directory "~/Dropbox/org/") + +(setq display-line-numbers-type nil) +;; Remove the ring for emacs +(setq ring-bell-function 'ignore) +;; Automatically refresh files +(global-auto-revert-mode 1) +(setq auto-revert-verbose nil) + +;; Set sentence to end with double space +(setq sentence-end-double-space t) +;; Remove automatic `auto-fill-mode', and replace it by `visual-line-mode', which is a personal +;; preference. +(setq-default fill-column 100) +;;(remove-hook 'text-mode-hook #'auto-fill-mode) +(add-hook 'text-mode-hook #'auto-fill-mode) +;;(add-hook 'text-mode-hook #'+word-wrap-mode) +;;(add-hook 'text-mode-hook #'visual-fill-column-mode) +;;;; Removes performance problems with opening coq files. +(add-to-list 'doom-detect-indentation-excluded-modes 'coq-mode) + +;; Projectile compilation buffer not there anymore for some reason +(setq compilation-buffer-name-function #'compilation--default-buffer-name) + +;; optimisations from https://200ok.ch/posts/2020-09-29_comprehensive_guide_on_handling_long_lines_in_emacs.html +(setq-default bidi-paragraph-direction 'left-to-right) +(if (version<= "27.1" emacs-version) + (setq bidi-inhibit-bpa t)) + +(setq abbrev-file-name + "~/.config/doom/abbrev-defs") +(add-hook 'text-mode-hook #'abbrev-mode) +#+end_src + +#+begin_src emacs-lisp +(use-package ef-themes + :defer nil + :bind ("" . ef-themes-select) + :config + (custom-theme-set-faces! ef-themes-collection + '(proof-locked-face :inherit hl-line) + '(proof-queue-face :inherit region)) + (setq ef-themes-height-0 2.0736 + ef-themes-height-1 1.728 + ef-themes-height-2 1.44 + ef-themes-height-3 1.2 + ef-themes-height-4 1.0 + ef-themes-height-5 1.0 + ef-themes-height-6 1.0 + ef-themes-height-7 1.0 + ef-themes-height-8 1.0) + (setq doom-theme 'ef-autumn)) + +(use-package modus-themes + :defer nil + :init + ;; Add all your customizations prior to loading the themes + (setq modus-themes-region '(bg-only no-extend)) + + ;; Load the theme files before enabling a theme + (modus-themes-load-themes) + (custom-theme-set-faces! '(modus-vivendi modus-operandi) + '(proof-locked-face :inherit modus-themes-nuanced-cyan) + '(proof-queue-face :inherit modus-themes-nuanced-magenta)) + :config + ;; Load the theme of your choice: + ;;(modus-themes-load-operandi) ;; OR (modus-themes-load-vivendi) + ;;:bind ("" . modus-themes-toggle)) + ) +#+end_src + +#+begin_src emacs-lisp +;; Disable stuff +(global-prettify-symbols-mode -1) +(electric-indent-mode -1) +(menu-bar-mode -1) + +(add-hook 'text-mode-hook (lambda () (company-mode -1))) +#+end_src + +#+begin_src emacs-lisp +(use-package! projectile + :config + (add-to-list 'projectile-globally-ignored-directories ".direnv")) +#+end_src + +** Key Binding Customisations + +#+begin_src emacs-lisp +;; Stop emacs from freezing when trying to minimize it on a tiling WM. +(global-unset-key (kbd "C-z")) +(global-set-key (kbd "M-u") #'upcase-dwim) +(global-set-key (kbd "M-l") #'downcase-dwim) +(global-set-key (kbd "M-c") #'capitalize-dwim) +(global-set-key (kbd "C-c z") #'quick-calc) +(global-set-key (kbd "") #'revert-buffer) +(global-set-key (kbd "C-.") (lambda () (interactive) (other-window -1))) +(global-set-key (kbd "C-,") #'other-window) +(global-set-key (kbd "C-c l") #'org-store-link) +(global-set-key (kbd "C-c a") #'org-agenda) +(global-set-key (kbd "C-c /") #'avy-goto-word-1) +(global-set-key (kbd "M-=") #'count-words) +(global-set-key (kbd "C-x m") #'+notmuch/compose) +(global-set-key (kbd "C-M-x") #'scroll-other-window-down) + +;; Set undo-only correctly +(global-set-key (kbd "C-\\") 'undo-only) + +;; Revert C-a and C-e to go to the beginning and end of line, not a fan of the +;; default smart functions. +(global-set-key (kbd "C-a") #'beginning-of-line) +(global-set-key (kbd "C-e") #'end-of-line) + +;; Define functions to push and pop from mark. +(defun push-mark-no-activate () + "Pushes `point' to `mark-ring' and does not activate the region + Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" + (interactive) + (push-mark (point) t nil) + (message "Pushed mark to ring")) + +(defun jump-to-mark () + "Jumps to the local mark, respecting the `mark-ring' order. + This is the same as using \\[set-mark-command] with the prefix argument." + (interactive) + (set-mark-command 1)) + +(global-set-key (kbd "C-`") #'push-mark-no-activate) +(global-set-key (kbd "M-`") #'jump-to-mark) + +;; Swap two window positions. +(defun y/swap-windows () + "Swaps two windows and leaves the cursor in the original one" + (interactive) + (ace-swap-window) + (aw-flip-window)) + +(defun ymhg/pass (query) + "Return the password as a string from QUERY." + (s-trim (shell-command-to-string (concat "pass show " query)))) + +;; Define a custom key map for other useful commands. +(define-prefix-command 'y-map) +(global-set-key (kbd "C-c y") 'y-map) + +(define-key y-map (kbd "p") #'password-store-copy) +(define-key y-map (kbd "q") #'password-store-otp-token-copy) +(define-key y-map (kbd "i") #'password-store-insert) +(define-key y-map (kbd "g") #'password-store-generate) +;(define-key y-map (kbd "r") #'toggle-rot13-mode) +(define-key y-map (kbd "c") #'calendar) +(define-key y-map (kbd "C-r") #'ymhg/reload-keywords) +(define-key y-map (kbd "d") #'y/insert-date) +(define-key y-map (kbd "C-g") #'org-zettelkasten-goto-id) +(define-key y-map (kbd "C-t") #'org-babel-detangle) +(define-key y-map (kbd "C-l") #'org-agenda-open-link) +(define-key y-map (kbd "C-p") #'org-previous-link) +(define-key y-map (kbd "C-n") #'org-next-link) +(define-key y-map (kbd "s") + (lambda () (interactive) + (let ((org-agenda-files + '("~/Dropbox/zk/hls.org" + "~/Dropbox/zk/computing.org" + "~/Dropbox/zk/verification.org" + "~/Dropbox/zk/mathematics.org" + "~/Dropbox/zk/hardware.org"))) (org-search-view)))) + +(setq browse-url-handlers + '(("wikipedia\\.org" . eww-browse-url) + ("yannherklotz\\.com" . eww-browse-url) + ("ymhg\\.org" . eww-browse-url) + ("archlinux\\.org" . eww-browse-url) + ("sachachua\\.com" . eww-browse-url) + ("comonad\\.com" . eww-browse-url) + ("drewdevault\\.com" . eww-browse-url) + ("wordpress\\.com" . eww-browse-url) + ("mathbabe\\.org" . eww-browse-url) + ("ethz\\.ch" . eww-browse-url) + ("pragmaticemacs\\.com" . eww-browse-url))) + +(defun y/insert-date () + "Insert a timestamp according to locale's date and time format." + (interactive) + (insert (format-time-string "%c" (current-time)))) +#+end_src + +** Mac Specific Customisations + +#+begin_src emacs-lisp +;; Mac configuration +(when (eq system-type 'darwin) + (progn (setq mac-right-option-modifier 'none + mac-command-modifier 'meta + mac-option-modifier nil) + + (defun ymhg/apply-theme (appearance) + "Load theme, taking current system APPEARANCE into consideration." + (mapc #'disable-theme custom-enabled-themes) + (pcase appearance + ('light (load-theme 'ef-day t)) + ('dark (load-theme 'ef-autumn t)))) + + (add-hook 'ns-system-appearance-change-functions #'ymhg/apply-theme))) +#+end_src + +** Backup Settings + +#+begin_src emacs-lisp +;; Set backup directories into the tmp folder +(defvar --backup-directory (concat user-emacs-directory "backups")) +(if (not (file-exists-p --backup-directory)) + (make-directory --backup-directory t)) +(setq backup-directory-alist `(("." . ,--backup-directory))) +(setq make-backup-files t ; backup of a file the first time it is saved. + backup-by-copying t ; don't clobber symlinks + version-control t ; version numbers for backup files + delete-old-versions t ; delete excess backup files silently + delete-by-moving-to-trash t + kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2) + kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2) + auto-save-default t ; auto-save every buffer that visits a file + auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30) + auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300) + ) +#+end_src + +** Whitespace Settings + +#+begin_src emacs-lisp +;; Configure activation for whitespace mode +(use-package! whitespace + :bind (("C-x w" . whitespace-mode)) + :init + (setq whitespace-style '(newline newline-mark)) + (setq whitespace-display-mappings '((newline-mark 10 [?¬ 10])))) + +;; Configure expand-region mode. +(use-package! expand-region + :bind ("M-o" . er/expand-region)) + +;; Delete all whitespace until the first non-whitespace character. +(use-package! hungry-delete + :config + (global-hungry-delete-mode) + ;; disable hungry delete in minibuffer-mode: https://github.com/abo-abo/swiper/issues/2761 + (add-to-list 'hungry-delete-except-modes 'minibuffer-mode)) +#+end_src + +* Tramp + +#+begin_src emacs-lisp +(setq tramp-auto-save-directory "/tmp") +(defvar disable-tramp-backups '(all)) +(eval-after-load "tramp" + '(progn + ;; Modified from https://www.gnu.org/software/emacs/manual/html_node/tramp/Auto_002dsave-and-Backup.html + (setq backup-enable-predicate + (lambda (name) + (and (normal-backup-enable-predicate name) + ;; Disable all tramp backups + (and disable-tramp-backups + (member 'all disable-tramp-backups) + (not (file-remote-p name 'method))) + (not ;; disable backup for tramp with the listed methods + (let ((method (file-remote-p name 'method))) + (when (stringp method) + (member method disable-tramp-backups))))))) + + (defun tramp-set-auto-save--check (original) + (if (funcall backup-enable-predicate (buffer-file-name)) + (funcall original) + (auto-save-mode -1))) + + (advice-add #'tramp-set-auto-save :around #'tramp-set-auto-save--check) + + ;; Use my ~/.ssh/config control master settings according to https://puppet.com/blog/speed-up-ssh-by-reusing-connections + (setq tramp-ssh-controlmaster-options ""))) +#+end_src + +* Language Settings +** Flycheck + +#+begin_src emacs-lisp +(use-package! flycheck + :config + (setq flycheck-idle-change-delay 1) + (setq flycheck-display-errors-delay 1.0) + (setq-default flycheck-disabled-checkers '(haskell-stack-ghc)) + (remove-hook 'flycheck-mode-hook #'+syntax-init-popups-h)) +#+end_src + +** Magit + +#+begin_src emacs-lisp +;; Set up magit when C-c g is called +(use-package! magit + :bind (("C-x g" . magit-status)) + :config + (add-hook 'magit-status-sections-hook #'magit-insert-modules 90)) +#+end_src + +** Org mode + +#+begin_src emacs-lisp +;; Org configuration +(use-package! org + :mode ("\\.org\\'" . org-mode) + :init + (map! :map org-mode-map + "M-n" #'outline-next-visible-heading + "M-p" #'outline-previous-visible-heading + "C-c ]" #'ebib-insert-citation + "C-," nil + "C-c C-." #'org-time-stamp-inactive) + (setq org-src-window-setup 'current-window + org-return-follows-link t + org-confirm-babel-evaluate nil + org-use-speed-commands t + org-hide-emphasis-markers nil + org-adapt-indentation nil + org-cycle-separator-lines 2 + org-startup-folded 'content + org-structure-template-alist '(("a" . "export ascii") + ("c" . "center") + ("C" . "comment") + ("e" . "example") + ("E" . "export") + ("h" . "export html") + ("l" . "export latex") + ("q" . "quote") + ("s" . "src") + ("v" . "verse") + ("el" . "src emacs-lisp") + ("d" . "definition") + ("t" . "theorem"))) + ;;(customize-set-variable 'org-blank-before-new-entry + ;; '((heading . nil) + ;; (plain-list-item . nil))) + (require 'oc) + (require 'oc-biblatex) + (require 'oc-csl) + (setq org-cite-export-processors '((latex biblatex) + (t csl)) + org-cite-csl-styles-dir "~/projects/csl-styles" + org-cite-global-bibliography '("~/Dropbox/bibliography/references.bib"))) + +(use-package! citeproc) + +(use-package! org-attach + :config + (setq org-attach-auto-tag "attach")) + +(use-package! org-crypt + :after org + :config + (org-crypt-use-before-save-magic) + (setq org-tags-exclude-from-inheritance '("crypt")) + (setq org-crypt-key "8CEF4104683551E8")) + +;;(use-package! org-contacts +;; :after org +;; :init +;; (setq org-contacts-files '("~/Dropbox/org/contacts.org"))) + +(use-package org-auto-tangle + :hook (org-mode . org-auto-tangle-mode)) + +;; Disable org indent mode and remove C-, from the org-mode-map. +(after! org + (setq org-element-use-cache nil) + ;; Set agenda files, refile targets and todo keywords. + (setq org-startup-indented nil) + (setq org-log-done 'time + org-log-into-drawer t) + (setq org-agenda-files (mapcar 'expand-file-name + (list "~/Dropbox/org/inbox.org" + "~/Dropbox/org/main.org" + "~/Dropbox/org/tickler.org" + "~/Dropbox/org/projects.org" + (format-time-string "~/Dropbox/org/%Y-%m.org") + "~/Dropbox/bibliography/reading_list.org"))) + (setq org-agenda-tag-filter '("-backed")) + (setq org-refile-targets `(("~/Dropbox/org/main.org" :level . 1) + ("~/Dropbox/org/someday.org" :level . 1) + ("~/Dropbox/org/projects.org" :maxlevel . 2) + (,(format-time-string "~/Dropbox/org/%Y-%m.org") :level . 1))) + ;; Set custom agenda commands which can be activated in the agenda viewer. + (setq org-agenda-custom-commands + '(("w" "At work" tags-todo "@work" + ((org-agenda-overriding-header "Work"))) + ("h" "At home" tags-todo "@home" + ((org-agenda-overriding-header "Home"))) + ("u" "At uni" tags-todo "@uni" + ((org-agenda-overriding-header "University"))))) + + (setq org-agenda-span 7 + org-agenda-start-day "." + org-agenda-start-on-week 1) + (setq org-agenda-include-diary t) + + (setq org-icalendar-include-todo t) + (setq org-icalendar-include-bbdb-anniversaries t) + + (setq org-capture-templates + `(("t" "Todo" entry (file "inbox.org") + "* TODO %? +:PROPERTIES: +:ID: %(org-id-uuid) +:END: +:LOGBOOK: +- State \"TODO\" from \"\" %U +:END:" :empty-lines 1) + ("l" "Link Todo" entry (file "inbox.org") + "* TODO %? +:PROPERTIES: +:ID: %(org-id-uuid) +:END: +:LOGBOOK: +- State \"TODO\" from \"\" %U +:END: + +%a" :empty-lines 1) + ("c" "Contacts" entry (file "~/Dropbox/org/contacts.org") + "* %(org-contacts-template-name) + :PROPERTIES: + :EMAIL: %(org-contacts-template-email) + :END:" :empty-lines 1)) + + org-todo-keywords + '((sequence + "TODO(t)" ; A task that needs doing & is ready to do + "PROJ(p)" ; A project, which usually contains other tasks + "STRT(s)" ; A task that is in progress + "WAIT(w)" ; Something external is holding up this task + "HOLD(h)" ; This task is paused/on hold because of me + "DELG(l)" ; This task is delegated + "SMDY(m)" ; todo some day + "|" + "DONE(d!)" ; Task successfully completed + "KILL(k)") ; Task was cancelled, aborted or is no longer applicable + (sequence + "[ ](T)" ; A task that needs doing + "[-](S)" ; Task is in progress + "[?](W)" ; Task is being held up or paused + "|" + "[X](D)")) + org-todo-keyword-faces '(("[-]" . +org-todo-active) + ("STRT" . +org-todo-active) + ("[?]" . +org-todo-onhold) + ("WAIT" . +org-todo-onhold) + ("HOLD" . +org-todo-onhold) + ("DELG" . +org-todo-onhold) + ("SMDY" . +org-todo-onhold) + ("PROJ" . +org-todo-project) + ("NO" . +org-todo-cancel) + ("KILL" . +org-todo-cancel))); Task was completed +;; (setq org-html-head-extra +;; " +;; +;;" + (setq org-html-head-include-default-style nil + org-html-head-include-scripts nil + org-html-doctype "html5" + org-html-html5-fancy t + org-html-container-element "section" + org-html-postamble-format + '(("en" "")) + org-html-postamble t + org-html-divs '((preamble "header" "header") + (content "article" "content") + (postamble "footer" "postamble"))) + + (setq org-export-with-broken-links t) + (require 'org-habit) + + (require 'calendar) + (setq calendar-mark-diary-entries-flag t) + (setq calendar-mark-holidays-flag t) + (setq calendar-mode-line-format nil) + (setq calendar-time-display-form + '(24-hours ":" minutes + (when time-zone + (format "(%s)" time-zone)))) + (setq calendar-week-start-day 1) ; Monday + (setq calendar-date-style 'iso) + (setq calendar-date-display-form calendar-iso-date-display-form) + (setq calendar-time-zone-style 'numeric) ; Emacs 28.1 + + (require 'cal-dst) + (setq calendar-standard-time-zone-name "+0000") + (setq calendar-daylight-time-zone-name "+0100") + + (require 'diary-lib) + (setq diary-file "~/Dropbox/org/diary") + (setq diary-date-forms diary-iso-date-forms) + (setq diary-comment-start ";;") + (setq diary-comment-end "") + (setq diary-nonmarking-symbol "!") + (setq diary-show-holidays-flag t) + (setq diary-display-function #'diary-fancy-display) ; better than its alternative + (setq diary-header-line-format nil) + (setq diary-list-include-blanks nil) + (setq diary-number-of-entries 2) + (setq diary-mail-days 2) + (setq diary-abbreviated-year-flag nil) + + (add-hook 'calendar-today-visible-hook #'calendar-mark-today) + (add-hook 'diary-list-entries-hook #'diary-fix-timezone t) + (add-hook 'diary-list-entries-hook #'diary-sort-entries t) + + + (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) + (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files) + ;; Prevent Org from interfering with my key bindings. + (remove-hook 'calendar-mode-hook #'org--setup-calendar-bindings) + + (let ((map calendar-mode-map)) + (define-key map (kbd "s") #'calendar-sunrise-sunset) + (define-key map (kbd "l") #'lunar-phases) + (define-key map (kbd "i") nil) ; Org sets this, much to my chagrin (see `remove-hook' above) + (define-key map (kbd "i a") #'diary-insert-anniversary-entry) + (define-key map (kbd "i c") #'diary-insert-cyclic-entry) + (define-key map (kbd "i d") #'diary-insert-entry) ; for current "day" + (define-key map (kbd "i m") #'diary-insert-monthly-entry) + (define-key map (kbd "i w") #'diary-insert-weekly-entry) + (define-key map (kbd "i y") #'diary-insert-yearly-entry) + (define-key map (kbd "M-n") #'calendar-forward-month) + (define-key map (kbd "M-p") #'calendar-backward-month)) + + (defun diary-schedule (y1 m1 d1 y2 m2 d2 dayname) + "Entry applies if date is between dates on DAYNAME. + Order of the parameters is M1, D1, Y1, M2, D2, Y2 if + `european-calendar-style' is nil, and D1, M1, Y1, D2, M2, Y2 if + `european-calendar-style' is t. Entry does not apply on a history." + (let ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1))) + (date2 (calendar-absolute-from-gregorian (list m2 d2 y2))) + (d (calendar-absolute-from-gregorian date))) + (if (and + (<= date1 d) + (<= d date2) + (= (calendar-day-of-week date) dayname) + (not (calendar-check-holidays date))) + entry))) + + (defun diary-fix-timezone () + (let ((eqtimezone (string= + (replace-regexp-in-string + "\n" "" + (shell-command-to-string "date +%z")) + (replace-regexp-in-string + "\n" "" + (shell-command-to-string "TZ=\"Europe/London\" date +%z"))))) + (setq diary-entries-list + (mapcar (lambda (entry) + (pcase entry + (`(,date ,time ,sdate . ,rest) + (let ((dt (diary-entry-time time)) + (string-date (apply (lambda (a b c) (format "%d-%d-%d" c a b)) date))) + (if (or eqtimezone (= dt diary-unknown-time)) + entry + (let* ((tr (org-tz-conv (concat string-date " " (number-to-string dt)) "Europe/London" "from")) + (split (split-string tr "[- ]")) + (year (car split)) + (month (cadr split)) + (day (caddr split)) + (hour (cadddr split))) + (cons (mapcar #'string-to-number (list month day year)) + (cons (concat hour (replace-regexp-in-string "^[^ ]+" "" time)) + (cons (format "%s-%s-%s" year month day) rest))))))))) + diary-entries-list)))) + + (defun org-tz-conv (stamp tz way) + "Convert a STAMP to or from TZ depending on WAY. + +This function uses the date command line tool to do it." + (let* ((current-tz-offset (replace-regexp-in-string + "\n" "" + (shell-command-to-string "date +%z"))) + (stamp1 (concat (replace-regexp-in-string "[<>]" "" stamp))) + (date-cmd-p0 "TZ=%s gdate -d \"%s\"") + (date-cmd-p1 "gdate --date=\"TZ=\\\"%s\\\" %s\"") + (date-cmd-p2 " +\"%F %H:%M\"") + (date-cmd-from (concat (format date-cmd-p1 tz stamp1) date-cmd-p2)) + (date-cmd-to (concat (format date-cmd-p0 tz + (concat stamp1 " " current-tz-offset)) + date-cmd-p2)) + + (shell-result-from (shell-command-to-string date-cmd-from)) + (shell-result-to (shell-command-to-string date-cmd-to)) + + (result-from (replace-regexp-in-string "\n" "" shell-result-from)) + (result-to (replace-regexp-in-string "\n" "" shell-result-to))) + (cond ((string-equal way "from") result-from) + ((string-equal way "to") result-to)))) + + (require 'ox-extra) + (ox-extras-activate '(ignore-headlines)) + + (require 'ox-beamer) + (require 'ox-latex) + (add-to-list 'org-latex-classes + '("beamer" + "\\documentclass\[presentation\]\{beamer\}" + ("\\section\{%s\}" . "\\section*\{%s\}") + ("\\subsection\{%s\}" . "\\subsection*\{%s\}") + ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}"))) + (add-to-list 'org-latex-classes + '("scrartcl" + "\\documentclass\{scrartcl\}" + ("\\section\{%s\}" . "\\section*\{%s\}") + ("\\subsection\{%s\}" . "\\subsection*\{%s\}") + ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}") + ("\\paragraph{%s}" . "\\paragraph*{%s}"))) + (add-to-list 'org-latex-packages-alist '("" "minted")) + (setq org-latex-listings 'minted) + (setq org-latex-pdf-process '("latexmk -f -pdf -%latex -shell-escape -interaction=nonstopmode -output-directory=%o %f")) + (setq org-beamer-environments-extra '(("onlyenv" "o" "\\begin{onlyenv}%a{%h}" "\\end{onlyenv}") + ("onlyenvNH" "o" "\\begin{onlyenv}%a" "\\end{onlyenv}") + ("blockNH" "o" "\\begin{block}%a{}" "\\end{block}") + ("oeblock" "o" "\\only%a{\\begin{block}%a{%h}" "\\end{block}}") + ("oeblockNH" "o" "\\only%a{\\begin{block}%a{}" "\\end{block}}") + ("minipage" "o" "\\begin{minipage}[t]%o[t]{1.0\\textwidth}" "\\end{minipage}"))) + + (add-to-list 'org-latex-packages-alist '("" "tikz" t)) + (eval-after-load "preview" + '(add-to-list 'preview-default-preamble + "\\PreviewEnvironment{tikzpicture}" t))) + +(use-package appt + :config + (setq appt-display-diary nil) + (setq appt-disp-window-function #'appt-disp-window) + (setq appt-display-mode-line t) + (setq appt-display-interval 3) + (setq appt-audible nil) + (setq appt-warning-time-regexp "appt \\([0-9]+\\)") + (setq appt-message-warning-time 15) + (run-at-time 10 nil #'appt-activate 1)) + +(use-package! org-transclusion + :after org + :config + (setq org-transclusion-exclude-elements nil) + (advice-remove 'org-link-search '+org--recenter-after-follow-link-a)) + +(use-package! org-superstar + :hook (org-mode . org-superstar-mode) + :config + (setq org-superstar-headline-bullets-list '("♚" "♛" "♜" "♝" "♞" "♔" "♕" "♖" "♗" "♘" "♙") + org-superstar-special-todo-items t)) + +(use-package! org-id + :after org + :config + (setq org-id-link-to-org-use-id 'use-existing) + (setq org-id-track-globally t)) + +;; Set up org registers to quickly jump to files that I use often. +(set-register ?l (cons 'file "~/.emacs.d/loader.org")) +(set-register ?m (cons 'file "~/Dropbox/org/meetings.org")) +(set-register ?i (cons 'file "~/Dropbox/org/inbox.org")) +(set-register ?p (cons 'file "~/Dropbox/org/projects.org")) +(set-register ?c (cons 'file (format-time-string "~/Dropbox/org/%Y-%m.org"))) +#+end_src + +#+begin_src emacs-lisp +(use-package! ox-context + :after org + :config + (add-to-list + 'org-context-presets-alist + '("ymhg-article" . + (:literal "\\setupwhitespace[none]" + :template "article" + :snippets + ("description-article" "quote-article" "verse-article" + "table-article" "title-ymhg" "sectioning-article" "page-numbering-article")))) + (add-to-list 'org-context-snippets-alist + '("title-ymhg" . "\\setuphead[title][align=middle] +\\definestartstop[OrgTitlePage] +\\define\\OrgMakeTitle{% + \\startalignment[center] + \\blank[force,2*big] + \\title{\\documentvariable{metadata:title}} + \\doifnot{\\documentvariable{metadata:subtitle}}{}{ + \\blank[force,1*big] + \\tfa \\documentvariable{metadata:subtitle}} + \\doifelse{\\documentvariable{metadata:author}}{}{ + \\blank[2*medium] + {\\tfa \\documentvariable{metadata:email}} + }{ + \\blank[force,2*medium] + {\\it by \\documentvariable{metadata:author}}, on \\documentvariable{metadata:date} + } + \\blank[3*medium] + \\stopalignment} +\\setupsectionblock[frontpart][page=no] +\\setupsectionblock[bodypart][page=no] +\\setuppagenumbering[location={footer,middle}]")) + (setq org-context-headline-command + '("OrgHeadline" . "\\def\\OrgHeadline#1[#2]{% + \\getparameters + [OrgHeadline] + [Todo=, + TodoType=, + Priority=, + Text=, + Tags=, + #2]% + \\doifnot{\\OrgHeadlineTodo}{}{{\\sansbold{\\smallcaps{\\OrgHeadlineTodo}}\\space}}% + \\doifnot{\\OrgHeadlinePriority}{}{{\\inframed{\\OrgHeadlinePriority}\\space}}% + \\OrgHeadlineText% + \\doifnot{\\OrgHeadlineTags}{}{{\\hfill\\tt\\OrgHeadlineTags}}% +}"))) +#+end_src + +** Latex/Context + +#+begin_src emacs-lisp +(after! pdf-tools + (pdf-tools-install)) + +(after! latex + (setq TeX-view-program-selection '((output-pdf "PDF Tools")) + TeX-source-correlate-start-server t) + (setq-default TeX-command-extra-options "-shell-escape") + (add-hook 'TeX-after-compilation-finished-functions + #'TeX-revert-document-buffer)) + +(after! context + (setq TeX-command-list + (append + '(("context" + "context --purgeall %s" + TeX-run-command nil t :help "Run ConTeXt")) TeX-command-list)) + (map! :map ConTeXt-mode-map + "C-c ]" #'ebib-insert-citation) + (add-hook 'ConTeXt-mode-hook #'reftex-mode)) + +(use-package! ox-gfm :after ox) +(use-package! ox-hugo :after ox) + +(use-package! elfeed-org + :config + (elfeed-org) + (setq rmh-elfeed-org-files (list "~/Dropbox/org/elfeed.org")) + (run-at-time nil (* 8 60 60) #'elfeed-update)) + +(use-package! mmm-mode + :config + (mmm-add-group + 'fancy-context + '((embedded-lua + :submode lua-mode + :front "\\\\startluacode" + :back "\\\\stopluacode") + (embedded-C + :submode c-mode + :front "\\\\starthlC" + :back "\\\\stophlC") + (embedded-metapost + :submode metapost-mode + :front "\\\\startuseMPgraphic" + :back "\\\\stopuseMPgraphic") + )) + + (mmm-add-mode-ext-class 'ConTeXt-en/PS nil 'fancy-context) + (setq mmm-global-mode 'maybe) + ;;(setq mmm-never-modes + ;; (append '(ediff-mode) '(text-mode) mmm-never-modes)) + ) + +(require 'mmm-auto) + +#+end_src + +*** Zettelkasten + +#+begin_src emacs-lisp +(use-package! org-zettelkasten + :config + (add-hook 'org-mode-hook #'org-zettelkasten-mode) + + (defun org-zettelkasten-search-current-id () + "Use `consult-ripgrep' to search for the current ID in all files." + (interactive) + (let ((current-id (org-entry-get nil "CUSTOM_ID"))) + (consult-ripgrep org-zettelkasten-directory (concat "[\\[:]." current-id "\\]#")))) + + (define-key org-zettelkasten-mode-map (kbd "r") #'org-zettelkasten-search-current-id) + (setq org-zettelkasten-directory "~/Dropbox/zk") + + (defun org-zettelkasten-goto-id (id) + "Go to an ID." + (interactive "sID: #") + (cond ((string-prefix-p "1" id) + (org-link-open-from-string + (concat "[[file:" org-zettelkasten-directory + "/hls.org::#" id "]]"))) + ((string-prefix-p "2" id) + (org-link-open-from-string + (concat "[[file:" org-zettelkasten-directory + "/computing.org::#" id "]]"))) + ((string-prefix-p "3" id) + (org-link-open-from-string + (concat "[[file:" org-zettelkasten-directory + "/verification.org::#" id "]]"))) + ((string-prefix-p "4" id) + (org-link-open-from-string + (concat "[[file:" org-zettelkasten-directory + "/mathematics.org::#" id "]]"))) + ((string-prefix-p "5" id) + (org-link-open-from-string + (concat "[[file:" org-zettelkasten-directory + "/hardware.org::#" id "]]")))))) +#+end_src + +#+begin_src emacs-lisp +;; Set up zettelkasten mode +(use-package! zettelkasten + :bind-keymap + ("C-c k" . zettelkasten-mode-map)) +#+end_src + +** Verilog + +#+begin_src emacs-lisp +;; Set sensitive data mode +(setq auto-mode-alist + (append + (list ;;'("\\.\\(vcf\\|gpg\\)\\'" . sensitive-minor-mode) + '("\\.sv\\'" . verilog-mode) + '("\\.mkiv\\'" . context-mode) + '("\\.mkii\\'" . context-mode) + '("\\.mkxl\\'" . context-mode)) + auto-mode-alist)) + +(after! verilog-mode + (setq verilog-simulator "iverilog")) +#+end_src + +** Ebib + +#+begin_src emacs-lisp +;; Bibtex stuff +(use-package! ebib + :bind (("C-c y b" . ebib)) + :init + (defun ymhg/ebib-create-identifier (key _) key) + (setq ebib-preload-bib-files '("~/Dropbox/bibliography/references.bib") + ebib-notes-default-file "~/Dropbox/bibliography/notes.org" + ebib-notes-template "* %T\n:PROPERTIES:\n%K\n:NOTER_DOCUMENT: papers/%k.pdf\n:END:\n%%?\n" + ebib-keywords (expand-file-name "~/Dropbox/bibliography/keywords.txt") + ebib-reading-list-file "~/Dropbox/bibliography/reading_list.org" + ebib-notes-storage 'multiple-notes-per-file) + :config + (add-to-list 'ebib-notes-template-specifiers '(?k . ymhg/ebib-create-identifier)) + (add-to-list 'ebib-file-search-dirs "~/Dropbox/bibliography/papers") + (if (eq system-type 'darwin) + (add-to-list 'ebib-file-associations '("pdf" . "open")) + (add-to-list 'ebib-file-associations '("pdf" . nil))) + (add-to-list 'ebib-citation-commands '(org-mode (("ref" "[cite:@%(%K%,)]")))) + (add-to-list 'ebib-citation-commands '(context-mode (("cite" "\\cite[%(%K%,)]") + ("authoryear" "\\cite[authoryear][%(%K%,)]") + ("authoryears" "\\cite[authoryears][%(%K%,)]") + ("entry" "\\cite[entry][%(%K%,)]") + ("author" "\\cite[author][%(%K%,)]")))) + + (advice-add 'bibtex-generate-autokey :around + (lambda (orig-func &rest args) + (replace-regexp-in-string ":" "" (apply orig-func args)))) + (remove-hook 'ebib-notes-new-note-hook #'org-narrow-to-subtree) + + (map! :map ebib-index-mode-map + "D" #'ebib-download-pdf-from-doi)) + +(defun sci-hub-pdf-url (doi) + "Get url to the pdf from SCI-HUB using DOI." + (setq *doi-utils-pdf-url* (concat "https://sci-hub.hkvisa.net/" doi) ;captcha + ,*doi-utils-waiting* t + ) + ;; try to find PDF url (if it exists) + (url-retrieve (concat "https://sci-hub.hkvisa.net/" doi) + (lambda (_) + (goto-char (point-min)) + (while (search-forward-regexp + "\\(https:\\|sci-hub.hkvisa.net/downloads\\).+download=true'" nil t) + (let ((foundurl (match-string 0))) + (message foundurl) + (if (string-match "https:" foundurl) + (setq *doi-utils-pdf-url* foundurl) + (setq *doi-utils-pdf-url* (concat "https:" foundurl)))) + (setq *doi-utils-waiting* nil)))) + (while *doi-utils-waiting* (sleep-for 0.1)) + (replace-regexp-in-string "\\\\" "" *doi-utils-pdf-url*)) + +(defun acm-pdf-url (doi) + "Retrieve a DOI pdf from the ACM." + (concat "https://dl.acm.org/doi/pdf/" doi)) + +(defun ieee-pdf-url (doi) + "Retrieve a DOI pdf from the IEEE." + (when (string-match "\\.\\([0-9]*\\)$" doi) + (let ((doi-bit (match-string 1 doi))) + (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber=" doi-bit "&ref=")))) + +(defun springer-pdf-url (doi) + "Retrieve a DOI pdf from the Springer." + (concat "https://link.springer.com/content/pdf/" doi ".pdf")) + +(defun arxiv-pdf-url (epr) + (concat "https://arxiv.org/pdf/" epr ".pdf")) + +(defun download-pdf-from-doi (key &optional doi publisher eprint journal organization url) + "Download pdf from doi with KEY name." + (let ((pub (or publisher "")) + (epr (or eprint "")) + (jour (or journal "")) + (org (or organization "")) + (link (or url ""))) + (url-copy-file (cond + ((not doi) link) + ((or (string-match "ACM" (s-upcase pub)) + (string-match "association for computing machinery" (s-downcase pub))) + (acm-pdf-url doi)) + ((string-match "arxiv" (s-downcase pub)) + (arxiv-pdf-url epr)) + ((or (string-match "IEEE" (s-upcase pub)) + (string-match "IEEE" (s-upcase jour)) + (string-match "IEEE" (s-upcase org))) + (ieee-pdf-url doi)) + ((string-match "springer" (s-downcase pub)) + (springer-pdf-url doi)) + (t (sci-hub-pdf-url doi))) + (concat (car ebib-file-search-dirs) "/" key ".pdf")))) + +(defun download-pdf-from-link (link key) + (url-copy-file link + (concat (car ebib-file-search-dirs) "/" key ".pdf"))) + +(defun download-pdf-from-downloads (key) + (copy-file (concat "~/Downloads/" key ".pdf") + (concat (car ebib-file-search-dirs) "/" key ".pdf") t)) + +(defun get-bib-from-doi (doi) + "Get the bibtex from DOI." + (shell-command (concat "curl -L -H \"Accept: application/x-bibtex; charset=utf-8\" " + "https://doi.org/" doi))) + +(defun ebib-download-pdf-from-doi () + "Download a PDF for the current entry." + (interactive) + (let* ((key (ebib--get-key-at-point)) + (doi (ebib-get-field-value "doi" key ebib--cur-db 'noerror 'unbraced 'xref)) + (publisher (ebib-get-field-value "publisher" key ebib--cur-db 'noerror 'unbraced 'xref)) + (eprinttype (ebib-get-field-value "eprinttype" key ebib--cur-db 'noerror 'unbraced 'xref)) + (eprint (ebib-get-field-value "eprint" key ebib--cur-db 'noerror 'unbraced 'xref)) + (journal (ebib-get-field-value "journal" key ebib--cur-db 'noerror 'unbraced 'xref)) + (journaltitle (ebib-get-field-value "journaltitle" key ebib--cur-db 'noerror 'unbraced 'xref)) + (organization (ebib-get-field-value "organization" key ebib--cur-db 'noerror 'unbraced 'xref)) + (url (ebib-get-field-value "url" key ebib--cur-db 'noerror 'unbraced 'xref))) + (unless key + (error "[Ebib] No key assigned to entry")) + (download-pdf-from-doi key doi (or publisher eprinttype) eprint (or journal journaltitle) organization url))) + +(defun ebib-check-file () + "Download a PDF for the current entry." + (interactive) + (let ((key (ebib--get-key-at-point))) + (unless (file-exists-p (concat (car ebib-file-search-dirs) "/" key ".pdf")) + (error "[Ebib] No PDF found.")) + t)) +#+end_src + +** Ocaml + +#+begin_src emacs-lisp +(after! tuareg-mode + (add-hook 'tuareg-mode-hook + (lambda () + (define-key tuareg-mode-map (kbd "C-M-") #'ocamlformat) + (add-hook 'before-save-hook #'ocamlformat-before-save)))) +#+end_src + +** Spell check + +#+begin_src emacs-lisp +;; Set up dictionaries +(setq ispell-dictionary "british") + +(use-package! spell-fu + :config + (add-hook 'spell-fu-mode-hook + (lambda () + (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "en_GB")) + (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "de_DE")) + (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "fr_FR")) + (spell-fu-dictionary-add + (spell-fu-get-personal-dictionary "fr-personal" "~/.aspell.en_GB.pws")) + (spell-fu-dictionary-add + (spell-fu-get-personal-dictionary "de-personal" "~/.aspell.de_DE.pws")) + (spell-fu-dictionary-add + (spell-fu-get-personal-dictionary "fr-personal" "~/.aspell.fr_FR.pws"))))) + +(after! flyspell + (define-key flyspell-mode-map (kbd "C-.") nil) + (define-key flyspell-mode-map (kbd "C-,") nil) + (setq flyspell-mouse-map (make-sparse-keymap))) +#+end_src + +** Coq configuration + +#+begin_src emacs-lisp +(use-package! proof-general + :config + (setq proof-splash-enable nil + proof-auto-action-when-deactivating-scripting 'retract + proof-delete-empty-windows nil + proof-multiple-frames-enable nil + proof-three-window-enable nil + proof-auto-raise-buffers nil + coq-compile-before-require nil + coq-compile-vos t + coq-compile-parallel-in-background t + coq-max-background-compilation-jobs 4 + coq-compile-keep-going nil + coq-compile-quick 'no-quick)) + +(use-package! company-coq + :after coq + :config + (setq company-idle-delay 1 + company-coq-disabled-features '(prettify-symbols hello company-defaults spinner smart-subscripts snippets compile-command))) +#+end_src + +** Mail + +#+begin_src emacs-lisp +(setq message-send-mail-function 'message-send-mail-with-sendmail) +(setq message-fill-column 80) + +(use-package! sendmail + :config + (if (eq system-type 'darwin) + (setq sendmail-program "/usr/local/bin/msmtp") + (setq sendmail-program "/usr/bin/msmtp"))) + +(setq message-signature "Yann Herklotz +Imperial College London +https://yannherklotz.com") + +(setq auth-sources '("~/.authinfo" "~/.authinfo.gpg" "~/.netrc")) + +(setq mail-specify-envelope-from t + message-sendmail-envelope-from 'header + mail-envelope-from 'header) + +(use-package! notmuch + :config + (defun ymhg/notmuch-search-delete-mail (&optional beg end) + "Delete a message." + (interactive (notmuch-interactive-region)) + (if (member "deleted" (notmuch-search-get-tags)) + (notmuch-search-tag (list "-deleted")) + (notmuch-search-tag (list "+deleted" "-unread") beg end))) + + (defun ymhg/notmuch-show-delete-mail (&optional beg end) + "Delete a message." + (interactive (notmuch-interactive-region)) + (if (member "deleted" (notmuch-show-get-tags)) + (notmuch-show-tag (list "-deleted")) + (notmuch-show-tag (list "+deleted" "-unread") beg end))) + + (setq notmuch-archive-tags '("-inbox" "-unread" "+archive")) + + (map! + :map notmuch-show-mode-map + "d" #'ymhg/notmuch-show-delete-mail) + (map! + :map notmuch-search-mode-map + "d" #'ymhg/notmuch-search-delete-mail) + + (setq notmuch-saved-searches + '((:name "inbox" :query "date:last_month..this_month and tag:inbox not tag:deleted" :key "n") + (:name "flagged" :query "tag:flagged" :key "f") + (:name "sent" :query "tag:sent" :key "s") + (:name "drafts" :query "tag:draft" :key "d") + (:name "mailbox" :query "date:last_month..this_month and (tag:mailbox and tag:inbox) and not tag:deleted and not tag:sent" :key "m") + (:name "imperial" :query "date:last_month..this_month and (tag:imperial and tag:inbox) and not tag:deleted and not tag:sent" :key "i") + (:name "all recent" :query "date:last_month..this_month" :key "r"))) + + (setq notmuch-fcc-dirs + '(("yann@yannherklotz.com" . "mailbox/Sent -inbox +sent -unread +mailbox -new") + ("git@ymhg.org" . "mailbox/Sent -inbox +sent -unread +mailbox -new") + ("yann.herklotz15@imperial.ac.uk" . "\"imperial/Sent Items\" -inbox +sent -unread +imperial -new"))) + + (setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox")))) + +(after! shr (setq shr-use-fonts nil + shr-max-image-proportion 0.5)) +#+end_src + +** Smartparens + +#+begin_src emacs-lisp +(use-package! smartparens + :config + (map! :map smartparens-mode-map + "M-[" #'sp-backward-unwrap-sexp + "M-]" #'sp-unwrap-sexp + "C-M-f" #'sp-forward-sexp + "C-M-b" #'sp-backward-sexp + "C-M-d" #'sp-down-sexp + "C-M-a" #'sp-backward-down-sexp + "C-M-e" #'sp-up-sexp + "C-M-u" #'sp-backward-up-sexp + "C-M-t" #'sp-transpose-sexp + "C-M-n" #'sp-next-sexp + "C-M-p" #'sp-previous-sexp + "C-M-k" #'sp-kill-sexp + "C-M-w" #'sp-copy-sexp + "C-)" #'sp-forward-slurp-sexp + "C-}" #'sp-forward-barf-sexp + "C-(" #'sp-backward-slurp-sexp + "C-{" #'sp-backward-barf-sexp + "M-D" #'sp-splice-sexp + "C-]" #'sp-select-next-thing-exchange + "C-" #'sp-select-previous-thing + "C-M-]" #'sp-select-next-thing + "M-F" #'sp-forward-symbol + "M-B" #'sp-backward-symbol + "M-r" #'sp-split-sexp) + (require 'smartparens-config) + (show-smartparens-global-mode +1) + (smartparens-global-mode 1) +;;(sp-pair "'" nil :actions :rem) + (sp-local-pair 'coq-mode "'" nil :actions nil)) +#+end_src + +#+begin_src emacs-lisp +(after! writeroom-mode (setq +zen-text-scale 1)) + +(use-package! direnv :config (direnv-mode)) + +(use-package alert + :custom + (alert-default-style 'osx-notifier)) + +(use-package ledger-mode) + +(defun diary-last-day-of-month (date) + "Return `t` if DATE is the last day of the month." + (let* ((day (calendar-extract-day date)) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) + (last-day-of-month + (calendar-last-day-of-month month year))) + (= day last-day-of-month))) + +(use-package! calc-forms + :config + (add-to-list 'math-tzone-names '("AOE" 12 0)) + (add-to-list 'math-tzone-names '("IST" (float -55 -1) 0))) + +(use-package! orderless + :custom (completion-styles '(substring orderless))) + +(use-package! vertico + :init + (vertico-mode)) + +(use-package! savehist + :init + (savehist-mode)) + +(use-package! marginalia + :bind (("M-A" . marginalia-cycle) + :map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + ;; Must be in the :init section of use-package such that the mode gets + ;; enabled right away. Note that this forces loading the package. + (marginalia-mode)) +#+end_src + +** Embark + +#+begin_src emacs-lisp +(use-package! embark + :bind + (("C-;" . embark-act)) + :init + ;; Optionally replace the key help with a completing-read interface + (setq prefix-help-command #'embark-prefix-help-command) + :config + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + nil + (window-parameters (mode-line-format . none))))) + +(use-package! embark-consult + :after (embark consult) + :demand t ; only necessary if you have the hook below + ;; if you want to have consult previews as you move around an + ;; auto-updating embark collect buffer + :hook + (embark-collect-mode . consult-preview-at-point-mode)) +#+end_src + +** Consult + +#+begin_src emacs-lisp +;; Example configuration for Consult +(use-package! consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings (mode-specific-map) + ("C-c h" . consult-history) + ("C-c m" . consult-mode-command) + ("C-c b" . consult-bookmark) + ("C-c k" . consult-kmacro) + ;; C-x bindings (ctl-x-map) + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + (" a" . consult-apropos) ;; orig. apropos-command + ;; M-g bindings (goto-map) + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-imenu-multi) + ;; M-s bindings (search-map) + ("M-s f" . consult-find) + ("M-s F" . consult-locate) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s m" . consult-multi-occur) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch) + :map isearch-mode-map + ("M-e" . consult-isearch) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi)) ;; needed by consult-line to detect isearch + + ;; Enable automatic preview at point in the *Completions* buffer. + ;; This is relevant when you use the default completion UI, + ;; and not necessary for Vertico, Selectrum, etc. + :hook (completion-list-mode . consult-preview-at-point-mode) + + ;; The :init configuration is always executed (Not lazy) + :init + + (setq register-preview-delay 0 + register-preview-function #'consult-register-format) + + (advice-add #'register-preview :override #'consult-register-window) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + :config + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; (kbd "C-+") + + (setq consult-project-root-function + (lambda () + (when-let (project (project-current)) + (car (project-roots project)))))) +#+end_src + +** Scheme + +#+begin_src emacs-lisp +(use-package! geiser-chicken + :config + (setq geiser-chicken-binary "chicken-csi")) + +(use-package! geiser + :init + (map! :map geiser-mode-map "C-." nil) + (map! :map geiser-repl-mode-map "C-." nil)) +#+end_src + +** Emacs + +#+begin_src emacs-lisp +(use-package! emacs + :init + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + (setq read-extended-command-predicate + #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) + +(use-package! boogie-friends) + +(use-package! ol-notmuch :after org) + +(use-package! circe + :config + (setq circe-network-options + `(("soju" :host "chat.sr.ht" :port 6697 :tls t + :sasl-username "ymherklotz/irc.libera.chat" + :sasl-password ,(ymhg/pass "sr.ht/chat.sr.ht") + :nick "ymherklotz")))) + +(defun ymhg/reset-coq-windows () + "Resets the Goald and Response windows." + (interactive) + (other-frame 1) + (delete-other-windows) + (split-window-below) + (switch-to-buffer "*goals*") + (other-window 1) + (switch-to-buffer "*response*") + (other-frame 1)) + +(define-key y-map (kbd "o") #'ymhg/reset-coq-windows) + +(defun ymhg--reset-coq-indentation () + "Reset slow indentation." + (setq-local indent-line-function #'indent-relative)) + +(after! coq-mode + (add-hook 'coq-mode-hook #'ymhg--reset-coq-indentation t) + (define-key coq-mode-map (kbd "C-c TAB") #'smie-indent-line) + (setq coq-indent-modulestart 0)) + +(use-package! alectryon + :hook (coq-mode . alectryon-mode) + :config + (when (eq system-type 'darwin) + (setq alectryon-executable "/nix/store/bvlk3hyrjdgl0sg93rrdr2z71hgza0m9-python3.9-alectryon-1.4.0/bin/alectryon")) + (map! :map alectryon-mode-map + "C-c u t" #'alectryon-toggle + "C-c u p" #'ymhg/alectryon-preview) + (defun ymhg/alectryon-preview () + "Display an HTML preview of the current buffer." + (interactive) + (let* ((html-fname (make-temp-file "alectryon" nil ".html")) + (args `("-r" "5" "-" ,html-fname))) + (apply #'call-process-region nil nil "rst2html5" nil nil nil args) + (message "Compilation complete") + (browse-url html-fname)))) + +(use-package! rst + :config + (add-hook 'rst-mode-hook (lambda () (setq fill-column 80)))) + +(use-package! ox-tufte + :after org + :config) + +(use-package! scroll-other-window + :hook (ConTeXt-mode . sow-mode)) + +(use-package! cdlatex + :hook (ConTeXt-mode . turn-on-cdlatex) + :init + (setq cdlatex-command-alist nil) + (setq cdlatex-math-modify-alist nil)) + +(use-package! boogie-friends + :config + (setq flycheck-dafny-executable (executable-find "dafny")) + (setq dafny-verification-backend 'cli)) + +;;(add-to-list 'load-path "/usr/local/Cellar/agda/2.6.2.2/cabal/store/ghc-8.10.7/Agd-2.6.2.2-3bca6588/share/emacs-mode") +;; +;;(use-package! agda2-mode) +#+end_src diff --git a/doom/.config/doom/init.el b/doom/.config/doom/init.el new file mode 100644 index 0000000..e6e4aef --- /dev/null +++ b/doom/.config/doom/init.el @@ -0,0 +1,188 @@ +;;; init.el -*- lexical-binding: t; -*- + +;; This file controls what Doom modules are enabled and what order they load in. +;; Remember to run 'doom sync' after modifying it! + +;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's +;; documentation. There you'll find information about all of Doom's modules +;; and what flags they support. + +;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or +;; 'C-c g k' for non-vim users) to view its documentation. This works on +;; flags as well (those symbols that start with a plus). +;; +;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its +;; directory (for easy access to its source code). + +(setq native-comp-deferred-compilation nil) +(after! (doom-packages straight) + (setq straight--native-comp-available t)) + +(doom! :input + ;;chinese + ;;japanese + + :completion + company ; the ultimate code completion backend + ;;helm ; the *other* search engine for love and life + ;;ido ; the other *other* search engine... + ;;ivy ; a search engine for love and life + vertico + + :ui + ;;deft ; notational velocity for Emacs + doom ; what makes DOOM look the way it does + ;;doom-dashboard ; a nifty splash screen for Emacs + ;;doom-quit ; DOOM quit-message prompts when you quit Emacs + ;;fill-column ; a `fill-column' indicator + ;;hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW + hydra + ;;indent-guides ; highlighted in dent columns + (modeline +light) ; snazzy, Atom-inspired modeline, plus API + ;;nav-flash ; blink the current line after jumping + ;;neotree ; a project drawer, like NERDTree for vim + ;;ophints ; highlight the region an operation acts on + (popup +defaults) ; tame sudden yet inevitable temporary windows + ;;pretty-code ; replace bits of code with pretty symbols + ;;tabs ; an tab bar for Emacs + ;;treemacs ; a project drawer, like neotree but cooler + ;;unicode ; extended unicode support for various languages + ;;vc-gutter ; vcs diff in the fringe + ;;vi-tilde-fringe ; fringe tildes to mark beyond EOB + ;;window-select ; visually switch windows + workspaces ; tab emulation, persistence & separate workspaces + zen ; distraction-free coding or writing + + :editor + ;;(evil +everywhere); come to the dark side, we have cookies + ;;file-templates ; auto-snippets for empty files + fold ; (nigh) universal code folding + ;;(format +onsave) ; automated prettiness + ;;god ; run Emacs commands without modifier keys + ;;lispy ; vim for lisp, for people who don't like vim + ;;multiple-cursors ; editing in many places at once + ;; (objed +manual) ; text object editing for the innocent + ;;parinfer ; turn lisp into python, sort of + ;;rotate-text ; cycle region at point between text candidates + ;;snippets ; my elves. They type so I don't have to + word-wrap ; soft wrapping with language-aware indent + + :emacs + dired ; making dired pretty [functional] + electric ; smarter, keyword-based electric-indent + ;;ibuffer ; interactive buffer management + vc ; version-control and Emacs, sitting in a tree + + :term + ;;eshell ; a consistent, cross-platform shell (WIP) + ;;shell ; a terminal REPL for Emacs + ;;term ; terminals in Emacs + ;;vterm ; another terminals in Emacs + + :checkers + syntax ; tasing you for every semicolon you forget + (spell +aspell) ; tasing you for misspelling mispelling + ;;grammar ; tasing grammar mistake every you make + + :tools + ;;ansible + ;;debugger ; FIXME stepping through code, to help you add bugs + direnv + ;;docker + ;;editorconfig ; let someone else argue about tabs vs spaces + ;;ein ; tame Jupyter notebooks with emacs + eval ; run code, run (also, repls) + ;;gist ; interacting with github gists + lookup ; navigate your code and its documentation + (lsp +eglot) + magit ; a git porcelain for Emacs + ;;make ; run make tasks from Emacs + (pass +auth) ; password manager for nerds + pdf ; pdf enhancements + ;;prodigy ; FIXME managing external services & code builders + ;;rgb ; creating color strings + ;;terraform ; infrastructure as code + ;;tmux ; an API for interacting with tmux + ;;upload ; map local to remote projects via ssh/ftp + + :lang + ;;agda ; types of types of types of types... + ;;assembly ; assembly for fun or debugging + cc ; C/C++/Obj-C madness + ;;clojure ; java with a lisp + common-lisp ; if you've seen one lisp, you've seen them all + coq ; proofs-as-programs + ;;crystal ; ruby at the speed of c + ;;csharp ; unity, .NET, and mono shenanigans + data ; config/data formats + ;;elixir ; erlang done right + ;;elm ; care for a cup of TEA? + emacs-lisp ; drown in parentheses + ;;erlang ; an elegant language for a more civilized age + ;;ess ; emacs speaks statistics + ;;faust ; dsp, but you get to keep your soul + ;;fsharp ; ML stands for Microsoft's Language + ;;fstar ; (dependent) types and (monadic) effects and Z3 + ;;go ; the hipster dialect + (haskell +lsp) ; a language that's lazier than I am + ;;hy ; readability of scheme w/ speed of python + ;;idris ; + ;;(java +meghanada) ; the poster child for carpal tunnel syndrome + ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) + ;;julia ; a better, faster MATLAB + ;;kotlin ; a better, slicker Java(Script) + latex ; writing papers in Emacs has never been so fun + ;;lean + ;;factor + ledger ; an accounting system in Emacs + lua ; one-based indices? one-based indices + markdown ; writing docs for people to ignore + ;;nim ; python + lisp at the speed of c + nix ; I hereby declare "nix geht mehr!" + ocaml ; an objective camel + (org ; organize your plain life in plain text + +gnuplot + ;;+dragndrop ; drag & drop files/images into org buffers + +hugo ; use Emacs for hugo blogging + ;;+jupyter ; ipython/jupyter support for babel + +pandoc ; export-with-pandoc support + ;;+pomodoro ; be fruitful with the tomato technique + +present ; using org-mode for presentations + ) + ;;perl ; write code no one else can comprehend + ;;php ; perl's insecure younger brother + ;;plantuml ; diagrams for confusing people more + ;;purescript ; javascript, but functional + python ; beautiful is better than ugly + ;;qt ; the 'cutest' gui framework ever + ;;racket ; a DSL for DSLs + ;;rest ; Emacs as a REST client + rst ; ReST in peace + ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} + rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap() + ;;scala ; java, but good + (scheme +guile +chicken +racket) ; a fully conniving family of lisps + sh ; she sells {ba,z,fi}sh shells on the C xor + ;;solidity ; do you need a blockchain? No. + ;;swift ; who asked for emoji variables? + ;;terra ; Earth and Moon in alignment for performance. + ;;web ; the tubes + + :email + ;;(mu4e +gmail) + notmuch + ;;(wanderlust +gmail) + + :app + ;;calendar + irc ; how neckbeards socialize + (rss +org) ; emacs as an RSS reader + ;;twitter ; twitter client https://twitter.com/vnought + + :config + literate + (default +bindings +smartparens) + + :os + (:if IS-MAC macos) + tty) diff --git a/doom/.config/doom/packages.el b/doom/.config/doom/packages.el new file mode 100644 index 0000000..3d4e82a --- /dev/null +++ b/doom/.config/doom/packages.el @@ -0,0 +1,75 @@ +;; Disabling packages +(disable-packages! undo-tree org-bullets helm pretty-code) + +;; `org-mode' dependencies +(package! ol-notmuch) +(package! org-contrib + :recipe (:host nil :repo "https://git.sr.ht/~bzg/org-contrib") + :pin "c6aef31ccfc7c4418c3b51e98f7c3bd8e255f5e6") +;;(package! org-contacts) +;; `org-bullets' replacement +(package! org-superstar) +(package! ox-gfm) +(package! ox-tufte + :recipe (:host nil :repo "https://git.sr.ht/~ymherklotz/ox-tufte")) +(package! scroll-other-window + :recipe (:host nil :repo "https://git.sr.ht/~ymherklotz/scroll-other-window")) +(package! cdlatex) +(package! citeproc) +(package! ox-context + :recipe (:host github :repo "Jason-S-Ross/ox-context")) +(package! org-transclusion + :recipe (:host github :repo "nobiot/org-transclusion")) +(package! org-zettelkasten + :recipe (:host github :repo "ymherklotz/emacs-zettelkasten") + :pin "7278052cb451178a2f1ffc61569156ca0adcc34a") +(package! org-auto-tangle + :recipe (:host github :repo "yilkalargaw/org-auto-tangle") + :pin "bce665c79fc29f1e80f1eae7db7e91c56b0788fc") +(package! elfeed-score) + +(package! ef-themes + :recipe (:host nil :repo "https://git.sr.ht/~protesilaos/ef-themes")) + +(package! alectryon) + +;; Bibtex stuff +(package! ebib) + +;; Haskell stuff +(package! ormolu) + +;; Completion +(package! orderless) +(package! marginalia) +(package! embark) +(package! embark-consult) +(package! ripgrep) + +;; Extra language mobdes +(package! yaml-mode) +(package! pollen-mode) + +;; Nix +(package! direnv) + +;; Misc dependencies +(package! hungry-delete) + +;; Teaching +(package! boogie-friends) + +;; Privacy +(package! pinentry) + +;; Emacs lisp +(package! package-lint) + +;; Themes +(package! color-theme-sanityinc-tomorrow) +(package! modus-themes) + +(package! ef-themes + :recipe (:host nil :repo "https://git.sr.ht/~protesilaos/ef-themes")) + +(package! mmm-mode) diff --git a/doom/abbrev-defs b/doom/abbrev-defs deleted file mode 100644 index b9b6d7e..0000000 --- a/doom/abbrev-defs +++ /dev/null @@ -1,9 +0,0 @@ -;;-*-coding: utf-8;-*- -(define-abbrev-table 'global-abbrev-table - '( - ("alth" "although" nil :count 1) - ("bc" "because" nil :count 0) - ("th" "though" nil :count 0) - ("vc" "Vericert" nil :count 0) - )) - diff --git a/doom/config.org b/doom/config.org deleted file mode 100644 index 6b9534b..0000000 --- a/doom/config.org +++ /dev/null @@ -1,1409 +0,0 @@ -#+title: Org configuration -#+property: header-args:emacs-lisp :tangle config.el - -* Top-Level Configuration - -#+begin_src emacs-lisp -(setq doom-font (font-spec :family "Iosevka YMHG Medium" :size 16)) -(when (eq system-type 'darwin) - (setq doom-variable-pitch-font (font-spec :family "Alegreya" :size 20)) - (setq doom-serif-font (font-spec :family "Alegreya" :size 20))) -#+end_src - -#+begin_src emacs-lisp -(setq org-directory "~/Dropbox/org/") - -(setq display-line-numbers-type nil) -;; Remove the ring for emacs -(setq ring-bell-function 'ignore) -;; Automatically refresh files -(global-auto-revert-mode 1) -(setq auto-revert-verbose nil) - -;; Set sentence to end with double space -(setq sentence-end-double-space t) -;; Remove automatic `auto-fill-mode', and replace it by `visual-line-mode', which is a personal -;; preference. -(setq-default fill-column 100) -;;(remove-hook 'text-mode-hook #'auto-fill-mode) -(add-hook 'text-mode-hook #'auto-fill-mode) -;;(add-hook 'text-mode-hook #'+word-wrap-mode) -;;(add-hook 'text-mode-hook #'visual-fill-column-mode) -;;;; Removes performance problems with opening coq files. -(add-to-list 'doom-detect-indentation-excluded-modes 'coq-mode) - -;; Projectile compilation buffer not there anymore for some reason -(setq compilation-buffer-name-function #'compilation--default-buffer-name) - -;; optimisations from https://200ok.ch/posts/2020-09-29_comprehensive_guide_on_handling_long_lines_in_emacs.html -(setq-default bidi-paragraph-direction 'left-to-right) -(if (version<= "27.1" emacs-version) - (setq bidi-inhibit-bpa t)) - -(setq abbrev-file-name - "~/.config/doom/abbrev-defs") -(add-hook 'text-mode-hook #'abbrev-mode) -#+end_src - -#+begin_src emacs-lisp -(use-package ef-themes - :defer nil - :bind ("" . ef-themes-select) - :config - (custom-theme-set-faces! ef-themes-collection - '(proof-locked-face :inherit hl-line) - '(proof-queue-face :inherit region)) - (setq ef-themes-height-0 2.0736 - ef-themes-height-1 1.728 - ef-themes-height-2 1.44 - ef-themes-height-3 1.2 - ef-themes-height-4 1.0 - ef-themes-height-5 1.0 - ef-themes-height-6 1.0 - ef-themes-height-7 1.0 - ef-themes-height-8 1.0) - (setq doom-theme 'ef-autumn)) - -(use-package modus-themes - :defer nil - :init - ;; Add all your customizations prior to loading the themes - (setq modus-themes-region '(bg-only no-extend)) - - ;; Load the theme files before enabling a theme - (modus-themes-load-themes) - (custom-theme-set-faces! '(modus-vivendi modus-operandi) - '(proof-locked-face :inherit modus-themes-nuanced-cyan) - '(proof-queue-face :inherit modus-themes-nuanced-magenta)) - :config - ;; Load the theme of your choice: - ;;(modus-themes-load-operandi) ;; OR (modus-themes-load-vivendi) - ;;:bind ("" . modus-themes-toggle)) - ) -#+end_src - -#+begin_src emacs-lisp -;; Disable stuff -(global-prettify-symbols-mode -1) -(electric-indent-mode -1) -(menu-bar-mode -1) - -(add-hook 'text-mode-hook (lambda () (company-mode -1))) -#+end_src - -#+begin_src emacs-lisp -(use-package! projectile - :config - (add-to-list 'projectile-globally-ignored-directories ".direnv")) -#+end_src - -** Key Binding Customisations - -#+begin_src emacs-lisp -;; Stop emacs from freezing when trying to minimize it on a tiling WM. -(global-unset-key (kbd "C-z")) -(global-set-key (kbd "M-u") #'upcase-dwim) -(global-set-key (kbd "M-l") #'downcase-dwim) -(global-set-key (kbd "M-c") #'capitalize-dwim) -(global-set-key (kbd "C-c z") #'quick-calc) -(global-set-key (kbd "") #'revert-buffer) -(global-set-key (kbd "C-.") (lambda () (interactive) (other-window -1))) -(global-set-key (kbd "C-,") #'other-window) -(global-set-key (kbd "C-c l") #'org-store-link) -(global-set-key (kbd "C-c a") #'org-agenda) -(global-set-key (kbd "C-c /") #'avy-goto-word-1) -(global-set-key (kbd "M-=") #'count-words) -(global-set-key (kbd "C-x m") #'+notmuch/compose) -(global-set-key (kbd "C-M-x") #'scroll-other-window-down) - -;; Set undo-only correctly -(global-set-key (kbd "C-\\") 'undo-only) - -;; Revert C-a and C-e to go to the beginning and end of line, not a fan of the -;; default smart functions. -(global-set-key (kbd "C-a") #'beginning-of-line) -(global-set-key (kbd "C-e") #'end-of-line) - -;; Define functions to push and pop from mark. -(defun push-mark-no-activate () - "Pushes `point' to `mark-ring' and does not activate the region - Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" - (interactive) - (push-mark (point) t nil) - (message "Pushed mark to ring")) - -(defun jump-to-mark () - "Jumps to the local mark, respecting the `mark-ring' order. - This is the same as using \\[set-mark-command] with the prefix argument." - (interactive) - (set-mark-command 1)) - -(global-set-key (kbd "C-`") #'push-mark-no-activate) -(global-set-key (kbd "M-`") #'jump-to-mark) - -;; Swap two window positions. -(defun y/swap-windows () - "Swaps two windows and leaves the cursor in the original one" - (interactive) - (ace-swap-window) - (aw-flip-window)) - -(defun ymhg/pass (query) - "Return the password as a string from QUERY." - (s-trim (shell-command-to-string (concat "pass show " query)))) - -;; Define a custom key map for other useful commands. -(define-prefix-command 'y-map) -(global-set-key (kbd "C-c y") 'y-map) - -(define-key y-map (kbd "p") #'password-store-copy) -(define-key y-map (kbd "q") #'password-store-otp-token-copy) -(define-key y-map (kbd "i") #'password-store-insert) -(define-key y-map (kbd "g") #'password-store-generate) -;(define-key y-map (kbd "r") #'toggle-rot13-mode) -(define-key y-map (kbd "c") #'calendar) -(define-key y-map (kbd "C-r") #'ymhg/reload-keywords) -(define-key y-map (kbd "d") #'y/insert-date) -(define-key y-map (kbd "C-g") #'org-zettelkasten-goto-id) -(define-key y-map (kbd "C-t") #'org-babel-detangle) -(define-key y-map (kbd "C-l") #'org-agenda-open-link) -(define-key y-map (kbd "C-p") #'org-previous-link) -(define-key y-map (kbd "C-n") #'org-next-link) -(define-key y-map (kbd "s") - (lambda () (interactive) - (let ((org-agenda-files - '("~/Dropbox/zk/hls.org" - "~/Dropbox/zk/computing.org" - "~/Dropbox/zk/verification.org" - "~/Dropbox/zk/mathematics.org" - "~/Dropbox/zk/hardware.org"))) (org-search-view)))) - -(setq browse-url-handlers - '(("wikipedia\\.org" . eww-browse-url) - ("yannherklotz\\.com" . eww-browse-url) - ("ymhg\\.org" . eww-browse-url) - ("archlinux\\.org" . eww-browse-url) - ("sachachua\\.com" . eww-browse-url) - ("comonad\\.com" . eww-browse-url) - ("drewdevault\\.com" . eww-browse-url) - ("wordpress\\.com" . eww-browse-url) - ("mathbabe\\.org" . eww-browse-url) - ("ethz\\.ch" . eww-browse-url) - ("pragmaticemacs\\.com" . eww-browse-url))) - -(defun y/insert-date () - "Insert a timestamp according to locale's date and time format." - (interactive) - (insert (format-time-string "%c" (current-time)))) -#+end_src - -** Mac Specific Customisations - -#+begin_src emacs-lisp -;; Mac configuration -(when (eq system-type 'darwin) - (progn (setq mac-right-option-modifier 'none - mac-command-modifier 'meta - mac-option-modifier nil) - - (defun ymhg/apply-theme (appearance) - "Load theme, taking current system APPEARANCE into consideration." - (mapc #'disable-theme custom-enabled-themes) - (pcase appearance - ('light (load-theme 'ef-day t)) - ('dark (load-theme 'ef-autumn t)))) - - (add-hook 'ns-system-appearance-change-functions #'ymhg/apply-theme))) -#+end_src - -** Backup Settings - -#+begin_src emacs-lisp -;; Set backup directories into the tmp folder -(defvar --backup-directory (concat user-emacs-directory "backups")) -(if (not (file-exists-p --backup-directory)) - (make-directory --backup-directory t)) -(setq backup-directory-alist `(("." . ,--backup-directory))) -(setq make-backup-files t ; backup of a file the first time it is saved. - backup-by-copying t ; don't clobber symlinks - version-control t ; version numbers for backup files - delete-old-versions t ; delete excess backup files silently - delete-by-moving-to-trash t - kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2) - kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2) - auto-save-default t ; auto-save every buffer that visits a file - auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30) - auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300) - ) -#+end_src - -** Whitespace Settings - -#+begin_src emacs-lisp -;; Configure activation for whitespace mode -(use-package! whitespace - :bind (("C-x w" . whitespace-mode)) - :init - (setq whitespace-style '(newline newline-mark)) - (setq whitespace-display-mappings '((newline-mark 10 [?¬ 10])))) - -;; Configure expand-region mode. -(use-package! expand-region - :bind ("M-o" . er/expand-region)) - -;; Delete all whitespace until the first non-whitespace character. -(use-package! hungry-delete - :config - (global-hungry-delete-mode) - ;; disable hungry delete in minibuffer-mode: https://github.com/abo-abo/swiper/issues/2761 - (add-to-list 'hungry-delete-except-modes 'minibuffer-mode)) -#+end_src - -* Tramp - -#+begin_src emacs-lisp -(setq tramp-auto-save-directory "/tmp") -(defvar disable-tramp-backups '(all)) -(eval-after-load "tramp" - '(progn - ;; Modified from https://www.gnu.org/software/emacs/manual/html_node/tramp/Auto_002dsave-and-Backup.html - (setq backup-enable-predicate - (lambda (name) - (and (normal-backup-enable-predicate name) - ;; Disable all tramp backups - (and disable-tramp-backups - (member 'all disable-tramp-backups) - (not (file-remote-p name 'method))) - (not ;; disable backup for tramp with the listed methods - (let ((method (file-remote-p name 'method))) - (when (stringp method) - (member method disable-tramp-backups))))))) - - (defun tramp-set-auto-save--check (original) - (if (funcall backup-enable-predicate (buffer-file-name)) - (funcall original) - (auto-save-mode -1))) - - (advice-add #'tramp-set-auto-save :around #'tramp-set-auto-save--check) - - ;; Use my ~/.ssh/config control master settings according to https://puppet.com/blog/speed-up-ssh-by-reusing-connections - (setq tramp-ssh-controlmaster-options ""))) -#+end_src - -* Language Settings -** Flycheck - -#+begin_src emacs-lisp -(use-package! flycheck - :config - (setq flycheck-idle-change-delay 1) - (setq flycheck-display-errors-delay 1.0) - (setq-default flycheck-disabled-checkers '(haskell-stack-ghc)) - (remove-hook 'flycheck-mode-hook #'+syntax-init-popups-h)) -#+end_src - -** Magit - -#+begin_src emacs-lisp -;; Set up magit when C-c g is called -(use-package! magit - :bind (("C-x g" . magit-status)) - :config - (add-hook 'magit-status-sections-hook #'magit-insert-modules 90)) -#+end_src - -** Org mode - -#+begin_src emacs-lisp -;; Org configuration -(use-package! org - :mode ("\\.org\\'" . org-mode) - :init - (map! :map org-mode-map - "M-n" #'outline-next-visible-heading - "M-p" #'outline-previous-visible-heading - "C-c ]" #'ebib-insert-citation - "C-," nil - "C-c C-." #'org-time-stamp-inactive) - (setq org-src-window-setup 'current-window - org-return-follows-link t - org-confirm-babel-evaluate nil - org-use-speed-commands t - org-hide-emphasis-markers nil - org-adapt-indentation nil - org-cycle-separator-lines 2 - org-startup-folded 'content - org-structure-template-alist '(("a" . "export ascii") - ("c" . "center") - ("C" . "comment") - ("e" . "example") - ("E" . "export") - ("h" . "export html") - ("l" . "export latex") - ("q" . "quote") - ("s" . "src") - ("v" . "verse") - ("el" . "src emacs-lisp") - ("d" . "definition") - ("t" . "theorem"))) - ;;(customize-set-variable 'org-blank-before-new-entry - ;; '((heading . nil) - ;; (plain-list-item . nil))) - (require 'oc) - (require 'oc-biblatex) - (require 'oc-csl) - (setq org-cite-export-processors '((latex biblatex) - (t csl)) - org-cite-csl-styles-dir "~/projects/csl-styles" - org-cite-global-bibliography '("~/Dropbox/bibliography/references.bib"))) - -(use-package! citeproc) - -(use-package! org-attach - :config - (setq org-attach-auto-tag "attach")) - -(use-package! org-crypt - :after org - :config - (org-crypt-use-before-save-magic) - (setq org-tags-exclude-from-inheritance '("crypt")) - (setq org-crypt-key "8CEF4104683551E8")) - -;;(use-package! org-contacts -;; :after org -;; :init -;; (setq org-contacts-files '("~/Dropbox/org/contacts.org"))) - -(use-package org-auto-tangle - :hook (org-mode . org-auto-tangle-mode)) - -;; Disable org indent mode and remove C-, from the org-mode-map. -(after! org - (setq org-element-use-cache nil) - ;; Set agenda files, refile targets and todo keywords. - (setq org-startup-indented nil) - (setq org-log-done 'time - org-log-into-drawer t) - (setq org-agenda-files (mapcar 'expand-file-name - (list "~/Dropbox/org/inbox.org" - "~/Dropbox/org/main.org" - "~/Dropbox/org/tickler.org" - "~/Dropbox/org/projects.org" - (format-time-string "~/Dropbox/org/%Y-%m.org") - "~/Dropbox/bibliography/reading_list.org"))) - (setq org-agenda-tag-filter '("-backed")) - (setq org-refile-targets `(("~/Dropbox/org/main.org" :level . 1) - ("~/Dropbox/org/someday.org" :level . 1) - ("~/Dropbox/org/projects.org" :maxlevel . 2) - (,(format-time-string "~/Dropbox/org/%Y-%m.org") :level . 1))) - ;; Set custom agenda commands which can be activated in the agenda viewer. - (setq org-agenda-custom-commands - '(("w" "At work" tags-todo "@work" - ((org-agenda-overriding-header "Work"))) - ("h" "At home" tags-todo "@home" - ((org-agenda-overriding-header "Home"))) - ("u" "At uni" tags-todo "@uni" - ((org-agenda-overriding-header "University"))))) - - (setq org-agenda-span 7 - org-agenda-start-day "." - org-agenda-start-on-week 1) - (setq org-agenda-include-diary t) - - (setq org-icalendar-include-todo t) - (setq org-icalendar-include-bbdb-anniversaries t) - - (setq org-capture-templates - `(("t" "Todo" entry (file "inbox.org") - "* TODO %? -:PROPERTIES: -:ID: %(org-id-uuid) -:END: -:LOGBOOK: -- State \"TODO\" from \"\" %U -:END:" :empty-lines 1) - ("l" "Link Todo" entry (file "inbox.org") - "* TODO %? -:PROPERTIES: -:ID: %(org-id-uuid) -:END: -:LOGBOOK: -- State \"TODO\" from \"\" %U -:END: - -%a" :empty-lines 1) - ("c" "Contacts" entry (file "~/Dropbox/org/contacts.org") - "* %(org-contacts-template-name) - :PROPERTIES: - :EMAIL: %(org-contacts-template-email) - :END:" :empty-lines 1)) - - org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "DELG(l)" ; This task is delegated - "SMDY(m)" ; todo some day - "|" - "DONE(d!)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)")) - org-todo-keyword-faces '(("[-]" . +org-todo-active) - ("STRT" . +org-todo-active) - ("[?]" . +org-todo-onhold) - ("WAIT" . +org-todo-onhold) - ("HOLD" . +org-todo-onhold) - ("DELG" . +org-todo-onhold) - ("SMDY" . +org-todo-onhold) - ("PROJ" . +org-todo-project) - ("NO" . +org-todo-cancel) - ("KILL" . +org-todo-cancel))); Task was completed -;; (setq org-html-head-extra -;; " -;; -;;" - (setq org-html-head-include-default-style nil - org-html-head-include-scripts nil - org-html-doctype "html5" - org-html-html5-fancy t - org-html-container-element "section" - org-html-postamble-format - '(("en" "")) - org-html-postamble t - org-html-divs '((preamble "header" "header") - (content "article" "content") - (postamble "footer" "postamble"))) - - (setq org-export-with-broken-links t) - (require 'org-habit) - - (require 'calendar) - (setq calendar-mark-diary-entries-flag t) - (setq calendar-mark-holidays-flag t) - (setq calendar-mode-line-format nil) - (setq calendar-time-display-form - '(24-hours ":" minutes - (when time-zone - (format "(%s)" time-zone)))) - (setq calendar-week-start-day 1) ; Monday - (setq calendar-date-style 'iso) - (setq calendar-date-display-form calendar-iso-date-display-form) - (setq calendar-time-zone-style 'numeric) ; Emacs 28.1 - - (require 'cal-dst) - (setq calendar-standard-time-zone-name "+0000") - (setq calendar-daylight-time-zone-name "+0100") - - (require 'diary-lib) - (setq diary-file "~/Dropbox/org/diary") - (setq diary-date-forms diary-iso-date-forms) - (setq diary-comment-start ";;") - (setq diary-comment-end "") - (setq diary-nonmarking-symbol "!") - (setq diary-show-holidays-flag t) - (setq diary-display-function #'diary-fancy-display) ; better than its alternative - (setq diary-header-line-format nil) - (setq diary-list-include-blanks nil) - (setq diary-number-of-entries 2) - (setq diary-mail-days 2) - (setq diary-abbreviated-year-flag nil) - - (add-hook 'calendar-today-visible-hook #'calendar-mark-today) - (add-hook 'diary-list-entries-hook #'diary-fix-timezone t) - (add-hook 'diary-list-entries-hook #'diary-sort-entries t) - - - (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) - (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files) - ;; Prevent Org from interfering with my key bindings. - (remove-hook 'calendar-mode-hook #'org--setup-calendar-bindings) - - (let ((map calendar-mode-map)) - (define-key map (kbd "s") #'calendar-sunrise-sunset) - (define-key map (kbd "l") #'lunar-phases) - (define-key map (kbd "i") nil) ; Org sets this, much to my chagrin (see `remove-hook' above) - (define-key map (kbd "i a") #'diary-insert-anniversary-entry) - (define-key map (kbd "i c") #'diary-insert-cyclic-entry) - (define-key map (kbd "i d") #'diary-insert-entry) ; for current "day" - (define-key map (kbd "i m") #'diary-insert-monthly-entry) - (define-key map (kbd "i w") #'diary-insert-weekly-entry) - (define-key map (kbd "i y") #'diary-insert-yearly-entry) - (define-key map (kbd "M-n") #'calendar-forward-month) - (define-key map (kbd "M-p") #'calendar-backward-month)) - - (defun diary-schedule (y1 m1 d1 y2 m2 d2 dayname) - "Entry applies if date is between dates on DAYNAME. - Order of the parameters is M1, D1, Y1, M2, D2, Y2 if - `european-calendar-style' is nil, and D1, M1, Y1, D2, M2, Y2 if - `european-calendar-style' is t. Entry does not apply on a history." - (let ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1))) - (date2 (calendar-absolute-from-gregorian (list m2 d2 y2))) - (d (calendar-absolute-from-gregorian date))) - (if (and - (<= date1 d) - (<= d date2) - (= (calendar-day-of-week date) dayname) - (not (calendar-check-holidays date))) - entry))) - - (defun diary-fix-timezone () - (let ((eqtimezone (string= - (replace-regexp-in-string - "\n" "" - (shell-command-to-string "date +%z")) - (replace-regexp-in-string - "\n" "" - (shell-command-to-string "TZ=\"Europe/London\" date +%z"))))) - (setq diary-entries-list - (mapcar (lambda (entry) - (pcase entry - (`(,date ,time ,sdate . ,rest) - (let ((dt (diary-entry-time time)) - (string-date (apply (lambda (a b c) (format "%d-%d-%d" c a b)) date))) - (if (or eqtimezone (= dt diary-unknown-time)) - entry - (let* ((tr (org-tz-conv (concat string-date " " (number-to-string dt)) "Europe/London" "from")) - (split (split-string tr "[- ]")) - (year (car split)) - (month (cadr split)) - (day (caddr split)) - (hour (cadddr split))) - (cons (mapcar #'string-to-number (list month day year)) - (cons (concat hour (replace-regexp-in-string "^[^ ]+" "" time)) - (cons (format "%s-%s-%s" year month day) rest))))))))) - diary-entries-list)))) - - (defun org-tz-conv (stamp tz way) - "Convert a STAMP to or from TZ depending on WAY. - -This function uses the date command line tool to do it." - (let* ((current-tz-offset (replace-regexp-in-string - "\n" "" - (shell-command-to-string "date +%z"))) - (stamp1 (concat (replace-regexp-in-string "[<>]" "" stamp))) - (date-cmd-p0 "TZ=%s gdate -d \"%s\"") - (date-cmd-p1 "gdate --date=\"TZ=\\\"%s\\\" %s\"") - (date-cmd-p2 " +\"%F %H:%M\"") - (date-cmd-from (concat (format date-cmd-p1 tz stamp1) date-cmd-p2)) - (date-cmd-to (concat (format date-cmd-p0 tz - (concat stamp1 " " current-tz-offset)) - date-cmd-p2)) - - (shell-result-from (shell-command-to-string date-cmd-from)) - (shell-result-to (shell-command-to-string date-cmd-to)) - - (result-from (replace-regexp-in-string "\n" "" shell-result-from)) - (result-to (replace-regexp-in-string "\n" "" shell-result-to))) - (cond ((string-equal way "from") result-from) - ((string-equal way "to") result-to)))) - - (require 'ox-extra) - (ox-extras-activate '(ignore-headlines)) - - (require 'ox-beamer) - (require 'ox-latex) - (add-to-list 'org-latex-classes - '("beamer" - "\\documentclass\[presentation\]\{beamer\}" - ("\\section\{%s\}" . "\\section*\{%s\}") - ("\\subsection\{%s\}" . "\\subsection*\{%s\}") - ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}"))) - (add-to-list 'org-latex-classes - '("scrartcl" - "\\documentclass\{scrartcl\}" - ("\\section\{%s\}" . "\\section*\{%s\}") - ("\\subsection\{%s\}" . "\\subsection*\{%s\}") - ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}") - ("\\paragraph{%s}" . "\\paragraph*{%s}"))) - (add-to-list 'org-latex-packages-alist '("" "minted")) - (setq org-latex-listings 'minted) - (setq org-latex-pdf-process '("latexmk -f -pdf -%latex -shell-escape -interaction=nonstopmode -output-directory=%o %f")) - (setq org-beamer-environments-extra '(("onlyenv" "o" "\\begin{onlyenv}%a{%h}" "\\end{onlyenv}") - ("onlyenvNH" "o" "\\begin{onlyenv}%a" "\\end{onlyenv}") - ("blockNH" "o" "\\begin{block}%a{}" "\\end{block}") - ("oeblock" "o" "\\only%a{\\begin{block}%a{%h}" "\\end{block}}") - ("oeblockNH" "o" "\\only%a{\\begin{block}%a{}" "\\end{block}}") - ("minipage" "o" "\\begin{minipage}[t]%o[t]{1.0\\textwidth}" "\\end{minipage}"))) - - (add-to-list 'org-latex-packages-alist '("" "tikz" t)) - (eval-after-load "preview" - '(add-to-list 'preview-default-preamble - "\\PreviewEnvironment{tikzpicture}" t))) - -(use-package appt - :config - (setq appt-display-diary nil) - (setq appt-disp-window-function #'appt-disp-window) - (setq appt-display-mode-line t) - (setq appt-display-interval 3) - (setq appt-audible nil) - (setq appt-warning-time-regexp "appt \\([0-9]+\\)") - (setq appt-message-warning-time 15) - (run-at-time 10 nil #'appt-activate 1)) - -(use-package! org-transclusion - :after org - :config - (setq org-transclusion-exclude-elements nil) - (advice-remove 'org-link-search '+org--recenter-after-follow-link-a)) - -(use-package! org-superstar - :hook (org-mode . org-superstar-mode) - :config - (setq org-superstar-headline-bullets-list '("♚" "♛" "♜" "♝" "♞" "♔" "♕" "♖" "♗" "♘" "♙") - org-superstar-special-todo-items t)) - -(use-package! org-id - :after org - :config - (setq org-id-link-to-org-use-id 'use-existing) - (setq org-id-track-globally t)) - -;; Set up org registers to quickly jump to files that I use often. -(set-register ?l (cons 'file "~/.emacs.d/loader.org")) -(set-register ?m (cons 'file "~/Dropbox/org/meetings.org")) -(set-register ?i (cons 'file "~/Dropbox/org/inbox.org")) -(set-register ?p (cons 'file "~/Dropbox/org/projects.org")) -(set-register ?c (cons 'file (format-time-string "~/Dropbox/org/%Y-%m.org"))) -#+end_src - -#+begin_src emacs-lisp -(use-package! ox-context - :after org - :config - (add-to-list - 'org-context-presets-alist - '("ymhg-article" . - (:literal "\\setupwhitespace[none]" - :template "article" - :snippets - ("description-article" "quote-article" "verse-article" - "table-article" "title-ymhg" "sectioning-article" "page-numbering-article")))) - (add-to-list 'org-context-snippets-alist - '("title-ymhg" . "\\setuphead[title][align=middle] -\\definestartstop[OrgTitlePage] -\\define\\OrgMakeTitle{% - \\startalignment[center] - \\blank[force,2*big] - \\title{\\documentvariable{metadata:title}} - \\doifnot{\\documentvariable{metadata:subtitle}}{}{ - \\blank[force,1*big] - \\tfa \\documentvariable{metadata:subtitle}} - \\doifelse{\\documentvariable{metadata:author}}{}{ - \\blank[2*medium] - {\\tfa \\documentvariable{metadata:email}} - }{ - \\blank[force,2*medium] - {\\it by \\documentvariable{metadata:author}}, on \\documentvariable{metadata:date} - } - \\blank[3*medium] - \\stopalignment} -\\setupsectionblock[frontpart][page=no] -\\setupsectionblock[bodypart][page=no] -\\setuppagenumbering[location={footer,middle}]")) - (setq org-context-headline-command - '("OrgHeadline" . "\\def\\OrgHeadline#1[#2]{% - \\getparameters - [OrgHeadline] - [Todo=, - TodoType=, - Priority=, - Text=, - Tags=, - #2]% - \\doifnot{\\OrgHeadlineTodo}{}{{\\sansbold{\\smallcaps{\\OrgHeadlineTodo}}\\space}}% - \\doifnot{\\OrgHeadlinePriority}{}{{\\inframed{\\OrgHeadlinePriority}\\space}}% - \\OrgHeadlineText% - \\doifnot{\\OrgHeadlineTags}{}{{\\hfill\\tt\\OrgHeadlineTags}}% -}"))) -#+end_src - -** Latex/Context - -#+begin_src emacs-lisp -(after! pdf-tools - (pdf-tools-install)) - -(after! latex - (setq TeX-view-program-selection '((output-pdf "PDF Tools")) - TeX-source-correlate-start-server t) - (setq-default TeX-command-extra-options "-shell-escape") - (add-hook 'TeX-after-compilation-finished-functions - #'TeX-revert-document-buffer)) - -(after! context - (setq TeX-command-list - (append - '(("context" - "context --purgeall %s" - TeX-run-command nil t :help "Run ConTeXt")) TeX-command-list)) - (map! :map ConTeXt-mode-map - "C-c ]" #'ebib-insert-citation) - (add-hook 'ConTeXt-mode-hook #'reftex-mode)) - -(use-package! ox-gfm :after ox) -(use-package! ox-hugo :after ox) - -(use-package! elfeed-org - :config - (elfeed-org) - (setq rmh-elfeed-org-files (list "~/Dropbox/org/elfeed.org")) - (run-at-time nil (* 8 60 60) #'elfeed-update)) - -(use-package! mmm-mode - :config - (mmm-add-group - 'fancy-context - '((embedded-lua - :submode lua-mode - :front "\\\\startluacode" - :back "\\\\stopluacode") - (embedded-C - :submode c-mode - :front "\\\\starthlC" - :back "\\\\stophlC") - (embedded-metapost - :submode metapost-mode - :front "\\\\startuseMPgraphic" - :back "\\\\stopuseMPgraphic") - )) - - (mmm-add-mode-ext-class 'ConTeXt-en/PS nil 'fancy-context) - (setq mmm-global-mode 'maybe) - ;;(setq mmm-never-modes - ;; (append '(ediff-mode) '(text-mode) mmm-never-modes)) - ) - -(require 'mmm-auto) - -#+end_src - -*** Zettelkasten - -#+begin_src emacs-lisp -(use-package! org-zettelkasten - :config - (add-hook 'org-mode-hook #'org-zettelkasten-mode) - - (defun org-zettelkasten-search-current-id () - "Use `consult-ripgrep' to search for the current ID in all files." - (interactive) - (let ((current-id (org-entry-get nil "CUSTOM_ID"))) - (consult-ripgrep org-zettelkasten-directory (concat "[\\[:]." current-id "\\]#")))) - - (define-key org-zettelkasten-mode-map (kbd "r") #'org-zettelkasten-search-current-id) - (setq org-zettelkasten-directory "~/Dropbox/zk") - - (defun org-zettelkasten-goto-id (id) - "Go to an ID." - (interactive "sID: #") - (cond ((string-prefix-p "1" id) - (org-link-open-from-string - (concat "[[file:" org-zettelkasten-directory - "/hls.org::#" id "]]"))) - ((string-prefix-p "2" id) - (org-link-open-from-string - (concat "[[file:" org-zettelkasten-directory - "/computing.org::#" id "]]"))) - ((string-prefix-p "3" id) - (org-link-open-from-string - (concat "[[file:" org-zettelkasten-directory - "/verification.org::#" id "]]"))) - ((string-prefix-p "4" id) - (org-link-open-from-string - (concat "[[file:" org-zettelkasten-directory - "/mathematics.org::#" id "]]"))) - ((string-prefix-p "5" id) - (org-link-open-from-string - (concat "[[file:" org-zettelkasten-directory - "/hardware.org::#" id "]]")))))) -#+end_src - -#+begin_src emacs-lisp -;; Set up zettelkasten mode -(use-package! zettelkasten - :bind-keymap - ("C-c k" . zettelkasten-mode-map)) -#+end_src - -** Verilog - -#+begin_src emacs-lisp -;; Set sensitive data mode -(setq auto-mode-alist - (append - (list ;;'("\\.\\(vcf\\|gpg\\)\\'" . sensitive-minor-mode) - '("\\.sv\\'" . verilog-mode) - '("\\.mkiv\\'" . context-mode) - '("\\.mkii\\'" . context-mode) - '("\\.mkxl\\'" . context-mode)) - auto-mode-alist)) - -(after! verilog-mode - (setq verilog-simulator "iverilog")) -#+end_src - -** Ebib - -#+begin_src emacs-lisp -;; Bibtex stuff -(use-package! ebib - :bind (("C-c y b" . ebib)) - :init - (defun ymhg/ebib-create-identifier (key _) key) - (setq ebib-preload-bib-files '("~/Dropbox/bibliography/references.bib") - ebib-notes-default-file "~/Dropbox/bibliography/notes.org" - ebib-notes-template "* %T\n:PROPERTIES:\n%K\n:NOTER_DOCUMENT: papers/%k.pdf\n:END:\n%%?\n" - ebib-keywords (expand-file-name "~/Dropbox/bibliography/keywords.txt") - ebib-reading-list-file "~/Dropbox/bibliography/reading_list.org" - ebib-notes-storage 'multiple-notes-per-file) - :config - (add-to-list 'ebib-notes-template-specifiers '(?k . ymhg/ebib-create-identifier)) - (add-to-list 'ebib-file-search-dirs "~/Dropbox/bibliography/papers") - (if (eq system-type 'darwin) - (add-to-list 'ebib-file-associations '("pdf" . "open")) - (add-to-list 'ebib-file-associations '("pdf" . nil))) - (add-to-list 'ebib-citation-commands '(org-mode (("ref" "[cite:@%(%K%,)]")))) - (add-to-list 'ebib-citation-commands '(context-mode (("cite" "\\cite[%(%K%,)]") - ("authoryear" "\\cite[authoryear][%(%K%,)]") - ("authoryears" "\\cite[authoryears][%(%K%,)]") - ("entry" "\\cite[entry][%(%K%,)]") - ("author" "\\cite[author][%(%K%,)]")))) - - (advice-add 'bibtex-generate-autokey :around - (lambda (orig-func &rest args) - (replace-regexp-in-string ":" "" (apply orig-func args)))) - (remove-hook 'ebib-notes-new-note-hook #'org-narrow-to-subtree) - - (map! :map ebib-index-mode-map - "D" #'ebib-download-pdf-from-doi)) - -(defun sci-hub-pdf-url (doi) - "Get url to the pdf from SCI-HUB using DOI." - (setq *doi-utils-pdf-url* (concat "https://sci-hub.hkvisa.net/" doi) ;captcha - ,*doi-utils-waiting* t - ) - ;; try to find PDF url (if it exists) - (url-retrieve (concat "https://sci-hub.hkvisa.net/" doi) - (lambda (_) - (goto-char (point-min)) - (while (search-forward-regexp - "\\(https:\\|sci-hub.hkvisa.net/downloads\\).+download=true'" nil t) - (let ((foundurl (match-string 0))) - (message foundurl) - (if (string-match "https:" foundurl) - (setq *doi-utils-pdf-url* foundurl) - (setq *doi-utils-pdf-url* (concat "https:" foundurl)))) - (setq *doi-utils-waiting* nil)))) - (while *doi-utils-waiting* (sleep-for 0.1)) - (replace-regexp-in-string "\\\\" "" *doi-utils-pdf-url*)) - -(defun acm-pdf-url (doi) - "Retrieve a DOI pdf from the ACM." - (concat "https://dl.acm.org/doi/pdf/" doi)) - -(defun ieee-pdf-url (doi) - "Retrieve a DOI pdf from the IEEE." - (when (string-match "\\.\\([0-9]*\\)$" doi) - (let ((doi-bit (match-string 1 doi))) - (concat "https://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&arnumber=" doi-bit "&ref=")))) - -(defun springer-pdf-url (doi) - "Retrieve a DOI pdf from the Springer." - (concat "https://link.springer.com/content/pdf/" doi ".pdf")) - -(defun arxiv-pdf-url (epr) - (concat "https://arxiv.org/pdf/" epr ".pdf")) - -(defun download-pdf-from-doi (key &optional doi publisher eprint journal organization url) - "Download pdf from doi with KEY name." - (let ((pub (or publisher "")) - (epr (or eprint "")) - (jour (or journal "")) - (org (or organization "")) - (link (or url ""))) - (url-copy-file (cond - ((not doi) link) - ((or (string-match "ACM" (s-upcase pub)) - (string-match "association for computing machinery" (s-downcase pub))) - (acm-pdf-url doi)) - ((string-match "arxiv" (s-downcase pub)) - (arxiv-pdf-url epr)) - ((or (string-match "IEEE" (s-upcase pub)) - (string-match "IEEE" (s-upcase jour)) - (string-match "IEEE" (s-upcase org))) - (ieee-pdf-url doi)) - ((string-match "springer" (s-downcase pub)) - (springer-pdf-url doi)) - (t (sci-hub-pdf-url doi))) - (concat (car ebib-file-search-dirs) "/" key ".pdf")))) - -(defun download-pdf-from-link (link key) - (url-copy-file link - (concat (car ebib-file-search-dirs) "/" key ".pdf"))) - -(defun download-pdf-from-downloads (key) - (copy-file (concat "~/Downloads/" key ".pdf") - (concat (car ebib-file-search-dirs) "/" key ".pdf") t)) - -(defun get-bib-from-doi (doi) - "Get the bibtex from DOI." - (shell-command (concat "curl -L -H \"Accept: application/x-bibtex; charset=utf-8\" " - "https://doi.org/" doi))) - -(defun ebib-download-pdf-from-doi () - "Download a PDF for the current entry." - (interactive) - (let* ((key (ebib--get-key-at-point)) - (doi (ebib-get-field-value "doi" key ebib--cur-db 'noerror 'unbraced 'xref)) - (publisher (ebib-get-field-value "publisher" key ebib--cur-db 'noerror 'unbraced 'xref)) - (eprinttype (ebib-get-field-value "eprinttype" key ebib--cur-db 'noerror 'unbraced 'xref)) - (eprint (ebib-get-field-value "eprint" key ebib--cur-db 'noerror 'unbraced 'xref)) - (journal (ebib-get-field-value "journal" key ebib--cur-db 'noerror 'unbraced 'xref)) - (journaltitle (ebib-get-field-value "journaltitle" key ebib--cur-db 'noerror 'unbraced 'xref)) - (organization (ebib-get-field-value "organization" key ebib--cur-db 'noerror 'unbraced 'xref)) - (url (ebib-get-field-value "url" key ebib--cur-db 'noerror 'unbraced 'xref))) - (unless key - (error "[Ebib] No key assigned to entry")) - (download-pdf-from-doi key doi (or publisher eprinttype) eprint (or journal journaltitle) organization url))) - -(defun ebib-check-file () - "Download a PDF for the current entry." - (interactive) - (let ((key (ebib--get-key-at-point))) - (unless (file-exists-p (concat (car ebib-file-search-dirs) "/" key ".pdf")) - (error "[Ebib] No PDF found.")) - t)) -#+end_src - -** Ocaml - -#+begin_src emacs-lisp -(after! tuareg-mode - (add-hook 'tuareg-mode-hook - (lambda () - (define-key tuareg-mode-map (kbd "C-M-") #'ocamlformat) - (add-hook 'before-save-hook #'ocamlformat-before-save)))) -#+end_src - -** Spell check - -#+begin_src emacs-lisp -;; Set up dictionaries -(setq ispell-dictionary "british") - -(use-package! spell-fu - :config - (add-hook 'spell-fu-mode-hook - (lambda () - (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "en_GB")) - (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "de_DE")) - (spell-fu-dictionary-add (spell-fu-get-ispell-dictionary "fr_FR")) - (spell-fu-dictionary-add - (spell-fu-get-personal-dictionary "fr-personal" "~/.aspell.en_GB.pws")) - (spell-fu-dictionary-add - (spell-fu-get-personal-dictionary "de-personal" "~/.aspell.de_DE.pws")) - (spell-fu-dictionary-add - (spell-fu-get-personal-dictionary "fr-personal" "~/.aspell.fr_FR.pws"))))) - -(after! flyspell - (define-key flyspell-mode-map (kbd "C-.") nil) - (define-key flyspell-mode-map (kbd "C-,") nil) - (setq flyspell-mouse-map (make-sparse-keymap))) -#+end_src - -** Coq configuration - -#+begin_src emacs-lisp -(use-package! proof-general - :config - (setq proof-splash-enable nil - proof-auto-action-when-deactivating-scripting 'retract - proof-delete-empty-windows nil - proof-multiple-frames-enable nil - proof-three-window-enable nil - proof-auto-raise-buffers nil - coq-compile-before-require nil - coq-compile-vos t - coq-compile-parallel-in-background t - coq-max-background-compilation-jobs 4 - coq-compile-keep-going nil - coq-compile-quick 'no-quick)) - -(use-package! company-coq - :after coq - :config - (setq company-idle-delay 1 - company-coq-disabled-features '(prettify-symbols hello company-defaults spinner smart-subscripts snippets compile-command))) -#+end_src - -** Mail - -#+begin_src emacs-lisp -(setq message-send-mail-function 'message-send-mail-with-sendmail) -(setq message-fill-column 80) - -(use-package! sendmail - :config - (if (eq system-type 'darwin) - (setq sendmail-program "/usr/local/bin/msmtp") - (setq sendmail-program "/usr/bin/msmtp"))) - -(setq message-signature "Yann Herklotz -Imperial College London -https://yannherklotz.com") - -(setq auth-sources '("~/.authinfo" "~/.authinfo.gpg" "~/.netrc")) - -(setq mail-specify-envelope-from t - message-sendmail-envelope-from 'header - mail-envelope-from 'header) - -(use-package! notmuch - :config - (defun ymhg/notmuch-search-delete-mail (&optional beg end) - "Delete a message." - (interactive (notmuch-interactive-region)) - (if (member "deleted" (notmuch-search-get-tags)) - (notmuch-search-tag (list "-deleted")) - (notmuch-search-tag (list "+deleted" "-unread") beg end))) - - (defun ymhg/notmuch-show-delete-mail (&optional beg end) - "Delete a message." - (interactive (notmuch-interactive-region)) - (if (member "deleted" (notmuch-show-get-tags)) - (notmuch-show-tag (list "-deleted")) - (notmuch-show-tag (list "+deleted" "-unread") beg end))) - - (setq notmuch-archive-tags '("-inbox" "-unread" "+archive")) - - (map! - :map notmuch-show-mode-map - "d" #'ymhg/notmuch-show-delete-mail) - (map! - :map notmuch-search-mode-map - "d" #'ymhg/notmuch-search-delete-mail) - - (setq notmuch-saved-searches - '((:name "inbox" :query "date:last_month..this_month and tag:inbox not tag:deleted" :key "n") - (:name "flagged" :query "tag:flagged" :key "f") - (:name "sent" :query "tag:sent" :key "s") - (:name "drafts" :query "tag:draft" :key "d") - (:name "mailbox" :query "date:last_month..this_month and (tag:mailbox and tag:inbox) and not tag:deleted and not tag:sent" :key "m") - (:name "imperial" :query "date:last_month..this_month and (tag:imperial and tag:inbox) and not tag:deleted and not tag:sent" :key "i") - (:name "all recent" :query "date:last_month..this_month" :key "r"))) - - (setq notmuch-fcc-dirs - '(("yann@yannherklotz.com" . "mailbox/Sent -inbox +sent -unread +mailbox -new") - ("git@ymhg.org" . "mailbox/Sent -inbox +sent -unread +mailbox -new") - ("yann.herklotz15@imperial.ac.uk" . "\"imperial/Sent Items\" -inbox +sent -unread +imperial -new"))) - - (setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox")))) - -(after! shr (setq shr-use-fonts nil - shr-max-image-proportion 0.5)) -#+end_src - -** Smartparens - -#+begin_src emacs-lisp -(use-package! smartparens - :config - (map! :map smartparens-mode-map - "M-[" #'sp-backward-unwrap-sexp - "M-]" #'sp-unwrap-sexp - "C-M-f" #'sp-forward-sexp - "C-M-b" #'sp-backward-sexp - "C-M-d" #'sp-down-sexp - "C-M-a" #'sp-backward-down-sexp - "C-M-e" #'sp-up-sexp - "C-M-u" #'sp-backward-up-sexp - "C-M-t" #'sp-transpose-sexp - "C-M-n" #'sp-next-sexp - "C-M-p" #'sp-previous-sexp - "C-M-k" #'sp-kill-sexp - "C-M-w" #'sp-copy-sexp - "C-)" #'sp-forward-slurp-sexp - "C-}" #'sp-forward-barf-sexp - "C-(" #'sp-backward-slurp-sexp - "C-{" #'sp-backward-barf-sexp - "M-D" #'sp-splice-sexp - "C-]" #'sp-select-next-thing-exchange - "C-" #'sp-select-previous-thing - "C-M-]" #'sp-select-next-thing - "M-F" #'sp-forward-symbol - "M-B" #'sp-backward-symbol - "M-r" #'sp-split-sexp) - (require 'smartparens-config) - (show-smartparens-global-mode +1) - (smartparens-global-mode 1) -;;(sp-pair "'" nil :actions :rem) - (sp-local-pair 'coq-mode "'" nil :actions nil)) -#+end_src - -#+begin_src emacs-lisp -(after! writeroom-mode (setq +zen-text-scale 1)) - -(use-package! direnv :config (direnv-mode)) - -(use-package alert - :custom - (alert-default-style 'osx-notifier)) - -(use-package ledger-mode) - -(defun diary-last-day-of-month (date) - "Return `t` if DATE is the last day of the month." - (let* ((day (calendar-extract-day date)) - (month (calendar-extract-month date)) - (year (calendar-extract-year date)) - (last-day-of-month - (calendar-last-day-of-month month year))) - (= day last-day-of-month))) - -(use-package! calc-forms - :config - (add-to-list 'math-tzone-names '("AOE" 12 0)) - (add-to-list 'math-tzone-names '("IST" (float -55 -1) 0))) - -(use-package! orderless - :custom (completion-styles '(substring orderless))) - -(use-package! vertico - :init - (vertico-mode)) - -(use-package! savehist - :init - (savehist-mode)) - -(use-package! marginalia - :bind (("M-A" . marginalia-cycle) - :map minibuffer-local-map - ("M-A" . marginalia-cycle)) - :init - ;; Must be in the :init section of use-package such that the mode gets - ;; enabled right away. Note that this forces loading the package. - (marginalia-mode)) -#+end_src - -** Embark - -#+begin_src emacs-lisp -(use-package! embark - :bind - (("C-;" . embark-act)) - :init - ;; Optionally replace the key help with a completing-read interface - (setq prefix-help-command #'embark-prefix-help-command) - :config - (add-to-list 'display-buffer-alist - '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" - nil - (window-parameters (mode-line-format . none))))) - -(use-package! embark-consult - :after (embark consult) - :demand t ; only necessary if you have the hook below - ;; if you want to have consult previews as you move around an - ;; auto-updating embark collect buffer - :hook - (embark-collect-mode . consult-preview-at-point-mode)) -#+end_src - -** Consult - -#+begin_src emacs-lisp -;; Example configuration for Consult -(use-package! consult - ;; Replace bindings. Lazily loaded due by `use-package'. - :bind (;; C-c bindings (mode-specific-map) - ("C-c h" . consult-history) - ("C-c m" . consult-mode-command) - ("C-c b" . consult-bookmark) - ("C-c k" . consult-kmacro) - ;; C-x bindings (ctl-x-map) - ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command - ("C-x b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window - ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame - ;; Custom M-# bindings for fast register access - ("M-#" . consult-register-load) - ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) - ("C-M-#" . consult-register) - ;; Other custom bindings - ("M-y" . consult-yank-pop) ;; orig. yank-pop - (" a" . consult-apropos) ;; orig. apropos-command - ;; M-g bindings (goto-map) - ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck - ("M-g g" . consult-goto-line) ;; orig. goto-line - ("M-g M-g" . consult-goto-line) ;; orig. goto-line - ("M-g o" . consult-outline) ;; Alternative: consult-org-heading - ("M-g m" . consult-mark) - ("M-g k" . consult-global-mark) - ("M-g i" . consult-imenu) - ("M-g I" . consult-imenu-multi) - ;; M-s bindings (search-map) - ("M-s f" . consult-find) - ("M-s F" . consult-locate) - ("M-s g" . consult-grep) - ("M-s G" . consult-git-grep) - ("M-s r" . consult-ripgrep) - ("M-s l" . consult-line) - ("M-s L" . consult-line-multi) - ("M-s m" . consult-multi-occur) - ("M-s k" . consult-keep-lines) - ("M-s u" . consult-focus-lines) - ;; Isearch integration - ("M-s e" . consult-isearch) - :map isearch-mode-map - ("M-e" . consult-isearch) ;; orig. isearch-edit-string - ("M-s e" . consult-isearch) ;; orig. isearch-edit-string - ("M-s l" . consult-line) ;; needed by consult-line to detect isearch - ("M-s L" . consult-line-multi)) ;; needed by consult-line to detect isearch - - ;; Enable automatic preview at point in the *Completions* buffer. - ;; This is relevant when you use the default completion UI, - ;; and not necessary for Vertico, Selectrum, etc. - :hook (completion-list-mode . consult-preview-at-point-mode) - - ;; The :init configuration is always executed (Not lazy) - :init - - (setq register-preview-delay 0 - register-preview-function #'consult-register-format) - - (advice-add #'register-preview :override #'consult-register-window) - - ;; Use Consult to select xref locations with preview - (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref) - :config - ;; Optionally configure the narrowing key. - ;; Both < and C-+ work reasonably well. - (setq consult-narrow-key "<") ;; (kbd "C-+") - - (setq consult-project-root-function - (lambda () - (when-let (project (project-current)) - (car (project-roots project)))))) -#+end_src - -** Scheme - -#+begin_src emacs-lisp -(use-package! geiser-chicken - :config - (setq geiser-chicken-binary "chicken-csi")) - -(use-package! geiser - :init - (map! :map geiser-mode-map "C-." nil) - (map! :map geiser-repl-mode-map "C-." nil)) -#+end_src - -** Emacs - -#+begin_src emacs-lisp -(use-package! emacs - :init - ;; Do not allow the cursor in the minibuffer prompt - (setq minibuffer-prompt-properties - '(read-only t cursor-intangible t face minibuffer-prompt)) - (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) - - ;; Emacs 28: Hide commands in M-x which do not work in the current mode. - ;; Vertico commands are hidden in normal buffers. - (setq read-extended-command-predicate - #'command-completion-default-include-p) - - ;; Enable recursive minibuffers - (setq enable-recursive-minibuffers t)) - -(use-package! boogie-friends) - -(use-package! ol-notmuch :after org) - -(use-package! circe - :config - (setq circe-network-options - `(("soju" :host "chat.sr.ht" :port 6697 :tls t - :sasl-username "ymherklotz/irc.libera.chat" - :sasl-password ,(ymhg/pass "sr.ht/chat.sr.ht") - :nick "ymherklotz")))) - -(defun ymhg/reset-coq-windows () - "Resets the Goald and Response windows." - (interactive) - (other-frame 1) - (delete-other-windows) - (split-window-below) - (switch-to-buffer "*goals*") - (other-window 1) - (switch-to-buffer "*response*") - (other-frame 1)) - -(define-key y-map (kbd "o") #'ymhg/reset-coq-windows) - -(defun ymhg--reset-coq-indentation () - "Reset slow indentation." - (setq-local indent-line-function #'indent-relative)) - -(after! coq-mode - (add-hook 'coq-mode-hook #'ymhg--reset-coq-indentation t) - (define-key coq-mode-map (kbd "C-c TAB") #'smie-indent-line) - (setq coq-indent-modulestart 0)) - -(use-package! alectryon - :hook (coq-mode . alectryon-mode) - :config - (when (eq system-type 'darwin) - (setq alectryon-executable "/nix/store/bvlk3hyrjdgl0sg93rrdr2z71hgza0m9-python3.9-alectryon-1.4.0/bin/alectryon")) - (map! :map alectryon-mode-map - "C-c u t" #'alectryon-toggle - "C-c u p" #'ymhg/alectryon-preview) - (defun ymhg/alectryon-preview () - "Display an HTML preview of the current buffer." - (interactive) - (let* ((html-fname (make-temp-file "alectryon" nil ".html")) - (args `("-r" "5" "-" ,html-fname))) - (apply #'call-process-region nil nil "rst2html5" nil nil nil args) - (message "Compilation complete") - (browse-url html-fname)))) - -(use-package! rst - :config - (add-hook 'rst-mode-hook (lambda () (setq fill-column 80)))) - -(use-package! ox-tufte - :after org - :config) - -(use-package! scroll-other-window - :hook (ConTeXt-mode . sow-mode)) - -(use-package! cdlatex - :hook (ConTeXt-mode . turn-on-cdlatex) - :init - (setq cdlatex-command-alist nil) - (setq cdlatex-math-modify-alist nil)) - -(use-package! boogie-friends - :config - (setq flycheck-dafny-executable (executable-find "dafny")) - (setq dafny-verification-backend 'cli)) - -;;(add-to-list 'load-path "/usr/local/Cellar/agda/2.6.2.2/cabal/store/ghc-8.10.7/Agd-2.6.2.2-3bca6588/share/emacs-mode") -;; -;;(use-package! agda2-mode) -#+end_src diff --git a/doom/init.el b/doom/init.el deleted file mode 100644 index e6e4aef..0000000 --- a/doom/init.el +++ /dev/null @@ -1,188 +0,0 @@ -;;; init.el -*- lexical-binding: t; -*- - -;; This file controls what Doom modules are enabled and what order they load in. -;; Remember to run 'doom sync' after modifying it! - -;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's -;; documentation. There you'll find information about all of Doom's modules -;; and what flags they support. - -;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or -;; 'C-c g k' for non-vim users) to view its documentation. This works on -;; flags as well (those symbols that start with a plus). -;; -;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its -;; directory (for easy access to its source code). - -(setq native-comp-deferred-compilation nil) -(after! (doom-packages straight) - (setq straight--native-comp-available t)) - -(doom! :input - ;;chinese - ;;japanese - - :completion - company ; the ultimate code completion backend - ;;helm ; the *other* search engine for love and life - ;;ido ; the other *other* search engine... - ;;ivy ; a search engine for love and life - vertico - - :ui - ;;deft ; notational velocity for Emacs - doom ; what makes DOOM look the way it does - ;;doom-dashboard ; a nifty splash screen for Emacs - ;;doom-quit ; DOOM quit-message prompts when you quit Emacs - ;;fill-column ; a `fill-column' indicator - ;;hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW - hydra - ;;indent-guides ; highlighted in dent columns - (modeline +light) ; snazzy, Atom-inspired modeline, plus API - ;;nav-flash ; blink the current line after jumping - ;;neotree ; a project drawer, like NERDTree for vim - ;;ophints ; highlight the region an operation acts on - (popup +defaults) ; tame sudden yet inevitable temporary windows - ;;pretty-code ; replace bits of code with pretty symbols - ;;tabs ; an tab bar for Emacs - ;;treemacs ; a project drawer, like neotree but cooler - ;;unicode ; extended unicode support for various languages - ;;vc-gutter ; vcs diff in the fringe - ;;vi-tilde-fringe ; fringe tildes to mark beyond EOB - ;;window-select ; visually switch windows - workspaces ; tab emulation, persistence & separate workspaces - zen ; distraction-free coding or writing - - :editor - ;;(evil +everywhere); come to the dark side, we have cookies - ;;file-templates ; auto-snippets for empty files - fold ; (nigh) universal code folding - ;;(format +onsave) ; automated prettiness - ;;god ; run Emacs commands without modifier keys - ;;lispy ; vim for lisp, for people who don't like vim - ;;multiple-cursors ; editing in many places at once - ;; (objed +manual) ; text object editing for the innocent - ;;parinfer ; turn lisp into python, sort of - ;;rotate-text ; cycle region at point between text candidates - ;;snippets ; my elves. They type so I don't have to - word-wrap ; soft wrapping with language-aware indent - - :emacs - dired ; making dired pretty [functional] - electric ; smarter, keyword-based electric-indent - ;;ibuffer ; interactive buffer management - vc ; version-control and Emacs, sitting in a tree - - :term - ;;eshell ; a consistent, cross-platform shell (WIP) - ;;shell ; a terminal REPL for Emacs - ;;term ; terminals in Emacs - ;;vterm ; another terminals in Emacs - - :checkers - syntax ; tasing you for every semicolon you forget - (spell +aspell) ; tasing you for misspelling mispelling - ;;grammar ; tasing grammar mistake every you make - - :tools - ;;ansible - ;;debugger ; FIXME stepping through code, to help you add bugs - direnv - ;;docker - ;;editorconfig ; let someone else argue about tabs vs spaces - ;;ein ; tame Jupyter notebooks with emacs - eval ; run code, run (also, repls) - ;;gist ; interacting with github gists - lookup ; navigate your code and its documentation - (lsp +eglot) - magit ; a git porcelain for Emacs - ;;make ; run make tasks from Emacs - (pass +auth) ; password manager for nerds - pdf ; pdf enhancements - ;;prodigy ; FIXME managing external services & code builders - ;;rgb ; creating color strings - ;;terraform ; infrastructure as code - ;;tmux ; an API for interacting with tmux - ;;upload ; map local to remote projects via ssh/ftp - - :lang - ;;agda ; types of types of types of types... - ;;assembly ; assembly for fun or debugging - cc ; C/C++/Obj-C madness - ;;clojure ; java with a lisp - common-lisp ; if you've seen one lisp, you've seen them all - coq ; proofs-as-programs - ;;crystal ; ruby at the speed of c - ;;csharp ; unity, .NET, and mono shenanigans - data ; config/data formats - ;;elixir ; erlang done right - ;;elm ; care for a cup of TEA? - emacs-lisp ; drown in parentheses - ;;erlang ; an elegant language for a more civilized age - ;;ess ; emacs speaks statistics - ;;faust ; dsp, but you get to keep your soul - ;;fsharp ; ML stands for Microsoft's Language - ;;fstar ; (dependent) types and (monadic) effects and Z3 - ;;go ; the hipster dialect - (haskell +lsp) ; a language that's lazier than I am - ;;hy ; readability of scheme w/ speed of python - ;;idris ; - ;;(java +meghanada) ; the poster child for carpal tunnel syndrome - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) - ;;julia ; a better, faster MATLAB - ;;kotlin ; a better, slicker Java(Script) - latex ; writing papers in Emacs has never been so fun - ;;lean - ;;factor - ledger ; an accounting system in Emacs - lua ; one-based indices? one-based indices - markdown ; writing docs for people to ignore - ;;nim ; python + lisp at the speed of c - nix ; I hereby declare "nix geht mehr!" - ocaml ; an objective camel - (org ; organize your plain life in plain text - +gnuplot - ;;+dragndrop ; drag & drop files/images into org buffers - +hugo ; use Emacs for hugo blogging - ;;+jupyter ; ipython/jupyter support for babel - +pandoc ; export-with-pandoc support - ;;+pomodoro ; be fruitful with the tomato technique - +present ; using org-mode for presentations - ) - ;;perl ; write code no one else can comprehend - ;;php ; perl's insecure younger brother - ;;plantuml ; diagrams for confusing people more - ;;purescript ; javascript, but functional - python ; beautiful is better than ugly - ;;qt ; the 'cutest' gui framework ever - ;;racket ; a DSL for DSLs - ;;rest ; Emacs as a REST client - rst ; ReST in peace - ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap() - ;;scala ; java, but good - (scheme +guile +chicken +racket) ; a fully conniving family of lisps - sh ; she sells {ba,z,fi}sh shells on the C xor - ;;solidity ; do you need a blockchain? No. - ;;swift ; who asked for emoji variables? - ;;terra ; Earth and Moon in alignment for performance. - ;;web ; the tubes - - :email - ;;(mu4e +gmail) - notmuch - ;;(wanderlust +gmail) - - :app - ;;calendar - irc ; how neckbeards socialize - (rss +org) ; emacs as an RSS reader - ;;twitter ; twitter client https://twitter.com/vnought - - :config - literate - (default +bindings +smartparens) - - :os - (:if IS-MAC macos) - tty) diff --git a/doom/packages.el b/doom/packages.el deleted file mode 100644 index 3d4e82a..0000000 --- a/doom/packages.el +++ /dev/null @@ -1,75 +0,0 @@ -;; Disabling packages -(disable-packages! undo-tree org-bullets helm pretty-code) - -;; `org-mode' dependencies -(package! ol-notmuch) -(package! org-contrib - :recipe (:host nil :repo "https://git.sr.ht/~bzg/org-contrib") - :pin "c6aef31ccfc7c4418c3b51e98f7c3bd8e255f5e6") -;;(package! org-contacts) -;; `org-bullets' replacement -(package! org-superstar) -(package! ox-gfm) -(package! ox-tufte - :recipe (:host nil :repo "https://git.sr.ht/~ymherklotz/ox-tufte")) -(package! scroll-other-window - :recipe (:host nil :repo "https://git.sr.ht/~ymherklotz/scroll-other-window")) -(package! cdlatex) -(package! citeproc) -(package! ox-context - :recipe (:host github :repo "Jason-S-Ross/ox-context")) -(package! org-transclusion - :recipe (:host github :repo "nobiot/org-transclusion")) -(package! org-zettelkasten - :recipe (:host github :repo "ymherklotz/emacs-zettelkasten") - :pin "7278052cb451178a2f1ffc61569156ca0adcc34a") -(package! org-auto-tangle - :recipe (:host github :repo "yilkalargaw/org-auto-tangle") - :pin "bce665c79fc29f1e80f1eae7db7e91c56b0788fc") -(package! elfeed-score) - -(package! ef-themes - :recipe (:host nil :repo "https://git.sr.ht/~protesilaos/ef-themes")) - -(package! alectryon) - -;; Bibtex stuff -(package! ebib) - -;; Haskell stuff -(package! ormolu) - -;; Completion -(package! orderless) -(package! marginalia) -(package! embark) -(package! embark-consult) -(package! ripgrep) - -;; Extra language mobdes -(package! yaml-mode) -(package! pollen-mode) - -;; Nix -(package! direnv) - -;; Misc dependencies -(package! hungry-delete) - -;; Teaching -(package! boogie-friends) - -;; Privacy -(package! pinentry) - -;; Emacs lisp -(package! package-lint) - -;; Themes -(package! color-theme-sanityinc-tomorrow) -(package! modus-themes) - -(package! ef-themes - :recipe (:host nil :repo "https://git.sr.ht/~protesilaos/ef-themes")) - -(package! mmm-mode) diff --git a/emacs/.config/emacs/init.el b/emacs/.config/emacs/init.el new file mode 100644 index 0000000..8029cb2 --- /dev/null +++ b/emacs/.config/emacs/init.el @@ -0,0 +1,19 @@ +(setq init-dir (file-name-directory (or load-file-name (buffer-file-name)))) + +(require 'package) + +(defvar gnu '("gnu" . "https://elpa.gnu.org/packages/")) +(defvar melpa '("melpa" . "https://melpa.org/packages/")) +(defvar melpa-stable '("melpa-stable" . "https://stable.melpa.org/packages/")) +(defvar org-elpa '("org" . "https://orgmode.org/elpa/")) + +(setq package-archives nil) +(add-to-list 'package-archives melpa-stable t) +(add-to-list 'package-archives melpa t) +(add-to-list 'package-archives gnu t) +(add-to-list 'package-archives org-elpa t) + +(setq package-enable-at-startup nil) +(package-initialize) + +(org-babel-load-file (expand-file-name "loader.org" init-dir)) diff --git a/emacs/.config/emacs/loader.org b/emacs/.config/emacs/loader.org new file mode 100644 index 0000000..b885599 --- /dev/null +++ b/emacs/.config/emacs/loader.org @@ -0,0 +1,1268 @@ +#+TITLE: GNU Emacs Configuration +#+DATE: <2017-08-11 Fri> +#+AUTHOR: Yann Herklotz Grave + +* Introduction +This is my GNU Emacs Configuration. + +It is written in a literate style using orgmode tangling to generate the actual +configuration file. This can be done by adding the following line to the +~init.el~ file. + +#+BEGIN_SRC + (setq init-dir (file-name-directory (or load-file-name (buffer-file-name)))) + (org-babel-load-file (expand-file-name "loader.org" init-dir)) +#+END_SRC + +It has support for many programming languages such as C++, Haskell and +Clojure. The configurations for the different languages can be found in the +[[#Programming][Programming]] section. It also supports academic writing with org mode using the +amazing [[https://github.com/jkitchin/org-ref][org-ref]] package to add citations to the LaTeX output. The configuration +for that can be found in the [[#Writing][Writing]] section. + +#+BEGIN_SRC emacs-lisp + (setq user-full-name "Yann Herklotz") + (setq user-mail-address "yann@yannherklotz.com") +#+END_SRC + +* Setup + +Set path so that it picks up some executables that I use. This is done because +when emacs is started as a server, the PATH is not set correctly, so it has to +be manually set inside emacs. + +#+BEGIN_SRC emacs-lisp + (setenv "PATH" + (concat + "/home/ymherklotz/.local/bin" ":" + "/home/ymherklotz/.yarn/bin" ":" + "/usr/bin/vendor_perl" ":" + "/home/ymherklotz/.nix-profile/bin" ":" + (getenv "PATH"))) + (setq exec-path (append + '("/home/ymherklotz/.local/bin" + "/home/ymherklotz/.yarn/bin" + "/home/ymherklotz/.nix-profile/bin") + exec-path)) +#+END_SRC + +Define a function to load a user file whenever I want to add configurations that +are not pushed as part of this configuration file. This includes a private file +containing email configurations for [[https://www.emacswiki.org/emacs/mu4e][mu4e]]. In this case, ~user-init-dir~ is used +to find the current init directory that Emacs is using and ~load-user-file~ can +be used to load any file in that directory. + +#+BEGIN_SRC emacs-lisp + (defconst user-init-dir + (cond ((boundp 'user-emacs-directory) + user-emacs-directory) + ((boundp 'user-init-directory) + user-init-directory) + (t "~/.emacs.d/"))) + + (defun load-user-file (file) + (interactive "f") + "Load a file in current user's configuration directory" + (load-file (expand-file-name file user-init-dir))) + + (setq load-path + (cons (expand-file-name "~/.emacs.d/modes") load-path)) +#+END_SRC + +** Repositories +Defining all the package repositories that are going to be used. + +- ~gnu~ :: The default package repository for emacs +- ~melpa~ :: Contains a lot of additional packages for emacs that are made by + the community. +- ~melpa-stable~ :: The stable melpa repository that only contains that full + versions for packages. This repository will be used for + packages that maybe get updated often, so that they do not + break the config. +- ~org~ :: org package repository that contains many packages to extend org-mode. + +Use ~use-package~ to manage other packages, and improve load times. + +#+BEGIN_SRC emacs-lisp + (require 'use-package) + + (setq use-package-always-ensure t) +#+END_SRC + +** GC Threshold + +Threshold for faster startup. This should increase the garbage collector's +threshold at which it will start cleaning, so that it is not triggered during +startup. + +#+BEGIN_SRC emacs-lisp + (setq gc-cons-threshold (* 1024 1024 1024)) +#+END_SRC + +** General Configuration +*** Editor settings + +Editor specific options such as adding line numbers. + +Disable UI that starts when starting emacs and also set the y or n instead of +yes or no. Also stop the start up message from popping up and enter the scratch +buffer instead. + +#+BEGIN_SRC emacs-lisp + (setq warning-minimum-level :emergency) + (setq inhibit-startup-message t + confirm-nonexistent-file-or-buffer nil + default-directory "~/") + (setq-default fill-column 80) + (setq-default truncate-lines t) + (tool-bar-mode 0) + (unless (string= system-type "darwin") + (menu-bar-mode 0)) + (fset 'yes-or-no-p 'y-or-n-p) + (global-hl-line-mode 1) + (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") + (add-to-list 'load-path "~/.emacs.d/modes/") + (setq ring-bell-function 'ignore) + (when (eq system-type 'darwin) + (setq dired-use-ls-dired nil)) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (global-unset-key (kbd "C-z")) + (when (eq system-type 'darwin) + (setq mac-right-option-modifier 'none + mac-option-key-is-meta nil + mac-command-key-is-meta t + mac-command-modifier 'meta + mac-option-modifier nil)) + + (global-set-key (kbd "M-u") #'upcase-dwim) + (global-set-key (kbd "M-l") #'downcase-dwim) + (global-set-key (kbd "M-c") #'capitalize-dwim) + (global-set-key (kbd "C-c z") #'quick-calc) + (global-set-key (kbd "") #'revert-buffer) + (global-set-key (kbd "C-c q") #'y/exit-emacs-client) + (global-set-key (kbd "C-c i") #'y/eshell-here) + (global-set-key (kbd "C-.") #'other-window) + (global-set-key (kbd "C-,") #'prev-window) + (global-set-key (kbd "C-`") #'push-mark-no-activate) + (global-set-key (kbd "M-`") #'jump-to-mark) + + (global-set-key (kbd "C-c l") #'org-store-link) + (global-set-key (kbd "C-c a") #'org-agenda) + (global-set-key (kbd "C-c c") #'org-capture) +#+END_SRC + +#+begin_src emacs-lisp + (global-visual-line-mode t) +#+end_src + +*** Custom modeline + +Editing the modeline. ~%c~ might be a bit slow though, so that could be removed +if that is ever a problem. + +#+BEGIN_SRC emacs-lisp + (defun -custom-modeline-github-vc () + (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-"))) + (concat + (propertize (format " %s" (all-the-icons-octicon "git-branch")) + 'face `(:height 1 :family ,(all-the-icons-octicon-family)) + 'display '(raise 0)) + (propertize (format " %s" branch)) + (propertize " ")))) + + (defun -custom-modeline-svn-vc () + (let ((revision (cadr (split-string vc-mode "-")))) + (concat + (propertize (format " %s" (all-the-icons-faicon "cloud")) + 'face `(:height 1) + 'display '(raise 0)) + (propertize (format " %s" revision) 'face `(:height 0.9))))) + + (define-minor-mode minor-mode-blackout-mode + "Hides minor modes from the mode line." + t) + + (catch 'done + (mapc (lambda (x) + (when (and (consp x) + (equal (cadr x) '("" minor-mode-alist))) + (let ((original (copy-sequence x))) + (setcar x 'minor-mode-blackout-mode) + (setcdr x (list "" original))) + (throw 'done t))) + mode-line-modes)) + + (defun simple-mode-line-render (left middle right) + "Return a string of `window-width' length containing LEFT, and RIGHT aligned respectively." + (let* ((available-width + (/ (- (window-total-width) + (+ (length (format-mode-line left)) + (length (format-mode-line right)) + (length (format-mode-line middle)))) + 2))) + (append left (list (format (format "%%%ds" available-width) "")) + middle (list (format (format "%%%ds" available-width) "")) + right))) + + (setq-default mode-line-format + '((:eval + (simple-mode-line-render + (quote (" " mode-line-modified + " " mode-line-buffer-identification + " %l:%c " mode-line-modes " ")) + (quote ((:propertize + (:eval (when vc-mode + (cond + ((string-match "Git[:-]" vc-mode) (-custom-modeline-github-vc)) + ((string-match "SVN-" vc-mode) (-custom-modeline-svn-vc)) + (t (format "%s" vc-mode))))) + face mode-line-vc))) + (quote (" " mode-line-misc-info)))))) +#+END_SRC + +Move the backup files into the temporaty directory so that they are out of the +way. + +#+BEGIN_SRC emacs-lisp + (setq backup-directory-alist + `((".*" . ,temporary-file-directory))) + (setq auto-save-file-name-transforms + `((".*" ,temporary-file-directory t))) +#+END_SRC + +Make emacs follow symlinks every time, this means that it will open the actual +file and go to where the file is actually stored instead of editing it through +the symlink. This enables the use of git and other version control when editing +the file. +#+BEGIN_SRC emacs-lisp + (setq vc-follow-symlinks t) +#+END_SRC + +This stops paren mode with interfering with the modeline. +#+BEGIN_SRC emacs-lisp + (show-paren-mode 'expression) +#+END_SRC + +Revert the buffer automatically when a file changes on disc. This is useful when +monitoring a file such as a log file. It will also do this silently. +#+BEGIN_SRC emacs-lisp + (global-auto-revert-mode 1) + (setq auto-revert-verbose nil) +#+END_SRC + +Disable tabs, I want to move towards only using spaces everywhere as that is my +preferred style. This is just personal preference though. +#+BEGIN_SRC emacs-lisp + (setq-default indent-tabs-mode nil) + (setq-default tab-width 4) + (setq tab-width 4) + (setq-default python-indent-offset 4) + (setq-default c-basic-offset 4) + (setq-default python-indent 4) +#+END_SRC + +Set the line number display very high so that it is always shown in the modeline. +#+BEGIN_SRC emacs-lisp + (setq line-number-display-limit 2000000) +#+END_SRC + +Set the undo correctly +#+BEGIN_SRC emacs-lisp + (define-key global-map (kbd "C-\\") 'undo-only) +#+END_SRC + +Setting up my keybindings + +#+BEGIN_SRC emacs-lisp + (defun y/swap-windows () + "Swaps two windows and leaves the cursor in the original one" + (interactive) + (ace-swap-window) + (aw-flip-window)) + + (defun y/exit-emacs-client () + "consistent exit emacsclient. If not in emacs client, echo a + message in minibuffer, don't exit emacs. If in server mode and + editing file, do C-x # server-edit else do C-x 5 0 + delete-frame" + (interactive) + (if server-buffer-clients + (server-edit) + (delete-frame))) + + (defun y/beautify-json () + (interactive) + (let ((b (if mark-active (min (point) (mark)) (point-min))) + (e (if mark-active (max (point) (mark)) (point-max)))) + (shell-command-on-region b e + "python -m json.tool" (current-buffer) t))) + + (use-package pass + :commands (password-store-copy + password-store-insert + password-store-generate)) + + (define-prefix-command 'y-map) + (global-set-key (kbd "C-c y") 'y-map) + + (define-key y-map (kbd "s") 'y/swap-windows) + (define-key y-map (kbd "j") 'y/beautify-json) + (define-key y-map (kbd "p") 'password-store-copy) + (define-key y-map (kbd "i") 'password-store-insert) + (define-key y-map (kbd "g") 'password-store-generate) + (define-key y-map (kbd "r") 'toggle-rot13-mode) +#+END_SRC + +Set the font to Hack, which is an opensource monospace font designed for +programming and looking at source code. + +#+BEGIN_SRC text + (set-default-font "Misc Tamsyn-16") + (setq default-frame-alist '((font . "Misc Tamsyn-16"))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (if (string= system-type "darwin") + (set-face-attribute 'default nil + :family "Iosevka" :height 145 :weight 'normal) + (progn + (set-default-font "Iosevka Medium-16") + (setq default-frame-alist '((font . "Iosevka Medium-16"))))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (use-package eshell + :ensure nil + :bind (("C-c e" . eshell)) + :init + (defun eshell/vi (&rest args) + "Invoke `find-file' on the file. + \"vi +42 foo\" also goes to line 42 in the buffer." + (while args + (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args)) + (let* ((line (string-to-number (match-string 1 (pop args)))) + (file (pop args))) + (find-file file) + (goto-line line)) + (find-file (pop args))))) + + (defun eshell/em (&rest args) + "Open a file in emacs. Some habits die hard." + (if (null args) + (bury-buffer) + (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args)))))) + + (defun y/eshell-here () + "Go to eshell and set current directory to the buffer's directory" + (interactive) + (let ((dir (file-name-directory (or (buffer-file-name) + default-directory)))) + (eshell) + (eshell/pushd ".") + (cd dir) + (goto-char (point-max)) + (eshell-kill-input) + (eshell-send-input)))) +#+END_SRC + +*** Reload + +#+BEGIN_SRC emacs-lisp + (defun y/reload () + (interactive) + (load-file (expand-file-name "~/.emacs.d/init.el"))) +#+END_SRC + +* Social +** Mail +~mu4e~ is automatically in the load path when installed through a package +manager. + +For archlinux, the command to install mu4e is: + +#+BEGIN_SRC shell + pacman -S mu +#+END_SRC + +which comes with mu. + +Set the email client to be mu4e in emacs, and set the correct mail directory. As +I am downloading all the mailboxes, there will be duplicates, which can be +ignored in searches by setting ~mu4e-headers-skip-duplicates~. + +Also delete messages when they are sent, and don't copy them over to the sent +directory, as Gmail will do that for us. + +To download the mail using imap, I use ~mbsync~, which downloads all mail with +the ~-a~ flag. + +Finally, remove buffers when an email has been sent. + +#+BEGIN_SRC text + (load-user-file "personal.el") +#+END_SRC + +** Elfeed + +#+BEGIN_SRC emacs-lisp + (use-package elfeed-org + :config + (elfeed-org) + (setq rmh-elfeed-org-files + (list (expand-file-name "~/Annex/Dropbox/org/elfeed.org")))) + + (use-package elfeed + :bind (:map elfeed-search-mode-map + ("A" . y/elfeed-show-all) + ("E" . y/elfeed-show-emacs) + ("D" . y/elfeed-show-daily) + ("q" . y/elfeed-save-db-and-bury))) +#+END_SRC + +Define utility functions to make the reader work. + +#+BEGIN_SRC emacs-lisp + (defun y/elfeed-show-all () + (interactive) + (bookmark-maybe-load-default-file) + (bookmark-jump "elfeed-all")) + + (defun y/elfeed-show-emacs () + (interactive) + (bookmark-maybe-load-default-file) + (bookmark-jump "elfeed-emacs")) + + (defun y/elfeed-show-daily () + (interactive) + (bookmark-maybe-load-default-file) + (bookmark-jump "elfeed-daily")) + + ;;functions to support syncing .elfeed between machines + ;;makes sure elfeed reads index from disk before launching + (defun y/elfeed-load-db-and-open () + "Wrapper to load the elfeed db from disk before opening" + (interactive) + (elfeed-db-load) + (elfeed) + (elfeed-search-update--force)) + + ;;write to disk when quiting + (defun y/elfeed-save-db-and-bury () + "Wrapper to save the elfeed db to disk before burying buffer" + (interactive) + (elfeed-db-save) + (quit-window)) +#+END_SRC + +* Utility +** Zettelkasten + +#+begin_src emacs-lisp + (when (file-directory-p "~/projects/emacs-zettelkasten") + (add-to-list 'load-path "~/projects/emacs-zettelkasten") + (require 'zettelkasten) + (zettelkasten-mode t)) +#+end_src + +** Navigation + +Set navigation commands in all the buffers +#+BEGIN_SRC emacs-lisp + (defun prev-window () + (interactive) + (other-window -1)) + + (defun push-mark-no-activate () + "Pushes `point' to `mark-ring' and does not activate the region + Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" + (interactive) + (push-mark (point) t nil) + (message "Pushed mark to ring")) + + (defun jump-to-mark () + "Jumps to the local mark, respecting the `mark-ring' order. + This is the same as using \\[set-mark-command] with the prefix argument." + (interactive) + (set-mark-command 1)) +#+END_SRC + +Enable winner mode to save window state. +#+BEGIN_SRC emacs-lisp + (winner-mode 1) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (use-package flx) + + (use-package ivy + :bind + (("C-c s" . swiper) + ("M-x" . counsel-M-x) + ("C-x C-f" . counsel-find-file) + ("C-c g" . counsel-git) + ("C-c j" . counsel-git-grep) + ("C-c C-r" . ivy-resume) + ("C-x b" . ivy-switch-buffer) + ("C-x 8 RET" . counsel-unicode-char)) + :config + (ivy-mode 1) + (counsel-mode t) + (setq ivy-use-virtual-buffers t) + (setq ivy-count-format "(%d/%d) ") + (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history) + (setq ivy-re-builders-alist + '((t . ivy--regex-fuzzy)))) +#+END_SRC + +#+begin_src emacs-lisp + (use-package avy + :bind + (("C-'" . avy-goto-char-2)) + :config + (setq avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?o))) +#+end_src + +** Visual +*** All the icons +#+BEGIN_SRC emacs-lisp + (use-package all-the-icons) +#+END_SRC + +** Editing +*** Hungry Delete +#+BEGIN_SRC emacs-lisp + (use-package hungry-delete + :config + (global-hungry-delete-mode)) +#+END_SRC + +*** SmartParens +#+BEGIN_SRC emacs-lisp + (use-package smartparens + :bind (("M-[" . sp-backward-unwrap-sexp) + ("M-]" . sp-unwrap-sexp) + ("C-M-f" . sp-forward-sexp) + ("C-M-b" . sp-backward-sexp) + ("C-M-d" . sp-down-sexp) + ("C-M-a" . sp-backward-down-sexp) + ("C-M-e" . sp-up-sexp) + ("C-M-u" . sp-backward-up-sexp) + ("C-M-t" . sp-transpose-sexp) + ("C-M-n" . sp-next-sexp) + ("C-M-p" . sp-previous-sexp) + ("C-M-k" . sp-kill-sexp) + ("C-M-w" . sp-copy-sexp) + ("C-)" . sp-forward-slurp-sexp) + ("C-}" . sp-forward-barf-sexp) + ("C-(" . sp-backward-slurp-sexp) + ("C-{" . sp-backward-barf-sexp) + ("M-D" . sp-splice-sexp) + ("C-]" . sp-select-next-thing-exchange) + ("C-" . sp-select-previous-thing) + ("C-M-]" . sp-select-next-thing) + ("M-F" . sp-forward-symbol) + ("M-B" . sp-backward-symbol) + ("M-S" . sp-split-sexp)) + :hook ((minibuffer-setup) . turn-on-smartparens-strict-mode) + :config + (require 'smartparens-config) + (show-smartparens-global-mode +1) + (smartparens-global-mode 1) + + (sp-with-modes '(c-mode c++-mode) + (sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET"))) + (sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC") + ("* ||\n[i]" "RET"))))) +#+END_SRC + +*** Whitespace +#+BEGIN_SRC emacs-lisp + (use-package whitespace + :bind (("C-x w" . whitespace-mode))) +#+END_SRC + +*** IEdit +#+BEGIN_SRC emacs-lisp + (use-package iedit + :bind (("C-;" . iedit-mode))) +#+END_SRC + +*** Expand Region + +Expand region is very useful to select words and structures quickly by +incrementally selecting more and more of the text. + +#+BEGIN_SRC emacs-lisp + (use-package expand-region + :bind ("M-o" . er/expand-region)) +#+END_SRC + +*** Dired + +#+BEGIN_SRC emacs-lisp + (add-hook 'dired-load-hook + (function (lambda () (load "dired-x")))) + + (setq dired-dwim-target t) +#+END_SRC + +** Search +*** Deadgrep + +#+BEGIN_SRC emacs-lisp + (use-package deadgrep + :bind (("C-c d" . deadgrep))) +#+END_SRC + +** Yasnippets + +#+BEGIN_SRC emacs-lisp + (use-package yasnippet + :config + (yas-global-mode)) +#+END_SRC + +** Nix + +#+BEGIN_SRC emacs-lisp + (use-package direnv + :config (direnv-mode)) +#+END_SRC + +* Writing + +** Spellcheck in emacs +#+BEGIN_SRC emacs-lisp + (use-package flyspell + :ensure nil + :hook + (text-mode . flyspell-mode) + :init + (setq ispell-dictionary "en_GB") + (setq ispell-dictionary-alist + '(("en_GB" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_GB") nil utf-8))) + (setq ispell-program-name (executable-find "hunspell")) + (setq ispell-really-hunspell t) + :config + (define-key flyspell-mode-map (kbd "C-.") nil) + (define-key flyspell-mode-map (kbd "C-,") nil)) +#+END_SRC + +** Latex +#+BEGIN_SRC emacs-lisp + (use-package tex-site + :ensure auctex + :mode (".tex'" . latex-mode) + :config + ;; to use pdfview with auctex + (setq TeX-view-program-selection '((output-pdf "PDF Tools")) + TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)) + TeX-source-correlate-start-server t) ;; not sure if last line is neccessary + ;; to have the buffer refresh after compilation + (add-hook 'TeX-after-compilation-finished-functions + #'TeX-revert-document-buffer) + (setq TeX-engine 'luatex) + (setq TeX-auto-save t) + (setq TeX-parse-self t) + (setq-default TeX-command-extra-options "-shell-escape") + (setq TeX-save-query nil) + (setq-default TeX-master nil) + (setq TeX-PDF-mode t) + (add-hook 'LaTeX-mode-hook 'flyspell-mode) + (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) + (defun turn-on-outline-minor-mode () + (outline-minor-mode 1)) + (add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode) + (setq outline-minor-mode-prefix "\C-c \C-o") + (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t) + (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil) + (autoload 'reftex-citation "reftex-cite" "Make citation" nil) + (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t) + (add-hook 'LaTeX-mode-hook 'turn-on-reftex) + (setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource")) + (setq org-latex-listings 'minted) + (add-to-list 'org-latex-packages-alist '("" "minted")) ; with Emacs latex mode + + (require 'ox-latex)) +#+END_SRC + +** Markdown +Markdown is the standard for writing documentation. This snippet loads GFM +(Github Flavoured Markdown) style. + +#+BEGIN_SRC emacs-lisp + (use-package markdown-mode + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :init (setq markdown-command "multimarkdown")) +#+END_SRC + +** Org + +#+BEGIN_SRC emacs-lisp + (use-package org + :ensure org-plus-contrib + :pin org + :config + (setq org-log-into-drawer t + org-log-done "note" + org-hide-leading-stars t + org-confirm-babel-evaluate nil + org-directory (expand-file-name "~/Dropbox/org") + org-image-actual-width nil + org-format-latex-options (plist-put org-format-latex-options :scale 1.5) + org-latex-pdf-process (list "latexmk -lualatex -shell-escape -bibtex -f -pdf %f") + org-default-notes-file (concat org-directory "/inbox.org") + org-image-actual-width nil + org-export-allow-bind-keywords t) + + (eval-after-load "org" + '(setq org-metaup-hook nil + org-metadown-hook nil)) + + (add-hook 'org-trigger-hook 'save-buffer)) +#+END_SRC + +Set up ob for executing code blocks + +#+BEGIN_SRC emacs-lisp + (use-package ob + :ensure nil + :config + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (js . t) + (java . t) + (haskell . t) + (python . t) + (ruby . t) + (org . t) + (matlab . t) + (ditaa . t) + (clojure . t) + (dot . t) + (shell . t)))) +#+END_SRC + +Exporting to html needs htmlize. + +#+BEGIN_SRC emacs-lisp + (use-package htmlize + :commands (htmlize-file + htmlize-buffer + htmlize-region + htmlize-many-files + htmlize-many-files-dired + htmlize-region-save-screenshot)) +#+END_SRC + +Add md backend + +#+BEGIN_SRC emacs-lisp + (require 'ox-md) +#+END_SRC + +Add org noter + +#+BEGIN_SRC emacs-lisp + (use-package org-noter + :after org + :config (setq org-noter-default-notes-file-names '("notes.org") + org-noter-notes-search-path '("~/org/bibliography") + org-noter-separate-notes-from-heading t)) + + (use-package org-ref + :after org + :bind (("C-c r" . org-ref-cite-hydra/body) + ("C-c b" . org-ref-bibtex-hydra/body)) + :init + (require 'org-ref) + :config + (setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org" + org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib") + org-ref-pdf-directory "~/Dropbox/bibliography/papers/") + (setq org-ref-completion-library 'org-ref-ivy-cite)) +#+END_SRC + +*** Org ID + +#+begin_src emacs-lisp + (use-package org-id + :ensure nil + :after org) +#+end_src + +*** Templates +#+BEGIN_SRC emacs-lisp + (setq org-capture-templates + '(("t" "todo" entry (file+headline "~/Dropbox/org/inbox.org" "Tasks") + "* TODO %?\n\n%i\n%a\n\n") + ())) +#+END_SRC + +*** Agenda + +#+BEGIN_SRC emacs-lisp + (setq org-agenda-files (mapcar 'expand-file-name + (list "~/Dropbox/org/inbox.org" + "~/Dropbox/org/main.org" + "~/Dropbox/org/tickler.org" + (format-time-string "~/Dropbox/org/journals/%Y-%m.org"))) + org-refile-targets `(("~/Dropbox/org/main.org" :maxlevel . 2) + ("~/Dropbox/org/someday.org" :level . 1) + ("~/Dropbox/org/tickler.org" :maxlevel . 2) + (,(format-time-string "~/Dropbox/org/journals/%Y-%m.org") :maxlevel . 2)) + org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELLED(c)"))) + + (setq org-agenda-custom-commands + '(("w" "At work" tags-todo "@work" + ((org-agenda-overriding-header "Work"))) + ("h" "At home" tags-todo "@home" + ((org-agenda-overriding-header "Home"))) + ("u" "At uni" tags-todo "@uni" + ((org-agenda-overriding-header "University"))))) +#+END_SRC + +*** Contacts + +#+BEGIN_SRC emacs-lisp + (setq org-contacts-files (mapcar 'expand-file-name + '("~/Dropbox/org/contacts.org"))) +#+END_SRC + +*** Remove Binding +#+BEGIN_SRC emacs-lisp + (define-key org-mode-map (kbd "C-,") nil) +#+END_SRC + +*** Registers + +#+BEGIN_SRC emacs-lisp + (set-register ?l (cons 'file "~/.emacs.d/loader.org")) + (set-register ?m (cons 'file "~/Dropbox/org/main.org")) + (set-register ?i (cons 'file "~/Dropbox/org/inbox.org")) + (set-register ?c (cons 'file (format-time-string "~/Dropbox/org/journals/%Y-%m.org"))) +#+END_SRC + +*** Exporting + +#+BEGIN_SRC emacs-lisp + (use-package ox-twbs) +#+END_SRC + +** PDF Tools + +#+BEGIN_SRC emacs-lisp + (use-package pdf-tools + :config + ;; initialise + (pdf-tools-install) + ;; open pdfs scaled to fit page + (setq-default pdf-view-display-size 'fit-page) + ;; automatically annotate highlights + (setq pdf-annot-activate-created-annotations t) + ;; use normal isearch + (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)) +#+END_SRC + +** Writeroom + +#+begin_src emacs-lisp + (use-package writeroom-mode + :config + (setq writeroom-width 100)) +#+end_src + +* Programming +My emacs configuration is mostly focused on programming, therefore there is a +lot of different language support. + +** Version Control and Project Management +*** Magit +#+BEGIN_SRC emacs-lisp + (use-package magit + :bind (("C-x g" . magit-status)) + :config + (setq server-switch-hook nil)) +#+END_SRC + +*** Projectile +#+BEGIN_SRC emacs-lisp + (use-package projectile + :config + (projectile-mode +1) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (setq projectile-enable-caching nil) + (setq projectile-git-submodule-command "") + (setq projectile-mode-line '(:eval (format " Proj[%s]" (projectile-project-name)))) + (defun projectile-tags-exclude-patterns () "")) + + (use-package counsel-projectile + :config + (counsel-projectile-mode t)) +#+END_SRC + +*** Diff + +#+BEGIN_SRC emacs-lisp + (defun command-line-diff (switch) + (let ((file1 (pop command-line-args-left)) + (file2 (pop command-line-args-left))) + (ediff file1 file2))) + (add-to-list 'command-switch-alist '("diff" . command-line-diff)) + (setq-default ediff-forward-word-function 'forward-char) +#+END_SRC + +** Language Support +*** C++ + +Setting up CC mode with a hook that uses my settings. + +#+BEGIN_SRC emacs-lisp + (use-package cc-mode + :config + (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) + (setq c-default-style "linux" + tab-width 4 + c-indent-level 4) + (defun my-c++-mode-hook () + (c-set-offset 'inline-open 0) + (c-set-offset 'inline-close 0) + (c-set-offset 'innamespace 0) + (c-set-offset 'arglist-cont-nonempty 8) + (setq indent-tabs-mode nil)) + (add-hook 'c-mode-hook 'my-c++-mode-hook) + (add-hook 'c++-mode-hook 'my-c++-mode-hook) + + (define-key c-mode-map (kbd "C-c C-c") 'comment-or-uncomment-region)) +#+END_SRC + +Adding C headers to company backend for completion. + +#+BEGIN_SRC emacs-lisp + (use-package irony + :config + (add-hook 'c++-mode-hook 'irony-mode) + (add-hook 'c-mode-hook 'irony-mode) + (add-hook 'objc-mode-hook 'irony-mode) + + (defun my-irony-mode-hook () + (define-key irony-mode-map [remap completion-at-point] + 'irony-completion-at-point-async) + (define-key irony-mode-map [remap complete-symbol] + 'irony-completion-at-point-async)) + (add-hook 'irony-mode-hook 'my-irony-mode-hook) + (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)) + + (use-package company-irony) + + (use-package flycheck-irony + :config + (add-hook 'c++-mode-hook #'flycheck-irony-setup)) + + (use-package company-c-headers + :config + (add-to-list 'company-backends 'company-c-headers) + (add-to-list 'company-backends 'company-irony) + + (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)) +#+END_SRC + +Using clang format to format the region that is currently being selected (need +to install clang format script). + +#+BEGIN_SRC emacs-lisp + (use-package clang-format + :bind (("C-c C-i" . 'clang-format-region) + ("C-c u" . 'clang-format-buffer))) +#+END_SRC + +*** Clojure +Using Cider for clojure environment. + +#+BEGIN_SRC emacs-lisp + (use-package cider + :commands cider-mode + :config + (setq cider-repl-display-help-banner nil)) +#+END_SRC + +Adding hook to clojure mode to enable strict parentheses mode. + +#+BEGIN_SRC emacs-lisp + (add-hook 'clojure-mode-hook 'turn-on-smartparens-strict-mode) +#+END_SRC + +*** CMake +#+BEGIN_SRC emacs-lisp + (use-package cmake-mode + :commands cmake-mode + :config + (setq auto-mode-alist + (append + '(("CMakeLists\\.txt\\'" . cmake-mode)) + '(("\\.cmake\\'" . cmake-mode)) + auto-mode-alist)) + (autoload 'cmake-mode "~/CMake/Auxiliary/cmake-mode.el" t)) +#+END_SRC + +*** Coq + +#+begin_src emacs-lisp + (use-package proof-general + :config + (setq coq-compile-before-require t) + (setq proof-splash-enable nil)) +#+end_src + +*** Elm + +#+BEGIN_SRC emacs-lisp + (use-package elm-mode + :mode ("\\.elm\\'")) +#+END_SRC + +*** Emacs Lisp +Adding strict parentheses to emacs lisp. + +#+BEGIN_SRC emacs-lisp + (add-hook 'emacs-lisp-mode-hook 'turn-on-smartparens-strict-mode) +#+END_SRC + +*** F# +F# mode for uni work. + +#+BEGIN_SRC emacs-lisp + (use-package fsharp-mode + :commands fsharp-mode + :config + (defun y/fsharp-reload-file () + "Reloads the whole file when in fsharp mode." + (interactive) + (fsharp-eval-region (point-min) (point-max))) + (add-hook 'fsharp-mode-hook + (lambda () (local-set-key (kbd "C-c C-c") #'y/fsharp-reload-file)))) +#+END_SRC + +*** Flex + +#+begin_src emacs-lisp + (add-to-list 'auto-mode-alist '("\\.flex\\'" . c-mode)) +#+end_src + +*** Haskell + +Haskell mode with company mode completion. + +#+BEGIN_SRC emacs-lisp + (defun y/haskell-align-comment (start end) + (interactive "r") + (align-regexp start end "\\(\\s-*\\)--")) + + (use-package haskell-mode + :commands haskell-mode + :bind (("M-." . haskell-mode-jump-to-def)) + :config + (add-hook 'haskell-mode-hook 'haskell-decl-scan-mode) + (add-hook 'haskell-mode-hook (lambda () + (local-set-key (kbd "C-c y a") 'y/haskell-align-comment))) + (add-hook 'haskell-mode-hook (lambda () + (local-set-key (kbd "C-c v") 'haskell-add-import))) + (add-hook 'haskell-mode-hook (lambda () + (set (make-local-variable 'projectile-tags-command) + "hasktags -Re -f \"%s\" %s \"%s\""))) + (setq ;;haskell-mode-stylish-haskell-path "brittany" + flycheck-ghc-language-extensions '("OverloadedStrings")) + + (setq haskell-indentation-layout-offset 4 + haskell-indentation-starter-offset 4 + haskell-indentation-left-offset 4 + haskell-indentation-where-pre-offset 2 + haskell-indentation-where-post-offset 2)) + + + (use-package interactive-haskell-mode + :ensure haskell-mode + :hook haskell-mode) +#+END_SRC + +*** LLVM IR + +#+begin_src emacs-lisp + (when (file-exists-p "~/.emacs.d/modes/llvm-mode.el") + (require 'llvm-mode)) +#+end_src + +*** HOL + +#+begin_src emacs-lisp + (when (file-exists-p "/opt/hol/tools/hol-mode.el") + (setq hol-executable "/opt/hol/bin/hol") + (load "/opt/hol/tools/hol-mode.el")) +#+end_src + +*** Python +Elpy package for python, which provides an IDE type environment for python. + +#+BEGIN_SRC emacs-lisp + (use-package elpy + :commands python-mode + :config + (elpy-enable) + (setq py-python-command "python3") + (setq python-shell-interpreter "python3")) + (setq tab-width 4) + + (with-eval-after-load 'python + (defun python-shell-completion-native-try () + "Return non-nil if can trigger native completion." + (let ((python-shell-completion-native-enable t) + (python-shell-completion-native-output-timeout + python-shell-completion-native-try-output-timeout)) + (python-shell-completion-native-get-completions + (get-buffer-process (current-buffer)) + nil "_")))) +#+END_SRC + +*** JSON +JSON files should be opened in js-mode. +#+BEGIN_SRC emacs-lisp + (add-to-list 'auto-mode-alist '("\\.json\\'" . js-mode)) +#+END_SRC + +*** SCSS +#+BEGIN_SRC emacs-lisp + (use-package css-mode + :ensure nil + :commands (scss-mode + css-mode) + :config + (setq css-indent-offset 2)) +#+END_SRC + +*** Scala + +#+begin_src emacs-lisp + (use-package scala-mode) +#+end_src + +*** Shell +#+BEGIN_SRC emacs-lisp + (setq sh-basic-offset 2) + (setq sh-indentation 2) +#+END_SRC + +*** SMTLIBv2 + +#+begin_src emacs-lisp + (require 'smtlib-mode) + (add-to-list 'auto-mode-alist '("\\.smt\\'" . smtlib-mode)) +#+end_src + +*** Verilog + +#+begin_src emacs-lisp + (setq flycheck-verilog-verilator-executable "verilator_bin") +#+end_src + +** Completion Support +*** Company +#+BEGIN_SRC emacs-lisp + (use-package company + :config + (add-hook 'after-init-hook 'global-company-mode) + (setq company-backends (delete 'company-semantic company-backends)) + + (define-key c-mode-map (kbd "C-c n") 'company-complete) + (define-key c++-mode-map (kbd "C-c n") 'company-complete) + (setq company-dabbrev-downcase 0)) +#+END_SRC + +*** Flycheck +Enabling global flycheck support. +#+BEGIN_SRC emacs-lisp + (use-package flycheck + :config (global-flycheck-mode)) +#+END_SRC + +*** Yasnippets +#+BEGIN_SRC emacs-lisp + (use-package yasnippet + :hook ((org-mode cc-mode) . yas-minor-mode) + :config + (yas-minor-mode 1)) +#+END_SRC + +*** SMerge + +Shamelessly taken from https://github.com/alphapapa/unpackaged.el#hydra. +#+BEGIN_SRC emacs-lisp + (use-package smerge-mode + :config + (defhydra unpackaged/smerge-hydra + (:color pink :hint nil :post (smerge-auto-leave)) + " + ^Move^ ^Keep^ ^Diff^ ^Other^ + ^^-----------^^-------------------^^---------------------^^------- + _n_ext _b_ase _<_: upper/base _C_ombine + _p_rev _u_pper _=_: upper/lower _r_esolve + ^^ _l_ower _>_: base/lower _k_ill current + ^^ _a_ll _R_efine + ^^ _RET_: current _E_diff + " + ("n" smerge-next) + ("p" smerge-prev) + ("b" smerge-keep-base) + ("u" smerge-keep-upper) + ("l" smerge-keep-lower) + ("a" smerge-keep-all) + ("RET" smerge-keep-current) + ("\C-m" smerge-keep-current) + ("<" smerge-diff-base-upper) + ("=" smerge-diff-upper-lower) + (">" smerge-diff-base-lower) + ("R" smerge-refine) + ("E" smerge-ediff) + ("C" smerge-combine-with-next) + ("r" smerge-resolve) + ("k" smerge-kill-current) + ("ZZ" (lambda () + (interactive) + (save-buffer) + (bury-buffer)) + "Save and bury buffer" :color blue) + ("q" nil "cancel" :color blue)) + :hook (magit-diff-visit-file . (lambda () + (when smerge-mode + (unpackaged/smerge-hydra/body))))) +#+END_SRC + +* Look and Feel + +#+BEGIN_SRC emacs-lisp + (defadvice load-theme + (before theme-dont-propagate activate) + (mapc #'disable-theme custom-enabled-themes)) + + (add-hook 'after-make-frame-functions + (lambda (frame) + (select-frame frame) + (toggle-scroll-bar -1))) + + (unless (boundp 'server-process) + (progn (load-theme 'sanityinc-tomorrow-night t) + (toggle-scroll-bar -1))) +#+END_SRC + +* Conclusion +Setting the gc-cons threshold back to what it was at the beginning. + +#+BEGIN_SRC emacs-lisp + (server-start) + (setq gc-cons-threshold (* 1024 1024 10)) +#+END_SRC diff --git a/emacs/init.el b/emacs/init.el deleted file mode 100644 index 8029cb2..0000000 --- a/emacs/init.el +++ /dev/null @@ -1,19 +0,0 @@ -(setq init-dir (file-name-directory (or load-file-name (buffer-file-name)))) - -(require 'package) - -(defvar gnu '("gnu" . "https://elpa.gnu.org/packages/")) -(defvar melpa '("melpa" . "https://melpa.org/packages/")) -(defvar melpa-stable '("melpa-stable" . "https://stable.melpa.org/packages/")) -(defvar org-elpa '("org" . "https://orgmode.org/elpa/")) - -(setq package-archives nil) -(add-to-list 'package-archives melpa-stable t) -(add-to-list 'package-archives melpa t) -(add-to-list 'package-archives gnu t) -(add-to-list 'package-archives org-elpa t) - -(setq package-enable-at-startup nil) -(package-initialize) - -(org-babel-load-file (expand-file-name "loader.org" init-dir)) diff --git a/emacs/loader.org b/emacs/loader.org deleted file mode 100644 index b885599..0000000 --- a/emacs/loader.org +++ /dev/null @@ -1,1268 +0,0 @@ -#+TITLE: GNU Emacs Configuration -#+DATE: <2017-08-11 Fri> -#+AUTHOR: Yann Herklotz Grave - -* Introduction -This is my GNU Emacs Configuration. - -It is written in a literate style using orgmode tangling to generate the actual -configuration file. This can be done by adding the following line to the -~init.el~ file. - -#+BEGIN_SRC - (setq init-dir (file-name-directory (or load-file-name (buffer-file-name)))) - (org-babel-load-file (expand-file-name "loader.org" init-dir)) -#+END_SRC - -It has support for many programming languages such as C++, Haskell and -Clojure. The configurations for the different languages can be found in the -[[#Programming][Programming]] section. It also supports academic writing with org mode using the -amazing [[https://github.com/jkitchin/org-ref][org-ref]] package to add citations to the LaTeX output. The configuration -for that can be found in the [[#Writing][Writing]] section. - -#+BEGIN_SRC emacs-lisp - (setq user-full-name "Yann Herklotz") - (setq user-mail-address "yann@yannherklotz.com") -#+END_SRC - -* Setup - -Set path so that it picks up some executables that I use. This is done because -when emacs is started as a server, the PATH is not set correctly, so it has to -be manually set inside emacs. - -#+BEGIN_SRC emacs-lisp - (setenv "PATH" - (concat - "/home/ymherklotz/.local/bin" ":" - "/home/ymherklotz/.yarn/bin" ":" - "/usr/bin/vendor_perl" ":" - "/home/ymherklotz/.nix-profile/bin" ":" - (getenv "PATH"))) - (setq exec-path (append - '("/home/ymherklotz/.local/bin" - "/home/ymherklotz/.yarn/bin" - "/home/ymherklotz/.nix-profile/bin") - exec-path)) -#+END_SRC - -Define a function to load a user file whenever I want to add configurations that -are not pushed as part of this configuration file. This includes a private file -containing email configurations for [[https://www.emacswiki.org/emacs/mu4e][mu4e]]. In this case, ~user-init-dir~ is used -to find the current init directory that Emacs is using and ~load-user-file~ can -be used to load any file in that directory. - -#+BEGIN_SRC emacs-lisp - (defconst user-init-dir - (cond ((boundp 'user-emacs-directory) - user-emacs-directory) - ((boundp 'user-init-directory) - user-init-directory) - (t "~/.emacs.d/"))) - - (defun load-user-file (file) - (interactive "f") - "Load a file in current user's configuration directory" - (load-file (expand-file-name file user-init-dir))) - - (setq load-path - (cons (expand-file-name "~/.emacs.d/modes") load-path)) -#+END_SRC - -** Repositories -Defining all the package repositories that are going to be used. - -- ~gnu~ :: The default package repository for emacs -- ~melpa~ :: Contains a lot of additional packages for emacs that are made by - the community. -- ~melpa-stable~ :: The stable melpa repository that only contains that full - versions for packages. This repository will be used for - packages that maybe get updated often, so that they do not - break the config. -- ~org~ :: org package repository that contains many packages to extend org-mode. - -Use ~use-package~ to manage other packages, and improve load times. - -#+BEGIN_SRC emacs-lisp - (require 'use-package) - - (setq use-package-always-ensure t) -#+END_SRC - -** GC Threshold - -Threshold for faster startup. This should increase the garbage collector's -threshold at which it will start cleaning, so that it is not triggered during -startup. - -#+BEGIN_SRC emacs-lisp - (setq gc-cons-threshold (* 1024 1024 1024)) -#+END_SRC - -** General Configuration -*** Editor settings - -Editor specific options such as adding line numbers. - -Disable UI that starts when starting emacs and also set the y or n instead of -yes or no. Also stop the start up message from popping up and enter the scratch -buffer instead. - -#+BEGIN_SRC emacs-lisp - (setq warning-minimum-level :emergency) - (setq inhibit-startup-message t - confirm-nonexistent-file-or-buffer nil - default-directory "~/") - (setq-default fill-column 80) - (setq-default truncate-lines t) - (tool-bar-mode 0) - (unless (string= system-type "darwin") - (menu-bar-mode 0)) - (fset 'yes-or-no-p 'y-or-n-p) - (global-hl-line-mode 1) - (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") - (add-to-list 'load-path "~/.emacs.d/modes/") - (setq ring-bell-function 'ignore) - (when (eq system-type 'darwin) - (setq dired-use-ls-dired nil)) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (global-unset-key (kbd "C-z")) - (when (eq system-type 'darwin) - (setq mac-right-option-modifier 'none - mac-option-key-is-meta nil - mac-command-key-is-meta t - mac-command-modifier 'meta - mac-option-modifier nil)) - - (global-set-key (kbd "M-u") #'upcase-dwim) - (global-set-key (kbd "M-l") #'downcase-dwim) - (global-set-key (kbd "M-c") #'capitalize-dwim) - (global-set-key (kbd "C-c z") #'quick-calc) - (global-set-key (kbd "") #'revert-buffer) - (global-set-key (kbd "C-c q") #'y/exit-emacs-client) - (global-set-key (kbd "C-c i") #'y/eshell-here) - (global-set-key (kbd "C-.") #'other-window) - (global-set-key (kbd "C-,") #'prev-window) - (global-set-key (kbd "C-`") #'push-mark-no-activate) - (global-set-key (kbd "M-`") #'jump-to-mark) - - (global-set-key (kbd "C-c l") #'org-store-link) - (global-set-key (kbd "C-c a") #'org-agenda) - (global-set-key (kbd "C-c c") #'org-capture) -#+END_SRC - -#+begin_src emacs-lisp - (global-visual-line-mode t) -#+end_src - -*** Custom modeline - -Editing the modeline. ~%c~ might be a bit slow though, so that could be removed -if that is ever a problem. - -#+BEGIN_SRC emacs-lisp - (defun -custom-modeline-github-vc () - (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-"))) - (concat - (propertize (format " %s" (all-the-icons-octicon "git-branch")) - 'face `(:height 1 :family ,(all-the-icons-octicon-family)) - 'display '(raise 0)) - (propertize (format " %s" branch)) - (propertize " ")))) - - (defun -custom-modeline-svn-vc () - (let ((revision (cadr (split-string vc-mode "-")))) - (concat - (propertize (format " %s" (all-the-icons-faicon "cloud")) - 'face `(:height 1) - 'display '(raise 0)) - (propertize (format " %s" revision) 'face `(:height 0.9))))) - - (define-minor-mode minor-mode-blackout-mode - "Hides minor modes from the mode line." - t) - - (catch 'done - (mapc (lambda (x) - (when (and (consp x) - (equal (cadr x) '("" minor-mode-alist))) - (let ((original (copy-sequence x))) - (setcar x 'minor-mode-blackout-mode) - (setcdr x (list "" original))) - (throw 'done t))) - mode-line-modes)) - - (defun simple-mode-line-render (left middle right) - "Return a string of `window-width' length containing LEFT, and RIGHT aligned respectively." - (let* ((available-width - (/ (- (window-total-width) - (+ (length (format-mode-line left)) - (length (format-mode-line right)) - (length (format-mode-line middle)))) - 2))) - (append left (list (format (format "%%%ds" available-width) "")) - middle (list (format (format "%%%ds" available-width) "")) - right))) - - (setq-default mode-line-format - '((:eval - (simple-mode-line-render - (quote (" " mode-line-modified - " " mode-line-buffer-identification - " %l:%c " mode-line-modes " ")) - (quote ((:propertize - (:eval (when vc-mode - (cond - ((string-match "Git[:-]" vc-mode) (-custom-modeline-github-vc)) - ((string-match "SVN-" vc-mode) (-custom-modeline-svn-vc)) - (t (format "%s" vc-mode))))) - face mode-line-vc))) - (quote (" " mode-line-misc-info)))))) -#+END_SRC - -Move the backup files into the temporaty directory so that they are out of the -way. - -#+BEGIN_SRC emacs-lisp - (setq backup-directory-alist - `((".*" . ,temporary-file-directory))) - (setq auto-save-file-name-transforms - `((".*" ,temporary-file-directory t))) -#+END_SRC - -Make emacs follow symlinks every time, this means that it will open the actual -file and go to where the file is actually stored instead of editing it through -the symlink. This enables the use of git and other version control when editing -the file. -#+BEGIN_SRC emacs-lisp - (setq vc-follow-symlinks t) -#+END_SRC - -This stops paren mode with interfering with the modeline. -#+BEGIN_SRC emacs-lisp - (show-paren-mode 'expression) -#+END_SRC - -Revert the buffer automatically when a file changes on disc. This is useful when -monitoring a file such as a log file. It will also do this silently. -#+BEGIN_SRC emacs-lisp - (global-auto-revert-mode 1) - (setq auto-revert-verbose nil) -#+END_SRC - -Disable tabs, I want to move towards only using spaces everywhere as that is my -preferred style. This is just personal preference though. -#+BEGIN_SRC emacs-lisp - (setq-default indent-tabs-mode nil) - (setq-default tab-width 4) - (setq tab-width 4) - (setq-default python-indent-offset 4) - (setq-default c-basic-offset 4) - (setq-default python-indent 4) -#+END_SRC - -Set the line number display very high so that it is always shown in the modeline. -#+BEGIN_SRC emacs-lisp - (setq line-number-display-limit 2000000) -#+END_SRC - -Set the undo correctly -#+BEGIN_SRC emacs-lisp - (define-key global-map (kbd "C-\\") 'undo-only) -#+END_SRC - -Setting up my keybindings - -#+BEGIN_SRC emacs-lisp - (defun y/swap-windows () - "Swaps two windows and leaves the cursor in the original one" - (interactive) - (ace-swap-window) - (aw-flip-window)) - - (defun y/exit-emacs-client () - "consistent exit emacsclient. If not in emacs client, echo a - message in minibuffer, don't exit emacs. If in server mode and - editing file, do C-x # server-edit else do C-x 5 0 - delete-frame" - (interactive) - (if server-buffer-clients - (server-edit) - (delete-frame))) - - (defun y/beautify-json () - (interactive) - (let ((b (if mark-active (min (point) (mark)) (point-min))) - (e (if mark-active (max (point) (mark)) (point-max)))) - (shell-command-on-region b e - "python -m json.tool" (current-buffer) t))) - - (use-package pass - :commands (password-store-copy - password-store-insert - password-store-generate)) - - (define-prefix-command 'y-map) - (global-set-key (kbd "C-c y") 'y-map) - - (define-key y-map (kbd "s") 'y/swap-windows) - (define-key y-map (kbd "j") 'y/beautify-json) - (define-key y-map (kbd "p") 'password-store-copy) - (define-key y-map (kbd "i") 'password-store-insert) - (define-key y-map (kbd "g") 'password-store-generate) - (define-key y-map (kbd "r") 'toggle-rot13-mode) -#+END_SRC - -Set the font to Hack, which is an opensource monospace font designed for -programming and looking at source code. - -#+BEGIN_SRC text - (set-default-font "Misc Tamsyn-16") - (setq default-frame-alist '((font . "Misc Tamsyn-16"))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (if (string= system-type "darwin") - (set-face-attribute 'default nil - :family "Iosevka" :height 145 :weight 'normal) - (progn - (set-default-font "Iosevka Medium-16") - (setq default-frame-alist '((font . "Iosevka Medium-16"))))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (use-package eshell - :ensure nil - :bind (("C-c e" . eshell)) - :init - (defun eshell/vi (&rest args) - "Invoke `find-file' on the file. - \"vi +42 foo\" also goes to line 42 in the buffer." - (while args - (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args)) - (let* ((line (string-to-number (match-string 1 (pop args)))) - (file (pop args))) - (find-file file) - (goto-line line)) - (find-file (pop args))))) - - (defun eshell/em (&rest args) - "Open a file in emacs. Some habits die hard." - (if (null args) - (bury-buffer) - (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args)))))) - - (defun y/eshell-here () - "Go to eshell and set current directory to the buffer's directory" - (interactive) - (let ((dir (file-name-directory (or (buffer-file-name) - default-directory)))) - (eshell) - (eshell/pushd ".") - (cd dir) - (goto-char (point-max)) - (eshell-kill-input) - (eshell-send-input)))) -#+END_SRC - -*** Reload - -#+BEGIN_SRC emacs-lisp - (defun y/reload () - (interactive) - (load-file (expand-file-name "~/.emacs.d/init.el"))) -#+END_SRC - -* Social -** Mail -~mu4e~ is automatically in the load path when installed through a package -manager. - -For archlinux, the command to install mu4e is: - -#+BEGIN_SRC shell - pacman -S mu -#+END_SRC - -which comes with mu. - -Set the email client to be mu4e in emacs, and set the correct mail directory. As -I am downloading all the mailboxes, there will be duplicates, which can be -ignored in searches by setting ~mu4e-headers-skip-duplicates~. - -Also delete messages when they are sent, and don't copy them over to the sent -directory, as Gmail will do that for us. - -To download the mail using imap, I use ~mbsync~, which downloads all mail with -the ~-a~ flag. - -Finally, remove buffers when an email has been sent. - -#+BEGIN_SRC text - (load-user-file "personal.el") -#+END_SRC - -** Elfeed - -#+BEGIN_SRC emacs-lisp - (use-package elfeed-org - :config - (elfeed-org) - (setq rmh-elfeed-org-files - (list (expand-file-name "~/Annex/Dropbox/org/elfeed.org")))) - - (use-package elfeed - :bind (:map elfeed-search-mode-map - ("A" . y/elfeed-show-all) - ("E" . y/elfeed-show-emacs) - ("D" . y/elfeed-show-daily) - ("q" . y/elfeed-save-db-and-bury))) -#+END_SRC - -Define utility functions to make the reader work. - -#+BEGIN_SRC emacs-lisp - (defun y/elfeed-show-all () - (interactive) - (bookmark-maybe-load-default-file) - (bookmark-jump "elfeed-all")) - - (defun y/elfeed-show-emacs () - (interactive) - (bookmark-maybe-load-default-file) - (bookmark-jump "elfeed-emacs")) - - (defun y/elfeed-show-daily () - (interactive) - (bookmark-maybe-load-default-file) - (bookmark-jump "elfeed-daily")) - - ;;functions to support syncing .elfeed between machines - ;;makes sure elfeed reads index from disk before launching - (defun y/elfeed-load-db-and-open () - "Wrapper to load the elfeed db from disk before opening" - (interactive) - (elfeed-db-load) - (elfeed) - (elfeed-search-update--force)) - - ;;write to disk when quiting - (defun y/elfeed-save-db-and-bury () - "Wrapper to save the elfeed db to disk before burying buffer" - (interactive) - (elfeed-db-save) - (quit-window)) -#+END_SRC - -* Utility -** Zettelkasten - -#+begin_src emacs-lisp - (when (file-directory-p "~/projects/emacs-zettelkasten") - (add-to-list 'load-path "~/projects/emacs-zettelkasten") - (require 'zettelkasten) - (zettelkasten-mode t)) -#+end_src - -** Navigation - -Set navigation commands in all the buffers -#+BEGIN_SRC emacs-lisp - (defun prev-window () - (interactive) - (other-window -1)) - - (defun push-mark-no-activate () - "Pushes `point' to `mark-ring' and does not activate the region - Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" - (interactive) - (push-mark (point) t nil) - (message "Pushed mark to ring")) - - (defun jump-to-mark () - "Jumps to the local mark, respecting the `mark-ring' order. - This is the same as using \\[set-mark-command] with the prefix argument." - (interactive) - (set-mark-command 1)) -#+END_SRC - -Enable winner mode to save window state. -#+BEGIN_SRC emacs-lisp - (winner-mode 1) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (use-package flx) - - (use-package ivy - :bind - (("C-c s" . swiper) - ("M-x" . counsel-M-x) - ("C-x C-f" . counsel-find-file) - ("C-c g" . counsel-git) - ("C-c j" . counsel-git-grep) - ("C-c C-r" . ivy-resume) - ("C-x b" . ivy-switch-buffer) - ("C-x 8 RET" . counsel-unicode-char)) - :config - (ivy-mode 1) - (counsel-mode t) - (setq ivy-use-virtual-buffers t) - (setq ivy-count-format "(%d/%d) ") - (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history) - (setq ivy-re-builders-alist - '((t . ivy--regex-fuzzy)))) -#+END_SRC - -#+begin_src emacs-lisp - (use-package avy - :bind - (("C-'" . avy-goto-char-2)) - :config - (setq avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?o))) -#+end_src - -** Visual -*** All the icons -#+BEGIN_SRC emacs-lisp - (use-package all-the-icons) -#+END_SRC - -** Editing -*** Hungry Delete -#+BEGIN_SRC emacs-lisp - (use-package hungry-delete - :config - (global-hungry-delete-mode)) -#+END_SRC - -*** SmartParens -#+BEGIN_SRC emacs-lisp - (use-package smartparens - :bind (("M-[" . sp-backward-unwrap-sexp) - ("M-]" . sp-unwrap-sexp) - ("C-M-f" . sp-forward-sexp) - ("C-M-b" . sp-backward-sexp) - ("C-M-d" . sp-down-sexp) - ("C-M-a" . sp-backward-down-sexp) - ("C-M-e" . sp-up-sexp) - ("C-M-u" . sp-backward-up-sexp) - ("C-M-t" . sp-transpose-sexp) - ("C-M-n" . sp-next-sexp) - ("C-M-p" . sp-previous-sexp) - ("C-M-k" . sp-kill-sexp) - ("C-M-w" . sp-copy-sexp) - ("C-)" . sp-forward-slurp-sexp) - ("C-}" . sp-forward-barf-sexp) - ("C-(" . sp-backward-slurp-sexp) - ("C-{" . sp-backward-barf-sexp) - ("M-D" . sp-splice-sexp) - ("C-]" . sp-select-next-thing-exchange) - ("C-" . sp-select-previous-thing) - ("C-M-]" . sp-select-next-thing) - ("M-F" . sp-forward-symbol) - ("M-B" . sp-backward-symbol) - ("M-S" . sp-split-sexp)) - :hook ((minibuffer-setup) . turn-on-smartparens-strict-mode) - :config - (require 'smartparens-config) - (show-smartparens-global-mode +1) - (smartparens-global-mode 1) - - (sp-with-modes '(c-mode c++-mode) - (sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET"))) - (sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC") - ("* ||\n[i]" "RET"))))) -#+END_SRC - -*** Whitespace -#+BEGIN_SRC emacs-lisp - (use-package whitespace - :bind (("C-x w" . whitespace-mode))) -#+END_SRC - -*** IEdit -#+BEGIN_SRC emacs-lisp - (use-package iedit - :bind (("C-;" . iedit-mode))) -#+END_SRC - -*** Expand Region - -Expand region is very useful to select words and structures quickly by -incrementally selecting more and more of the text. - -#+BEGIN_SRC emacs-lisp - (use-package expand-region - :bind ("M-o" . er/expand-region)) -#+END_SRC - -*** Dired - -#+BEGIN_SRC emacs-lisp - (add-hook 'dired-load-hook - (function (lambda () (load "dired-x")))) - - (setq dired-dwim-target t) -#+END_SRC - -** Search -*** Deadgrep - -#+BEGIN_SRC emacs-lisp - (use-package deadgrep - :bind (("C-c d" . deadgrep))) -#+END_SRC - -** Yasnippets - -#+BEGIN_SRC emacs-lisp - (use-package yasnippet - :config - (yas-global-mode)) -#+END_SRC - -** Nix - -#+BEGIN_SRC emacs-lisp - (use-package direnv - :config (direnv-mode)) -#+END_SRC - -* Writing - -** Spellcheck in emacs -#+BEGIN_SRC emacs-lisp - (use-package flyspell - :ensure nil - :hook - (text-mode . flyspell-mode) - :init - (setq ispell-dictionary "en_GB") - (setq ispell-dictionary-alist - '(("en_GB" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_GB") nil utf-8))) - (setq ispell-program-name (executable-find "hunspell")) - (setq ispell-really-hunspell t) - :config - (define-key flyspell-mode-map (kbd "C-.") nil) - (define-key flyspell-mode-map (kbd "C-,") nil)) -#+END_SRC - -** Latex -#+BEGIN_SRC emacs-lisp - (use-package tex-site - :ensure auctex - :mode (".tex'" . latex-mode) - :config - ;; to use pdfview with auctex - (setq TeX-view-program-selection '((output-pdf "PDF Tools")) - TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)) - TeX-source-correlate-start-server t) ;; not sure if last line is neccessary - ;; to have the buffer refresh after compilation - (add-hook 'TeX-after-compilation-finished-functions - #'TeX-revert-document-buffer) - (setq TeX-engine 'luatex) - (setq TeX-auto-save t) - (setq TeX-parse-self t) - (setq-default TeX-command-extra-options "-shell-escape") - (setq TeX-save-query nil) - (setq-default TeX-master nil) - (setq TeX-PDF-mode t) - (add-hook 'LaTeX-mode-hook 'flyspell-mode) - (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) - (defun turn-on-outline-minor-mode () - (outline-minor-mode 1)) - (add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode) - (setq outline-minor-mode-prefix "\C-c \C-o") - (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t) - (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil) - (autoload 'reftex-citation "reftex-cite" "Make citation" nil) - (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t) - (add-hook 'LaTeX-mode-hook 'turn-on-reftex) - (setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource")) - (setq org-latex-listings 'minted) - (add-to-list 'org-latex-packages-alist '("" "minted")) ; with Emacs latex mode - - (require 'ox-latex)) -#+END_SRC - -** Markdown -Markdown is the standard for writing documentation. This snippet loads GFM -(Github Flavoured Markdown) style. - -#+BEGIN_SRC emacs-lisp - (use-package markdown-mode - :commands (markdown-mode gfm-mode) - :mode (("README\\.md\\'" . gfm-mode) - ("\\.md\\'" . markdown-mode) - ("\\.markdown\\'" . markdown-mode)) - :init (setq markdown-command "multimarkdown")) -#+END_SRC - -** Org - -#+BEGIN_SRC emacs-lisp - (use-package org - :ensure org-plus-contrib - :pin org - :config - (setq org-log-into-drawer t - org-log-done "note" - org-hide-leading-stars t - org-confirm-babel-evaluate nil - org-directory (expand-file-name "~/Dropbox/org") - org-image-actual-width nil - org-format-latex-options (plist-put org-format-latex-options :scale 1.5) - org-latex-pdf-process (list "latexmk -lualatex -shell-escape -bibtex -f -pdf %f") - org-default-notes-file (concat org-directory "/inbox.org") - org-image-actual-width nil - org-export-allow-bind-keywords t) - - (eval-after-load "org" - '(setq org-metaup-hook nil - org-metadown-hook nil)) - - (add-hook 'org-trigger-hook 'save-buffer)) -#+END_SRC - -Set up ob for executing code blocks - -#+BEGIN_SRC emacs-lisp - (use-package ob - :ensure nil - :config - (org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (js . t) - (java . t) - (haskell . t) - (python . t) - (ruby . t) - (org . t) - (matlab . t) - (ditaa . t) - (clojure . t) - (dot . t) - (shell . t)))) -#+END_SRC - -Exporting to html needs htmlize. - -#+BEGIN_SRC emacs-lisp - (use-package htmlize - :commands (htmlize-file - htmlize-buffer - htmlize-region - htmlize-many-files - htmlize-many-files-dired - htmlize-region-save-screenshot)) -#+END_SRC - -Add md backend - -#+BEGIN_SRC emacs-lisp - (require 'ox-md) -#+END_SRC - -Add org noter - -#+BEGIN_SRC emacs-lisp - (use-package org-noter - :after org - :config (setq org-noter-default-notes-file-names '("notes.org") - org-noter-notes-search-path '("~/org/bibliography") - org-noter-separate-notes-from-heading t)) - - (use-package org-ref - :after org - :bind (("C-c r" . org-ref-cite-hydra/body) - ("C-c b" . org-ref-bibtex-hydra/body)) - :init - (require 'org-ref) - :config - (setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org" - org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib") - org-ref-pdf-directory "~/Dropbox/bibliography/papers/") - (setq org-ref-completion-library 'org-ref-ivy-cite)) -#+END_SRC - -*** Org ID - -#+begin_src emacs-lisp - (use-package org-id - :ensure nil - :after org) -#+end_src - -*** Templates -#+BEGIN_SRC emacs-lisp - (setq org-capture-templates - '(("t" "todo" entry (file+headline "~/Dropbox/org/inbox.org" "Tasks") - "* TODO %?\n\n%i\n%a\n\n") - ())) -#+END_SRC - -*** Agenda - -#+BEGIN_SRC emacs-lisp - (setq org-agenda-files (mapcar 'expand-file-name - (list "~/Dropbox/org/inbox.org" - "~/Dropbox/org/main.org" - "~/Dropbox/org/tickler.org" - (format-time-string "~/Dropbox/org/journals/%Y-%m.org"))) - org-refile-targets `(("~/Dropbox/org/main.org" :maxlevel . 2) - ("~/Dropbox/org/someday.org" :level . 1) - ("~/Dropbox/org/tickler.org" :maxlevel . 2) - (,(format-time-string "~/Dropbox/org/journals/%Y-%m.org") :maxlevel . 2)) - org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELLED(c)"))) - - (setq org-agenda-custom-commands - '(("w" "At work" tags-todo "@work" - ((org-agenda-overriding-header "Work"))) - ("h" "At home" tags-todo "@home" - ((org-agenda-overriding-header "Home"))) - ("u" "At uni" tags-todo "@uni" - ((org-agenda-overriding-header "University"))))) -#+END_SRC - -*** Contacts - -#+BEGIN_SRC emacs-lisp - (setq org-contacts-files (mapcar 'expand-file-name - '("~/Dropbox/org/contacts.org"))) -#+END_SRC - -*** Remove Binding -#+BEGIN_SRC emacs-lisp - (define-key org-mode-map (kbd "C-,") nil) -#+END_SRC - -*** Registers - -#+BEGIN_SRC emacs-lisp - (set-register ?l (cons 'file "~/.emacs.d/loader.org")) - (set-register ?m (cons 'file "~/Dropbox/org/main.org")) - (set-register ?i (cons 'file "~/Dropbox/org/inbox.org")) - (set-register ?c (cons 'file (format-time-string "~/Dropbox/org/journals/%Y-%m.org"))) -#+END_SRC - -*** Exporting - -#+BEGIN_SRC emacs-lisp - (use-package ox-twbs) -#+END_SRC - -** PDF Tools - -#+BEGIN_SRC emacs-lisp - (use-package pdf-tools - :config - ;; initialise - (pdf-tools-install) - ;; open pdfs scaled to fit page - (setq-default pdf-view-display-size 'fit-page) - ;; automatically annotate highlights - (setq pdf-annot-activate-created-annotations t) - ;; use normal isearch - (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)) -#+END_SRC - -** Writeroom - -#+begin_src emacs-lisp - (use-package writeroom-mode - :config - (setq writeroom-width 100)) -#+end_src - -* Programming -My emacs configuration is mostly focused on programming, therefore there is a -lot of different language support. - -** Version Control and Project Management -*** Magit -#+BEGIN_SRC emacs-lisp - (use-package magit - :bind (("C-x g" . magit-status)) - :config - (setq server-switch-hook nil)) -#+END_SRC - -*** Projectile -#+BEGIN_SRC emacs-lisp - (use-package projectile - :config - (projectile-mode +1) - (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) - (setq projectile-enable-caching nil) - (setq projectile-git-submodule-command "") - (setq projectile-mode-line '(:eval (format " Proj[%s]" (projectile-project-name)))) - (defun projectile-tags-exclude-patterns () "")) - - (use-package counsel-projectile - :config - (counsel-projectile-mode t)) -#+END_SRC - -*** Diff - -#+BEGIN_SRC emacs-lisp - (defun command-line-diff (switch) - (let ((file1 (pop command-line-args-left)) - (file2 (pop command-line-args-left))) - (ediff file1 file2))) - (add-to-list 'command-switch-alist '("diff" . command-line-diff)) - (setq-default ediff-forward-word-function 'forward-char) -#+END_SRC - -** Language Support -*** C++ - -Setting up CC mode with a hook that uses my settings. - -#+BEGIN_SRC emacs-lisp - (use-package cc-mode - :config - (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) - (setq c-default-style "linux" - tab-width 4 - c-indent-level 4) - (defun my-c++-mode-hook () - (c-set-offset 'inline-open 0) - (c-set-offset 'inline-close 0) - (c-set-offset 'innamespace 0) - (c-set-offset 'arglist-cont-nonempty 8) - (setq indent-tabs-mode nil)) - (add-hook 'c-mode-hook 'my-c++-mode-hook) - (add-hook 'c++-mode-hook 'my-c++-mode-hook) - - (define-key c-mode-map (kbd "C-c C-c") 'comment-or-uncomment-region)) -#+END_SRC - -Adding C headers to company backend for completion. - -#+BEGIN_SRC emacs-lisp - (use-package irony - :config - (add-hook 'c++-mode-hook 'irony-mode) - (add-hook 'c-mode-hook 'irony-mode) - (add-hook 'objc-mode-hook 'irony-mode) - - (defun my-irony-mode-hook () - (define-key irony-mode-map [remap completion-at-point] - 'irony-completion-at-point-async) - (define-key irony-mode-map [remap complete-symbol] - 'irony-completion-at-point-async)) - (add-hook 'irony-mode-hook 'my-irony-mode-hook) - (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)) - - (use-package company-irony) - - (use-package flycheck-irony - :config - (add-hook 'c++-mode-hook #'flycheck-irony-setup)) - - (use-package company-c-headers - :config - (add-to-list 'company-backends 'company-c-headers) - (add-to-list 'company-backends 'company-irony) - - (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)) -#+END_SRC - -Using clang format to format the region that is currently being selected (need -to install clang format script). - -#+BEGIN_SRC emacs-lisp - (use-package clang-format - :bind (("C-c C-i" . 'clang-format-region) - ("C-c u" . 'clang-format-buffer))) -#+END_SRC - -*** Clojure -Using Cider for clojure environment. - -#+BEGIN_SRC emacs-lisp - (use-package cider - :commands cider-mode - :config - (setq cider-repl-display-help-banner nil)) -#+END_SRC - -Adding hook to clojure mode to enable strict parentheses mode. - -#+BEGIN_SRC emacs-lisp - (add-hook 'clojure-mode-hook 'turn-on-smartparens-strict-mode) -#+END_SRC - -*** CMake -#+BEGIN_SRC emacs-lisp - (use-package cmake-mode - :commands cmake-mode - :config - (setq auto-mode-alist - (append - '(("CMakeLists\\.txt\\'" . cmake-mode)) - '(("\\.cmake\\'" . cmake-mode)) - auto-mode-alist)) - (autoload 'cmake-mode "~/CMake/Auxiliary/cmake-mode.el" t)) -#+END_SRC - -*** Coq - -#+begin_src emacs-lisp - (use-package proof-general - :config - (setq coq-compile-before-require t) - (setq proof-splash-enable nil)) -#+end_src - -*** Elm - -#+BEGIN_SRC emacs-lisp - (use-package elm-mode - :mode ("\\.elm\\'")) -#+END_SRC - -*** Emacs Lisp -Adding strict parentheses to emacs lisp. - -#+BEGIN_SRC emacs-lisp - (add-hook 'emacs-lisp-mode-hook 'turn-on-smartparens-strict-mode) -#+END_SRC - -*** F# -F# mode for uni work. - -#+BEGIN_SRC emacs-lisp - (use-package fsharp-mode - :commands fsharp-mode - :config - (defun y/fsharp-reload-file () - "Reloads the whole file when in fsharp mode." - (interactive) - (fsharp-eval-region (point-min) (point-max))) - (add-hook 'fsharp-mode-hook - (lambda () (local-set-key (kbd "C-c C-c") #'y/fsharp-reload-file)))) -#+END_SRC - -*** Flex - -#+begin_src emacs-lisp - (add-to-list 'auto-mode-alist '("\\.flex\\'" . c-mode)) -#+end_src - -*** Haskell - -Haskell mode with company mode completion. - -#+BEGIN_SRC emacs-lisp - (defun y/haskell-align-comment (start end) - (interactive "r") - (align-regexp start end "\\(\\s-*\\)--")) - - (use-package haskell-mode - :commands haskell-mode - :bind (("M-." . haskell-mode-jump-to-def)) - :config - (add-hook 'haskell-mode-hook 'haskell-decl-scan-mode) - (add-hook 'haskell-mode-hook (lambda () - (local-set-key (kbd "C-c y a") 'y/haskell-align-comment))) - (add-hook 'haskell-mode-hook (lambda () - (local-set-key (kbd "C-c v") 'haskell-add-import))) - (add-hook 'haskell-mode-hook (lambda () - (set (make-local-variable 'projectile-tags-command) - "hasktags -Re -f \"%s\" %s \"%s\""))) - (setq ;;haskell-mode-stylish-haskell-path "brittany" - flycheck-ghc-language-extensions '("OverloadedStrings")) - - (setq haskell-indentation-layout-offset 4 - haskell-indentation-starter-offset 4 - haskell-indentation-left-offset 4 - haskell-indentation-where-pre-offset 2 - haskell-indentation-where-post-offset 2)) - - - (use-package interactive-haskell-mode - :ensure haskell-mode - :hook haskell-mode) -#+END_SRC - -*** LLVM IR - -#+begin_src emacs-lisp - (when (file-exists-p "~/.emacs.d/modes/llvm-mode.el") - (require 'llvm-mode)) -#+end_src - -*** HOL - -#+begin_src emacs-lisp - (when (file-exists-p "/opt/hol/tools/hol-mode.el") - (setq hol-executable "/opt/hol/bin/hol") - (load "/opt/hol/tools/hol-mode.el")) -#+end_src - -*** Python -Elpy package for python, which provides an IDE type environment for python. - -#+BEGIN_SRC emacs-lisp - (use-package elpy - :commands python-mode - :config - (elpy-enable) - (setq py-python-command "python3") - (setq python-shell-interpreter "python3")) - (setq tab-width 4) - - (with-eval-after-load 'python - (defun python-shell-completion-native-try () - "Return non-nil if can trigger native completion." - (let ((python-shell-completion-native-enable t) - (python-shell-completion-native-output-timeout - python-shell-completion-native-try-output-timeout)) - (python-shell-completion-native-get-completions - (get-buffer-process (current-buffer)) - nil "_")))) -#+END_SRC - -*** JSON -JSON files should be opened in js-mode. -#+BEGIN_SRC emacs-lisp - (add-to-list 'auto-mode-alist '("\\.json\\'" . js-mode)) -#+END_SRC - -*** SCSS -#+BEGIN_SRC emacs-lisp - (use-package css-mode - :ensure nil - :commands (scss-mode - css-mode) - :config - (setq css-indent-offset 2)) -#+END_SRC - -*** Scala - -#+begin_src emacs-lisp - (use-package scala-mode) -#+end_src - -*** Shell -#+BEGIN_SRC emacs-lisp - (setq sh-basic-offset 2) - (setq sh-indentation 2) -#+END_SRC - -*** SMTLIBv2 - -#+begin_src emacs-lisp - (require 'smtlib-mode) - (add-to-list 'auto-mode-alist '("\\.smt\\'" . smtlib-mode)) -#+end_src - -*** Verilog - -#+begin_src emacs-lisp - (setq flycheck-verilog-verilator-executable "verilator_bin") -#+end_src - -** Completion Support -*** Company -#+BEGIN_SRC emacs-lisp - (use-package company - :config - (add-hook 'after-init-hook 'global-company-mode) - (setq company-backends (delete 'company-semantic company-backends)) - - (define-key c-mode-map (kbd "C-c n") 'company-complete) - (define-key c++-mode-map (kbd "C-c n") 'company-complete) - (setq company-dabbrev-downcase 0)) -#+END_SRC - -*** Flycheck -Enabling global flycheck support. -#+BEGIN_SRC emacs-lisp - (use-package flycheck - :config (global-flycheck-mode)) -#+END_SRC - -*** Yasnippets -#+BEGIN_SRC emacs-lisp - (use-package yasnippet - :hook ((org-mode cc-mode) . yas-minor-mode) - :config - (yas-minor-mode 1)) -#+END_SRC - -*** SMerge - -Shamelessly taken from https://github.com/alphapapa/unpackaged.el#hydra. -#+BEGIN_SRC emacs-lisp - (use-package smerge-mode - :config - (defhydra unpackaged/smerge-hydra - (:color pink :hint nil :post (smerge-auto-leave)) - " - ^Move^ ^Keep^ ^Diff^ ^Other^ - ^^-----------^^-------------------^^---------------------^^------- - _n_ext _b_ase _<_: upper/base _C_ombine - _p_rev _u_pper _=_: upper/lower _r_esolve - ^^ _l_ower _>_: base/lower _k_ill current - ^^ _a_ll _R_efine - ^^ _RET_: current _E_diff - " - ("n" smerge-next) - ("p" smerge-prev) - ("b" smerge-keep-base) - ("u" smerge-keep-upper) - ("l" smerge-keep-lower) - ("a" smerge-keep-all) - ("RET" smerge-keep-current) - ("\C-m" smerge-keep-current) - ("<" smerge-diff-base-upper) - ("=" smerge-diff-upper-lower) - (">" smerge-diff-base-lower) - ("R" smerge-refine) - ("E" smerge-ediff) - ("C" smerge-combine-with-next) - ("r" smerge-resolve) - ("k" smerge-kill-current) - ("ZZ" (lambda () - (interactive) - (save-buffer) - (bury-buffer)) - "Save and bury buffer" :color blue) - ("q" nil "cancel" :color blue)) - :hook (magit-diff-visit-file . (lambda () - (when smerge-mode - (unpackaged/smerge-hydra/body))))) -#+END_SRC - -* Look and Feel - -#+BEGIN_SRC emacs-lisp - (defadvice load-theme - (before theme-dont-propagate activate) - (mapc #'disable-theme custom-enabled-themes)) - - (add-hook 'after-make-frame-functions - (lambda (frame) - (select-frame frame) - (toggle-scroll-bar -1))) - - (unless (boundp 'server-process) - (progn (load-theme 'sanityinc-tomorrow-night t) - (toggle-scroll-bar -1))) -#+END_SRC - -* Conclusion -Setting the gc-cons threshold back to what it was at the beginning. - -#+BEGIN_SRC emacs-lisp - (server-start) - (setq gc-cons-threshold (* 1024 1024 10)) -#+END_SRC diff --git a/firefox/.config/firefox/userChrome.css b/firefox/.config/firefox/userChrome.css new file mode 100644 index 0000000..4e1e033 --- /dev/null +++ b/firefox/.config/firefox/userChrome.css @@ -0,0 +1 @@ +#TabsToolbar { visibility: collapse !important; } diff --git a/firefox/userChrome.css b/firefox/userChrome.css deleted file mode 100644 index 4e1e033..0000000 --- a/firefox/userChrome.css +++ /dev/null @@ -1 +0,0 @@ -#TabsToolbar { visibility: collapse !important; } diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish new file mode 100644 index 0000000..47c1744 --- /dev/null +++ b/fish/.config/fish/config.fish @@ -0,0 +1,36 @@ +set -x _JAVA_AWT_WM_NONREPARENTING 1 +set -x DOTNET_CLI_TELEMETRY_OPTOUT 1 +set -x EDITOR 'emacsclient -nw' +set -x VISUAL 'emacsclient -c' +set -x CLICOLOR 1 +set -x LEDGER_FILE "$HOME/Dropbox/ledger/main.ledger" +set -x VAGRANT_HOME /mnt/orca/vagrant +set -x QMK_HOME "$HOME/projects/qmk_firmware" +set -x NIX_IGNORE_SYMLINK_STORE 1 + +set -x CDS_LIC_FILE 5280@ee-llic01.ee.ic.ac.uk +set -x SNPS_LICENSE_FILE 7182@ee-llic01.ee.ic.ac.uk +set -x MGLS_LICENSE_FILE 1717@ee-llic01.ee.ic.ac.uk +set -x LM_LICENSE_FILE 2100@ee-llic01.ee.ic.ac.uk:7193@ee-llic01.ee.ic.ac.uk:5280@ee-llic01.ee.ic.ac.uk:7182@ee-llic01.ee.ic.ac.uk:1717@ee-llic01.ee.ic.ac.uk + +# nix section +set -x NIX_LINK $HOME/.nix-profile +set -x NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt +set -x MANPATH "$NIX_LINK/share/man:$MANPATH" +set -x PATH "$NIX_LINK/bin:$PATH" +set -e NIX_LINK + +function latestqr -d "Return the string corresponding to the latest QR code." + ls -aS $HOME/Desktop | tail -n1 | tr \\n \\0 | xargs -0 -I% zbarimg --raw -q $HOME/Desktop/% +end + +function open; xdg-open $argv; end +function ls; exa $argv; end +function ll; ls -lah $argv; end +function vim; nvim $argv; end + +if status is-interactive + # Commands to run in interactive sessions can go here +end + +direnv hook fish | source diff --git a/fish/config.fish b/fish/config.fish deleted file mode 100644 index 47c1744..0000000 --- a/fish/config.fish +++ /dev/null @@ -1,36 +0,0 @@ -set -x _JAVA_AWT_WM_NONREPARENTING 1 -set -x DOTNET_CLI_TELEMETRY_OPTOUT 1 -set -x EDITOR 'emacsclient -nw' -set -x VISUAL 'emacsclient -c' -set -x CLICOLOR 1 -set -x LEDGER_FILE "$HOME/Dropbox/ledger/main.ledger" -set -x VAGRANT_HOME /mnt/orca/vagrant -set -x QMK_HOME "$HOME/projects/qmk_firmware" -set -x NIX_IGNORE_SYMLINK_STORE 1 - -set -x CDS_LIC_FILE 5280@ee-llic01.ee.ic.ac.uk -set -x SNPS_LICENSE_FILE 7182@ee-llic01.ee.ic.ac.uk -set -x MGLS_LICENSE_FILE 1717@ee-llic01.ee.ic.ac.uk -set -x LM_LICENSE_FILE 2100@ee-llic01.ee.ic.ac.uk:7193@ee-llic01.ee.ic.ac.uk:5280@ee-llic01.ee.ic.ac.uk:7182@ee-llic01.ee.ic.ac.uk:1717@ee-llic01.ee.ic.ac.uk - -# nix section -set -x NIX_LINK $HOME/.nix-profile -set -x NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt -set -x MANPATH "$NIX_LINK/share/man:$MANPATH" -set -x PATH "$NIX_LINK/bin:$PATH" -set -e NIX_LINK - -function latestqr -d "Return the string corresponding to the latest QR code." - ls -aS $HOME/Desktop | tail -n1 | tr \\n \\0 | xargs -0 -I% zbarimg --raw -q $HOME/Desktop/% -end - -function open; xdg-open $argv; end -function ls; exa $argv; end -function ll; ls -lah $argv; end -function vim; nvim $argv; end - -if status is-interactive - # Commands to run in interactive sessions can go here -end - -direnv hook fish | source diff --git a/i3/.config/i3/config b/i3/.config/i3/config new file mode 100644 index 0000000..5af7f9f --- /dev/null +++ b/i3/.config/i3/config @@ -0,0 +1,226 @@ +# This file has been auto-generated by i3-config-wizard(1). +# It will not be overwritten, so edit it as you like. +# +# Should you change your keyboard layout some time, delete +# this file and re-run i3-config-wizard(1). +# + +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font pango:monospace 8 + +# This font is widely installed, provides lots of unicode glyphs, right-to-left +# text rendering and scalability on retina/hidpi displays (thanks to pango). +#font pango:DejaVu Sans Mono 8 + +# Before i3 v4.8, we used to recommend this one as the default: +# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 +# The font above is very space-efficient, that is, it looks good, sharp and +# clear in small sizes. However, its unicode glyph coverage is limited, the old +# X core fonts rendering does not support right-to-left and this being a bitmap +# font, it doesn’t scale on retina/hidpi displays. + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec i3-sensible-terminal + +# kill focused window +bindsym $mod+Shift+q kill + +# start dmenu (a program launcher) +bindsym $mod+d exec --no-startup-id rofi -show +bindsym $mod+k exec --no-startup-id keepmenu +# There also is the (new) i3-dmenu-desktop which only displays applications +# shipping a .desktop file. It is a wrapper around dmenu, so you need that +# installed. +# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop + +# change focus +bindsym $mod+n focus left +bindsym $mod+e focus down +bindsym $mod+u focus up +bindsym $mod+i focus right + +# alternatively, you can use the cursor keys: +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# move focused window +bindsym $mod+Shift+n move left +bindsym $mod+Shift+e move down +bindsym $mod+Shift+u move up +bindsym $mod+Shift+i move right + +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# split in horizontal orientation +bindsym $mod+h split h + +# split in vertical orientation +bindsym $mod+v split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+g layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindsym $mod+d focus child + +# switch to workspace +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace 1 +bindsym $mod+Shift+2 move container to workspace 2 +bindsym $mod+Shift+3 move container to workspace 3 +bindsym $mod+Shift+4 move container to workspace 4 +bindsym $mod+Shift+5 move container to workspace 5 +bindsym $mod+Shift+6 move container to workspace 6 +bindsym $mod+Shift+7 move container to workspace 7 +bindsym $mod+Shift+8 move container to workspace 8 +bindsym $mod+Shift+9 move container to workspace 9 +bindsym $mod+Shift+0 move container to workspace 10 + +# reload the configuration file +bindsym $mod+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart + +# App bindings to open +set $open_mode Open: (e) Emacs, (f) Firefox +mode "$open_mode" { + bindsym f exec firefox-developer-edition, mode "default" + bindsym e exec emacsclient -c -a "emacs", mode "default" + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+o mode "$open_mode" + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym n resize shrink width 25 px or 25 ppt + bindsym e resize grow height 25 px or 25 ppt + bindsym u resize shrink height 25 px or 25 ppt + bindsym i resize grow width 25 px or 25 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +#============================================================ +# i3 Gaps +#============================================================ + +# Disable titles +for_window [class="^.*"] border pixel 0 + +smart_gaps on +gaps inner 10 +gaps outer 0 + +#============================================================ +# Custom Bindings +#============================================================ + +# Volume settings +bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master 5%+ # increase sound volume +bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master 5%- # decrease sound volume +bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle-mute # mute sound + +# Sreen brightness controls +bindsym XF86MonBrightnessUp exec light -A 5 +bindsym XF86MonBrightnessDown exec light -U 5 + +# Media Controls +bindsym XF86AudioPlay exec playerctl play-pause +bindsym XF86AudioStop exec playerctl stop +bindsym XF86AudioNext exec playerctl next +bindsym XF86AudioPrev exec playerctl previous + +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id ~/.local/bin/i3exit lock, mode "default" + bindsym e exec --no-startup-id ~/.local/bin/i3exit logout, mode "default" + bindsym s exec --no-startup-id ~/.local/bin/i3exit suspend, mode "default" + bindsym h exec --no-startup-id ~/.local/bin/i3exit hibernate, mode "default" + bindsym r exec --no-startup-id ~/.local/bin/i3exit reboot, mode "default" + bindsym Shift+s exec --no-startup-id ~/.local/bin/i3exit shutdown, mode "default" + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+Shift+p mode "$mode_system" + +#============================================================ +# Application Startup +#============================================================ + +# set the background +exec --no-startup-id sh ~/.fehbg + +# Activate redshift +exec --no-startup-id redshift & + +# Startup dropbox +exec --no-startup-id dropbox & + +# Start polybar +exec_always --no-startup-id $HOME/.config/polybar/launch.sh + +# Enable smooth scrolling +exec --no-startup-id xinput set-prop 'DLL075B:01 06CB:76AF Touchpad' 'libinput Natural Scrolling Enabled' 1 diff --git a/i3/.config/i3/i3exit b/i3/.config/i3/i3exit new file mode 100755 index 0000000..4292234 --- /dev/null +++ b/i3/.config/i3/i3exit @@ -0,0 +1,30 @@ +#!/bin/sh +lock() { + i3lock -c 2f2f2f +} + +case "$1" in + lock) + lock + ;; + logout) + i3-msg exit + ;; + suspend) + lock && systemctl suspend + ;; + hibernate) + lock && systemctl hibernate + ;; + reboot) + systemctl reboot + ;; + shutdown) + systemctl poweroff + ;; + *) + echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" + exit 2 +esac + +exit 0 diff --git a/i3/config b/i3/config deleted file mode 100644 index 5af7f9f..0000000 --- a/i3/config +++ /dev/null @@ -1,226 +0,0 @@ -# This file has been auto-generated by i3-config-wizard(1). -# It will not be overwritten, so edit it as you like. -# -# Should you change your keyboard layout some time, delete -# this file and re-run i3-config-wizard(1). -# - -# i3 config file (v4) -# -# Please see http://i3wm.org/docs/userguide.html for a complete reference! - -set $mod Mod4 - -# Font for window titles. Will also be used by the bar unless a different font -# is used in the bar {} block below. -font pango:monospace 8 - -# This font is widely installed, provides lots of unicode glyphs, right-to-left -# text rendering and scalability on retina/hidpi displays (thanks to pango). -#font pango:DejaVu Sans Mono 8 - -# Before i3 v4.8, we used to recommend this one as the default: -# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 -# The font above is very space-efficient, that is, it looks good, sharp and -# clear in small sizes. However, its unicode glyph coverage is limited, the old -# X core fonts rendering does not support right-to-left and this being a bitmap -# font, it doesn’t scale on retina/hidpi displays. - -# Use Mouse+$mod to drag floating windows to their wanted position -floating_modifier $mod - -# start a terminal -bindsym $mod+Return exec i3-sensible-terminal - -# kill focused window -bindsym $mod+Shift+q kill - -# start dmenu (a program launcher) -bindsym $mod+d exec --no-startup-id rofi -show -bindsym $mod+k exec --no-startup-id keepmenu -# There also is the (new) i3-dmenu-desktop which only displays applications -# shipping a .desktop file. It is a wrapper around dmenu, so you need that -# installed. -# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop - -# change focus -bindsym $mod+n focus left -bindsym $mod+e focus down -bindsym $mod+u focus up -bindsym $mod+i focus right - -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right - -# move focused window -bindsym $mod+Shift+n move left -bindsym $mod+Shift+e move down -bindsym $mod+Shift+u move up -bindsym $mod+Shift+i move right - -# alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right - -# split in horizontal orientation -bindsym $mod+h split h - -# split in vertical orientation -bindsym $mod+v split v - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen toggle - -# change container layout (stacked, tabbed, toggle split) -bindsym $mod+s layout stacking -bindsym $mod+w layout tabbed -bindsym $mod+g layout toggle split - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+space focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -#bindsym $mod+d focus child - -# switch to workspace -bindsym $mod+1 workspace 1 -bindsym $mod+2 workspace 2 -bindsym $mod+3 workspace 3 -bindsym $mod+4 workspace 4 -bindsym $mod+5 workspace 5 -bindsym $mod+6 workspace 6 -bindsym $mod+7 workspace 7 -bindsym $mod+8 workspace 8 -bindsym $mod+9 workspace 9 -bindsym $mod+0 workspace 10 - -# move focused container to workspace -bindsym $mod+Shift+1 move container to workspace 1 -bindsym $mod+Shift+2 move container to workspace 2 -bindsym $mod+Shift+3 move container to workspace 3 -bindsym $mod+Shift+4 move container to workspace 4 -bindsym $mod+Shift+5 move container to workspace 5 -bindsym $mod+Shift+6 move container to workspace 6 -bindsym $mod+Shift+7 move container to workspace 7 -bindsym $mod+Shift+8 move container to workspace 8 -bindsym $mod+Shift+9 move container to workspace 9 -bindsym $mod+Shift+0 move container to workspace 10 - -# reload the configuration file -bindsym $mod+Shift+c reload -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) -bindsym $mod+Shift+r restart - -# App bindings to open -set $open_mode Open: (e) Emacs, (f) Firefox -mode "$open_mode" { - bindsym f exec firefox-developer-edition, mode "default" - bindsym e exec emacsclient -c -a "emacs", mode "default" - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} - -bindsym $mod+o mode "$open_mode" - -# resize window (you can also use the mouse for that) -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the window’s width. - # Pressing right will grow the window’s width. - # Pressing up will shrink the window’s height. - # Pressing down will grow the window’s height. - bindsym n resize shrink width 25 px or 25 ppt - bindsym e resize grow height 25 px or 25 ppt - bindsym u resize shrink height 25 px or 25 ppt - bindsym i resize grow width 25 px or 25 ppt - - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} - -bindsym $mod+r mode "resize" - -#============================================================ -# i3 Gaps -#============================================================ - -# Disable titles -for_window [class="^.*"] border pixel 0 - -smart_gaps on -gaps inner 10 -gaps outer 0 - -#============================================================ -# Custom Bindings -#============================================================ - -# Volume settings -bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master 5%+ # increase sound volume -bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master 5%- # decrease sound volume -bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle-mute # mute sound - -# Sreen brightness controls -bindsym XF86MonBrightnessUp exec light -A 5 -bindsym XF86MonBrightnessDown exec light -U 5 - -# Media Controls -bindsym XF86AudioPlay exec playerctl play-pause -bindsym XF86AudioStop exec playerctl stop -bindsym XF86AudioNext exec playerctl next -bindsym XF86AudioPrev exec playerctl previous - -set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown -mode "$mode_system" { - bindsym l exec --no-startup-id ~/.local/bin/i3exit lock, mode "default" - bindsym e exec --no-startup-id ~/.local/bin/i3exit logout, mode "default" - bindsym s exec --no-startup-id ~/.local/bin/i3exit suspend, mode "default" - bindsym h exec --no-startup-id ~/.local/bin/i3exit hibernate, mode "default" - bindsym r exec --no-startup-id ~/.local/bin/i3exit reboot, mode "default" - bindsym Shift+s exec --no-startup-id ~/.local/bin/i3exit shutdown, mode "default" - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} -bindsym $mod+Shift+p mode "$mode_system" - -#============================================================ -# Application Startup -#============================================================ - -# set the background -exec --no-startup-id sh ~/.fehbg - -# Activate redshift -exec --no-startup-id redshift & - -# Startup dropbox -exec --no-startup-id dropbox & - -# Start polybar -exec_always --no-startup-id $HOME/.config/polybar/launch.sh - -# Enable smooth scrolling -exec --no-startup-id xinput set-prop 'DLL075B:01 06CB:76AF Touchpad' 'libinput Natural Scrolling Enabled' 1 diff --git a/i3/i3exit b/i3/i3exit deleted file mode 100755 index 4292234..0000000 --- a/i3/i3exit +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -lock() { - i3lock -c 2f2f2f -} - -case "$1" in - lock) - lock - ;; - logout) - i3-msg exit - ;; - suspend) - lock && systemctl suspend - ;; - hibernate) - lock && systemctl hibernate - ;; - reboot) - systemctl reboot - ;; - shutdown) - systemctl poweroff - ;; - *) - echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" - exit 2 -esac - -exit 0 diff --git a/mpd/.config/mpd/mpd.conf b/mpd/.config/mpd/mpd.conf new file mode 100644 index 0000000..dabd350 --- /dev/null +++ b/mpd/.config/mpd/mpd.conf @@ -0,0 +1,29 @@ +# Recommended location for database +db_file "~/.config/mpd/database" + +# Logs to systemd journal +log_file "syslog" + +# The music directory is by default the XDG directory, uncomment to amend and choose a different directory +music_directory "~/Music" + +# Uncomment to refresh the database whenever files in the music_directory are changed +auto_update "yes" + +# Uncomment to enable the functionalities +playlist_directory "~/.config/mpd/playlists" +#pid_file "~/.config/mpd/pid" +#state_file "~/.config/mpd/state" +#sticker_file "~/.config/mpd/sticker.sql" + +audio_output { + type "fifo" + name "FIFO" + path "/tmp/mpd.fifo" + format "44100:16:2" +} + +audio_output { + type "pulse" + name "PulseAudio" +} diff --git a/mpd/mpd.conf b/mpd/mpd.conf deleted file mode 100644 index dabd350..0000000 --- a/mpd/mpd.conf +++ /dev/null @@ -1,29 +0,0 @@ -# Recommended location for database -db_file "~/.config/mpd/database" - -# Logs to systemd journal -log_file "syslog" - -# The music directory is by default the XDG directory, uncomment to amend and choose a different directory -music_directory "~/Music" - -# Uncomment to refresh the database whenever files in the music_directory are changed -auto_update "yes" - -# Uncomment to enable the functionalities -playlist_directory "~/.config/mpd/playlists" -#pid_file "~/.config/mpd/pid" -#state_file "~/.config/mpd/state" -#sticker_file "~/.config/mpd/sticker.sql" - -audio_output { - type "fifo" - name "FIFO" - path "/tmp/mpd.fifo" - format "44100:16:2" -} - -audio_output { - type "pulse" - name "PulseAudio" -} diff --git a/msmtp/.config/msmtp/config b/msmtp/.config/msmtp/config new file mode 100644 index 0000000..f921ea4 --- /dev/null +++ b/msmtp/.config/msmtp/config @@ -0,0 +1,27 @@ +defaults +auth on +tls on +logfile ~/.msmtp.log + +account mailbox +host smtp.mailbox.org +port 587 +from yann@yannherklotz.com +user ymherklotz@mailbox.org +passwordeval "pass show mailbox/ymherklotz@mailbox.org" + +account git +host smtp.mailbox.org +port 587 +from git@yannherklotz.com +user ymherklotz@mailbox.org +passwordeval "pass show mailbox/ymherklotz@mailbox.org" + +account imperial +host smtp.office365.com +port 587 +from yann.herklotz15@imperial.ac.uk +user ymh15@ic.ac.uk +passwordeval "pass show imperial/emacs-app" + +account default : mailbox diff --git a/msmtp/config b/msmtp/config deleted file mode 100644 index f921ea4..0000000 --- a/msmtp/config +++ /dev/null @@ -1,27 +0,0 @@ -defaults -auth on -tls on -logfile ~/.msmtp.log - -account mailbox -host smtp.mailbox.org -port 587 -from yann@yannherklotz.com -user ymherklotz@mailbox.org -passwordeval "pass show mailbox/ymherklotz@mailbox.org" - -account git -host smtp.mailbox.org -port 587 -from git@yannherklotz.com -user ymherklotz@mailbox.org -passwordeval "pass show mailbox/ymherklotz@mailbox.org" - -account imperial -host smtp.office365.com -port 587 -from yann.herklotz15@imperial.ac.uk -user ymh15@ic.ac.uk -passwordeval "pass show imperial/emacs-app" - -account default : mailbox diff --git a/ncmpcpp/.config/ncmpcpp/bindings b/ncmpcpp/.config/ncmpcpp/bindings new file mode 100644 index 0000000..d961edc --- /dev/null +++ b/ncmpcpp/.config/ncmpcpp/bindings @@ -0,0 +1,559 @@ +############################################################## +## This is the example bindings file. Copy it to ## +## ~/.ncmpcpp/bindings or $XDG_CONFIG_HOME/ncmpcpp/bindings ## +## and set up your preferences ## +############################################################## +## +##### General rules ##### +## +## 1) Because each action has runtime checks whether it's +## ok to run it, a few actions can be bound to one key. +## Actions will be bound in order given in configuration +## file. When a key is pressed, first action in order +## will test itself whether it's possible to run it. If +## test succeeds, action is executed and other actions +## bound to this key are ignored. If it doesn't, next +## action in order tests itself etc. +## +## 2) It's possible to bind more that one action at once +## to a key. It can be done using the following syntax: +## +## def_key "key" +## action1 +## action2 +## ... +## +## This creates a chain of actions. When such chain is +## executed, each action in chain is run until the end of +## chain is reached or one of its actions fails to execute +## due to its requirements not being met. If multiple actions +## and/or chains are bound to the same key, they will be +## consecutively run until one of them gets fully executed. +## +## 3) When ncmpcpp starts, bindings configuration file is +## parsed and then ncmpcpp provides "missing pieces" +## of default keybindings. If you want to disable some +## bindings, there is a special action called 'dummy' +## for that purpose. Eg. if you want to disable ability +## to crop playlists, you need to put the following +## into configuration file: +## +## def_key "C" +## dummy +## +## After that ncmpcpp will not bind any default action +## to this key. +## +## 4) To let you write simple macros, the following special +## actions are provided: +## +## - push_character "character" - pushes given special +## character into input queue, so it will be immediately +## picked by ncmpcpp upon next call to readKey function. +## Accepted values: mouse, up, down, page_up, page_down, +## home, end, space, enter, insert, delete, left, right, +## tab, ctrl-a, ctrl-b, ..., ctrl-z, ctrl-[, ctrl-\\, +## ctrl-], ctrl-^, ctrl-_, f1, f2, ..., f12, backspace. +## In addition, most of these names can be prefixed with +## alt-/ctrl-/shift- to be recognized with the appropriate +## modifier key(s). +## +## - push_characters "string" - pushes given string into +## input queue. +## +## - require_runnable "action" - checks whether given action +## is runnable and fails if it isn't. This is especially +## useful when mixed with previous two functions. Consider +## the following macro definition: +## +## def_key "key" +## push_characters "custom_filter" +## apply_filter +## +## If apply_filter can't be currently run, we end up with +## sequence of characters in input queue which will be +## treated just as we typed them. This may lead to unexpected +## results (in this case 'c' will most likely clear current +## playlist, 'u' will trigger database update, 's' will stop +## playback etc.). To prevent such thing from happening, we +## need to change above definition to this one: +## +## def_key "key" +## require_runnable "apply_filter" +## push_characters "custom_filter" +## apply_filter +## +## Here, first we test whether apply_filter can be actually run +## before we stuff characters into input queue, so if condition +## is not met, whole chain is aborted and we're fine. +## +## - require_screen "screen" - checks whether given screen is +## currently active. accepted values: browser, clock, help, +## media_library, outputs, playlist, playlist_editor, +## search_engine, tag_editor, visualizer, last_fm, lyrics, +## selected_items_adder, server_info, song_info, +## sort_playlist_dialog, tiny_tag_editor. +## +## - run_external_command "command" - runs given command using +## system() function. +## +## 5) In addition to binding to a key, you can also bind actions +## or chains of actions to a command. If it comes to commands, +## syntax is very similar to defining keys. Here goes example +## definition of a command: +## +## def_command "quit" [deferred] +## stop +## quit +## +## If you execute the above command (which can be done by +## invoking action execute_command, typing 'quit' and pressing +## enter), ncmpcpp will stop the player and then quit. Note the +## presence of word 'deferred' enclosed in square brackets. It +## tells ncmpcpp to wait for confirmation (ie. pressing enter) +## after you typed quit. Instead of 'deferred', 'immediate' +## could be used. Then ncmpcpp will not wait for confirmation +## (enter) and will execute the command the moment it sees it. +## +## Note: while command chains are executed, internal environment +## update (which includes current window refresh and mpd status +## update) is not performed for performance reasons. However, it +## may be desirable to do so in some situration. Therefore it's +## possible to invoke by hand by performing 'update enviroment' +## action. +## +## Note: There is a difference between: +## +## def_key "key" +## action1 +## +## def_key "key" +## action2 +## +## and +## +## def_key "key" +## action1 +## action2 +## +## First one binds two single actions to the same key whilst +## second one defines a chain of actions. The behavior of +## these two is different and is described in (1) and (2). +## +## Note: Function def_key accepts non-ascii characters. +## +##### List of unbound actions ##### +## +## The following actions are not bound to any key/command: +## +## - set_volume +## +# +#def_key "mouse" +# mouse_event +# +#def_key "up" +# scroll_up +# +#def_key "shift-up" +# select_item +# scroll_up +# +#def_key "down" +# scroll_down +# +#def_key "shift-down" +# select_item +# scroll_down +# +#def_key "[" +# scroll_up_album +# +#def_key "]" +# scroll_down_album +# +#def_key "{" +# scroll_up_artist +# +#def_key "}" +# scroll_down_artist +# +#def_key "page_up" +# page_up +# +#def_key "page_down" +# page_down +# +#def_key "home" +# move_home +# +#def_key "end" +# move_end +# +#def_key "insert" +# select_item +# +#def_key "enter" +# enter_directory +# +#def_key "enter" +# toggle_output +# +#def_key "enter" +# run_action +# +#def_key "enter" +# play_item +# +#def_key "space" +# add_item_to_playlist +# +#def_key "space" +# toggle_lyrics_update_on_song_change +# +#def_key "space" +# toggle_visualization_type +# +#def_key "delete" +# delete_playlist_items +# +#def_key "delete" +# delete_browser_items +# +#def_key "delete" +# delete_stored_playlist +# +#def_key "right" +# next_column +# +#def_key "right" +# slave_screen +# +#def_key "right" +# volume_up +# +#def_key "+" +# volume_up +# +#def_key "left" +# previous_column +# +#def_key "left" +# master_screen +# +#def_key "left" +# volume_down +# +#def_key "-" +# volume_down +# +#def_key ":" +# execute_command +# +#def_key "tab" +# next_screen +# +#def_key "shift-tab" +# previous_screen +# +#def_key "f1" +# show_help +# +#def_key "1" +# show_playlist +# +#def_key "2" +# show_browser +# +#def_key "2" +# change_browse_mode +# +#def_key "3" +# show_search_engine +# +#def_key "3" +# reset_search_engine +# +#def_key "4" +# show_media_library +# +#def_key "4" +# toggle_media_library_columns_mode +# +#def_key "5" +# show_playlist_editor +# +#def_key "6" +# show_tag_editor +# +#def_key "7" +# show_outputs +# +#def_key "8" +# show_visualizer +# +#def_key "=" +# show_clock +# +#def_key "@" +# show_server_info +# +#def_key "s" +# stop +# +#def_key "p" +# pause +# +#def_key ">" +# next +# +#def_key "<" +# previous +# +#def_key "ctrl-h" +# jump_to_parent_directory +# +#def_key "ctrl-h" +# replay_song +# +#def_key "backspace" +# jump_to_parent_directory +# +#def_key "backspace" +# replay_song +# +#def_key "f" +# seek_forward +# +#def_key "b" +# seek_backward +# +#def_key "r" +# toggle_repeat +# +#def_key "z" +# toggle_random +# +#def_key "y" +# save_tag_changes +# +#def_key "y" +# start_searching +# +#def_key "y" +# toggle_single +# +#def_key "R" +# toggle_consume +# +#def_key "Y" +# toggle_replay_gain_mode +# +#def_key "T" +# toggle_add_mode +# +#def_key "|" +# toggle_mouse +# +#def_key "#" +# toggle_bitrate_visibility +# +#def_key "Z" +# shuffle +# +#def_key "x" +# toggle_crossfade +# +#def_key "X" +# set_crossfade +# +#def_key "u" +# update_database +# +#def_key "ctrl-s" +# sort_playlist +# +#def_key "ctrl-s" +# toggle_browser_sort_mode +# +#def_key "ctrl-s" +# toggle_media_library_sort_mode +# +#def_key "ctrl-r" +# reverse_playlist +# +#def_key "ctrl-f" +# apply_filter +# +#def_key "ctrl-_" +# select_found_items +# +#def_key "/" +# find +# +#def_key "/" +# find_item_forward +# +#def_key "?" +# find +# +#def_key "?" +# find_item_backward +# +#def_key "." +# next_found_item +# +#def_key "," +# previous_found_item +# +#def_key "w" +# toggle_find_mode +# +#def_key "e" +# edit_song +# +#def_key "e" +# edit_library_tag +# +#def_key "e" +# edit_library_album +# +#def_key "e" +# edit_directory_name +# +#def_key "e" +# edit_playlist_name +# +#def_key "e" +# edit_lyrics +# +#def_key "i" +# show_song_info +# +#def_key "I" +# show_artist_info +# +#def_key "g" +# jump_to_position_in_song +# +#def_key "l" +# show_lyrics +# +#def_key "ctrl-v" +# select_range +# +#def_key "v" +# reverse_selection +# +#def_key "V" +# remove_selection +# +#def_key "B" +# select_album +# +#def_key "a" +# add_selected_items +# +#def_key "c" +# clear_playlist +# +#def_key "c" +# clear_main_playlist +# +#def_key "C" +# crop_playlist +# +#def_key "C" +# crop_main_playlist +# +#def_key "m" +# move_sort_order_up +# +#def_key "m" +# move_selected_items_up +# +#def_key "n" +# move_sort_order_down +# +#def_key "n" +# move_selected_items_down +# +#def_key "M" +# move_selected_items_to +# +#def_key "A" +# add +# +#def_key "S" +# save_playlist +# +#def_key "o" +# jump_to_playing_song +# +#def_key "G" +# jump_to_browser +# +#def_key "G" +# jump_to_playlist_editor +# +#def_key "~" +# jump_to_media_library +# +#def_key "E" +# jump_to_tag_editor +# +#def_key "U" +# toggle_playing_song_centering +# +#def_key "P" +# toggle_display_mode +# +#def_key "\\" +# toggle_interface +# +#def_key "!" +# toggle_separators_between_albums +# +#def_key "L" +# toggle_lyrics_fetcher +# +#def_key "F" +# fetch_lyrics_in_background +# +#def_key "alt-l" +# toggle_fetching_lyrics_in_background +# +#def_key "ctrl-l" +# toggle_screen_lock +# +#def_key "`" +# toggle_library_tag_type +# +#def_key "`" +# refetch_lyrics +# +#def_key "`" +# add_random_items +# +#def_key "ctrl-p" +# set_selected_items_priority +# +#def_key "q" +# quit +# +def_key "h" + previous_column +def_key "j" + scroll_down +def_key "shift-j" + select_item + scroll_down +def_key "k" + scroll_up +def_key "shift-k" + select_item + scroll_up +def_key "l" + next_column +def_key "d" + show_lyrics diff --git a/ncmpcpp/.config/ncmpcpp/config b/ncmpcpp/.config/ncmpcpp/config new file mode 100644 index 0000000..5eb721f --- /dev/null +++ b/ncmpcpp/.config/ncmpcpp/config @@ -0,0 +1,11 @@ +progressbar_look = "─⊙ " + +header_visibility = "no" + +visualizer_fifo_path = "/tmp/mpd.fifo" +visualizer_output_name = "FIFO" +visualizer_sync_interval = "30" +visualizer_in_stereo = "yes" +visualizer_type = "spectrum" +visualizer_look = "+▊" +visualizer_color = "blue" \ No newline at end of file diff --git a/ncmpcpp/bindings b/ncmpcpp/bindings deleted file mode 100644 index d961edc..0000000 --- a/ncmpcpp/bindings +++ /dev/null @@ -1,559 +0,0 @@ -############################################################## -## This is the example bindings file. Copy it to ## -## ~/.ncmpcpp/bindings or $XDG_CONFIG_HOME/ncmpcpp/bindings ## -## and set up your preferences ## -############################################################## -## -##### General rules ##### -## -## 1) Because each action has runtime checks whether it's -## ok to run it, a few actions can be bound to one key. -## Actions will be bound in order given in configuration -## file. When a key is pressed, first action in order -## will test itself whether it's possible to run it. If -## test succeeds, action is executed and other actions -## bound to this key are ignored. If it doesn't, next -## action in order tests itself etc. -## -## 2) It's possible to bind more that one action at once -## to a key. It can be done using the following syntax: -## -## def_key "key" -## action1 -## action2 -## ... -## -## This creates a chain of actions. When such chain is -## executed, each action in chain is run until the end of -## chain is reached or one of its actions fails to execute -## due to its requirements not being met. If multiple actions -## and/or chains are bound to the same key, they will be -## consecutively run until one of them gets fully executed. -## -## 3) When ncmpcpp starts, bindings configuration file is -## parsed and then ncmpcpp provides "missing pieces" -## of default keybindings. If you want to disable some -## bindings, there is a special action called 'dummy' -## for that purpose. Eg. if you want to disable ability -## to crop playlists, you need to put the following -## into configuration file: -## -## def_key "C" -## dummy -## -## After that ncmpcpp will not bind any default action -## to this key. -## -## 4) To let you write simple macros, the following special -## actions are provided: -## -## - push_character "character" - pushes given special -## character into input queue, so it will be immediately -## picked by ncmpcpp upon next call to readKey function. -## Accepted values: mouse, up, down, page_up, page_down, -## home, end, space, enter, insert, delete, left, right, -## tab, ctrl-a, ctrl-b, ..., ctrl-z, ctrl-[, ctrl-\\, -## ctrl-], ctrl-^, ctrl-_, f1, f2, ..., f12, backspace. -## In addition, most of these names can be prefixed with -## alt-/ctrl-/shift- to be recognized with the appropriate -## modifier key(s). -## -## - push_characters "string" - pushes given string into -## input queue. -## -## - require_runnable "action" - checks whether given action -## is runnable and fails if it isn't. This is especially -## useful when mixed with previous two functions. Consider -## the following macro definition: -## -## def_key "key" -## push_characters "custom_filter" -## apply_filter -## -## If apply_filter can't be currently run, we end up with -## sequence of characters in input queue which will be -## treated just as we typed them. This may lead to unexpected -## results (in this case 'c' will most likely clear current -## playlist, 'u' will trigger database update, 's' will stop -## playback etc.). To prevent such thing from happening, we -## need to change above definition to this one: -## -## def_key "key" -## require_runnable "apply_filter" -## push_characters "custom_filter" -## apply_filter -## -## Here, first we test whether apply_filter can be actually run -## before we stuff characters into input queue, so if condition -## is not met, whole chain is aborted and we're fine. -## -## - require_screen "screen" - checks whether given screen is -## currently active. accepted values: browser, clock, help, -## media_library, outputs, playlist, playlist_editor, -## search_engine, tag_editor, visualizer, last_fm, lyrics, -## selected_items_adder, server_info, song_info, -## sort_playlist_dialog, tiny_tag_editor. -## -## - run_external_command "command" - runs given command using -## system() function. -## -## 5) In addition to binding to a key, you can also bind actions -## or chains of actions to a command. If it comes to commands, -## syntax is very similar to defining keys. Here goes example -## definition of a command: -## -## def_command "quit" [deferred] -## stop -## quit -## -## If you execute the above command (which can be done by -## invoking action execute_command, typing 'quit' and pressing -## enter), ncmpcpp will stop the player and then quit. Note the -## presence of word 'deferred' enclosed in square brackets. It -## tells ncmpcpp to wait for confirmation (ie. pressing enter) -## after you typed quit. Instead of 'deferred', 'immediate' -## could be used. Then ncmpcpp will not wait for confirmation -## (enter) and will execute the command the moment it sees it. -## -## Note: while command chains are executed, internal environment -## update (which includes current window refresh and mpd status -## update) is not performed for performance reasons. However, it -## may be desirable to do so in some situration. Therefore it's -## possible to invoke by hand by performing 'update enviroment' -## action. -## -## Note: There is a difference between: -## -## def_key "key" -## action1 -## -## def_key "key" -## action2 -## -## and -## -## def_key "key" -## action1 -## action2 -## -## First one binds two single actions to the same key whilst -## second one defines a chain of actions. The behavior of -## these two is different and is described in (1) and (2). -## -## Note: Function def_key accepts non-ascii characters. -## -##### List of unbound actions ##### -## -## The following actions are not bound to any key/command: -## -## - set_volume -## -# -#def_key "mouse" -# mouse_event -# -#def_key "up" -# scroll_up -# -#def_key "shift-up" -# select_item -# scroll_up -# -#def_key "down" -# scroll_down -# -#def_key "shift-down" -# select_item -# scroll_down -# -#def_key "[" -# scroll_up_album -# -#def_key "]" -# scroll_down_album -# -#def_key "{" -# scroll_up_artist -# -#def_key "}" -# scroll_down_artist -# -#def_key "page_up" -# page_up -# -#def_key "page_down" -# page_down -# -#def_key "home" -# move_home -# -#def_key "end" -# move_end -# -#def_key "insert" -# select_item -# -#def_key "enter" -# enter_directory -# -#def_key "enter" -# toggle_output -# -#def_key "enter" -# run_action -# -#def_key "enter" -# play_item -# -#def_key "space" -# add_item_to_playlist -# -#def_key "space" -# toggle_lyrics_update_on_song_change -# -#def_key "space" -# toggle_visualization_type -# -#def_key "delete" -# delete_playlist_items -# -#def_key "delete" -# delete_browser_items -# -#def_key "delete" -# delete_stored_playlist -# -#def_key "right" -# next_column -# -#def_key "right" -# slave_screen -# -#def_key "right" -# volume_up -# -#def_key "+" -# volume_up -# -#def_key "left" -# previous_column -# -#def_key "left" -# master_screen -# -#def_key "left" -# volume_down -# -#def_key "-" -# volume_down -# -#def_key ":" -# execute_command -# -#def_key "tab" -# next_screen -# -#def_key "shift-tab" -# previous_screen -# -#def_key "f1" -# show_help -# -#def_key "1" -# show_playlist -# -#def_key "2" -# show_browser -# -#def_key "2" -# change_browse_mode -# -#def_key "3" -# show_search_engine -# -#def_key "3" -# reset_search_engine -# -#def_key "4" -# show_media_library -# -#def_key "4" -# toggle_media_library_columns_mode -# -#def_key "5" -# show_playlist_editor -# -#def_key "6" -# show_tag_editor -# -#def_key "7" -# show_outputs -# -#def_key "8" -# show_visualizer -# -#def_key "=" -# show_clock -# -#def_key "@" -# show_server_info -# -#def_key "s" -# stop -# -#def_key "p" -# pause -# -#def_key ">" -# next -# -#def_key "<" -# previous -# -#def_key "ctrl-h" -# jump_to_parent_directory -# -#def_key "ctrl-h" -# replay_song -# -#def_key "backspace" -# jump_to_parent_directory -# -#def_key "backspace" -# replay_song -# -#def_key "f" -# seek_forward -# -#def_key "b" -# seek_backward -# -#def_key "r" -# toggle_repeat -# -#def_key "z" -# toggle_random -# -#def_key "y" -# save_tag_changes -# -#def_key "y" -# start_searching -# -#def_key "y" -# toggle_single -# -#def_key "R" -# toggle_consume -# -#def_key "Y" -# toggle_replay_gain_mode -# -#def_key "T" -# toggle_add_mode -# -#def_key "|" -# toggle_mouse -# -#def_key "#" -# toggle_bitrate_visibility -# -#def_key "Z" -# shuffle -# -#def_key "x" -# toggle_crossfade -# -#def_key "X" -# set_crossfade -# -#def_key "u" -# update_database -# -#def_key "ctrl-s" -# sort_playlist -# -#def_key "ctrl-s" -# toggle_browser_sort_mode -# -#def_key "ctrl-s" -# toggle_media_library_sort_mode -# -#def_key "ctrl-r" -# reverse_playlist -# -#def_key "ctrl-f" -# apply_filter -# -#def_key "ctrl-_" -# select_found_items -# -#def_key "/" -# find -# -#def_key "/" -# find_item_forward -# -#def_key "?" -# find -# -#def_key "?" -# find_item_backward -# -#def_key "." -# next_found_item -# -#def_key "," -# previous_found_item -# -#def_key "w" -# toggle_find_mode -# -#def_key "e" -# edit_song -# -#def_key "e" -# edit_library_tag -# -#def_key "e" -# edit_library_album -# -#def_key "e" -# edit_directory_name -# -#def_key "e" -# edit_playlist_name -# -#def_key "e" -# edit_lyrics -# -#def_key "i" -# show_song_info -# -#def_key "I" -# show_artist_info -# -#def_key "g" -# jump_to_position_in_song -# -#def_key "l" -# show_lyrics -# -#def_key "ctrl-v" -# select_range -# -#def_key "v" -# reverse_selection -# -#def_key "V" -# remove_selection -# -#def_key "B" -# select_album -# -#def_key "a" -# add_selected_items -# -#def_key "c" -# clear_playlist -# -#def_key "c" -# clear_main_playlist -# -#def_key "C" -# crop_playlist -# -#def_key "C" -# crop_main_playlist -# -#def_key "m" -# move_sort_order_up -# -#def_key "m" -# move_selected_items_up -# -#def_key "n" -# move_sort_order_down -# -#def_key "n" -# move_selected_items_down -# -#def_key "M" -# move_selected_items_to -# -#def_key "A" -# add -# -#def_key "S" -# save_playlist -# -#def_key "o" -# jump_to_playing_song -# -#def_key "G" -# jump_to_browser -# -#def_key "G" -# jump_to_playlist_editor -# -#def_key "~" -# jump_to_media_library -# -#def_key "E" -# jump_to_tag_editor -# -#def_key "U" -# toggle_playing_song_centering -# -#def_key "P" -# toggle_display_mode -# -#def_key "\\" -# toggle_interface -# -#def_key "!" -# toggle_separators_between_albums -# -#def_key "L" -# toggle_lyrics_fetcher -# -#def_key "F" -# fetch_lyrics_in_background -# -#def_key "alt-l" -# toggle_fetching_lyrics_in_background -# -#def_key "ctrl-l" -# toggle_screen_lock -# -#def_key "`" -# toggle_library_tag_type -# -#def_key "`" -# refetch_lyrics -# -#def_key "`" -# add_random_items -# -#def_key "ctrl-p" -# set_selected_items_priority -# -#def_key "q" -# quit -# -def_key "h" - previous_column -def_key "j" - scroll_down -def_key "shift-j" - select_item - scroll_down -def_key "k" - scroll_up -def_key "shift-k" - select_item - scroll_up -def_key "l" - next_column -def_key "d" - show_lyrics diff --git a/ncmpcpp/config b/ncmpcpp/config deleted file mode 100644 index 5eb721f..0000000 --- a/ncmpcpp/config +++ /dev/null @@ -1,11 +0,0 @@ -progressbar_look = "─⊙ " - -header_visibility = "no" - -visualizer_fifo_path = "/tmp/mpd.fifo" -visualizer_output_name = "FIFO" -visualizer_sync_interval = "30" -visualizer_in_stereo = "yes" -visualizer_type = "spectrum" -visualizer_look = "+▊" -visualizer_color = "blue" \ No newline at end of file diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config new file mode 100644 index 0000000..2350a5c --- /dev/null +++ b/polybar/.config/polybar/config @@ -0,0 +1,490 @@ +;===================================================== +; +; To learn more about how to configure Polybar +; go to https://github.com/jaagr/polybar +; +; The README contains alot of information +; +;===================================================== + +[colors] +background = ${xrdb:background:#222} +background-alt = ${xrdb:color8:#444} +foreground = ${xrdb:foreground:#fff} +foreground-alt = ${xrdb:color15:#555} +primary = ${xrdb:color4:#ffb52a} +secondary = ${xrdb:color5:#e60053} +alert = ${xrdb:color1:#bd2c40} + +[bar/main] +monitor = DP-1 +width = 100% +height = 27 +;offset-x = 1% +;offset-y = 1% +radius = 0 +fixed-center = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = ${colors.primary} + +border-size = 0 +border-color = #00000000 + +padding-left = 1 +padding-right = 1 + +module-margin-left = 1 +module-margin-right = 2 + +font-0 = Iosevka Fixed:style=Regular:pixelsize=10 +font-1 = Font Awesome 6 Free:style=Solid:pixelsize=9 +font-2 = Font Awesome 6 Brands:style=Regular +font-3 = Siji:style=Regular:pixelsize=10 +font-4 = Unifont:fontformat=truetype:size=8:antialias=false + +modules-left = bspwm +modules-center = date +modules-right = volume filesystem memory cpu wlan eth battery powermenu + +tray-position = right +tray-padding = 2 +;tray-transparent = true +;tray-background = #0063ff + +wm-restack = bspwm +;wm-restack = i3 + +;override-redirect = true + +scroll-up = bspwm-desknext +scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[bar/third] +monitor = DVI-1-0 +width = 100% +height = 27 +;offset-x = 1% +;offset-y = 1% +radius = 0 +fixed-center = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = ${colors.primary} + +border-size = 0 +border-color = #00000000 + +padding-left = 1 +padding-right = 1 + +module-margin-left = 1 +module-margin-right = 2 + +font-0 = Iosevka Fixed:style=Regular:pixelsize=10 +font-1 = Font Awesome 6 Free:style=Solid:pixelsize=9 +font-2 = Font Awesome 6 Brands:style=Regular +font-3 = Siji:style=Regular:pixelsize=10 +font-4 = Unifont:fontformat=truetype:size=8:antialias=false + +modules-left = bspwm +modules-center = date + +tray-position = right +tray-padding = 2 +;tray-transparent = true +;tray-background = #0063ff + +wm-restack = bspwm +;wm-restack = i3 + +;override-redirect = true + +scroll-up = bspwm-desknext +scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[bar/second] +monitor = DP-2 +width = 100% +height = 27 +;offset-x = 1% +;offset-y = 1% +radius = 0 +fixed-center = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = ${colors.primary} + +border-size = 0 +border-color = #00000000 + +padding-left = 1 +padding-right = 1 + +module-margin-left = 1 +module-margin-right = 2 + +font-0 = Iosevka Fixed:style=Regular:pixelsize=10 +font-1 = Font Awesome 6 Free:style=Solid:pixelsize=9 +font-2 = Font Awesome 6 Brands:style=Regular +font-3 = Siji:style=Regular:pixelsize=10 +font-4 = Unifont:fontformat=truetype:size=8:antialias=false + +modules-left = bspwm +modules-center = date + +tray-position = right +tray-padding = 2 +;tray-transparent = true +;tray-background = #0063ff + +wm-restack = bspwm +;wm-restack = i3 + +;override-redirect = true + +scroll-up = bspwm-desknext +scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[module/xwindow] +type = internal/xwindow +label = %title:0:30:...% + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +format-prefix = " " +format-prefix-foreground = ${colors.foreground} +format-prefix-underline = ${colors.primary} + +label-layout = %layout% +label-layout-underline = ${colors.primary} + +label-indicator-padding = 2 +label-indicator-margin = 1 +label-indicator-background = ${colors.primary} +label-indicator-underline = ${colors.primary} + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% +label-unmounted = %mountpoint% not mounted +label-unmounted-foreground = ${colors.foreground} + +[module/i3] +type = internal/i3 +format = +index-sort = true +wrapping-scroll = false + +; Only show workspaces on the same output as the bar +;pin-workspaces = true + +label-mode-padding = 1 +label-mode-foreground = #000 +label-mode-background = ${colors.primary} + +; focused = Active workspace on focused monitor +label-focused = %index% +label-focused-background = ${colors.background} +label-focused-underline = ${colors.primary} +label-focused-padding = 1 + +; unfocused = Inactive workspace on any monitor +label-unfocused = %index% +label-unfocused-padding = 1 + +; visible = Active workspace on unfocused monitor +label-visible = %index% +label-visible-background = ${self.label-focused-background} +label-visible-underline = ${self.label-focused-underline} +label-visible-padding = ${self.label-focused-padding} + +; urgent = Workspace with urgency hint set +label-urgent = %index% +label-urgent-background = ${colors.alert} +label-urgent-padding = 1 + +[module/bspwm] +type = internal/bspwm + +ws-icon-0 = term; +ws-icon-1 = web; +ws-icon-2 = code; +ws-icon-3 = music; +ws-icon-default =  + +format = +index-sort = true +wrapping-scroll = false + +; Only show workspaces on the same output as the bar +;pin-workspaces = true + +label-focused = %icon% +label-focused-background = ${colors.background} +label-focused-underline= ${colors.primary} +label-focused-padding = 2 + +label-occupied = %icon% +label-occupied-padding = 2 + +label-urgent = %icon% +label-urgent-padding = 2 + +label-empty = %icon% +label-empty-foreground = ${colors.primary} +label-empty-padding = 2 + +[module/mpd] +type = internal/mpd +format-online = + +icon-prev =  +icon-stop =  +icon-play =  +icon-pause =  +icon-next =  + +label-song-maxlen = 25 +label-song-ellipsis = true + +[module/xbacklight] +type = internal/xbacklight + +format =