diff options
52 files changed, 4839 insertions, 0 deletions
diff --git a/.Xdefaults b/.Xdefaults new file mode 100644 index 0000000..69411cd --- /dev/null +++ b/.Xdefaults @@ -0,0 +1,19 @@ +Xft.antialias: 1 +Xft.autohint: 0 +Xft.dpi: 96 +Xft.hinting: 1 +Xft.hintstyle: hintslight +Xft.lcdfilter: lcddefault +Xft.rgba: rgb + +XTerm.saveLines:2500 +XTerm.dynamicColors:true +XTerm.sameName:false +XTerm.utf8:2 +XTerm.cursorBlink:False +XTerm.reverseVideo:False +! XTerm.borderWidth:2 +! XTerm.internalBorder:2 + +Xcursor.theme: Breeze +Xcursor.size: 64 diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..a6a0371 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,7 @@ +[user] + name = tslil clingman + email = " " +[push] + default = simple +[core] + editor = emacs @@ -0,0 +1 @@ +make-backup-files @@ -0,0 +1,72 @@ +export EDITOR=zile +export HISTFILE=$HOME/.histfile +export HISTSIZE=8192 +export LANGUAGE="en_ZA.UTF-8" +export PATH=$HOME/bin:$HOME/.local/bin:$PATH +export SUDO_EDITOR=zile +export TERMINAL=st +export VISUAL=emacs + +export BROWSER=firefox +export XDG_DESKTOP_DIR=$HOME +export XDG_DOCUMENTS_DIR=$HOME/store +export XDG_DOWLOAD_DIR=$HOME/store +export XDG_MUSIC_DIR=$HOME/store/music +export XDG_PICTURES_DIR=$HOME/picutures +export XDG_PUBLICSHARE_DIR=$HOME/public +export XDG_TEMPLATES_DIR=$HOME/store/templates +export XDG_VIDEOS_DIR=$HOME/store/videos + +export LESS="-S -R" +export LESSCHARSET=utf-8 +export LESSHISTFILE="-" + +LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:'; +export LS_COLORS + +PS1='${ local e=$?; local r=""; (( $e )) && r="<$e>"; + local p=$(echo ${PWD:-?} | sed "s#.*/\(.*\)/\(.*\)#\1/\2#"); # s#$HOME#~# #${PWD##*/} + local d=$(date +"%H.%M"); + local v=$(vcs); + local u=#; (( $USER_ID )) && u=\$; + echo -n "[$p]($d)$r$v$u "; + #echo -n "$(tput sgr0)[$(tput bold)$(tput setaf 30)$p$(tput sgr0)]($(tput setaf 32)$d$(tput sgr0))$r$v$u$(tput sgr0) "; + return $e }' + +PS4='[$EPOCHREALTIME]' + +alias rm='rm -i' +alias ls='ls --group-directories-first -vhF --color=always' +alias hh='cd $HOME' +alias bk='cd $OLDPWD' +alias t=tmux +#alias t="date +%H\ %M\ %S | dc -e '6k???86400/r1440/+r24/+p'" + +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' +alias ......='cd ../../../../..' + +alias lower="tr '[:upper:]' '[:lower:]'" +alias upper="tr '[:lower:]' '[:upper:]'" +alias rot13="tr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" +alias weather="wget -O - wttr.in/Baltimore?m | less" + +mvf() { mv $*; cd $_ ;} +c() { echo 'scale=13;' $* | bc -l; } +j() { ce $*; cd `head -n 1 $HOME/.local/share/dir_lst`; } +hd() { hexdump -e '"%08.8_ax " 8/1 "%02X " " - " 8/1 "%02X "' -e '" |" "%_p"' -e '"|\n"' "$@"; } +mkpw() { cat /dev/urandom | tr -dc "[:print:]" | fold -w `[[ "$2" == "" ]] && echo 16 || echo $2` | head -n `[[ "$1" == "" ]] && echo 1 || echo "$1"` ;} + +stty -ixon +umask 077 + +set -o emacs +set -o utf8-mode + +eval $(keychain --eval -q) + +if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" == "1" ] ; then + startx -- -keeptty +fi; diff --git a/.ratpoisonrc b/.ratpoisonrc new file mode 100644 index 0000000..024bbfc --- /dev/null +++ b/.ratpoisonrc @@ -0,0 +1,108 @@ +startup_message off +escape XF86Launch9 + +definekey top XF86AudioLowerVolume exec vol --down +definekey top XF86AudioRaiseVolume exec vol --up +definekey top S-XF86AudioLowerVolume exec vol --headphone --down +definekey top S-XF86AudioRaiseVolume exec vol --headphone --up +definekey top XF86Launch1 exec vol mute +definekey top S-XF86Launch1 exec vol --headphone mute +definekey top XF86ScreenSaver exec lock +definekey top XF86MonBrightnessUp exec xbacklight -inc 10 +definekey top XF86MonBrightnessDown exec xbacklight -dec 10 +definekey top XF86Battery exec ratpoison -c "echo $(battery)" +definekey top XF86WebCam exec ratpoison -c "echo Unread: $(notmuch count tag:unread)" + +set border 1 +set winname title +set winfmt %n %s %t (%a) +set padding 0 0 0 0 +set barpadding 8 8 +set bargravity center +set fgcolor "black" +set bgcolor "#FFFFEA" +set fwcolor "darkred" +set bwcolor "black" + +set framesels "neioarst123456789" + +bind minus clear +bind v vsplit +bind h hsplit +bind w windows +bind p prev +bind n next +bind O only +bind comma focusleft +bind o focusdown +bind i focusup +bind period focusright +bind M-comma exchangeleft +bind M-o exchangedown +bind M-i exchangeup +bind M-period exchangeright +bind d dedicate +bind f fselect +bind e remove +bind a resize +bind apostrophe exec ratpoison -c "echo $(date -R)" +bind M-n nextscreen +bind M-p prevscreen +bind C-Q quit + +bind c exec $TERMINAL -e tmux +bind C exec $TERMINAL +bind E exec $VISUAL +bind q exec $BROWSER + +#bind S-Return exec ratws -s +#bind S-space exec ratws -w +bind space exec ratws + +exec /usr/bin/rpws init 3 -a +bind l rpws1 +bind u rpws2 +bind y rpws3 +bind M-l rpwsm1 +bind M-u rpwsm2 +bind M-y rpwsm3 + +unbind G +unbind C-Left +unbind C-Right +unbind C-Up +unbind C-Down +unbind C-Return +unbind C-M-Left +unbind C-M-Right +# unbind Left +# unbind Right +# unbind Up +# unbind Down +unbind C-i +unbind C-k +unbind C-l +unbind C-m +unbind C-p +unbind Q +unbind C-apostrophe +unbind C-space +unbind C-V +unbind V +unbind C-w +unbind C-s +unbind C-S +unbind C-f +unbind C-r +unbind C-u +unbind C-underscore +unbind C-x +unbind C-A +unbind C-K +unbind C-return +unbind C-a +unbind C-b +unbind C-c +unbind C-exclam +unbind minus +unbind C-v diff --git a/.screenrc b/.screenrc new file mode 100644 index 0000000..f1f265a --- /dev/null +++ b/.screenrc @@ -0,0 +1,11 @@ +defscrollback 10000 +vbell off +startup_message off +altscreen on +term screen-256color +termcapinfo xterm* ti@:te@ + +defescape ^Tt +escape ^Tt + +hardstatus alwayslastline "%{+b wk} %-w%{+b kb} %n %t %{-}%+w %=%{+ kG} %c/%d.%m.%Y " diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..c891263 --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,48 @@ +set -g default-terminal "screen-256color" + +set -g status-bg '#DAEFEF' +set -g status-fg black + +setw -g window-status-format "#[fg=black]#[bg=#DAEFEF] #I #W " +setw -g window-status-current-format "#[fg=black]#[bg=#8888CC] * #[bg=#EAEA9E] #W " + +set -g status-left "" +set -g status-right "#[fg=black][ %y.%m.%d %Hh%M #(battery) ]" + +unbind C-b +set -g prefix ^T + +unbind ^T +bind ^T last-window + +unbind C-a + +unbind x +bind x lock-server + +unbind c +bind c new-window + +unbind " " +bind " " next-window + +unbind BSpace +bind BSpace previous-window + +unbind A +bind A command-prompt "rename-window %%" + +unbind w +bind w list-windows + +unbind k +bind k confirm-before "kill-window" + +unbind l +bind l refresh-client + +unbind | +bind | split-window + +unbind '"' +bind '"' choose-window diff --git a/.xinitrc b/.xinitrc new file mode 100755 index 0000000..cfebbd8 --- /dev/null +++ b/.xinitrc @@ -0,0 +1,17 @@ +setxkbmap -layout us -variant workman -option +setxkbmap -option terminate:ctrl_alt_bksp,ctrl:swap_lwin_lctl,caps:ctrl_modifier + +xset s off +xset -dpms +#xset m 5/1 4 + +xrdb -merge ~/.Xdefaults + +xsetroot -cursor_name left_ptr + +# Unfortunately redshift doesn't work +# redshift -l +39:-76 -t 5500:4900 & + +#compton --config ~/.config/compton.conf & + +exec emacs @@ -0,0 +1,15 @@ +;; Rebind keys with: +;; (global-set-key "key" 'func) + +(setq inhibit-splash-screen t) +(setq standard-indent 2) +(setq tab-width 2) + +(setq fill-column 70) +(setq auto-fill-mode nil) + +(setq ring-bell nil) + +(setq make-backup-files nil) + +(global-set-key "\M-h" 'backward-kill-word)
\ No newline at end of file diff --git a/compton.conf b/compton.conf new file mode 100644 index 0000000..4bdd8b4 --- /dev/null +++ b/compton.conf @@ -0,0 +1,244 @@ +# Thank you code_nomad: http://9m.no/ꪯ鵞
+# and Arch Wiki contributors: https://wiki.archlinux.org/index.php/Compton
+
+#################################
+#
+# Backend
+#
+#################################
+
+# Backend to use: "xrender" or "glx".
+# GLX backend is typically much faster but depends on a sane driver.
+backend = "glx";
+
+#################################
+#
+# GLX backend
+#
+#################################
+
+glx-no-stencil = true;
+
+# GLX backend: Copy unmodified regions from front buffer instead of redrawing them all.
+# My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified,
+# but a 20% increase when only 1/4 is.
+# My tests on nouveau show terrible slowdown.
+# Useful with --glx-swap-method, as well.
+glx-copy-from-front = false;
+
+# GLX backend: Use MESA_copy_sub_buffer to do partial screen update.
+# My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated.
+# May break VSync and is not available on some drivers.
+# Overrides --glx-copy-from-front.
+# glx-use-copysubbuffermesa = true;
+
+# GLX backend: Avoid rebinding pixmap on window damage.
+# Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe).
+# Recommended if it works.
+# glx-no-rebind-pixmap = true;
+
+# GLX backend: GLX buffer swap method we assume.
+# Could be undefined (0), copy (1), exchange (2), 3-6, or buffer-age (-1).
+# undefined is the slowest and the safest, and the default value.
+# copy is fastest, but may fail on some drivers,
+# 2-6 are gradually slower but safer (6 is still faster than 0).
+# Usually, double buffer means 2, triple buffer means 3.
+# buffer-age means auto-detect using GLX_EXT_buffer_age, supported by some drivers.
+# Useless with --glx-use-copysubbuffermesa.
+# Partially breaks --resize-damage.
+# Defaults to undefined.
+glx-swap-method = "undefined";
+
+#################################
+#
+# Shadows
+#
+#################################
+
+# Enabled client-side shadows on windows.
+shadow = false;
+# Don't draw shadows on DND windows.
+no-dnd-shadow = true;
+# Avoid drawing shadows on dock/panel windows.
+no-dock-shadow = true;
+# The blur radius for shadows. (default 12)
+shadow-radius = 5;
+# The left offset for shadows. (default -15)
+shadow-offset-x = -5;
+# The top offset for shadows. (default -15)
+shadow-offset-y = -5;
+# The translucency for shadows. (default .75)
+shadow-opacity = 0.5;
+
+# Set if you want different colour shadows
+# shadow-red = 0.0;
+# shadow-green = 0.0;
+# shadow-blue = 0.0;
+
+# The shadow exclude options are helpful if you have shadows enabled. Due to the way compton draws its shadows, certain applications will have visual glitches
+# (most applications are fine, only apps that do weird things with xshapes or argb are affected).
+# This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher.
+shadow-exclude = [
+ "! name~=''",
+ "name = 'Notification'",
+ "name = 'Plank'",
+ "name = 'Docky'",
+ "name = 'Kupfer'",
+ "name = 'xfce4-notifyd'",
+ "name *= 'VLC'",
+ "name *= 'compton'",
+ "name *= 'Chromium'",
+ "name *= 'Chrome'",
+ "class_g = 'Firefox' && argb",
+ "class_g = 'Conky'",
+ "class_g = 'Kupfer'",
+ "class_g = 'Synapse'",
+ "class_g ?= 'Notify-osd'",
+ "class_g ?= 'Cairo-dock'",
+ "class_g ?= 'Xfce4-notifyd'",
+ "class_g ?= 'Xfce4-power-manager'",
+ "_GTK_FRAME_EXTENTS@:c",
+ "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
+];
+# Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners)
+shadow-ignore-shaped = false;
+
+#################################
+#
+# Opacity
+#
+#################################
+
+menu-opacity = 1;
+inactive-opacity = 1;
+active-opacity = 1;
+frame-opacity = 1;
+inactive-opacity-override = false;
+alpha-step = 0.06;
+
+# Dim inactive windows. (0.0 - 1.0)
+# inactive-dim = 0.2;
+# Do not let dimness adjust based on window opacity.
+# inactive-dim-fixed = true;
+# Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred.
+# blur-background = true;
+# Blur background of opaque windows with transparent frames as well.
+# blur-background-frame = true;
+# Do not let blur radius adjust based on window opacity.
+blur-background-fixed = false;
+blur-background-exclude = [
+ "window_type = 'dock'",
+ "window_type = 'desktop'"
+];
+
+#################################
+#
+# Fading
+#
+#################################
+
+# Fade windows during opacity changes.
+fading = true;
+# The time between steps in a fade in milliseconds. (default 10).
+fade-delta = 4;
+# Opacity change between steps while fading in. (default 0.028).
+fade-in-step = 0.03;
+# Opacity change between steps while fading out. (default 0.03).
+fade-out-step = 0.03;
+# Fade windows in/out when opening/closing
+# no-fading-openclose = true;
+
+# Specify a list of conditions of windows that should not be faded.
+fade-exclude = [ ];
+
+#################################
+#
+# Other
+#
+#################################
+
+# Try to detect WM windows and mark them as active.
+mark-wmwin-focused = true;
+# Mark all non-WM but override-redirect windows active (e.g. menus).
+mark-ovredir-focused = true;
+# Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events.
+# Usually more reliable but depends on a EWMH-compliant WM.
+use-ewmh-active-win = true;
+# Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on.
+detect-rounded-corners = true;
+
+# Detect _NET_WM_OPACITY on client windows, useful for window managers not passing _NET_WM_OPACITY of client windows to frame windows.
+# This prevents opacity being ignored for some apps.
+# For example without this enabled my xfce4-notifyd is 100% opacity no matter what.
+detect-client-opacity = true;
+
+# Specify refresh rate of the screen.
+# If not specified or 0, compton will try detecting this with X RandR extension.
+refresh-rate = 0;
+
+# Set VSync method. VSync methods currently available:
+# none: No VSync
+# drm: VSync with DRM_IOCTL_WAIT_VBLANK. May only work on some drivers.
+# opengl: Try to VSync with SGI_video_sync OpenGL extension. Only work on some drivers.
+# opengl-oml: Try to VSync with OML_sync_control OpenGL extension. Only work on some drivers.
+# opengl-swc: Try to VSync with SGI_swap_control OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn’t have the effect of --sw-opti unlike other methods. Experimental.
+# opengl-mswc: Try to VSync with MESA_swap_control OpenGL extension. Basically the same as opengl-swc above, except the extension we use.
+# (Note some VSync methods may not be enabled at compile time.)
+vsync = "opengl";
+
+# Enable DBE painting mode, intended to use with VSync to (hopefully) eliminate tearing.
+# Reported to have no effect, though.
+dbe = false;
+
+# Limit compton to repaint at most once every 1 / refresh_rate second to boost performance.
+# This should not be used with --vsync drm/opengl/opengl-oml as they essentially does --sw-opti's job already,
+# unless you wish to specify a lower refresh rate than the actual value.
+#sw-opti = true;
+
+# Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games.
+# Known to cause flickering when redirecting/unredirecting windows.
+# paint-on-overlay may make the flickering less obvious.
+unredir-if-possible = false;
+
+# Specify a list of conditions of windows that should always be considered focused.
+focus-exclude = [ ];
+
+# Use WM_TRANSIENT_FOR to group windows, and consider windows in the same group focused at the same time.
+detect-transient = true;
+# Use WM_CLIENT_LEADER to group windows, and consider windows in the same group focused at the same time.
+# WM_TRANSIENT_FOR has higher priority if --detect-transient is enabled, too.
+detect-client-leader = true;
+
+#################################
+#
+# Window type settings
+#
+#################################
+
+wintypes:
+{
+ tooltip =
+ {
+ # fade: Fade the particular type of windows.
+ fade = true;
+ # shadow: Give those windows shadow
+ shadow = false;
+ # opacity: Default opacity for the type of windows.
+ opacity = 0.85;
+ # focus: Whether to always consider windows of this type focused.
+ focus = true;
+ };
+};
+
+######################
+#
+# XSync
+# See: https://github.com/yshui/compton/commit/b18d46bcbdc35a3b5620d817dd46fbc76485c20d
+#
+######################
+
+# Attempt to synchronize client applications' draw calls with `XSync()`, used on GLX backend to ensure up-to-date window content is painted.
+xrender-sync = true;
+
+# use X Sync fence to sync clients' draw calls. Needed on nvidia-drivers with GLX backend for some users.
+xrender-sync-fence = true;
diff --git a/emacs/init.el b/emacs/init.el new file mode 100644 index 0000000..8395564 --- /dev/null +++ b/emacs/init.el @@ -0,0 +1,59 @@ +;; Time-stamp: <2019-04-15 16:22:30 (tslil@basingstoke)> + +;; Faster startup +(setq gc-cons-threshold 100000000 + old-file-name-handler-alist file-name-handler-alist + file-name-handler-alist nil) + +(setq user-full-name "tslil") + +(setq network-security-level 'high + tls-connection-command "gnutls-cli -p %p %h" + tls-checktrust t + tls-program '("gnutls-cli --x509cafile %t -p %p %h") + gnutls-verify-error t + gnutls-log-level 0 + gnutls-min-prime-bits 2048 + gnutls-trustfiles '("/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/usr/ssl/certs/ca-bundle.crt") + ;;imap-ssl-program '("gnutls-cli --x509cafile %t -p %p %s") + smtpmail-stream-type 'starttls) + + +(require 'package) +(setq package-enable-at-startup nil + load-prefer-newer t + package-archives '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/"))) +(package-initialize) + +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(eval-when-compile + (require 'use-package)) +(use-package bind-key :ensure t :demand) + +(use-package pinentry + :ensure t + :demand + :config + (setq epa-pinentry-mode 'loopback) + (pinentry-start)) + +(use-package keychain-environment + :ensure t + :config + (keychain-refresh-environment)) + +(use-package init-loader + :ensure t + :demand + :config + (setq init-loader-byte-compile t) + (init-loader-load)) + +(setq custom-file "~/.emacs.d/custom.el") +(unless (file-exists-p custom-file) + (write-region "" nil custom-file)) +(load custom-file) diff --git a/emacs/inits/00-exwm.el b/emacs/inits/00-exwm.el new file mode 100644 index 0000000..381f54e --- /dev/null +++ b/emacs/inits/00-exwm.el @@ -0,0 +1,153 @@ +;; Time-stamp: <2019-09-11 14:35:00 (tslil@basingstoke)> + +(defun adjust-volume (mixer adjust) + (let ((tail " | tail -n 1") + (sed (concat " | sed 's/.*\\[\\([0-9]*.\\)\\] " + "\\[.*dB\\] \\[\\(.*\\)\\]$/" + mixer + " \\1 \\2/'"))) + (shell-command + (concat + (cond ((string-equal "+" adjust) (concat "amixer set " mixer " 2%+")) + ((string-equal "-" adjust) (concat "amixer set " mixer " 2%-")) + (t (concat "amixer set " mixer " toggle"))) + tail + sed)))) + +(defun banish-rat () + (interactive) + (shell-command "xdotool mousemove 1366 768") + (message "Rat banished.")) + +(use-package exwm + :if (window-system) + :ensure t + :demand + :config + + (setq exwm-workspace-number 1 + exwm-workspace-switch-create-limit 5 + exwm-workspace-show-all-buffers nil) + + (add-hook 'exwm-update-class-hook + (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) + + ;; ------------------------------------------------------------------- + ;; Global key binds + + (setq exwm-input-simulation-keys + '(([?\C-b] . [left]) + ([?\C-f] . [right]) + ([?\C-p] . [up]) + ([?\C-n] . [down]) + ([?\C-a] . [home]) + ([?\C-e] . [end]) + ([?\M-v] . [prior]) + ([?\C-v] . [next]) + ([?\C-s] . [C-f]) + ;;([?\C-d] . [delete]) + ;;([?\C-k] . [S-end delete]) + )) + + ;; reset + (exwm-input-set-key (kbd "s-r") 'exwm-reset) + + ;; workspaces + (exwm-input-set-key (kbd "s-e") 'exwm-workspace-switch) + + (dotimes (i 10) + (exwm-input-set-key (kbd (format "s-%d" i)) + `(lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + + ;; buffer and window management + (exwm-input-set-key (kbd "s-<tab>") 'next-buffer) + + (defvar exwm-last-workspace-index 0) + (defun exwm-last-workspace () + (interactive) + (let ((temp exwm-workspace-current-index)) + (exwm-workspace-switch exwm-last-workspace-index) + (setq exwm-last-workspace-index temp))) + + (exwm-input-set-key (kbd "s-n") 'ivy-switch-buffer) + (exwm-input-set-key (kbd "s-o") 'switch-window) + (exwm-input-set-key (kbd "s-\\") 'exwm-last-workspace) + + (exwm-input-set-key (kbd "s-b") 'banish-rat) + + ;; run command + (exwm-input-set-key (kbd "s-c") (lambda () + (interactive) + (start-process "" nil "st"))) + (exwm-input-set-key (kbd "s-q") (lambda () + (interactive) + (start-process "" nil "firefox-esr"))) + (exwm-input-set-key (kbd "s-<f2>") (lambda () + (interactive) + (start-process "" nil "lock"))) + (exwm-input-set-key (kbd "s-p") (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + ;; Volume + (exwm-input-set-key (kbd "s-<f10>") + (lambda () + (interactive) + (adjust-volume "Speaker" "+"))) + + (exwm-input-set-key (kbd "s-<f9>") + (lambda () + (interactive) + (adjust-volume "Speaker" "-"))) + + (exwm-input-set-key (kbd "s-<f8>") + (lambda () + (interactive) + (adjust-volume "Speaker" "toggle"))) + + (exwm-input-set-key (kbd "C-s-<f10>") + (lambda () + (interactive) + (adjust-volume "Headphone" "+"))) + + (exwm-input-set-key (kbd "C-s-<f9>") + (lambda () + (interactive) + (adjust-volume "Headphone" "-"))) + + (exwm-input-set-key (kbd "C-s-<f8>") + (lambda () + (interactive) + (adjust-volume "Headphone" "toggle"))) + + (exwm-input-set-key (kbd "s-<f7>") (lambda () + (interactive) + (shell-command "$HOME/bin/backlight_up.sh") + (message "Backlight up."))) + + (exwm-input-set-key (kbd "s-<f6>") (lambda () + (interactive) + (shell-command "$HOME/bin/backlight_down.sh") + (message "Backlight down."))) + + ;; ------------------------------------------------------------------- + ;; RandR + + (require 'exwm-randr) + (exwm-randr-enable) + + (setq exwm-randr-workspace-monitor-plist + '(1 "HDMI-1" 0 "eDP-1")) + + (exwm-enable)) + +;; ----------------------------------------------------------------------------- +;; EXWM-edit + +(use-package exwm-edit + :ensure t + :config + (add-hook 'exwm-edit-compose-hook (lambda () + (text-mode)))) diff --git a/emacs/inits/01-basic.el b/emacs/inits/01-basic.el new file mode 100644 index 0000000..5c66367 --- /dev/null +++ b/emacs/inits/01-basic.el @@ -0,0 +1,126 @@ +;; Time-stamp: <2019-09-11 10:19:29 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; Interface + +(tool-bar-mode -1) +(menu-bar-mode -1) +(scroll-bar-mode -1) +(fset 'yes-or-no-p 'y-or-n-p) + +(setq select-enable-clipboard t + select-enable-primary t + save-interprogram-paste-before-kill t + require-final-newline t + visible-bell nil) + +(setq echo-keystrokes 0.1 + confirm-kill-emacs 'y-or-n-p + disabled-command-function nil + ring-bell-function 'ignore) + +(size-indication-mode t) + +(defun enlarge-to-fill () + "Stretch the buffer to accomodate `fill-column` many columns." + (interactive) + (let ((ww (window-width))) + (when (< ww (+ 1 fill-column)) + (enlarge-window-horizontally (- (+ 1 fill-column) ww))))) + +(global-set-key (kbd "C-c 3") (lambda () + (interactive) + (split-window-horizontally) + (enlarge-to-fill))) + +(blink-cursor-mode 0) +(setq cursor-type 'box) +(set-cursor-color "black") + +(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") +(when (eq 'x (window-system)) + (load-theme 'zenburn t) + (set-face-attribute 'default nil :font "Fira Code-14")) + +(set-fringe-style 0) +;; (set-fringe-mode 128) + +;; ----------------------------------------------------------------------------- +;; Backups + +(setq backup-by-copying t + backup-directory-alist '((".*" . "~/store/backups/")) + delete-old-versions t + kept-new-versions 6 + kept-old-versions 2 + version-control t) + +(setq create-lockfiles nil) + +;; ----------------------------------------------------------------------------- +;; Defaults + +(setq fill-column 80) + +(setq standard-indent 2) +(setq-default tab-width 2 + indent-tabs-mode nil) +(add-hook 'before-save-hook #'whitespace-cleanup) + +(show-paren-mode t) + +(setq-default truncate-lines t + truncate-partial-width-windows nil) +(setq scroll-step 1) + +(setq next-line-add-newlines nil) + +(setq enable-dir-local-variables nil) + +;; ----------------------------------------------------------------------------- +;; Packages + +(use-package recentf + :demand t + :config + (setq recentf-max-saved-items 42) + (recentf-mode)) + +(use-package uniquify + :config + (setq uniquify-buffer-name-style 'forward)) + +(require 'saveplace) +(save-place-mode) + +(use-package undo-tree + :ensure t + :config (setq undo-tree-visualizer-timestamps t) + (global-undo-tree-mode 1)) + +(use-package keyfreq + :ensure t + :config + (setq keyfreq-file "~/.emacs.d/keyfreq" + keyfreq-file-lock "~/.emacs.d/keyfreq.lock") + (keyfreq-mode 1) + (keyfreq-autosave-mode 1)) + +;; ----------------------------------------------------------------------------- +;; Scratch buffer + +(defun immortal-scratch () + (if (eq (current-buffer) (get-buffer "*scratch*")) + (progn (bury-buffer) nil) t)) + +(add-hook 'kill-buffer-query-functions 'immortal-scratch) + +;; I couldn't figure the config options out, so this is the next best thing +(defun display-startup-echo-area-message () nil) + +(setq initial-scratch-message nil + initial-buffer-choice t) + +(add-hook 'after-init-hook + (lambda () + (setq default-directory "~/"))) diff --git a/emacs/inits/02-modeline.el b/emacs/inits/02-modeline.el new file mode 100644 index 0000000..58b2cd1 --- /dev/null +++ b/emacs/inits/02-modeline.el @@ -0,0 +1,96 @@ +;; Time-stamp: <2019-08-13 14:43:24 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; Battery status and CPU temperature + +(defvar sys-status "") +(defvar sys-status-cpu-temp-threshold "45") + +(defun linux-sys-status () + (let ((bat-s (if (not (file-exists-p "/sys/class/power_supply/sbs-20-000b/uevent")) "" + (with-temp-buffer + (insert-file-contents "/sys/class/power_supply/sbs-20-000b/uevent") + (re-search-forward "POWER_SUPPLY_STATUS=\\(Discharging\\|Charging\\|Full\\)") + (let ((status (match-string 1))) + (if (string-equal "Full" status) "Full" + (let* ((perc (progn + (re-search-forward "POWER_SUPPLY_CAPACITY=\\([0-9]+\\)") + (match-string 1))) + (field (concat "POWER_SUPPLY_TIME_TO_" + (if (string-equal "Discharging" status) + "EMPTY" "FULL") + "_AVG=\\([0-9]+\\)")) + (seconds (progn + (re-search-forward field) + (string-to-number (match-string 1)))) + (hours (/ seconds 3600)) + (minutes (/ (- seconds (* hours 3600)) 60))) + (format "%s%s%% %dh%dm" + (substring status 0 1) + perc hours minutes))))))) + (temp-s (if (not (file-exists-p "/sys/class/thermal/thermal_zone1/temp")) "" + (with-temp-buffer + (insert-file-contents "/sys/class/thermal/thermal_zone1/temp") + (let ((temp (substring-no-properties (buffer-string) 0 -4))) + (if (string-greaterp temp sys-status-cpu-temp-threshold) + (concat " " temp "C") "")))))) + (if (and (string-blank-p bat-s) (string-blank-p temp-s)) + "" (format " [%s%s]" bat-s temp-s)))) + +(defun sys-status-update () + (setq sys-status (linux-sys-status))) + +(defvar sys-status-update-timer (run-at-time nil 60 'sys-status-update)) + +;; ----------------------------------------------------------------------------- +;; Remind me of my mortality + +(defun mortality () + (format " %.4f" + (/ (float-time + (time-subtract (current-time) + (encode-time 0 0 0 DAY MONTH YEAR))) + (* 60 60 24 364.25)))) + +;; ----------------------------------------------------------------------------- +;; Mode-line and minibuffer defaults + +(use-package minibuffer-line + :ensure t + :config + (setq minibuffer-line-refresh-interval 60 + minibuffer-line-format + '("" (:eval (format-time-string "%d/%H.%M")) + display-time-string + (sys-status sys-status) + (:eval (mortality)) + " " (:eval (abbreviate-file-name default-directory)))) + ;; We redefine this function to centre the text + ;; Is there a better way? + (defun minibuffer-line--update () + (with-current-buffer minibuffer-line--buffer + (erase-buffer) + (insert (format-mode-line minibuffer-line-format 'minibuffer-line)) + (setq fill-column (frame-width)) + (center-line))) + (minibuffer-line-mode 1)) + +;; really want to hook buffer changes at all, and focus +(add-hook 'minibuffer-exit-hook #'minibuffer-line--update) + +(setq global-mode-string nil) +(setq-default mode-line-format + '("" mode-line-front-space + mode-line-modified "%@" + " %l:%c %[" mode-line-buffer-identification "%] %I" + " " mode-line-modes ;; (vc-mode vc-mode) + mode-line-misc-info mode-line-end-spaces)) + +;; ----------------------------------------------------------------------------- +;; Minions to clean mode-line + +(use-package minions + :ensure t + :config + (setq minions-mode-line-lighter ":") + (minions-mode 1)) diff --git a/emacs/inits/03-miscload.el b/emacs/inits/03-miscload.el new file mode 100644 index 0000000..2ac2f54 --- /dev/null +++ b/emacs/inits/03-miscload.el @@ -0,0 +1,17 @@ +;; Time-stamp: <2019-01-26 12:49:48 (tslil@winslow)> + +;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/scripts/")) + +(add-to-list 'load-path (expand-file-name "~/.emacs.d/scripts/siege-mode")) +(autoload 'siege-mode "siege-mode" nil t) + +;; (use-package siege-mode +;; :defer t +;; :load-path "/home/tslil/.emacs.d/scripts/siege-mode/siege-mode.el") + +(use-package imaxima + :defer t + :config (setq imaxima-use-maxima-mode-flag t)) + +(use-package notmuch + :defer t) diff --git a/emacs/inits/04-input_method.el b/emacs/inits/04-input_method.el new file mode 100644 index 0000000..b463ff6 --- /dev/null +++ b/emacs/inits/04-input_method.el @@ -0,0 +1,14 @@ +;; Time-stamp: <2019-09-11 11:26:28 (tslil@basingstoke)> + +(use-package agda-input + :load-path "~/.emacs.d/scripts/" + :config + (dolist (sym '(("chimney" "╝") + ("==>" "⟹") + ("amalg" "⨿") + ("bG" "𝔾") + ("bU" "𝕌"))) + (add-to-list 'agda-input-user-translations sym)) + (agda-input-setup)) + +(setq-default default-input-method "Agda") diff --git a/emacs/inits/05-helpful.el b/emacs/inits/05-helpful.el new file mode 100644 index 0000000..f8ac203 --- /dev/null +++ b/emacs/inits/05-helpful.el @@ -0,0 +1,17 @@ +;; Time-stamp: <2019-01-26 12:49:57 (tslil@winslow)> + +(use-package helpful + :ensure t + :bind (("C-h f" . helpful-callable) + ("C-h v" . helpful-variable) + ("C-h k" . helpful-key) + ("C-h F" . helpful-function) + ("C-c h" . heplful-at-point)) + :config + (advice-add #'describe-key :override #'helpful-key) + (advice-add #'describe-function :override #'helpful-callable) + (advice-add #'describe-variable :override #'helpful-variable) + (advice-add #'describe-symbol :override #'helpful-symbol)) + +(use-package apropos + :config (setq apropos-do-all t)) diff --git a/emacs/inits/06-dashboard.el b/emacs/inits/06-dashboard.el new file mode 100644 index 0000000..7aae2a0 --- /dev/null +++ b/emacs/inits/06-dashboard.el @@ -0,0 +1,30 @@ +;; Time-stamp: <2019-09-11 10:42:40 (tslil@basingstoke)> + +(use-package fortune + :config + (setq fortune-dir "/usr/share/games/fortunes/" + fortune-program "fortune" + fortune-file "/usr/share/games/fortunes/cookie" + fortune-program-options '("-s")) + (defun dashboard-fortune (n) + (insert + (with-temp-buffer + (let ((fortune-buffer-name (current-buffer))) + (fortune-in-buffer t) + (buffer-string)))))) + +(use-package dashboard + :ensure t + :config + (add-to-list 'dashboard-item-generators '(fortune . dashboard-fortune)) + + (setq dashboard-center-content t + dashboard-set-init-info t + dashboard-set-footer nil + dashboard-startup-banner 1 + dashboard-items '((recents . 5) + (projects . 5) + (fortune . 0)) + dashboard-init-info (format "Welcome ~%s!" (user-login-name))) + + (dashboard-setup-startup-hook)) diff --git a/emacs/inits/10-ivy.el b/emacs/inits/10-ivy.el new file mode 100644 index 0000000..8867bb8 --- /dev/null +++ b/emacs/inits/10-ivy.el @@ -0,0 +1,117 @@ +;; Time-stamp: <2019-09-09 22:10:08 (tslil@basingstoke)> + +(use-package amx :ensure t) + +(use-package counsel :ensure t + :after amx + :demand + :defines (counsel-for-files) + :bind (("C-s" . counsel-grep-or-swiper) + ("C-x f" . counsel-recentf) + ("C-x l" . counsel-locate) + ("C-c C-r" . ivy-resume) + ("C-c g" . counsel-rg) + ("M-x" . counsel-M-x) + ("C-s" . swiper-isearch) + :map ivy-minibuffer-map + ("C-m" . ivy-alt-done) + :map swiper-map + ("M-%" . swiper-query-replace)) + :config + (setq ivy-use-virtual-buffers nil + ivy-display-style 'fancy + ivy-initial-inputs-alist nil + ivy-format-function 'ivy-format-function-line + ivy-count-format "") + + (setq swiper-use-visual-line t) + + (setq counsel-find-file-at-point t + counsel-grep-base-command + "rg -i -M 120 --no-heading --line-number --color never '%s' %s" + counsel-describe-function-function 'helpful-function + counsel-describe-variable-function 'helpful-variable) + + (ivy-mode t) + (counsel-mode t)) + + +(use-package ivy-rich :ensure t + :config + (setq ivy-rich-path-style 'abbrev + ivy-rich-display-transformers-list + '(ivy-switch-buffer + (:columns + ((ivy-rich-candidate (:width 20)) + (ivy-rich-switch-buffer-size (:width 7 :align right)) + (ivy-rich-switch-buffer-indicators + (:width 2 :face error :align right)) + (ivy-rich-switch-buffer-major-mode (:width 12 :face warning)) + (ivy-rich-switch-buffer-project (:width 8 :face success)) + (ivy-rich-switch-buffer-path + (:width (lambda (x) + (ivy-rich-switch-buffer-shorten-path + x (ivy-rich-minibuffer-width 0.3)))))) + :predicate (lambda (cand) (get-buffer cand))) + counsel-M-x + (:columns + ((counsel-M-x-transformer (:width 40)) + (ivy-rich-counsel-function-docstring + (:face font-lock-doc-face)))) + counsel-describe-function + (:columns + ((counsel-describe-function-transformer (:width 40)) + (ivy-rich-counsel-function-docstring + (:face font-lock-doc-face)))) + counsel-describe-variable + (:columns + ((counsel-describe-variable-transformer (:width 40)) + (ivy-rich-counsel-variable-docstring + (:face font-lock-doc-face)))) + counsel-recentf + (:columns + ((ivy-rich-candidate (:width 0.8)) + (ivy-rich-file-last-modified-time + (:face font-lock-comment-face)))))) + + (ivy-rich-mode 1)) + +;; (defun limited-counsel-locate-cmd (input) +;; "Return a shell command based on INPUT." +;; (counsel-require-program "locate") +;; (format "locate -l 10 -i --regex '%s'" +;; (counsel-unquote-regex-parens +;; (ivy--regex input)))) + +;; (defun bad () +;; (interactive) +;; (let (process buffer) +;; (ivy-read "File: " +;; #'(lambda (input) +;; (append +;; '("Recent Files\n" . "") +;; (recentf-elements 10) +;; (directory-files default-directory "") +;; (mapcar (lambda (b) (buffer-name b)) (buffer-list)) +;; (if (< (length input) 3) (counsel-more-chars 3) +;; ;; (counsel--async-command +;; ;; (funcall #'limited-counsel-locate-cmd input)) +;; (when process (kill-process process)) +;; (setq process (start-file-process-shell-command +;; "*locate*" +;; "*locate*" +;; (funcall #'limited-counsel-locate-cmd input)))) +;; )) +;; :dynamic-collection t +;; :unwind #'(progn (kill-buffer)) +;; :sort nil +;; :action #'(lambda (x) +;; (with-ivy-window +;; (if (file-exists-p x) (find-file x) +;; (switch-to-buffer x))))))) + +;; '(helm-source-recentf +;; helm-source-file-cache +;; helm-source-files-in-current-dir +;; helm-source-buffers-list +;; helm-source-locate) diff --git a/emacs/inits/12-company.el b/emacs/inits/12-company.el new file mode 100644 index 0000000..d514496 --- /dev/null +++ b/emacs/inits/12-company.el @@ -0,0 +1,17 @@ +;; Time-stamp: <2019-01-26 12:50:26 (tslil@winslow)> + +(use-package company :ensure t + :bind (("M-<tab>" . company-complete) + :map company-active-map + ("C-n" . company-select-next) + ("C-p" . company-select-previous)) + + :config + (setq company-begin-commands '(self-insert-command) + company-idle-delay 1 + company-require-match nil + company-show-numbers t + company-auto-complete 'company-explicit-action-p + company-tooltip-align-annotations t) + + (global-company-mode)) diff --git a/emacs/inits/13-ibuffer.el b/emacs/inits/13-ibuffer.el new file mode 100644 index 0000000..c46babe --- /dev/null +++ b/emacs/inits/13-ibuffer.el @@ -0,0 +1,70 @@ +;; Time-stamp: <2019-05-26 18:21:05 (tslil@basingstoke)> + +(use-package ibuffer + :bind (("C-x C-b" . ibuffer)) + :hook (ibuffer-mode . (lambda () + (ibuffer-switch-to-saved-filter-groups "default"))) + :config + (setq ibuffer-display-summary nil + ibuffer-saved-filter-groups + '(("default" + ("agda" (or (mode . agda2-mode) + (name . "^\\*[aA]gda"))) + ("coq" (or (mode . coq-mode) + (mode . coq-goals-mode) + (mode . coq-response-mode) + (mode . coq-shell-mode))) + ("dired" (mode . dired-mode)) + ("elisp" (or (mode . emacs-lisp-mode) + (name . "^\\*Backtrace\\*"))) + ("emacs" (or (name . "^\\*scratch\\*$") + (name . "^\\*Messages\\*$") + (name . "^\\*init log\\*$") + (name . "^\\*Compile-Log\\*$"))) + ("exwm" (mode . exwm-mode)) + ("help" (or (mode . helpful-mode) + (name . "^\\*Help\\*$"))) + ("irc" (mode . rcirc-mode)) + ("magit" (name . "^magit[:-]")) + ("media" (or (mode . image-mode) + (mode . doc-view-mode))) + ("org" (mode . org-mode)) + ("REPL" (name . "^\\*.*REPL.*\\*$")) + ("slime" (name . "^\\*slime-[^*]*\\*$")) + ("tex" (mode . latex-mode)) + ("web" (or (mode . js2-mode) + (mode . js-mode) + (mode . html-mode) + (mode . css-mode) + (mode . mhtml-mode)))))) + + (defadvice ibuffer-update-title-and-summary (after remove-column-titles) + (with-current-buffer "*Ibuffer*" + (read-only-mode -1) + (goto-char 1) + (search-forward "-\n" nil t) + (delete-region 1 (point)) + (let ((window-min-height 1)) + ;; save a little screen estate + (shrink-window-if-larger-than-buffer)) + (read-only-mode 1))) + + (ad-activate 'ibuffer-update-title-and-summary) + + (define-ibuffer-column size-h + (:name "Size" :inline t) + (cond + ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) + ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0))) + ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) + (t (format "%8d" (buffer-size))))) + + (setq ibuffer-formats + '((mark modified read-only locked " " + (name 18 18 :left :elide) + " " + (size-h 9 -1 :right) + " " + (mode 16 16 :left :elide) + " " + filename-and-process)))) diff --git a/emacs/inits/14-movement.el b/emacs/inits/14-movement.el new file mode 100644 index 0000000..a1b27f6 --- /dev/null +++ b/emacs/inits/14-movement.el @@ -0,0 +1,170 @@ +;; Time-stamp: <2019-08-14 11:59:46 (tslil@basingstoke)> + +;; (eval-after-load "tiny-menu" +;; (progn +;; (defun hexl-input-smart () +;; (hexl-insert-char (0xc-string-to-number (read-string "Input: ")) 1)) + +;; (setq tiny-menu-forever t +;; tiny-menu-items '(("hexl-menu" +;; ("hexl" +;; ((?i "Insert" hexl-input-smart) +;; (?b "Byte" hexl-forward-char) +;; (?e "bytE" hexl-backward-char) +;; (?s "Short" hexl-forward-short) +;; (?t "shorT" hexl-backward-short)))) +;; )))) + +;; (add-hook 'hexl-mode-hook +;; (lambda () +;; (require '0xc) +;; (require 'tiny-menu) +;; (define-key hexl-mode-map (kbd "M-l") +;; (lambda () (interactive) (tiny-menu "hexl-menu"))))) + +;; ------------------------------------------------------------------- +;; Repeated key presses for region, deletion, and movement + +(use-package expand-region :ensure t + :bind ("C-r" . er/expand-region) + :config + (setq expand-region-fast-keys-enabled t + expand-region-contract-fast-key "c" + expand-region-reset-fast-key "e" + expand-region-autocopy-register "i")) + +(use-package viking-mode + :disabled + :after expand-region + :bind (:map viking-mode-map + ("C-d" . nil) + ("C-c d" . viking-kill-thing-at-point)) + :config + (setq viking-use-expand-region-when-loaded t + viking-really-delete nil) + (viking-global-mode)) + +;; (defun goto-begin-dwim () +;; "Read the source." +;; (interactive) +;; (let ((iter (viking-last-key-repeats)) +;; (lisp (memq major-mode '(emacs-lisp-mode +;; lisp-mode +;; scheme-mode +;; slime-repl-mode)))) +;; (if lisp +;; (cond +;; ((= iter 1) (back-to-indentation)) +;; ((= iter 2) (backward-sexp)) +;; ((= iter 3) (beginning-of-defun)) +;; (t (beginning-of-defun 1))) +;; (cond +;; ((= iter 1) (back-to-indentation)) +;; ((= iter 2) (beginning-of-line)) +;; ((= iter 3) (backward-paragraph)) +;; (t (goto-char (point-min))))))) + +;; (defun goto-end-dwim () +;; "Read the source." +;; (interactive) +;; (let ((iter (viking-last-key-repeats)) +;; (lisp (memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode slime-repl-mode)))) +;; (if lisp +;; (cond +;; ((= iter 1) (end-of-line)) +;; ((= iter 2) (end-of-defun)) +;; (t (end-of-defun 1))) +;; (if (< (point) (point-at-eol)) (end-of-line) +;; (forward-paragraph))))) + +;; (global-set-key (kbd "C-a") 'goto-begin-dwim) +;; (global-set-key (kbd "C-e") 'goto-end-dwim) + +;; ------------------------------------------------------------------- +;; Window switching +(use-package switch-window :ensure t + :bind (("C-x o" . switch-window) + ("C-x C-o" . other-frame) + ("C-c o" . switch-window) + ("C-c n" . switch-window-then-maximize) + :map switch-window-extra-map + ("u" . switch-window-mvborder-up) + ("e" . switch-window-mvborder-down) + ("n" . switch-window-mvborder-left) + ("o" . switch-window-mvborder-right) + ("i" . nil) + ("j" . nil) + ("k" . nil) + ("l" . nil)) + :config + (setq switch-window-input-style 'minibuffer + switch-window-shortcut-style 'qwerty + switch-window-multiple-frames nil + switch-window-qwerty-shortcuts + '("a" "s" "t" "h" "n" "e" "o" "i" "d" "r" "w" "f" "u" "p"))) + +;; ------------------------------------------------------------------- +;; Character jumping +(use-package avy + :ensure t + :demand + :bind (("C-," . avy-goto-char-timer) + ("C-." . avy-goto-char-in-line) + ("M-g s" . avy-goto-word-or-subword-1) + ("M-g w" . avy-goto-word-1) + ("M-g a" . avy-goto-word-0) + ("M-g M-g" . avy-goto-line)) + :config + (setq avy-keys '(?a ?s ?t ?h ?n ?e ?o ?i ?d ?r ?u ?p) + avy-dispatch-alist '((?w . avy-action-kill-move) + (?W . avy-action-kill-stay) + (?j . avy-action-teleport) + (?m . avy-action-mark) + (?c . avy-action-copy) + (?y . avy-action-yank) + (?i . avy-action-ispell) + (?z . avy-action-zap-to-char)))) + +;; ------------------------------------------------------------------- +;; General stuff + +(global-set-key (kbd "C-M-e") 'end-of-buffer) +(global-set-key (kbd "C-M-a") 'beginning-of-buffer) + +(global-set-key (kbd "M-h") 'backward-kill-word) + +(global-set-key (kbd "M-z") 'zap-up-to-char) + +;; Fast movement +(global-set-key (kbd "M-n") 'scroll-up-command) +(global-set-key (kbd "M-p") 'scroll-down-command) + +(global-set-key (kbd "C-S-n") + (lambda () (interactive) (ignore-errors (forward-line 5)))) + +(global-set-key (kbd "C-S-p") + (lambda () (interactive) (ignore-errors (forward-line -5)))) + +(global-set-key (kbd "C-S-f") + (lambda () (interactive) (ignore-errors (forward-char 5)))) + +(global-set-key (kbd "C-S-b") + (lambda () (interactive) (ignore-errors (backward-char 5)))) + +;; Hardcore mode +(defconst hardcore-nav-mode t) +(when hardcore-nav-mode + (global-set-key (kbd "<right>") nil) + (global-set-key (kbd "<left>") nil) + (global-set-key (kbd "<up>") nil) + (global-set-key (kbd "<down>") nil) + (global-set-key (kbd "S-<right>") nil) + (global-set-key (kbd "S-<left>") nil) + (global-set-key (kbd "S-<up>") nil) + (global-set-key (kbd "C-<down>") nil) + (global-set-key (kbd "C-<right>") nil) + (global-set-key (kbd "C-<left>") nil) + (global-set-key (kbd "C-<up>") nil) + (global-set-key (kbd "C-<down>") nil) + (global-set-key (kbd "<Home>") nil) + (global-set-key (kbd "<End>") nil)) diff --git a/emacs/inits/15-project-mgmt.el b/emacs/inits/15-project-mgmt.el new file mode 100644 index 0000000..8197f99 --- /dev/null +++ b/emacs/inits/15-project-mgmt.el @@ -0,0 +1,18 @@ +;; Time-stamp: <2019-04-09 23:20:17 (tslil@bison)> + +(use-package projectile + :ensure t + :bind (("C-c p" . projectile-switch-project) + ("C-c f" . projectile-find-file-dwim)) + :config + (projectile-mode 1) + + (setq projectile-completion-system 'ivy + projectile-mode-line-prefix "" + projectile-mode-line-function '(lambda () + (format " ¶[%s]" + (projectile-project-name))))) + +(use-package magit + :ensure t + :bind (("C-x g" . magit-status))) diff --git a/emacs/inits/20-programming.el b/emacs/inits/20-programming.el new file mode 100644 index 0000000..e2e0494 --- /dev/null +++ b/emacs/inits/20-programming.el @@ -0,0 +1,121 @@ +;; Time-stamp: <2019-09-11 11:30:39 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; General setup + +(defadvice compile (around split-horizontally activate) + (let ((split-width-threshold 0) + (split-height-threshold nil)) + ad-do-it)) + +(defadvice compile (after resize-window-properly activate) + (let ((ww (window-width))) + (when (< ww (+ 5 fill-column)) + (enlarge-window-horizontally (- (+ 5 fill-column) ww))))) + +(defun programming-setup () + (subword-mode 1) + (electric-pair-local-mode) + ;; Emacs25 compat + (if (fboundp 'display-line-numbers-mode) + (display-line-numbers-mode) + (linum-mode)) + (setq auto-hscroll-mode t)) + +(add-hook 'prog-mode-hook #'programming-setup) + +;; ----------------------------------------------------------------------------- +;; Specific packages + +(use-package shift-number + :ensure t + :bind (("C-c S-i" . shift-number-up) + ("C-c S-d" . shift-number-down))) + +(use-package comment-dwim-2 + :ensure t + :bind (("M-;" . comment-dwim-2))) + +(use-package aggressive-indent + :ensure t + :defer t) + +(use-package yasnippet + :ensure t + :defer t) + +(use-package elec-pair + :defer t + :config + (setq electric-pair-delete-adjacent-pairs t + electric-pair-skip-self t + electric-pair-preserve-balance t + electric-pair-skip-whitespace t)) + +(use-package js-comint + :ensure t + :defer t + :config + (setq js-comint-program-command "node" + js-comint-program-arguments nil)) + +(use-package js2-mode + :ensure t + :defer t + :after js-comint + :mode "\\.js$" + :bind (:map js2-mode-map + ("TAB" . js2-indent-line) + ("C-x C-e" . js-send-last-sexp) + ("C-c C-b" . js-send-buffer) + ("C-c C-l" . js-load-file)) + :hook (js2-mode . (lambda () + (auto-revert-mode -1) + (yas-minor-mode-on)))) + +;; What are these? +;; (setq gdb-show-threads-by-default nil +;; gdb-many-windows nil +;; gdb-show-main nil) + + +(use-package flycheck + :defer t + :ensure t) + +(use-package irony + :ensure t + :defer t + :hook (lambda () + (irony-cdb-autosetup-compile-options) + (company-irony-setup-begin-commands))) + +(use-package cc-mode + :defer t + :config + (c-set-offset 'case-label '+) + (setq-default c-basic-offset 2)) + +(add-hook 'c-mode-hook + (lambda () + (irony-mode) + (abbrev-mode 0) + (flycheck-mode) + (flycheck-irony-setup) + (c-toggle-hungry-state 1) + (c-toggle-electric-state 1) + (c-toggle-syntactic-indentation 1))) + +(use-package flycheck-rust + :after flycheck + :ensure t + :defer t) + +(use-package rust-mode + :ensure t + :defer t + :bind (:map rust-mode-map + ("C-c C-c" . rust-compile)) + :hook (rust-mode . (lambda () + (flycheck-mode) + (flycheck-rust-setup)))) diff --git a/emacs/inits/21-functional.el b/emacs/inits/21-functional.el new file mode 100644 index 0000000..90d0fba --- /dev/null +++ b/emacs/inits/21-functional.el @@ -0,0 +1,75 @@ +;; Time-stamp: <2019-06-03 17:36:44 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; Haskell + +(use-package haskell-mode + :ensure t + :defer t) + +(use-package intero + :ensure t + :defer t + :hook (haskell-mode . (lambda () + (intero-mode) + (flycheck-mode -1))) + ) + +;; (use-package ghc :ensure t :defer t) + +;; (use-package company-ghc :ensure t :defer t) + +;; (use-package company-ghci :ensure t :defer t) + +;; (use-package shm :ensure t +;; :functions structured-haskell-mode +;; :bind (:map shm-map +;; ("C-c C-s" . shm/case-split))) + +;; (use-package haskell-mode +;; :ensure t +;; :after (company-ghc company-ghci shm) +;; :bind (:map haskell-mode-map +;; ("[f8]". haskell-navigate-imports) +;; ("C-c C-c" . haskell-compile) +;; ("C-c C-z" . haskell-interactive-switch) +;; ("C-c C-l" . haskell-process-load-file) +;; ("C-c C-b" . haskell-interactive-switch) +;; ("C-c C-t" . haskell-process-do-type) +;; ("C-c C-i" . haskell-process-do-info) +;; ("C-x C-d" . nil) +;; ("C-c M-." . nil) +;; ("C-c C-d" . nil)) +;; :hook ((haskell-interactive-mode . visual-line-mode) +;; (haskell-mode . (lambda () +;; (subword-mode 1) +;; (aggressive-indent-mode -1) +;; (require 'shm) +;; (require 'shm-case-split) +;; (require 'ghc) +;; (ghc-init) +;; (structured-haskell-mode) +;; ;; (haskell-indentation-mode) +;; (interactive-haskell-mode) +;; (turn-on-haskell-doc-mode) +;; (turn-on-haskell-decl-scan) +;; (add-to-list 'company-backends 'company-ghc) +;; (add-to-list 'company-backends 'company-ghci) +;; ;; (turn-on-haskell-unicode-input-method) +;; ;; (haskell-mode-stylish-buffer) +;; ))) +;; :config +;; (setq haskell-doc-show-global-types t +;; haskell-doc-show-prelude t +;; haskell-doc-show-user-defined t +;; haskell-doc-show-reserved t +;; haskell-interactive-mode-eval-pretty t +;; haskell-process-type 'cabal-repl +;; company-ghc-show-info t +;; company-ghc-autoscan t +;; company-ghc-show-module t +;; haskell-stylish-on-save t +;; haskell-process-use-presentation-mode t +;; haskell-process-suggest-imports t +;; haskell-process-suggest-hoogle-imports t +;; haskell-process-show-debug-tips nil)) diff --git a/emacs/inits/22-lisp.el b/emacs/inits/22-lisp.el new file mode 100644 index 0000000..872fe9a --- /dev/null +++ b/emacs/inits/22-lisp.el @@ -0,0 +1,132 @@ +;; Time-stamp: <2019-03-20 17:11:15 (tslil@basingstoke)> + +;; ---------------------------------------------------------------------------- +;; Lisp helpers + +(defvar lh-pairs '(("(" . ")") + ("[" . "]") + ("{" . "}") + ("<" . ">") + ("\"" . "\""))) + +(defun lh-forward-delim () + (interactive) + (save-match-data + (re-search-forward + (regexp-opt (mapcar #'cdr lh-pairs))))) + +(defun lh-backward-delim () + (interactive) + (save-match-data + (re-search-backward + (regexp-opt (mapcar #'car lh-pairs))))) + +(defun lh-matching-delim () + (interactive) + (cond + ((looking-at (regexp-opt (mapcar #'car lh-pairs))) + (forward-sexp)) + ((looking-back (regexp-opt (mapcar #'cdr lh-pairs)) nil) + (backward-sexp)) + (t (backward-up-list 1 t t)))) + +(defun lh-slurp-forward () + (interactive) + (corral-shift-backward ?\( ?\))) + +(defun lh-slurp-backward () + (interactive) + (corral-shift-forward ?\( ?\))) + +(defun lh-open-parentheses-dwim (arg) + (interactive "P") + (if (or (= (line-beginning-position) (point)) + (looking-at "\\Sw")) (insert-parentheses arg) + (backward-sexp) + (insert-parentheses 1))) + +(defun lh-end-of-defun (arg) + (interactive "P") + (end-of-defun arg) + (re-search-backward ")") + (forward-char)) + +(defun lh-avy-open-paren () + (interactive) + (avy-goto-char ?\( )) + +(defun lh-avy-close-paren () + (interactive) + (avy-goto-char ?\) )) + +(use-package corral :ensure t) +(defun make-lisp-bindings () + (let ((map (eval (read (format "%s-map" major-mode))))) + (progn + (require 'corral) + (define-key map (kbd "M-e") 'forward-sexp) + (define-key map (kbd "M-a") 'backward-sexp) + (define-key map (kbd "M-,") 'lh-backward-delim) + (define-key map (kbd "M-.") 'lh-forward-delim) + (define-key map (kbd "M-/") 'lh-matching-delim) + (define-key map (kbd "C-c (") 'lh-avy-open-paren) + (define-key map (kbd "C-c )") 'lh-avy-close-paren) + (define-key map (kbd "(") 'lh-open-parentheses-dwim) + (define-key map (kbd "C-c r") 'raise-sexp) + (define-key map (kbd "C-k") 'kill-sexp) + (define-key map (kbd "M-(") 'corral-parentheses-forward) + (define-key map (kbd "M-)") 'corral-parentheses-backward) + (define-key map (kbd "M-{") 'corral-braces-forward) + (define-key map (kbd "M-}") 'corral-braces-backward) + (define-key map (kbd "M-[") 'corral-brackets-forward) + (define-key map (kbd "M-]") 'corral-brackets-backward) + (define-key map (kbd "C-(") 'lh-slurp-forward) + (define-key map (kbd "C-)") 'lh-slurp-backward) + (define-key map (kbd "M-p") 'beginning-of-defun) + (define-key map (kbd "M-n") 'lh-end-of-defun) + t))) + +;; ---------------------------------------------------------------------------- +;; Mode configurations + +(add-hook 'emacs-lisp-mode-hook + (lambda () + (eldoc-mode) + (aggressive-indent-mode) + (make-lisp-bindings))) + +(use-package caps-lock-mode + :load-path "~/.emacs.d/scripts/") + +(use-package slime-company + :ensure t :defer t) + +(use-package slime + :ensure t + :after caps-lock-mode + :hook ((lisp-mode . (lambda () + (aggressive-indent-mode) + (slime-setup '(slime-fancy + slime-asdf + slime-banner + slime-scratch + slime-autodoc + slime-company)) + (slime-mode) + (require 'caps-lock-mode) + (caps-lock-mode) + (make-lisp-bindings))) + (inferior-lisp-mode-hook . make-lisp-bindings)) + :config + (setq inferior-lisp-program "sbcl") + + (require 'slime-banner) + (setq slime-header-line-p nil + slime-kill-without-query-p t)) + +(use-package geiser + :ensure t + :hook (scheme-mode . (lambda () + (geiser-mode) + (aggressive-indent-mode) + (make-lisp-bindings)))) diff --git a/emacs/inits/23-text-related.el b/emacs/inits/23-text-related.el new file mode 100644 index 0000000..8d48795 --- /dev/null +++ b/emacs/inits/23-text-related.el @@ -0,0 +1,133 @@ +;; Time-stamp: <2019-07-17 18:18:58 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; Spelling + +(use-package flyspell-correct-ivy + :ensure t :defer t) + +(use-package flyspell + :ensure t + :bind (:map flyspell-mode-map + ("M-$" . flyspell-correct-wrapper) + ("C-," . nil) + ("C-." . nil) + ("C-\"" . nil)) + :init + (setq ispell-dictionary "british" + flyspell-default-dictionary "british" + flyspell-correct-interface #'flyspell-correct-ivy)) + +(setq sentence-end-double-space nil) + +(add-hook 'mail-mode-hook (lambda () + (electric-pair-local-mode 1) + (turn-on-auto-fill) + (flyspell-mode 1) + (company-mode 1))) + +(add-hook 'text-mode-hook (lambda () + ;; (set-input-method "Adga") + (subword-mode 1) + (electric-pair-local-mode 1) + (turn-on-auto-fill) + (siege-mode 1) + (flyspell-mode 1))) + +(use-package dictionary :ensure t :defer t) + +;; ----------------------------------------------------------------------------- +;; Org + +(use-package org + :defer t + :bind (:map org-mode-map + ("M-h" . nil)) + ;; :hook (org-mode . (lambda () + ;; (activate-input-method default-input-method))) + :config + (setq org-use-sub-superscripts (quote {}) + org-modules nil)) + + +;; ----------------------------------------------------------------------------- +;; Deft + +(use-package deft + :ensure t + :defer t + :commands (deft) + :bind (("C-z" . deft-take-note) + ("C-c C-z" . deft)) + :config + (setq deft-default-extension "org" + deft-directory "~/store/notes" + deft-use-filename-as-title nil + deft-use-filter-string-for-filename t + deft-file-naming-rules '((noslash . "_") + (nospace . "_") + (case-fn . downcase)) + deft-org-mode-title-prefix t) + + (defvar deft-take-note-pre-grab + '((region-thing . (let ((r (if (region-active-p) + (buffer-substring (region-beginning) (region-end)) + (thing-at-point 'line)))) + (if r (concat r "\n") ""))) + (bfn . (let ((f (buffer-file-name)) + (b (buffer-name))) (if f f (concat b " (no file associated)"))))) + "List of pairs of symbol names and (functions evaluating to) + strings evaluated before the buffer is created, and made + available for deft-take-note-default-contents.") + + (defvar deft-take-note-post-grab '() + "List of pairs of symbol names and (functions evaluating to) + strings evaluated after the buffer is created, and made + available for deft-take-note-default-contents.") + + (defvar deft-take-note-default-contents '(region-thing bfn "\n") + "List with string literals and symbols defined in the pre and + post grab lists to be inserted into the buffer.") + + (defun deft-take-note () + (interactive) + (let ((pre-alist (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt)))) + deft-take-note-pre-grab))) + (let ((bn (concat (format-time-string "%Y%m%d-%H:%M:%S.%N-%Z") "." + deft-default-extension))) + (switch-to-buffer bn) + (set-visited-file-name (expand-file-name + (concat deft-directory "/" bn))) + (let ((complete-alist + (append pre-alist + (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt)))) + deft-take-note-post-grab)))) + (mapc #'(lambda (elt) (if (eq (type-of elt) 'string) + (insert elt) + (insert (cdr (assoc elt complete-alist))))) + deft-take-note-default-contents)))))) + +;; ----------------------------------------------------------------------------- +;; Useful keybinds + +(defun vi-open-line-above () + "Insert a newline above the current line and put point at beginning." + (interactive) + (unless (bolp) + (beginning-of-line)) + (newline) + (forward-line -1) + (indent-according-to-mode)) + +(defun vi-open-line-below () + "Insert a newline below the current line and put point at beginning." + (interactive) + (unless (eolp) + (end-of-line)) + (newline-and-indent)) + +(global-set-key (kbd "M-o") 'vi-open-line-below) +(global-set-key (kbd "C-o") 'vi-open-line-above) + +(global-set-key (kbd "M-C-+") 'text-scale-increase) +(global-set-key (kbd "M-C--") 'text-scale-decrease) diff --git a/emacs/inits/24-latex.el b/emacs/inits/24-latex.el new file mode 100644 index 0000000..98eb70c --- /dev/null +++ b/emacs/inits/24-latex.el @@ -0,0 +1,146 @@ +;; Time-stamp: <2019-05-27 11:22:10 (tslil@basingstoke)> + +(defvar latex-template-dir (expand-file-name "~/academic/typeset/latex-templates")) +(defun prompt-latex-file-template () + "Check if tex file does not exist or the command was called +interactively. If neither, prompt to insert from a template +populated from the directory *latex-template-dir*" + (interactive) + (when (and (if (file-exists-p (buffer-file-name)) + (called-interactively-p 'interactive) + t) + (yes-or-no-p "Insert template?")) + (let* ((tfiles (directory-files latex-template-dir nil "\\.tex")) + (template (ivy-read "Select template: " tfiles))) + (when template + (goto-char (point-min)) + (insert-file-contents (concat latex-template-dir "/" template)) + (search-forward "begin{document}") + (forward-line) + (save-buffer))))) + +;; Why does this not work? +;; (use-package cdm-mode +;; :functions cdm-mode +;; :defer t +;; :load-path "~/.emacs.d/scripts/") +(autoload 'cdm-mode "cdm-mode" nil t) + +(use-package company-auctex :ensure t :defer t) + +(use-package latex + :ensure auctex + :bind (:map LaTeX-mode-map + ("'" . better-TeX-insert-single-quote) + ("TAB" . LaTeX-indent-line)) + :hook (LaTeX-mode . (lambda () + (require 'company-auctex) + (electric-pair-local-mode -1) + (flyspell-mode) + (turn-on-auto-fill) + (cdlatex-mode t) + (company-auctex-init) + (siege-mode 1) + (cdm-mode) + (prompt-latex-file-template))) + :init + (defun better-TeX-insert-single-quote () + (interactive) + (let ((old-open TeX-open-quote) + (old-close TeX-close-quote)) + (unwind-protect (progn + (setq TeX-open-quote "`" + TeX-close-quote "'") + (call-interactively 'TeX-insert-quote)) + (setq TeX-open-quote old-open + TeX-close-quote old-close)))) + + :config + (add-to-list 'LaTeX-indent-environment-list + '("diagram")) + (add-to-list 'LaTeX-indent-environment-list + '("diagram*")) + + + (add-to-list 'TeX-command-list '("XeLaTeX" "xelatex %t" TeX-run-TeX nil + (latex-mode doctex-mode) + :help "Run XeLaTeX")) + + (setq TeX-electric-sub-and-superscript t + TeX-electric-math '("$" . "$") + TeX-electric-escape nil + LaTeX-electric-left-right-brace t) + + (setq-default TeX-master nil) + (setq TeX-auto-save t + TeX-parse-self t + TeX-PDF-mode t + TeX-source-correlate-mode nil + TeX-view-program-selection '( ((output-dvi style-pstricks) "dvips and gv") + (output-dvi "xdvi") + (output-pdf "Zathura") + (output-html "xdg-open")))) + + +(use-package cdlatex + :ensure t + :bind (:map cdlatex-mode-map + ("(" . nil) + ("{" . nil) + ("[" . nil) + ("|" . nil) + ("<" . nil) + ("$" . nil) + ("'" . nil) + ("TAB" . nil) + ;; ("TAB" . cdlatex-tab) + ("C-c e" . cdlatex-environment) + ("~" . cdlatex-math-modify) + ("`" . cdlatex-math-symbol)) + :init + (setq cdlatex-math-modify-prefix ?~ + cdlatex-math-symbol-prefix ?` + cdlatex-math-modify-alist '((?a "\\mathbb" nil t nil nil) + (?c "\\mathcal" "\\textsc" t nil nil) + (?t "\\trm" "\\trm" t nil nil) + (?y "\\ty" "\\ty" t nil nil) + (?v "\\texttt" "\\texttt" t nil nil) + (?u "\\tyu" "\\tyu" t nil nil) + (?k "\\mathfrak" nil t nil nil) + (?` nil "`'" t nil nil) + (?- "\\overline" nil t nil nil) + (?_ "\\underline" nil t nil nil)) + cdlatex-math-symbol-alist '((?% ("\\widehat{?}" "\\hat{?}")) + (?' ("^{\\prime}" "\\prime")) + (?* ("\\times" "\\otimes" "\\star")) + (?+ ("+" "\\oplus")) + (?- ("\\vdash" "\\setminus" "\\triangle")) + (?. ("\\sq" "\\circ" "\\cdot")) + (?0 ("\\emptyset" "\\circ")) + (?\; ("\\col")) + (?< ("\\leftarrow" "\\leftharpoonup" "\\xleftarrow")) + (?> ("\\to" "\\rightharpoonup" "\\xrightarrow")) + (?B ("\\bullet")) + (?C ("\\widecheck{?}" "\\check{?}")) + (?F ("\\Phi" "\\Varphi")) + (?M ("\\begin{bsmallmatrix}?\\end{bsmallmatrix}")) + (?P ("\\Prod{?}" "\\Pi" "\\partial")) + (?S ("\\Sum{?}" "\\Sigma" "\\arcsin")) + (?\"("^{\\prime\\prime}" "\\prime\\prime")) + (?a ("\\alpha" "\\cap" "\\sqcap")) + (?c ("\\cat{?}" "\\catn{?}")) + (?e ("\\varepsilon" "\\epsilon" "\\exp{?}")) + (?i ("\\iota" "\\in")) + (?j ("{\\id^{h}}_{?}" "{\\id^{v}}_{?}")) + (?r ("\\rho" "\\varrho" "\\restrict{?}")) + (?u ("\\upsilon" "\\cup" "\\sqcup")) + (?{ ("\\subseteq" "\\subsetneq")) + (?} ("\\supseteq" "\\supsetneq")) + ))) + +(use-package doc-view + :defer t + :functions doc-view-mode + :hook (doc-view-mode . auto-revert-mode) + :config (setq doc-view-resolution 300 + doc-view-continuous t)) diff --git a/emacs/inits/25-theorems.el b/emacs/inits/25-theorems.el new file mode 100644 index 0000000..ed3619d --- /dev/null +++ b/emacs/inits/25-theorems.el @@ -0,0 +1,124 @@ +;; Time-stamp: <2019-09-11 13:59:30 (tslil@basingstoke)> + +;; ----------------------------------------------------------------------------- +;; Coq + +;; (defvar pg-inserted-newline nil) +;; (defconst pg-whitespace-match "[ \\t]") +;; (defconst pg-subgoal-match "[*+\\-]") + +;; (defun pg-move-point-dwim () +;; (interactive) +;; ;; Did we move to a blank new line? +;; (when (= (point) (point-at-bol)) +;; ;; If there's nothing here, lets add another line below +;; (when (looking-at-p (concat pg-whitespace-match "*$")) +;; (save-excursion (newline)) +;; (setq pg-inserted-newline t)) +;; ;; Now let's work out where the point should go +;; (previous-line) +;; (beginning-of-line) +;; ;; Is the previous line essentially a subgoal marker? +;; (if (looking-at-p (concat pg-whitespace-match "*" +;; pg-subgoal-match "+" +;; pg-whitespace-match "*$")) +;; ;; If so, trim the line and put the point in after the subgoal marker +;; (progn +;; (delete-trailing-whitespace (point-at-bol) (point-at-eol)) +;; (end-of-line) +;; (insert-char ? )) +;; ;; If not, go back to where we were and indent +;; (next-line) +;; (indent-for-tab-command)))) + +(defconst coq-env '(("UniMath" + :topdir "~/theorems/coq/UniMath/" + :binary "sub/coq/bin/coqtop" + :args ("-coqlib" "/home/tslil/theorems/coq/UniMath/sub/coq/" + "-emacs" "-noinit" + "-indices-matter" + "-type-in-type" "-w" "-notation-overridden" + "-Q" "/home/tslil/theorems/coq/UniMath/UniMath" "UniMath" + "-Q" "/home/tslil/academic/proof_relevant_cats/formalisation" "wCats")) + ("HoTT" + :topdir "~/theorems/coq/HoTT/" + :binary "hoqtop" + :args nil))) + +(defvar use-coq-env "UniMath") + +(use-package proof-general + :ensure t + :defer t + :functions coq-local-environment + :init (setq proof-splash-enable nil + proof-follow-mode 'followdown) + ;; It's really annoying to have the code truncated due to equal + ;; division ratios of the windows. The 5 is to accomodate line + ;; numbers and the like + (defadvice proof-layout-windows (after resize-window-properly activate) + (let ((ww (window-width))) + (when (< ww (+ 5 fill-column)) + (enlarge-window-horizontally (- (+ 5 fill-column) ww))))) + (defun coq-local-environment () + (bind-key "C-s" #'isearch-forward proof-mode-map) + (let* ((data (alist-get use-coq-env coq-env nil nil #'string-equal)) + (topdir (expand-file-name (plist-get data :topdir))) + (binary (plist-get data :binary)) + (args (plist-get data :args))) + ;; TAGS + (visit-tags-table (concat topdir "TAGS")) + ;; Formatting + (setq fill-column 70) + (set-fringe-mode 0) + (make-local-variable 'before-save-hook) + (add-hook 'before-save-hook 'delete-trailing-whitespace) + (setq proof-three-window-mode-policy 'hybrid + proof-layout-windows-on-visit-file t + proof-shrink-windows-tofit t + proof-script-fly-past-comments t) + ;; Tweak syntax table + ;; (modify-syntax-entry ?' "w") + ;; Coq binary related + (dolist (var '(coq-use-project-file coq-prog-args coq-prog-name)) + (make-local-variable var)) + (setq coq-use-project-file nil + coq-prog-args args + coq-prog-name (concat topdir binary)) + (agda-input-setup) + (activate-input-method "Agda"))) + :mode ("\\.v$" . coq-mode) + :hook (coq-mode . (lambda () + (programming-setup) + (coq-local-environment) + (auto-fill-mode) + (company-coq-mode)))) + +(use-package company-coq + :after proof-general + :ensure t + :bind (:map company-coq-map + ("M-." . xref-find-references) + ("M-*" . pop-tag-mark)) + :init + (setq company-coq-disabled-features '(hello))) + +;; ----------------------------------------------------------------------------- +;; Agda + +(load-file (let ((coding-system-for-read 'utf-8)) + (shell-command-to-string "agda-mode locate"))) + +(add-hook 'agda2-mode + (lambda () + (subword-mode 1) + (auto-fill-mode) + (aggressive-indent-mode -1))) + +;; ----------------------------------------------------------------------------- +;; Lean + +;; (use-package lean-mode +;; :ensure t +;; :defer t +;; :mode ("\\.lean$" . lean-mode)) diff --git a/emacs/inits/30-irc.el b/emacs/inits/30-irc.el new file mode 100644 index 0000000..7d3566f --- /dev/null +++ b/emacs/inits/30-irc.el @@ -0,0 +1,45 @@ +;; Time-stamp: <2019-01-26 12:55:41 (tslil@winslow)> + +(use-package rcirc + :ensure t + :defer + :hook (rcirc-mode . (lambda () + (rcirc-track-minor-mode) + (flyspell-mode-on) + (set (make-local-variable 'scroll-conservatively) 8192))) + :config + (use-package rcirc-color + :ensure t + :if (window-system)) + + (require 'auth-source) + + (defadvice rcirc (before rcirc-read-from-authinfo activate) + (unless arg + (dolist (p (auth-source-search :port '("nickserv" + "bitlbee" + "quakenet") + :require '(:port :user :secret))) + (let ((secret (plist-get p :secret)) + (method (intern (plist-get p :port)))) + (add-to-list 'rcirc-authinfo + (list (plist-get p :host) + method + (plist-get p :user) + (if (functionp secret) + (funcall secret) + secret))))))) + + (setq rcirc-default-full-name "tslil" + rcirc-default-nick "maximum_yellow" + rcirc-default-user-name "maximum_yellow" + rcirc-time-format "%Y-%m-%d %H:%M " + rcirc-log-directory "~/irc/" + rcirc-fill-column 80 + rcirc-log-flag t + rcirc-server-alist + '(("irc.freenode.net" + :port 6697 + :encryption tls + :channels ("#emacs" "#guix") + )))) diff --git a/emacs/inits/50-file-assocs.el b/emacs/inits/50-file-assocs.el new file mode 100644 index 0000000..0024f1a --- /dev/null +++ b/emacs/inits/50-file-assocs.el @@ -0,0 +1,20 @@ +;; Time-stamp: <2019-09-11 11:29:16 (tslil@basingstoke)> + +(use-package gnuplot-mode + :ensure t + :mode "\\.gnp$") + +(use-package scad-mode + :ensure t + :mode "\\.scad$") + +(setq auto-mode-alist + (append + '(("\\.emacs$" . emacs-lisp-mode) + ("\\.scm$" . scheme-mode) + ("\\.sch$" . scheme-mode) + ("\\.sc$" . scheme-mode) + ("\\.cl$" . lisp-mode) + ("\\.py$" . python-mode) + ("\\.pg$" . perl-mode) + ) auto-mode-alist)) diff --git a/emacs/inits/60-misc-configs.el b/emacs/inits/60-misc-configs.el new file mode 100644 index 0000000..dd51a20 --- /dev/null +++ b/emacs/inits/60-misc-configs.el @@ -0,0 +1,22 @@ +;; Time-stamp: <2019-03-11 11:02:27 (tslil@basingstoke)> + +(use-package dired + :defer t + :config + (setq dired-listing-switches "--group-directories-first -alh" + dired-auto-revert-buffer t + dired-dwim-target t + ;; ??? + ;; dired-guess-shell-alist-user '(("\\.djvu\\'" "zathura") + ;; ("\\.pdf\\'" "zathura") + ;; ("\\.ps\\'" "zathura")) + )) + +(use-package browse-url + :defer t + :config + (setq browse-url-generic-program "firefox-esr" + browse-url-browser-function '(("." . browse-url-generic)))) + +(setq backup-directory-alist `((".*" . ,temporary-file-directory)) + auto-save-file-name-transforms `((".*" ,temporary-file-directory t))) diff --git a/emacs/inits/70-global-keybinds.el b/emacs/inits/70-global-keybinds.el new file mode 100644 index 0000000..92ae2fe --- /dev/null +++ b/emacs/inits/70-global-keybinds.el @@ -0,0 +1,32 @@ +;; Time-stamp: <2019-08-25 21:44:55 (tslil@basingstoke)> + +(setq time-stamp-active t + time-stamp-line-limit 3 + time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u@%s)") + +(add-hook 'before-save-hook #'time-stamp) + +(defun insert-timestamp () + (interactive) + (save-excursion + (goto-char (point-min)) + (unless (search-forward "Time-stamp: " + (line-beginning-position (1+ time-stamp-line-limit)) + t) + (goto-char (point-min)) + (newline) + (beginning-of-line 0) + (comment-dwim nil) + (insert (concat "Time-stamp: " "<>")) + (newline)) + (time-stamp))) +(global-set-key (kbd "C-x t") 'insert-timestamp) + +(global-set-key (kbd "<f11>") 'notmuch) +(global-set-key (kbd "C-x m") 'eshell) +(global-set-key (kbd "C-c c") 'shell) +(global-set-key (kbd "C-x e") 'eval-expression) + +(global-set-key (kbd "M-i") 'indent-region) + +(global-set-key (kbd "C-v") 'delete-indentation) diff --git a/emacs/inits/99-last.el b/emacs/inits/99-last.el new file mode 100644 index 0000000..dc6db7d --- /dev/null +++ b/emacs/inits/99-last.el @@ -0,0 +1,7 @@ +;; Time-stamp: <2019-01-26 12:56:04 (tslil@winslow)> + +(add-hook 'after-init-hook + (lambda () + (run-with-idle-timer 20 nil (lambda () (setq gc-cons-threshold 8000000))))) + +(setq file-name-handler-alist old-file-name-handler-alist) diff --git a/emacs/notmuch-config.el b/emacs/notmuch-config.el new file mode 100644 index 0000000..d916c3d --- /dev/null +++ b/emacs/notmuch-config.el @@ -0,0 +1,244 @@ +;; =================================================================== +;; Generic mail stuff +(setq user-full-name "tslil clingman" + user-mail-address "email" + mail-signature-file "~/.signature") + +(setq notmuch-fcc-dirs '(("email" . "folder"))) + +;; =================================================================== +;; SMTP server configuration +(setq message-send-mail-function 'smtpmail-send-it + send-mail-function 'smtpmail-send-it + mail-user-agent 'message-user-agent + smtpmail-auth-credentials "~/.authinfo.gpg" + smtpmail-smtp-server "server" + smtpmail-smtp-service 465 + smtpmail-stream-type 'ssl) + +(defconst smtp-from-server-alist '(("account" . "server"))) + +(defun set-smtp-server () + (let ((server (or (cdr (assoc (save-restriction + (message-narrow-to-headers) + (message-fetch-field "from")) + smtp-from-server-alist)) + "posteo.de"))) + (setq smtpmail-smtp-server server + smtpmail-stream-type 'ssl + smtpmail-smtp-service 465) + (when (string-equal server "smtp.office365.com") + (setq smtpmail-stream-type 'starttls + smtpmail-smtp-service 587)) + (message "SMTP server changed to %s" server))) + +;; =================================================================== +;; Crypto and related +(setq gnutls-min-prime-bits 2048 + mm-verify-option 'always + mm-decrypt-option 'always + mml-secure-method "pgpmime" + mml-default-sign-method "pgpmime" + notmuch-crypto-process-mime t) + +(defmacro secure-or-send (&rest body) + `(quote (lambda () + (interactive) + (set-smtp-server) + ,@(mapcar #'list body) + (notmuch-mua-send-and-exit)))) + +(define-key notmuch-message-mode-map (kbd "C-c C-S-c") 'message-send-and-exit) +(define-key notmuch-message-mode-map (kbd "C-c C-c") (secure-or-send mml-secure-sign)) +(define-key notmuch-message-mode-map (kbd "C-c M-c") (secure-or-send mml-secure-encrypt)) + +;; =================================================================== +;; bbdb stuff +;; (require 'bbdb) +;; (bbdb-initialize) + +;; (setq bbdb-file "~/.bbdb" +;; bbdb-completion-list t +;; bbdb-complete-mail t +;; bbdb-mail-user-agent 'message-user-agent +;; bbdb-complete-mail-allow-cycling t +;; bbdb-mua-pop-up nil +;; bbdb-mua-auto-update-p t) + +;; (add-hook 'notmuch-message-mode-hook (lambda () +;; (add-to-list 'company-backends 'company-bbdb))) + +;; =================================================================== +;; notmuch-hello bindings +(setq notmuch-saved-searches '(list-of-things)) + +(defvar notmuch-hello-tree-searches '(("u" . "tag:unread") + ("s" . "tag:sent") + ("f" . "tag:flagged") + ("i" . "tag:inbox") + ("*" . "*")) + "List of (key . query) pairs to bind in notmuch-hello.") + +(defvar notmuch-tag-keys '(("d" . '("+deleted")) + ("u" . '("-deleted")) + ("t" . nil)) + "List of (key . '(tags list)) pairs to bind in tree and search modes.") + +(defmacro make-binds (mode-map binds argfunc &rest body) + "Create keybindings in `mode-map' using a list of (keystr . arg) +pairs in `binds' of the form ( ... (argfunc arg) body)." + `(progn ,@(mapcar (lambda (pair) + `(define-key ,mode-map (kbd ,(car pair)) + (lambda () (interactive) (,argfunc ,(cdr pair)) ,@body))) + (eval binds)))) + +;;(define-key notmuch-show-mode-map (kbd "R") 'notmuch-show-reply) +;;(define-key notmuch-show-mode-map (kbd "r") 'notmuch-show-reply-sender) +(define-key notmuch-search-mode-map (kbd "R") 'notmuch-search-reply-to-thread) +(define-key notmuch-search-mode-map (kbd "r") 'notmuch-search-reply-to-thread-sender) +(define-key notmuch-tree-mode-map (kbd "R") (lambda () + (interactive) + (notmuch-tree-close-message-window) + (notmuch-show-reply))) +(define-key notmuch-tree-mode-map (kbd "r") (lambda () + (interactive) + (notmuch-tree-close-message-window) + (notmuch-show-reply-sender))) + + +(define-key notmuch-hello-mode-map (kbd "q") + (lambda () + (interactive) + (when (timerp offlineimap--timer) + (cancel-timer offlineimap--timer)) + (notmuch-bury-or-kill-this-buffer))) + +(make-binds notmuch-hello-mode-map + notmuch-hello-tree-searches + notmuch-tree) + +(make-binds notmuch-show-mode-map + notmuch-tag-keys + notmuch-show-tag + (notmuch-show-next-message)) + +(make-binds notmuch-tree-mode-map + notmuch-tag-keys + notmuch-tree-tag + (notmuch-tree-next-message)) + +;; =================================================================== +;; notmuch-hello widgets and offlineimap integration +(defun notmuch-hello-header-new () + (setq fill-column (window-width)) + (let ((widget-link-prefix "") + (widget-link-suffix "") + (unread (string-to-number (car (process-lines + notmuch-command "count" "tag:unread")))) + (total (string-to-number (car (process-lines + notmuch-command "count"))))) + (widget-insert "You have ") + (widget-create 'link :notify (lambda (&rest nope) (notmuch-hello-update)) + :help-echo "Update notmuch view" + (notmuch-hello-nice-number total)) + (widget-insert " emails,") + (center-line) (widget-insert "\n") + (widget-create 'link :notify (lambda (&rest nope) (notmuch-tree "tag:unread")) + :help-echo "View unread emails" + (notmuch-hello-nice-number unread)) + (widget-insert (format " of which %s unread." + (if (= 1 unread) "is" "are"))) + (center-line) (widget-insert "\n"))) + +(defun check-and-notify-new-mail () + (notmuch-hello-update t) + (let ((num (string-to-number (car (process-lines + notmuch-command "count" "tag:unread"))))) + (when (< 0 num) + (message (format "New mail! (%s)" num))))) + +(defun offlineimap-output-filter (process string) + "Handle output from offlineimap process." + (let ((buff (process-buffer process))) + (when (buffer-live-p buff) + (with-current-buffer buff + (save-excursion + (goto-char (point-max)) + (insert string))) + (let ((lines (split-string string "\n+" t))) + (cl-loop for line in lines do + (when (string-match-p "added to the database" line) + (check-and-notify-new-mail))))))) + +(defun offlineimap-sentinal (process string) + "Handle the termination of the offlineimap process." + (when (string-equal "finished\n" string) + (let ((buff (process-buffer process))) + (when (buffer-live-p buff) + (with-current-buffer buff + (save-excursion + (goto-char (point-max)) + (insert (format-time-string "--- %d.%m.%y/%H:%M:%S ---\n\n\n")))))) + (check-and-notify-new-mail))) + +(defun offlineimap-run () + "Run offlineimap and report on results." + (let ((proc (start-process "offlineimap-process" + "*offlineimap*" + "offlineimap"))) + (set-process-filter proc 'offlineimap-output-filter) + (set-process-sentinel proc 'offlineimap-sentinal))) + +(defun notmuch-hello-offlineimap () + "Widget to run offlineimap async." + (setq fill-column (window-width)) + (widget-create 'push-button :help-echo "Run offlineimap" + :notify (lambda (&rest nope) + (offlineimap-run)) + "Fetch mail") + (center-line) + (widget-insert "\n")) + +(setq notmuch-hello-sections '(notmuch-hello-header-new + notmuch-hello-offlineimap + notmuch-hello-insert-saved-searches + notmuch-hello-insert-search + notmuch-hello-insert-alltags)) + +(add-hook 'notmuch-hello-refresh-hook + (lambda () + (goto-char (point-min)) + (search-forward "You have" nil t) + (forward-word))) + +(defvar offlineimap--timer nil "Timer for running offlineimap.") +(defvar offlineimap-use-timer nil "Whether to use a timer for +running offlineimap (t) or manual (nil).") + +(add-hook 'notmuch-hello-mode-hook + (lambda () + (when offlineimap-use-timer + (when (timerp offlineimap--timer) + (cancel-timer offlineimap--timer)) + (setq offlineimap--timer + (run-with-timer 0 300 'offlineimap-run))))) + +;; =================================================================== +;; Message displaying and so on +(add-to-list 'mm-discouraged-alternatives "text/html") +(add-to-list 'mm-discouraged-alternatives "text/richtext") + +;; I don't actually want w3m anymore +(setq mm-text-html-renderer 'shr) + +(add-hook 'message-mode-hook (lambda () + (turn-on-auto-fill) + (flyspell-mode) + (company-mode))) + +(setq notmuch-tree-result-format '(("date" . "%12s | ") + ("authors" . "%-20s") + ((("tree" . "%s") + ("subject" . "%-10s")) + . " | %-54s") + ("tags" . "(%s)"))) diff --git a/emacs/scripts/acquiesce.el b/emacs/scripts/acquiesce.el new file mode 100644 index 0000000..0dcf9fc --- /dev/null +++ b/emacs/scripts/acquiesce.el @@ -0,0 +1,351 @@ +(require 'cl) + +(defmacro default (expr default) + "If `expr' evaluates to non-null then return the result, otherwise give `default'." + (let ((e (gensym))) + `(let ((,e ,expr)) + (if ,e ,e ,default)))) + +;; ============================================================================= +;; File stuff +(defun acme--file-p (str) + (and (file-exists-p str) + (file-readable-p str) + (not (car (file-attributes str))))) + +(defun acme--recursive-locate-file (regexp start-dir depth) + (let ((dirs (list start-dir)) found) + (cl-loop + while (and (not found) (/= depth 0)) do + (let (ndirs) + (cl-loop for dir in dirs unless found do + (let ((candidates (directory-files-and-attributes + dir t + directory-files-no-dot-files-regexp))) + (cl-loop for file in candidates unless found do + (let ((name (nth 0 file)) + (is-dir (nth 1 file))) + (if is-dir (add-to-list 'ndirs name nil nil) + (when (string-match-p regexp name) + (setq found name) nil)))))) + (setq depth (1- depth)) + (setq dirs ndirs))) + found)) + +(defun acme--as-pos-natural (arg) + (when arg + (if (stringp arg) + (unless (string-match-p "[^0-9]" arg) + (let ((n (string-to-number arg))) + (when (and (> n 0) (integerp n)) n))) + (when (and (integerp arg) (> arg 0)) arg)))) + +(defun acme--parse-as-file (str dir) + "Attempt to interpret a string as <head>[:<line>[:<column>]] or +:[<line>][:<column>] where at least one of <line> or <column> is +given, and find a file that best represents the string by processing the +following in order: + + 0. if <head> is not given, assume current file + 1. <head> as a file in dir + 2. <head> as an absolute path to a file + 3. If at least <line> is given, take <head> as a regexp against + which to match a file in dir, of which the first match + (alphabetically) is taken" + (let* ((spl (split-string str ":+?" nil)) + (line-s (nth 1 spl)) (col-s (nth 2 spl)) + (line (if line-s (acme--as-pos-natural line-s) 1)) + (col (if col-s (acme--as-pos-natural col-s) 1)) + (fn (nth 0 spl))) + (when (and line col (> 4 (length spl)) + (not (string-match-p ".*/$" fn))) + (cl-flet ((found (f) (when f (list :LINE line :COL col :FILE f)))) + (let ((rfn (concat dir fn))) + (cond + ((or (and line-s line) (and col-s col)) (list :LINE line :COL col :FILE nil)) + ((acme--file-p rfn) (found rfn)) + ((acme--file-p fn) (found fn)) + ((or col-s line-s) (found (acme--recursive-locate-file + fn dir + acme-find-file-recursive-depth))) + + )))))) + +(defun acme--process-file (file) + (let ((fname (plist-get file :FILE)) + (line (plist-get file :LINE)) + (col (plist-get file :COL))) + (when fname (find-file fname)) + (when line (goto-line line)) + (when col (forward-char col)))) + +;; ============================================================================= +;; General magic +(defmacro return-first (first &rest body) + "Execute `first' first, then `body', return whatever `first' did." + (let ((val (gensym))) + `(let ((,val ,first)) + ,@body + ,val))) + +(defun acme--extract-string (&optional count) + "Extract a string from the buffer as follows: +1. If there is a region, use it +2. If point is at the start of the line, then use the whole line. +3. Take the previous (count)?count:1 words +After this, place the point at the end of the appropriate block" + (let ((n (default count 1)) + (p (point)) + (b (line-beginning-position)) + (e (line-end-position))) + (assert (/= n 0) t) + (cond + ((use-region-p) + (return-first + (buffer-substring-no-properties (region-beginning) (region-end)) + (goto-char (region-end)))) + ((= p b) (return-first + (buffer-substring-no-properties b e) + (end-of-line))) + (t (let* ((re (default (search-forward " " e t) e)) + (rs (default (search-backward " " b t n) b))) + (return-first + (buffer-substring-no-properties rs re) + (goto-char re))))))) + +;; ============================================================================= +;; Tag window and buffers +(defun* acme--load-tags (&key (buffer nil) (init nil)) + "Retrieve or create the tags associated to `buffer' (or +current-buffer), saving the old tags if we are _changing_ +buffers." + (assert (window-live-p acme--tag-window)) + (assert (buffer-live-p acme--tag-buffer)) + (let* ((cur-buff (current-buffer)) + (new-buff (default buffer cur-buff)) + (existing-tags (assoc new-buff acme--tag-buffers-alist)) + ) + (set-buffer acme--tag-buffer) + (if (and existing-tags (not init)) + (setf (cdr (assoc cur-buff acme--tag-buffers-alist)) + (buffer-string))) + (erase-buffer) + (if existing-tags (insert (cdr existing-tags)) + (let ((new-tags (concat default-directory " " + (buffer-name new-buff) + acme-tag-default-string))) + (insert new-tags) + (add-to-list 'acme--tag-buffers-alist + `(,new-buff . ,new-tags)))))) + +(defun acme--init-tag-window () + "Initialise the tag window and tag buffer." + (when acme--tag-buffer + (unless (buffer-live-p acme--tag-buffer) + (setq acme--tag-buffer nil))) + (when acme--tag-window + (unless (window-live-p acme--tag-window) + (setq acme--tag-window nil))) + (when acme-delete-other-windows (delete-other-windows)) + (let* ((tag-win (selected-window)) + (content-win (split-window-vertically 2))) + (setq acme--tag-window tag-win + ;;window-size-fixed t + acme--tag-buffer (find-file acme-tag-buffer-name)) + (set-window-dedicated-p acme--tag-window t) + (select-window content-win))) + +(defun acme--get-nth-from-tag (n) + "Get the n'th field from the tag, only really useful n<3." + (save-current-buffer + (set-buffer (cdr (acme--get-tag-buffer))) + (nth n (split-string-and-unquote (buffer-string))))) + +(defun acme--get-directory-from-tag () + (acme--get-nth-from-tag 0)) + +(defun acme--get-buffer-name-from-tag () + (acme--get-nth-from-tag 1)) + +;; ============================================================================= +;; Marking input and output locations +(defun acme-mark-input (&optional arg) + "When the region is active, mark it as the ACME input field, +otherwise take the current buffer as input. Any argument causes +the input to be marked as blank." + (interactive "P") + (setq acme--input-pointer + (if arg 'EMPTY + (if (region-active-p) + (list :BUFFER (current-buffer) + :START (region-beginning) + :END (region-end)) + (list :BUFFER (current-buffer) + :START 0 + :END (buffer-size)))))) + +(defun acme-mark-output (&optional arg) + "When the region is active, mark it as the ACME output +field (thereby consigning it to be replaced by any output), +otherwise take the current buffer as output. Any argument causes +the output to be sent to `acme-error-buffer-name' for the +current directory." + (interactive "P") + (setq acme--output-pointer + (if arg 'EMPTY + (if (region-active-p) + (list :BUFFER (current-buffer) + :START (region-beginning) + :END (region-end)) + (list :BUFFER (current-buffer) + :START (point) + :END nil))))) + +(defun acme-mark-io () + "Mark the current buffer/region as a location for ACME +I/O (useful for piping through commands, for example)." + (interactive) + (acme-input-mark) + (acme-output-mark)) + +;; TODO: Overlays so you can see what is what? + +(defun acme--execute-command (command) + (let* ((list (split-string command)) + (cmd (car list)) + (args (combine-and-quote-strings (cdr list))) + (out-file (make-temp-file "acme--execute-command-output"))) + (save-excursion + (if (eq acme--input-pointer 'EMPTY) + (call-process cmd nil `(:file ,out-file) nil args) + (let ((in-file (make-temp-file "acme--execute-command-input"))) + (set-buffer (plist-get acme--input-pointer :BUFFER)) + (write-region (plist-get acme--input-pointer :START) + (plist-get acme--input-pointer :END) + in-file) + (call-process cmd in-file `(:file ,out-file) nil args) + (delete-file in-file))) + (if (eq acme--output-pointer 'EMPTY) + (progn + (find-file (concat default-directory acme-error-buffer-name)) + (end-of-buffer)) + (let ((out-buffer (plist-get acme--output-pointer :BUFFER)) + (s (plist-get acme--output-pointer :START)) + (e (plist-get acme--output-pointer :END))) + (set-buffer out-buffer) + (beginning-of-buffer) + (when e (delete-region s e)) + (goto-char s))) + (insert-file out-file) + (delete-file out-file)))) + +$date +%H/%M +$ls . +;; Output should start here: +;; 2 +;; 1 +;; 4 +;; 3 +;; 5 +;; 9 +;; $sort +$sort + +;; ============================================================================= +;; General interface +(defun acme-do () + "A generic wrapper around opening files, directories, man-pages, +URLS and other things" + (interactive) + ;; For now, + (acme--process-file + (acme--parse-as-file + (acme--extract-string) + (acme--get-directory-from-tag))) + ) + +(defun acme-execute () + "A DWIM executor. The command to execute is retrieved with + `acme--extract-string'. + +If the command begins with a $, then it is interpreted as a shell +command in the following ways: + +1. If there is neither input nor output marked then it is + executed and the output and errors sent to the buffer + `acme-error-buffer-name' for the current directory. + +2. Using whatever input is marked (whole buffer or region) + + a. If output is marked as a region, is it overwritten with the + result of the command on the input + + b. If output is marked as a buffer, then the result of command + on the input is inserted in that buffer at the marked + position. + +NOTE: When input and output buffers are set to be the same, the +input region is first sent to the command, and then the output +region is overwritten. + +If the command does not start with a $, then it shipped off to +eshell where more magic happens. +" + + (interactive) + (let ((str (acme--extract-string))) + (if (string-prefix-p "$" str) + (acme--execute-command (subseq str 1)) + (eshell-command str)))) + + +(defun acme-init () + ;; TODO: Potentially advise window-deletable-p + (acme--init-tag-window) + (acme--load-tags :init t) + ;;(add-hook 'buffer-list-update-hook 'acme--load-tags) + ;;(add-hook 'find-file-hook 'acme--load-tags) + ) + +;; ============================================================================= +;; Variables and customisable stuff +(defcustom acme-delete-other-windows t + "Delete all other windows when starting ACME mode so that the +tag window is above all others.") +(defcustom acme-find-file-recursive-depth 3 + "Maximum folder depth to recursively seek files for `acme-do'") +(defcustom acme-tag-default-string "Snarf Look Put" + "Default tags for new buffers") +(defcustom acme-tag-buffer-name "+tags" + "Name for tags buffer") +(defcustom acme-error-buffer-name "+errors" + "Name for error buffer used for general output") + +;; (defvar acme--tag-windows-alist nil) +(defvar acme--tag-buffers-alist nil) +(defvar acme--tag-window nil) +(defvar acme--tag-buffer nil) + +(defvar acme--input-pointer nil) +(defvar acme--output-pointer nil) + +;; ============================================================================= +;; Keymap +(defvar acme-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c d") 'acme-do) + (define-key map (kbd "C-c e") 'acme-execute) + (define-key map (kbd "C-c m i") 'acme-mark-input) + (define-key map (kbd "C-c m o") 'acme-mark-output) + (define-key map (kbd "C-c m b") 'acme-mark-io) + map)) + +;; ============================================================================= +;; Mode definition +(define-minor-mode acme-mode + "ACME-esque magic, but key driven" + :lighter " ACME" :keymap acme-mode-map + :global t + (acme-init)) + +(provide 'acme-mode) diff --git a/emacs/scripts/caps-lock-mode.el b/emacs/scripts/caps-lock-mode.el new file mode 100644 index 0000000..c80883a --- /dev/null +++ b/emacs/scripts/caps-lock-mode.el @@ -0,0 +1,21 @@ +(defvar caps-lock-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [remap self-insert-command] 'upcased-self-insert) + map)) + +(define-minor-mode caps-lock-mode + "Caps lock minor mode." + nil " CLK" caps-lock-mode-map) + +(defun upcased-self-insert (arg) + "Insert an uppercase version of the input, unless in a comment or string" + (interactive "p") + (let* ((syn (syntax-ppss)) + (comment-or-string (or (nth 4 syn) (nth 3 syn))) + (last-command-event (if (and (not comment-or-string) + (characterp last-command-event)) + (upcase last-command-event) + last-command-event))) + (self-insert-command arg))) + +(provide 'caps-lock-mode) diff --git a/emacs/scripts/cdm-mode.el b/emacs/scripts/cdm-mode.el new file mode 100644 index 0000000..03fcc76 --- /dev/null +++ b/emacs/scripts/cdm-mode.el @@ -0,0 +1,342 @@ +;; Time-stamp: <2019-05-22 19:10:33 (tslil@basingstoke)> + +(defvar cdm-arr-type-list '(("arrow" . "a") + ("id" . "d") + ("proarrow" . "proarrow") + ("proid" . "proequal") + ("prodotted" . "prodotted") + ("2-square" . "sn") + ("id-square" . "sd") + ("universal" . "u") + ("2-cell" . "n") + ("3-cell" . "t") + ("3-square" . "st") + ("parallel" . "p") + ("monomorphism" . "m") + ("epimorphism" . "e"))) + +(defvar cdm-parr-dir-list '(("left -> right" . 0) + ("right -> left" . 1) + ("up -> down" . 2) + ("down -> up" . 3))) + +(defvar cdm-wrap-list '("diagram" "tikzpicture" "diagram*" "dgrm")) + +(defvar cdm--pos-list '("below" "right" "left" "above" + "midway" "below right" "below left" + "above right" "above left" "none")) + +(defvar cdm-cell-len ".3cm") + +(defvar cdm--use-helm nil) + +(defvar cdm-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c a") 'cdm-insert-arrow) + (define-key map (kbd "C-c n") 'cdm-insert-node) + (define-key map (kbd "C-c d") 'cdm-insert-square) + (define-key map (kbd "C-c r") 'cdm-square-reset) + map)) + +(defvar cdm--node-list nil) +(defvar cdm--pos-helm-source nil) +(defvar cdm--node-helm-source nil) +(defvar cdm--parr-dir-helm-source nil) +(defvar cdm--arr-type-helm-source nil) + +(defvar cdm--strip-label t) + +(defvar cdm--square-progress 0) +(defvar cdm--square-nodes nil) + +(defun cdm--find-enclosing-pair () + (let* ((p (point)) s e + (lst (cl-loop + for delim in cdm-wrap-list collect + (save-excursion + (when (and + (setq s (search-backward (concat "\\begin{" delim "}") 0 t)) + (setq e (search-forward (concat "\\end{" delim "}") nil t)) + (<= s p) (<= p e)) + (list s e)))))) + (cl-flet + ((nearest (best curr) + (if (or (not best) + (and curr + (> (car curr) (car best)) + (< (cadr curr) (cadr best)))) + curr best))) + (reduce #'nearest lst :initial-value nil)))) + +(defun cdm--is-natural (str) + (when (and str (string-match "[0-9]+" str)) + (string-to-number str))) + +(defun cdm--sort-p (s1 s2) + (let ((n1 (cdm--is-natural (cdr s1))) + (n2 (cdm--is-natural (cdr s2)))) + (if (and n1 n2) (> n1 n2) + (string-lessp (cdr s1) (cdr s2))))) + +(defun cdm--strip-label-f (str) + (let ((strs (split-string str "$+"))) + (if (and (= 3 (length strs)) + (string-blank-p (car strs)) + (string-blank-p (caddr strs))) + (cadr strs) str))) + +;; TODO: This will probably pick up nodes in the text of other nodes. +(defun cdm--scan-for-nodes (start end) + (save-excursion + (setq cdm--node-list nil) + (goto-char start) + (let (node-start node-end label-start label-end) + (while (setq node-start (search-forward "node(" end t)) + (setq node-end (search-forward ")" end t) + label-start (search-forward "{" end t) + label-end (progn (backward-char) + (ignore-errors (1+ (forward-list))))) + (when (and node-end label-start label-end (< 1 (- node-end node-start))) + (let* ((temp (if (and label-end label-start (> label-end label-start)) + (buffer-substring-no-properties label-start (- label-end 2)) + "This literal will never appear in the list.")) + (node (buffer-substring-no-properties node-start (1- node-end))) + (label (if (string-blank-p temp) (concat node "\t(no label)") + (concat (if cdm--strip-label (cdm--strip-label-f temp) temp) + "\t(" node ")")))) + (push `(,label . ,node) cdm--node-list)))))) + cdm--node-list) + +(defun cdm--get-nodes () + (let ((enclosing-pair (cdm--find-enclosing-pair))) + (if enclosing-pair + (progn (apply #'cdm--scan-for-nodes enclosing-pair) + (setq cdm--node-list (sort (copy-list cdm--node-list) #'cdm--sort-p)) + (or cdm--node-list t)) + (error "Not currently in an enclosing diagram environment.")))) + +(defun cdm--ivy-complete (prompt list) + (cdr (assoc-string (ivy-read prompt list) list))) + +(defun cdm--complete-nodes (prompt) + (if cdm--use-helm (helm :sources cdm--node-helm-source + :prompt prompt + :buffer "*helm-node*") + (cdm--ivy-complete prompt cdm--node-list))) + +(defun cdm--complete-position () + (let* ((prompt "Select relative position: ") + (p (if cdm--use-helm (helm :sources cdm--pos-helm-source + :prompt prompt + :buffer "*helm-position*") + (ivy-read prompt cdm--pos-list)))) + (when p + (cond + ((string-equal "none" p) nil) + ((string-equal "midway" p) (concat p ", from= ")) + (t (concat p " of= ")))))) + +(defun cdm--complete-arr-type () + (let ((prompt "Select arrow type: ")) + (if cdm--use-helm (helm :sources cdm--arr-type-helm-source + :prompt prompt + :buffer "*helm-arrow*")) + (cdm--ivy-complete prompt cdm-arr-type-list))) + +(defun cdm--not-so-smart-move () + (back-to-indentation) + (unless (= (point) (line-end-position)) + (end-of-line) + (newline-and-indent))) + +(defun cdm--insert-raw-node (name modifiers content &optional goto) + (cdm--not-so-smart-move) + (insert "\\node(" name ")[" modifiers "]{" content "};") + (when goto (backward-char goto))) + +(defun cdm--insert-raw-path (name starting ending modifiers content &optional goto) + (cdm--not-so-smart-move) + (insert "\\path(" starting ") -- (" ending ")node(" + name ")[auto=false" modifiers "]{" content "};") + (when goto (backward-char goto))) + +(defun cdm--next-name () + (when (cdm--get-nodes) + (let* ((last-name (cdar cdm--node-list)) + (last-number (if last-name (string-to-number last-name) 0))) + (unless (and (= 0 last-number) + last-name) + (number-to-string (+ 1 last-number)))))) + +(defun cdm-insert-node (&optional node-name) + (interactive) + (let* ((name (or node-name + (read-string "New node name: " (cdm--next-name)))) + (position (cdm--complete-position)) + (rel-to (when position (cdm--complete-nodes position))) + (midway-other (when (and position + (string-prefix-p "midway" position)) + (cdm--complete-nodes "midway, ending=")))) + (if midway-other + (cdm--insert-raw-path name rel-to midway-other ",midway" "$$" 3) + (cdm--insert-raw-node name (if rel-to (concat position rel-to) "") "$$" 3)))) + +(defun cdm--string-good-p (str) + (and str (string-or-null-p str) (not (string-blank-p str)))) + +(defun cdm--insert-arrow-tex (from-node to-node type &optional label-props draw-style misc) + (end-of-line) + (newline-and-indent) + (insert "\\draw[" type + (if (cdm--string-good-p draw-style) + (concat "," draw-style) "") + "]" + (if (cdm--string-good-p misc) misc "") + "(" from-node ")to" + (if label-props + (concat " node[" label-props "]{$$}") "") + "(" to-node ");") + (when label-props (search-backward "$}"))) + +(defun cdm--insert-arrow-square-tex (from-node to-node type &optional label-props extra) + (cdm--insert-arrow-tex "\\p2" "\\p3" type + (unless (string-equal type "d") + (concat label-props "inner sep=0,swap")) + extra + (concat "let \\p1 = ($(" + from-node ")!.5!(" + to-node ")$), \\p2 = ($(\\p1)!" cdm-cell-len "!(" + from-node ")$), \\p3 =($(\\p1)!" cdm-cell-len "!(" + to-node ")$) in "))) + +(defun cdm--insert-parallel-arrows (from-node to-node &optional labelled) + (let* ((prompt "Select parallel arrow directionality: ") + (ty (if cdm--use-helm (helm :sources cdm--parr-dir-helm-source + :prompt prompt + :buffer "*helm-parr*") + (cdm--ivy-complete prompt cdm-parr-dir-list)))) + (when ty + (let ((dirs (case ty + (0 '(".east" . ".west" )) + (1 '(".west" . ".east" )) + (2 '(".south". ".north")) + (3 '(".north". ".south")))) + (pre-str (concat "[" (if (< ty 2) "y" "x") "shift=")) + (plus "+0.6ex]") + (minus "-0.6ex]") + (swaps (if (or (= ty 0) (= ty 2)) '("" . "swap") '("swap" . "")))) + (cdm--insert-arrow-tex (concat pre-str plus from-node (car dirs)) + (concat pre-str plus to-node (cdr dirs)) + "a" (when labelled (car swaps))) + (cdm--insert-arrow-tex (concat pre-str minus from-node (car dirs)) + (concat pre-str minus to-node (cdr dirs)) + "a" (when labelled (cdr swaps))))))) + +(defmacro let*-unless-null (list &rest body) + (if list + (let* ((curr (pop list)) + (dest (car curr)) + (expr (cadr curr))) + `(let ((,dest ,expr)) + (when ,dest (let*-unless-null ,list ,@body)))) + `(progn ,@body))) + +(defun cdm-insert-arrow (extra-props) + (interactive "P") + (when (cdm--get-nodes) + (unless cdm--node-list + (error "Cannot insert an arrow, no nodes found.")) + (end-of-line) + ;; TODO: recast i.t.o let*-unless-null + (let ((type (cdm--complete-arr-type))) + (when type + (let* ((par (string-equal "p" type)) + (extra (when (and (not par) extra-props) + (read-string "Extra properties: "))) + (from-node (cdm--complete-nodes "From: ")) + (to-node (cdm--complete-nodes "To: ")) + (labelled (unless (string-suffix-p "d" type) + (char-equal ?\C-m (read-char "Labelled (Return = yes)?")))) + (label-props (when (and (not par) labelled) + (read-string "Label properties: ")))) + (cond + (par (cdm--insert-parallel-arrows from-node to-node labelled)) + ((string-prefix-p "s" type) + (cdm--insert-arrow-square-tex from-node to-node + (string-remove-prefix "s" type) + label-props + extra)) + (t (cdm--insert-arrow-tex from-node to-node type label-props extra)))))))) + + +(defun cdm-square-reset () + (interactive) + (setq cdm--square-progress 0 + cdm--square-nodes nil) + (message "Square progress reset.")) + +;; TODO: Orientation? This is broken with swaps if you change orientation... +(defun cdm--prompt-insert-arrow-square (node-1 node-2 swap) + (when (cdm--get-nodes) + (let (r d) + (dolist (n cdm--node-list) + (when (or (string-equal node-1 (cdr n)) + (string-equal node-2 (cdr n))) + (add-to-list 'r n))) + (setq cdm--node-list r) + (setq d (cdm--complete-nodes "Domain for arrow: ")) + (if (string-equal d node-1) + (cdm--insert-arrow-tex d node-2 "a" swap) + (cdm--insert-arrow-tex d node-1 "a" swap))))) + +(defun cdm-insert-square () + (interactive) + (let ((p cdm--square-progress) + (n cdm--square-nodes) + (s (cdm--next-name))) + ;; Insert stuff + (cond + ((= p 7) (cdm--prompt-insert-arrow-square (nth 3 n) (nth 1 n) "swap")) + ((= p 6) (cdm--prompt-insert-arrow-square (nth 2 n) (nth 0 n) "")) + ((= p 5) (cdm--prompt-insert-arrow-square (nth 3 n) (nth 2 n) "")) + ((= p 4) (cdm--prompt-insert-arrow-square (nth 1 n) (nth 0 n) "swap")) + ((= p 3) (cdm--insert-raw-node s (concat "below of=" (cadr n)) "$$" 3)) + ((= p 2) (cdm--insert-raw-node s (concat "below of=" (car n)) "$$" 3)) + ((= p 1) (cdm--insert-raw-node s (concat "right of=" (car n)) "$$" 3)) + ((= p 0) (cdm-insert-node s))) + ;; Adjust state + (if (= p 7) (cdm-square-reset) + (setq cdm--square-progress (1+ cdm--square-progress)) + (when (and (<= p 3) (>= p 0)) + (add-to-list 'cdm--square-nodes s t))))) + +(defun cdm--init-helm () + (setq cdm--pos-helm-source (helm-build-sync-source "position" + :candidates 'cdm--pos-list + :fuzzy-match t + :nomark t) + cdm--arr-type-helm-source (helm-build-sync-source "arrow-type" + :candidates 'cdm-arr-type-list + :fuzzy-match t + :nomark t) + cdm--node-helm-source (helm-build-sync-source "nodes" + :candidates 'cdm--node-list + :fuzzy-match t + :nomark t + :multiline t) + cdm--parr-dir-helm-source (helm-build-sync-source "parr-dir" + :candidates 'cdm-parr-dir-list + :fuzzy-match t + :nomark t))) + +(defun cdm--init () + (require 'subr-x) + (require 'cl) + (if cdm--use-helm (cdm--init-helm)) ) + +(define-minor-mode cdm-mode + "Minor mode to help with commutative diagrams" + :lighter " CDM" :keymap cdm-mode-map + (cdm--init)) + +(provide 'cdm-mode) diff --git a/emacs/themes/acme-theme.el b/emacs/themes/acme-theme.el new file mode 100644 index 0000000..ad5baab --- /dev/null +++ b/emacs/themes/acme-theme.el @@ -0,0 +1,148 @@ +;; acme-theme.el -- A theme inspired by the classic colours of the ACME editor. +;; Copyright (C) 2014 , Tslil Clingman + +;; Version: 0.1 +;; Package-Requires: ((emacs "24")) + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;; This file is not part of Emacs. + +(deftheme acme + "A theme inspired by the classic colours of the ACME editor.") + +(let ((bg-yellow "#FFFFCA") + (bg-blue "#DAEFEF") + + (lazy "#D1D1C0") + (mud "#99994C") + + (yellow "#EAEA9E") + (blue "#268BD2") + (red "#AA0000") + (purple "#8888CC") + (green "#508050") + (link "#D05000")) + (custom-theme-set-faces + 'acme + + `(default ((t (:background ,bg-yellow :foreground "black")))) + '(cursor ((t (:background "black")))) + '(escape-glyph ((t (:foreground "black")))) + '(minibuffer-prompt ((t (:foreground "black" :weight bold)))) + '(highlight ((t (:foreground "grey30")))) + `(region ((t (:background ,yellow :foreground "black")))) + `(secondary-selection ((t (:background ,red)))) + '(trailing-whitespace ((t (:background "grey")))) + + '(font-lock-builtin-face ((t (:foreground "black" :slant normal)))) + '(font-lock-comment-delimiter-face ((default (:inherit (font-lock-comment-face))))) + '(font-lock-comment-face ((t (:foreground "black" :slant italic + :font "Hack")))) + '(font-lock-constant-face ((t (:foreground "black")))) + '(font-lock-doc-face ((t (:foreground "black" :slant italic + :font "Hack")))) + '(font-lock-function-name-face ((t (:foreground "black" :weight bold)))) + '(font-lock-keyword-face ((t (:foreground "black" :weight bold)))) + '(font-lock-negation-char-face ((t (:foreground "black")))) + '(font-lock-preprocessor-face ((t (:inherit (font-lock-builtin-face))))) + '(font-lock-string-face ((t (:foreground "black")))) + '(font-lock-type-face ((t (:foreground "black" :underline t)))) + '(font-lock-variable-name-face ((t (:foreground "black")))) + '(font-lock-warning-face ((t (:foreground "black")))) + + '(button ((t (:inherit (link))))) + `(link ((t (:underline (:color foreground-color :style line) + :foreground ,link)))) + '(link-visited ((default (:inherit (link))) + (((class color) (background light)) (:foreground "magenta4")) + (((class color) (background dark)) (:foreground "violet")))) + + `(fringe ((t (:background ,bg-yellow :foreground "black")))) + '(header-line ((default (:inherit (mode-line))) (((type tty)) (:underline (:color foreground-color :style line) :inverse-video nil)) (((class color grayscale) (background light)) (:box nil :foreground "grey20" :background "grey90")) (((class color grayscale) (background dark)) (:box nil :foreground "grey90" :background "grey20")) (((class mono) (background light)) (:underline (:color foreground-color :style line) :box nil :inverse-video nil :foreground "black" :background "white")) (((class mono) (background dark)) (:underline (:color foreground-color :style line) :box nil :inverse-video nil :foreground "white" :background "black")))) + '(tooltip ((((class color)) + (:inherit (variable-pitch) :foreground "black" :background "lightyellow")) + (t (:inherit (variable-pitch))))) + + `(mode-line ((t (:background ,bg-blue :foreground "black" :box 2)))) + '(mode-line-buffer-id ((t (:foreground "black" :weight bold)))) + '(mode-line-emphasis ((t (:foreground "black")))) + '(mode-line-highlight ((t (:weight bold :box nil :foreground "black")))) + `(mode-line-inactive ((t (:background ,bg-blue :foreground "#393939" :weight normal :box t)))) + + `(isearch ((t (:background ,yellow)))) + `(isearch-fail ((t (:background ,red)))) + `(lazy-highlight ((t (:foreground "black" :weight bold :background ,bg-blue)))) + `(match ((t (:background ,yellow)))) + '(next-error ((t (:inherit (region))))) + '(query-replace ((t (:inherit (isearch))))) + '(table-cell ((t (:inherit (default))))) + + `(show-paren-match ((t (:weight bold :background ,purple)))) + `(show-paren-mismatch ((t (:background ,red)))) + `(sp-show-pair-match-face ((t (:weight bold :background ,purple)))) + `(sp-show-pair-mismatch-face ((t (:background ,red)))) + + '(ivy-modified-buffer ((t (:underline t :inherit (default))))) + + `(company-echo-common ((t (:foreground "black" :background ,bg-blue :weight bold)))) + `(company-scrollbar-bg ((t (:background "grey")))) + `(company-scrollbar-fg ((t (:background ,green)))) + `(company-tooltip ((t (:foreground "black" :background ,bg-blue)))) + `(company-tooltip-search ((t (:foreground "black" :background ,yellow)))) + `(company-tooltip-annotation ((t (:foreground "black" :background "grey" :slant italic)))) + `(company-tooltip-common ((t (:foreground "black" :weight bold)))) + `(company-tooltip-common-selection ((t (:foreground "black" :background ,yellow :weight bold)))) + `(company-tooltip-selection ((t (:background ,yellow :foreground "black")))) + + '(font-latex-bold-face ((t (:weight bold)))) + '(font-latex-italic-face ((t (:slant italic)))) + `(font-latex-math-face ((t (:foreground "black" + :box (:line-width 2 :color ,lazy + :style pressed-button) + :foreground "black")))) + '(font-latex-string-face ((t (:foreground "black")))) + '(font-latex-verbatim-face ((t (:foreground "black")))) + '(font-latex-sedate-face ((t (:foreground "black")))) + '(font-latex-warning-face ((t (:foreground "black")))) + '(font-latex-sectioning-5-face ((t (:foreground "black" :weight normal)))) + + `(shm-current-face ((t (:background ,bg-blue)))) + '(shm-quarantine-face ((t nil))) + + `(avy-goto-char-timer-face ((t (:background ,bg-blue)))) + `(avy-lead-face ((t (:background ,yellow)))) + `(avy-lead-face-0 ((t (:background ,green)))) + `(avy-lead-face-1 ((t (:background ,red)))) + `(avy-lead-face-2 ((t (:background ,purple)))) + + '(company-coq-comment-h1-face ((t (:height 1.8 :slant italic + :inherit (default))))) + '(company-coq-comment-h2-face ((t (:height 1.4 :slant italic + :inherit (default))))) + '(company-coq-comment-h3-face ((t (:height 1.2 :slant italic + :inherit (default))))) + '(company-coq-coqdoc-h1-face ((t (:weight bold :inverse-video t)))) + '(company-coq-coqdoc-h2-face ((t (:weight bold :underline t)))) + '(company-coq-coqdoc-h3-face ((t (:underline t)))) + '(company-coq-coqdoc-h4-face ((t (:inherit (default))))) + + '(company-coq-features/code-folding-bullet-face + ((t (:foreground "black" :weight bold)))) + + `(coq-solve-tactics-face ((t (:foreground "black" :underline t)))) + `(proof-tactics-name-face ((t (:foreground "black" :weight bold)))) + )) + +(provide-theme 'acme) diff --git a/emacs/themes/soothe-theme.el b/emacs/themes/soothe-theme.el new file mode 100644 index 0000000..d4be92a --- /dev/null +++ b/emacs/themes/soothe-theme.el @@ -0,0 +1,856 @@ +;;; soothe-theme.el --- a dark colorful theme for Emacs24. +;;; Author: Jason Milkins <jasonm23@gmail.com> +;;; Changes by Tslil Clingman <tslil.clingman@gmail.com> +;;; Url: https://github.com/jasonm23/emacs-soothe-theme +;; Version: 20141104.2213 +;;; X-Original-Version: 0.3.19 +;;; Package-Requires: ((emacs "24.1")) +;;; +;;; Change Log: +;;; 0.3.19 : Filled in some helm stuff and added company tooltips +;;; 0.3.18 : Added stubs for helm and js3 +;;; 0.3.17 : Added support for which-func face (milkypostman) +;;; 0.3.16 : Fixed flymake colors; also added Package Requres Emacs 24 by Steve Purcell +;;; 0.3.15 : update by Sabof; Magit diff settings migrated over to diff +;;; : (magit will inherit from diff) +;;; 0.3.14 : Changed main-line colors and style, added powerline colors +;;; 0.3.13 : Different colors for hl-line and region +;;; 0.3.12 : Fixed issue #4 - region bg contrast too low. +;;; 0.3.11 : Added rainbow-mode switch for editing +;;; 0.3.10 : Themed Mode line emphasis +;;; 0.3.9 : Slightly improved dired support +;;; 0.3.8 : Added support for isearch +;;; : Additional support for mode-line +;;; : modified main-line colors +;;; : modified link / link-visited +;;; : added tooltip face +;;; 0.3.7 : extended magit support +;;; : added iedit support +;;; : added CUA support +;;; : added AutoComplete support +;;; : changed rainbow delimiters for better visibility +;;; 0.3.6 : beginning work on additional mode support +;;; : added git-gutter +;;; : added dropdown-list +;;; : added stubs/extention lists for gnus, rcirc, message +;;; : ido + magit (more), +;;; : ac, compilation, +;;; : dired, diff, iedit, +;;; : cua, change, Man, woman, +;;; : commint, info, custom, popup +;;; : widget, whitespace, w3m, more... +;;; 0.3.5 : bugfix +;;; 0.3.4 : added support for main-line and flymake +;;; 0.3.0 : cleaned up for elpa +;;; 0.1.0 : initial version +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, version 3 of the License. +;;; +;;; This file is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Emacs. +;;; +;;; This file is not a part of Emacs +;;; +;;; Commentary: An amalgam of muted color tones and highlighted +;;; backgrounds. Builtin support for rainbow-delimiters, org-mode, +;;; whitespace-mode, ECB, flyspell, ido, linum, highlight +;;; indentation, show-paren-mode, further mode support to come. + +(unless (>= 24 emacs-major-version) + (error "soothe-theme requires Emacs 24 or later.")) + +(deftheme soothe + "soothe-theme An amalgam of muted color tones and highlighted + backgrounds. Has builtin support for rainbow-delimiters, + org-mode, whitespace-mode, ECB, flyspell, ido, linum, + highlight indentation, show-paren-mode, further mode support + to come.") + +(let ( + ;; Palette + (foam "#E0E4CC") + (snow-code "#ECE5CE") + (crem "#F4EAD5") + (dirty-crem "#DBD2BF") + (dirty-crem-bg "#2B2A26") + (gray-1 "#aaaaaa") + (gray-2 "#828282") + (gray-3 "#333333") + (gray-4 "#2a2a2a") + (gray-5 "#252525") + (gray-6 "#202020") + (gray-1bg "#0a0a0a") + (gray-2bg "#111111") + (gray-3bg "#141414") + (gray-4bg "#171717") + (gray-5bg "#1a1a1a") + (gray-6bg "#1e1e1e") + (red-1 "#b13120") + (red-2 "#a23f1e") + (red-3 "#AA1100") + (red-4 "#660000") + (red-1bg "#1D1515") + (red-2bg "#251c1e") + (brown-1 "#8f621d") + (brown-1bg "#2a1f1f") + (orange-1 "#d94a05") + (orange-2 "#FF5211") + (orange-1bg "#1F1710") + (yellow-1 "#ceae3e") + (yellow-1bg "#18140C") + (green-1 "#719f34") + (green-2 "#3e8f75") + (green-3 "#839F5E") + (green-1bg "#1a2321") + (green-2bg "#1a2321") + (turquoise-1 "#01535F") + (turquoise-2 "#073E46") + (turquoise-1bg "#04181C") + (turquoise-2bg "#031316") + (blue-1 "#7c9fc9") + (blue-2 "#317598") + (blue-3 "#009090") + (blue-4 "#364e7a") + (blue-1bg "#1e252f") + (blue-2bg "#1b333e") + (blue-3bg "#132228") + (blue-4bg "#172028") + (purple-1 "#7868b5") + (purple-2 "#8A7FB5") + (purple-3 "#483E6C") + (purple-4 "#342B58") + (purple-1bg "#1D1B25") + (purple-2bg "#302948") + (purple-3bg "#241F36") + (selection "#11253a") + (hl-line "#11252a") + ;; (foreground "#E4DAC5") + ;; (background "#110F13") + ;; (background-dark "#0F0D11") + ;; (alt-background "#111013") + (foreground "grey70") + (background "#131313") + (background-dark "black") + (alt-background "#0B0B0E") + + ;; Somewhat stolen from Gotham + (base0 "#0c1014") + (base1 "#11151c") + (base2 "#091f2e") + (base3 "#0a3749") + (base4 "#245361") + (base5 "#599cab") + (base6 "grey70") + (base7 "grey80") + + ) + + ;; Terminal colors - set background to black. + ;; TODO: Use defface method (class color) (min-colors ...) + + (unless (window-system) + (setq background "#000000") + (setq background-dark "#000000") + (setq alt-background "#000000") + (setq dirty-crem-bg "#000000") + (setq gray-1bg "#000000") + (setq gray-2bg "#000000") + (setq gray-3bg "#000000") + (setq gray-4bg "#000000") + (setq gray-5bg "#000000") + (setq gray-6bg "#000000") + (setq red-1bg "#000000") + (setq red-2bg "#000000") + (setq brown-1bg "#000000") + (setq orange-1bg "#000000") + (setq yellow-1bg "#000000") + (setq green-1bg "#000000") + (setq green-2bg "#000000") + (setq turquoise-1bg "#000000") + (setq turquoise-2bg "#000000") + (setq blue-1bg "#000000") + (setq blue-2bg "#000000") + (setq blue-3bg "#000000") + (setq blue-4bg "#000000") + (setq purple-1bg "#000000") + (setq purple-2bg "#000000") + (setq purple-3bg "#000000") + ) + + (custom-theme-set-faces + 'soothe + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Basics + `(default ((t (:foreground ,foreground :background ,background )))) + `(cursor ((t ( :background ,orange-1 )))) + `(region ((t (:foreground nil :background ,selection )))) + `(highlight ((t (:foreground ,blue-3 :background ,blue-3bg )))) + `(hl-line ((t ( :background ,hl-line )))) + `(minibuffer-prompt ((t (:foreground ,red-1 :background ,red-1bg )))) + `(escape-glyph ((t (:foreground ,red-1 :background ,purple-1bg )))) + `(error ((t (:foreground ,red-1 :background ,red-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Font-lock stuff + `(font-lock-builtin-face ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(font-lock-constant-face ((t (:foreground ,blue-1 :background ,gray-1bg )))) + `(font-lock-comment-face ((t (:foreground ,turquoise-2 :background ,alt-background :italic t )))) + `(font-lock-comment-delimiter-face ((t (:foreground ,turquoise-1 :background ,alt-background :italic t )))) + `(font-lock-doc-face ((t (:foreground ,blue-3 :background ,gray-1bg )))) + `(font-lock-doc-string-face ((t (:foreground ,blue-3 :background ,gray-1bg )))) + `(font-lock-function-name-face ((t (:foreground ,red-1 :background ,red-1bg )))) + `(font-lock-keyword-face ((t (:foreground ,orange-2 :background ,orange-1bg )))) + `(font-lock-negation-char-face ((t (:foreground ,yellow-1 :background ,yellow-1bg )))) + `(font-lock-preprocessor-face ((t (:foreground ,green-1 :background ,green-1bg )))) + `(font-lock-string-face ((t (:foreground ,blue-3 :background ,turquoise-2bg )))) + `(font-lock-type-face ((t (:foreground ,blue-1 :background ,blue-1bg :bold nil )))) + `(font-lock-variable-name-face ((t (:foreground ,green-1 :background ,green-1bg )))) + `(font-lock-warning-face ((t (:foreground ,red-2 :background ,red-2bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; UI related + `(link ((t (:foreground ,blue-1 :background ,blue-1bg )))) + `(link-visited ((t (:foreground ,blue-3 :background ,blue-4bg )))) + `(fringe ((t ( :background ,gray-3bg )))) + `(vertical-border ((t (:foreground ,gray-4 :background ,background )))) + ;; `(mode-line ((t (:foreground ,gray-2 :background ,gray-3bg :box nil :height 120 )))) + ;; `(mode-line-inactive ((t (:foreground ,gray-5 :background ,gray-2bg :inherit mode-line )))) + ;; `(mode-line-highlight ((t (:foreground ,green-1)))) + ;; `(mode-line-buffer-id ((t (:foreground ,orange-1)))) + `(mode-line-emphasis ((t (:bold)))) + `(which-func ((t (:foreground ,blue-1)))) + + `(menu ((t (:background ,base3 :foreground ,base6)))) + `(header-line ((t (:foreground ,base5 :background ,base2 :weight bold)))) + `(mode-line ((t (:foreground ,base5 :background ,base2 :box nil)))) + `(mode-line-inactive ((t (:foreground ,base4 :background ,base1 :box nil)))) + `(mode-line-highlight ((t (:foreground ,base6)))) + `(mode-line-buffer-id ((t (:weight bold)))) + + ;;`(minibuffer-prompt ((t (:foreground ,orange-1 :background ,orange-1bg :box t)))) + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; isearch + `(isearch ((t (:foreground ,orange-1 :background ,blue-2bg :underline t)))) + `(isearch-fail ((t (:foreground ,red-4 :weight bold)))) + `(lazy-highlight ((t (:foreground ,green-1 :background ,green-1bg :underline t)))) + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Compilation mode + ;; `(compilation-column-number ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-error ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-info ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-line-number ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-mode-line-exit ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-mode-line-fail ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-mode-line-run ((t (:foreground ,foam :background ,background )))) + ;; `(compilation-warning ((t (:foreground ,foam :background ,background )))) + ;; `(completions-annotations ((t (:foreground ,foam :background ,background )))) + ;; `(completions-common-part ((t (:foreground ,foam :background ,background )))) + ;; `(completions-first-difference ((t (:foreground ,foam :background ,background )))) + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Auto Complete + ;; + `(ac-selection-face ((t (:foreground ,dirty-crem :background ,dirty-crem-bg )))) + `(ac-candidate-face ((t (:foreground ,background :background ,dirty-crem )))) + `(ac-yasnippet-candidate-face ((t (:foreground ,background :background ,green-2 )))) + `(ac-yasnippet-selection-face ((t (:foreground ,foam :background ,dirty-crem-bg )))) + `(ac-gtags-candidate-face ((t (:foreground ,background :background ,purple-3 )))) + `(ac-gtags-selection-face ((t (:foreground ,dirty-crem :background ,dirty-crem-bg )))) + `(ac-candidate-mouse-face ((t (:foreground ,foam :background ,turquoise-1 )))) + `(ac-completion-face ((t (:foreground ,snow-code :background ,purple-3bg :underline t )))) + ;; used by AC + `(popup-tip-face ((t (:foreground ,dirty-crem :background ,dirty-crem-bg )))) + `(tooltip ((t (:foreground ,dirty-crem-bg :background ,dirty-crem :height 110 )))) + + ;;; popup-face + ;;; popup-isearch-match + ;;; popup-menu-face + ;;; popup-menu-mouse-face + ;;; popup-menu-selection-face + ;;; popup-menu-summary-face + ;;; popup-scroll-bar-background-face + ;;; popup-scroll-bar-foreground-face + ;;; popup-summary-face + + ;; ------------------------------------------------------------------------------------------ + ;; Company + `(company-tooltip ((t (:foreground ,blue-1 :background ,blue-4bg)))) + `(company-tooltip-common-selection ((t (:foreground ,orange-1 :background ,blue-2bg)))) + `(company-tooltip-selection ((t (:foreground ,orange-1 :background ,blue-2bg)))) + `(company-tooltip-search ((t (:foreground ,green-1 :background ,green-1bg)))) + `(company-scrollbar-bg ((t (:background ,blue-1bg)))) + `(company-scrollbar-fg ((t (:background ,turquoise-1)))) + `(company-tooltip-common ((t (:foreground ,red-1 :background ,blue-4bg)))) + `(company-tooltip-annotation ((t (:foreground ,foam :background ,blue-4bg)))) + + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Dired + `(dired-directory ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(dired-flagged ((t (:foreground ,red-1 :background ,orange-1bg )))) + `(dired-header ((t (:foreground ,orange-1 :background ,background )))) + `(dired-ignored ((t (:foreground ,turquoise-1 :background ,background )))) + `(dired-mark ((t (:foreground ,orange-2 :background ,background )))) + `(dired-marked ((t (:foreground ,green-3 :background ,orange-1bg )))) + `(dired-perm-write ((t (:foreground ,foam :background ,background )))) + `(dired-symlink ((t (:foreground ,blue-1 :background ,blue-4bg )))) + `(dired-warning ((t (:foreground ,red-1 :background ,red-2bg )))) + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Gnus + + ;; gnus-group-mail-1 + ;; gnus-group-mail-1-empty + ;; gnus-group-mail-2 + ;; gnus-group-mail-2-empty + ;; gnus-group-mail-3 + ;; gnus-group-mail-3-empty + ;; gnus-group-mail-low + ;; gnus-group-mail-low-empty + ;; gnus-group-news-1 + ;; gnus-group-news-1-empty + ;; gnus-group-news-2 + ;; gnus-group-news-2-empty + ;; gnus-group-news-3 + ;; gnus-group-news-3-empty + ;; gnus-group-news-4 + ;; gnus-group-news-4-empty + ;; gnus-group-news-5 + ;; gnus-group-news-5-empty + ;; gnus-group-news-6 + ;; gnus-group-news-6-empty + ;; gnus-group-news-low + ;; gnus-group-news-low-empty + ;; gnus-splash + ;; gnus-summary-cancelled + ;; gnus-summary-high-ancient + ;; gnus-summary-high-read + ;; gnus-summary-high-ticked + ;; gnus-summary-high-undownloaded + ;; gnus-summary-high-unread + ;; gnus-summary-low-ancient + ;; gnus-summary-low-read + ;; gnus-summary-low-ticked + ;; gnus-summary-low-undownloaded + ;; gnus-summary-low-unread + ;; gnus-summary-normal-ancient + ;; gnus-summary-normal-read + ;; gnus-summary-normal-ticked + ;; gnus-summary-normal-undownloaded + ;; gnus-summary-normal-unread + ;; gnus-summary-selected + + ;; ------------------------------------------------------------------------------------------ + ;; helm + `(helm-M-x-key ((t (:foreground ,red-1 :background ,red-1bg :underline t)))) + `(helm-candidate-number ((t (:foreground ,blue-1 :background ,blue-1bg)))) + `(helm-ff-directory ((t (:foreground ,blue-3 :background nil)))) + `(helm-ff-executable ((t (:foreground ,green-2 :background nil)))) + `(helm-ff-file ((t (:foreground ,purple-1 :background nil)))) + `(helm-ff-invalid-symlink ((t (:foreground ,red-1 :background nil)))) + `(helm-ff-prefix ((t (:foreground ,turquoise-1 :background nil)))) + `(helm-ff-symlink ((t (:foreground ,orange-1 :background nil)))) + `(helm-match ((t (:foreground ,green-1 :background ,green-1bg)))) + `(helm-selection ((t (:foreground ,orange-2 :background ,blue-4bg :weight bold)))) + `(helm-source-header ((t (:foreground ,red-1 :background ,red-1bg :box t)))) + `(helm-buffer-file ((t (:foreground ,purple-1 :background nil)))) + `(helm-buffer-directory ((t (:foreground ,blue-3 :background nil)))) + `(helm-buffer-not-saved ((t (:foreground ,red-1 :background nil)))) + `(helm-buffer-process ((t (:foreground ,orange-1 :background nil)))) + `(helm-buffer-size ((t (:foreground "salmon" :background nil)))) + ;; helm-action + ;; helm-bookmark-addressbook + ;; helm-bookmark-directory + ;; helm-bookmark-file + ;; helm-bookmark-gnus + ;; helm-bookmark-info + ;; helm-bookmark-man + ;; helm-bookmark-w3m + ;; helm-buffer-saved-out + ;; helm-buffer-size + ;; helm-grep-cmd-line + ;; helm-grep-file + ;; helm-grep-finish + ;; helm-grep-lineno + ;; helm-grep-match + ;; helm-grep-running + ;; helm-header + ;; helm-helper + ;; helm-history-deleted + ;; helm-history-remote + ;; helm-moccur-buffer + ;; helm-selection-line + ;; helm-separator + ;; helm-visible-mark + + ;; ------------------------------------------------------------------------------------------ + ;; JS3 mode + + ;; js3-error-face + ;; js3-external-variable-face + ;; js3-function-param-face + ;; js3-instance-member-face + ;; js3-jsdoc-html-tag-delimiter-face + ;; js3-jsdoc-html-tag-name-face + ;; js3-jsdoc-tag-face + ;; js3-jsdoc-type-face + ;; js3-jsdoc-value-face + ;; js3-magic-paren-face + ;; js3-private-function-call-face + ;; js3-private-member-face + ;; js3-warning-face + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Diff + `(diff-added ((t (:foreground ,green-3 :background ,green-2bg )))) + `(diff-removed ((t (:foreground ,red-1 :background ,red-1bg )))) + `(diff-file-header ((t (:foreground ,orange-1 :background ,orange-1bg )))) + `(diff-context ((t (:foreground ,foam )))) + `(diff-hunk-header ((t (:foreground ,purple-1 :background ,purple-1bg )))) + ;; diff-changed + ;; diff-function + ;; diff-header + ;; diff-index + ;; diff-indicator-added + ;; diff-indicator-changed + ;; diff-indicator-removed + ;; diff-nonexistent + ;; diff-refine-added + ;; diff-refine-change + ;; diff-refine-removed + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; Linum + `(linum ((t (:foreground ,gray-3 :background ,alt-background :height 120 )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; show-paren-mode + `(show-paren-match ((t (:foreground ,gray-2 :background ,gray-4 )))) + `(Show-paren-mismatch ((t (:foreground ,orange-1 :background ,red-2bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; ido + `(ido-only-match ((t (:foreground ,green-1 :background ,green-1bg )))) + `(ido-subdir ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(ido-first-match ((t (:foreground ,orange-1 :background ,orange-1bg )))) + `(ido-incomplete-regexp ((t (:foreground ,red-1 :background ,orange-1bg )))) + `(ido-indicator ((t (:foreground ,turquoise-1 :background ,turquoise-1bg )))) + `(ido-virtual ((t (:foreground ,green-3 :background ,turquoise-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; whitespace-mode + `(whitespace-empty ((t (:foreground ,yellow-1 :background ,turquoise-2bg )))) + `(whitespace-hspace ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-indentation ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-line ((t (:foreground ,orange-1 :background ,turquoise-2bg )))) + `(whitespace-newline ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-space ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-space-after-tab ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-tab ((t (:foreground ,turquoise-2 :background ,turquoise-2bg )))) + `(whitespace-trailing ((t (:foreground ,red-1 :background ,turquoise-2bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; flyspell-mode + `(flyspell-incorrect ((t (:underline ,red-2 )))) + `(flyspell-duplicate ((t (:underline ,green-2 )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; flymake-mode + `(flymake-errline ((t (:underline ,red-2 :background nil :inherit nil )))) + `(flymake-warnline ((t (:underline ,green-2 :background nil :inherit nil )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; dropdown-list + `(dropdown-list-selection-face ((t (:foreground ,foam :background ,purple-1bg )))) + `(dropdown-list-face ((t (:foreground ,background :background ,foam )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; git gutter mode + `(git-gutter:added ((t (:foreground ,green-1 :background ,green-2bg )))) + `(git-gutter:deleted ((t (:foreground ,red-1 :background ,red-1bg )))) + `(git-gutter:modified ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(git-gutter:unchanged ((t ( :background ,yellow-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; magit + `(magit-item-highlight ((t ( :background ,purple-3bg )))) + `(magit-branch ((t (:foreground ,green-2 :background ,green-2bg )))) + `(magit-whitespace-warning-face ((t (:foreground ,red-3 :background ,red-1bg )))) + `(magit-section-title ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(magit-header ((t (:foreground ,orange-1 :background ,orange-1bg )))) + `(magit-item-mark ((t (:foreground ,green-1 )))) + `(magit-diff-merge-proposed ((t (:foreground ,foam )))) + `(magit-diff-merge-current ((t (:foreground ,blue-1 )))) + `(magit-diff-merge-separator ((t (:foreground ,blue-2 )))) + `(magit-log-author ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(magit-log-graph ((t (:foreground ,blue-2 :background ,blue-2bg )))) + `(magit-log-head-label-bisect-good ((t (:foreground ,turquoise-1 :background ,turquoise-1bg )))) + `(magit-log-head-label-local ((t (:foreground ,foam :background ,turquoise-1bg )))) + `(magit-log-head-label-remote ((t (:foreground ,foam :background ,purple-2bg )))) + `(magit-log-message ((t (:foreground ,dirty-crem :background ,background )))) + `(magit-log-date ((t (:foreground ,blue-4 :background ,background )))) + `(magit-log-head-label-bisect-bad ((t (:foreground ,red-1 :background ,red-1bg )))) + `(magit-log-head-label-default ((t (:foreground ,foam :background ,turquoise-1bg )))) + `(magit-log-head-label-patches ((t (:foreground ,blue-2 :background ,blue-1bg )))) + `(magit-log-head-label-tags ((t (:foreground ,orange-1 :background ,orange-1bg )))) + `(magit-log-sha1 ((t (:foreground ,turquoise-1 :background ,turquoise-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; IEdit + `(iedit-occurrence ((t (:foreground ,green-3 :background ,orange-1bg )))) + `(iedit-read-only-occurrence ((t (:foreground ,red-1 :background ,orange-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; highlight-indentation-mode + `(highlight-indentation-face ((t ( :background ,background-dark )))) + `(highlight-indentation-current-column-face ((t ( :background ,gray-5 )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; ECB + `(ecb-default-general-face ((t (:foreground ,gray-1 :background ,gray-1bg )))) + `(ecb-default-highlight-face ((t (:foreground ,red-1 :background ,red-1bg )))) + `(ecb-method-face ((t (:foreground ,red-1 :background ,red-1bg )))) + `(ecb-tag-header-face ((t ( :background ,blue-2bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; org-mode + `(org-date ((t (:foreground ,purple-1 :background ,purple-1bg )))) + `(org-done ((t (:foreground ,green-1 :background ,green-1bg )))) + `(org-hide ((t (:foreground ,gray-3 :background ,gray-1bg )))) + `(org-link ((t (:foreground ,blue-1 :background ,blue-1bg )))) + `(org-todo ((t (:foreground ,red-1 :background ,red-1bg )))) + ;;----------------------------------------------------------------------------------------------------------------------- + ;; cua-mode + `(cua-global-mark ((t(:foreground ,foam :background ,turquoise-1 )))) + `(cua-rectangle ((t(:foreground ,foam :background ,purple-4 )))) + `(cua-rectangle-noselect ((t(:foreground ,foam :background ,orange-1 )))) + + ;;----------------------------------------------------------------------------------------------------------------------- + ;; smartparens + `(sp-show-pair-match-face ((t (:foreground nil :background "grey10")))) + ) + + (custom-theme-set-variables + 'soothe + + `(main-line-color1 ,gray-6bg) + `(main-line-color2 ,gray-2bg) + + `(main-line-separator-style + 'chamfer + ) + + `(powerline-color1 ,gray-6bg) + `(powerline-color2 ,gray-2bg) + + ;; `(Linum-format "%7i ") + `(fringe-mode 4) + + ;; Fill Column Indicator mode + `(fci-rule-color ,gray-6) + `(fci-rule-character-color ,gray-6) + + `(ansi-color-names-vector + ;; black, red, green, yellow, blue, magenta, cyan, white + [,background ,red-1 ,green-1 ,yellow-1 ,blue-1 ,purple-1 ,blue-3 ,foreground]) + `(ansi-term-color-vector + ;; black, red, green, yellow, blue, magenta, cyan, white + [unspecified ,background ,red-1 ,green-1 ,yellow-1 ,blue-1 ,purple-1 ,blue-3 ,foreground]) + ) + ) + +;; Rainbow delimiters +(defun soothe-rainbow-delim-set-face () + (set-face-attribute 'rainbow-delimiters-depth-1-face nil :foreground "#2B583D") + (set-face-attribute 'rainbow-delimiters-depth-2-face nil :foreground "#2B5858") + (set-face-attribute 'rainbow-delimiters-depth-3-face nil :foreground "#2B3C58") + (set-face-attribute 'rainbow-delimiters-depth-4-face nil :foreground "#342B58") + (set-face-attribute 'rainbow-delimiters-depth-5-face nil :foreground "#4F2B58") + (set-face-attribute 'rainbow-delimiters-depth-6-face nil :foreground "#582B45") + (set-face-attribute 'rainbow-delimiters-depth-7-face nil :foreground "#58462B") + (set-face-attribute 'rainbow-delimiters-depth-8-face nil :foreground "#4E582B") + (set-face-attribute 'rainbow-delimiters-depth-9-face nil :foreground "#33582B") + (set-face-attribute 'rainbow-delimiters-unmatched-face nil :foreground "#660000")) + + +(eval-after-load "rainbow-delimiters" '(soothe-rainbow-delim-set-face)) + +;;;###autoload +(when load-file-name + (add-to-list 'custom-theme-load-path + (file-name-as-directory (file-name-directory load-file-name)))) + +(provide-theme 'soothe) + +;;; List of themes to include... + +;;; Man-overstrike +;;; Man-reverse +;;; Man-underline + +;;; bold +;;; bold-italic +;;; border +;;; buffer-menu-buffer +;;; button + +;;; c-annotation-face + +;;; change-log-acknowledgment +;;; change-log-conditionals +;;; change-log-date +;;; change-log-email +;;; change-log-file +;;; change-log-function +;;; change-log-list +;;; change-log-name + +;;; comint-highlight-input +;;; comint-highlight-prompt + +;;; completions-annotations +;;; completions-common-part +;;; completions-first-difference + +;;; custom-button +;;; custom-button-mouse +;;; custom-button-pressed +;;; custom-button-pressed-unraised +;;; custom-button-unraised +;;; custom-changed +;;; custom-comment +;;; custom-comment-tag +;;; custom-documentation +;;; custom-face-tag +;;; custom-group-subtitle +;;; custom-group-tag +;;; custom-group-tag-1 +;;; custom-invalid +;;; custom-link +;;; custom-modified +;;; custom-rogue +;;; custom-saved +;;; custom-set +;;; custom-state +;;; custom-themed +;;; custom-variable-button +;;; custom-variable-tag +;;; custom-visibility + +;;; ecb-default-general-face +;;; ecb-default-highlight-face +;;; ecb-method-face +;;; ecb-tag-header-face + +;;; error +;;; escape-glyph +;;; file-name-shadow +;;; fixed-pitch + +;;; glyphless-char + +;;; header-line +;;; help-argument-name + +;;; hi-black-b +;;; hi-black-hb +;;; hi-blue +;;; hi-blue-b +;;; hi-green +;;; hi-green-b +;;; hi-pink +;;; hi-red-b +;;; hi-yellow + +;;; hideshowvis-hidable-face + +;;; highlight +;;; highlight-changes +;;; highlight-changes-delete +;;; highlight-indentation-current-column-face +;;; highlight-indentation-face + +;;; hl-line + +;;; hs-face +;;; hs-fringe-face + +;;; info-header-node +;;; info-header-xref +;;; info-menu-header +;;; info-menu-star +;;; info-node +;;; info-title-1 +;;; info-title-2 +;;; info-title-3 +;;; info-title-4 +;;; info-xref +;;; info-xref-visited + +;;; italic + +;;; lazy-highlight + +;;; link +;;; link-visited + +;;; log-edit-header +;;; log-edit-summary +;;; log-edit-unknown-header + +;;; mac-ts-caret-position +;;; mac-ts-converted-text +;;; mac-ts-raw-text +;;; mac-ts-selected-converted-text + +;;; match +;;; menu + +;;; message-cited-text +;;; message-header-cc +;;; message-header-name +;;; message-header-newsgroups +;;; message-header-other +;;; message-header-subject +;;; message-header-to +;;; message-header-xheader +;;; message-mml +;;; message-separator + +;;; minibuffer-prompt + + +;;; mouse + +;;; next-error + +;;; nobreak-space + +;;; org-date +;;; org-done +;;; org-hide +;;; org-link +;;; org-todo + +;;; powerline-active1 +;;; powerline-active2 +;;; powerline-inactive1 +;;; powerline-inactive2 + +;;; proced-mark +;;; proced-marked +;;; proced-sort-header + +;;; query-replace + +;;; rcirc-bright-nick +;;; rcirc-dim-nick +;;; rcirc-keyword +;;; rcirc-my-nick +;;; rcirc-nick-in-message +;;; rcirc-nick-in-message-full-line +;;; rcirc-other-nick +;;; rcirc-prompt +;;; rcirc-server +;;; rcirc-server-prefix +;;; rcirc-timestamp +;;; rcirc-track-keyword +;;; rcirc-track-nick +;;; rcirc-url + +;;; rst-adornment +;;; rst-block +;;; rst-comment +;;; rst-definition +;;; rst-directive +;;; rst-emphasis1 +;;; rst-emphasis2 +;;; rst-external +;;; rst-level-1 +;;; rst-level-2 +;;; rst-level-3 +;;; rst-level-4 +;;; rst-level-5 +;;; rst-level-6 +;;; rst-literal +;;; rst-reference +;;; rst-transition + +;;; scroll-bar + +;;; secondary-selection +;;; shadow + +;;; show-paren-match +;;; show-paren-mismatch + +;;; speedbar-button-face +;;; speedbar-directory-face +;;; speedbar-file-face +;;; speedbar-highlight-face +;;; speedbar-selected-face +;;; speedbar-separator-face +;;; speedbar-tag-face + +;;; success + +;;; tool-bar + + +;;; trailing-whitespace + +;;; underline + +;;; variable-pitch + +;;; vertical-border + +;;; w3m-anchor +;;; w3m-arrived-anchor +;;; w3m-bold +;;; w3m-current-anchor +;;; w3m-form-button +;;; w3m-form-button-mouse +;;; w3m-form-button-pressed +;;; w3m-header-line-location-content +;;; w3m-header-line-location-title +;;; w3m-history-current-url +;;; w3m-image +;;; w3m-image-anchor +;;; w3m-insert +;;; w3m-italic +;;; w3m-strike-through +;;; w3m-tab-background +;;; w3m-tab-mouse +;;; w3m-tab-selected +;;; w3m-tab-selected-background +;;; w3m-tab-selected-retrieving +;;; w3m-tab-unselected +;;; w3m-tab-unselected-retrieving +;;; w3m-tab-unselected-unseen +;;; w3m-underline + +;;; warning + +;;; whitespace-empty +;;; whitespace-hspace +;;; whitespace-indentation +;;; whitespace-line +;;; whitespace-newline +;;; whitespace-space +;;; whitespace-space-after-tab +;;; whitespace-tab +;;; whitespace-trailing + +;;; widget-button +;;; widget-button-pressed +;;; widget-documentation +;;; widget-field +;;; widget-inactive +;;; widget-single-line-field + +;;; woman-addition +;;; woman-bold +;;; woman-italic +;;; woman-unknown + +;;; yas--field-debug-face +;;; yas-field-highlight-face + +;;; soothe-theme.el ends here diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..7825d8b --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,48 @@ +setup_env + +alias rm "rm -i" +alias ls 'ls --group-directories-first -vhF --color=always' +alias hh 'cd $HOME' +alias bk 'cd $OLDPWD' +alias um 'udevil mount' +alias uu 'udevil umount' +alias t "date +%H\ %M\ %S | dc -e '6k???86400/r1440/+r24/+p'" + +alias .. 'cd ..' +alias ... 'cd ../..' +alias .... 'cd ../../..' +alias ..... 'cd ../../../..' +alias ...... 'cd ../../../../..' + +alias performance 'sudo cpupower frequency-set -g performance' +alias powersave 'sudo cpupower frequency-set -g powersave' + +alias lower "tr '[:upper:]' '[:lower:]'" +alias upper "tr '[:lower:]' '[:upper:]'" + +function fish_user_key_bindings + bind \eh backward-kill-word +end + +function j + ce $argv + cd (head -n 1 "$HOME/.local/share/dir_lst") +end + +function c + echo 'scale=13;' $argv | bc -l +end + +function hd + hexdump -e '"%08.8_ax " 8/1 "%02X " " - " 8/1 "%02X "' -e '" |" "%_p"' -e '"|\n"' "$argv" +end + +function fish_title + echo fsh +end + +if status is-login + if test -z "$DISPLAY"; and test $XDG_VTNR -eq 1; + exec startx -- -keeptty + end +end diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..8037fc4 --- /dev/null +++ b/fish/functions/fish_prompt.fish @@ -0,0 +1,32 @@ +function fish_prompt + set -l fail $status + tput bold + echo -ne "[" + set_color magenta + echo -ne (pwd) | sed 's#.*/\(.*\)/\(.*\)#\1/\2#' + #echo -ne (pwd) | sed 's#.*/\(.*\)#\1#' + set_color normal + tput bold + echo -ne "](" + set_color -o cyan + echo -ne (date "+%y.%m.%d %Hh%M") + set_color normal + tput bold + echo -ne ")" + set_color normal + + vcs_string + + if [ $fail = 0 ]; + set_color -o green; + else + set_color -o red; + end; + + if test (id -u) -eq 0; + echo -ne "\# " + else + echo -ne "\$ " + end + set_color normal +end diff --git a/fish/functions/fish_right_prompt.fish b/fish/functions/fish_right_prompt.fish new file mode 100644 index 0000000..800203c --- /dev/null +++ b/fish/functions/fish_right_prompt.fish @@ -0,0 +1,8 @@ +function fish_right_prompt + set -l fail $status + + if [ $fail != 0 ]; + set_color red; + echo -ne "<$fail>"; + end; +end diff --git a/fish/functions/setup_env.fish b/fish/functions/setup_env.fish new file mode 100644 index 0000000..50e8f44 --- /dev/null +++ b/fish/functions/setup_env.fish @@ -0,0 +1,41 @@ +function setup_env + + set -l envs (keychain --eval -q) + for expr in $envs; + set -l nexpr (echo $expr | sed "s/^\([^=]*\)=\([^;]*\); export.*/set -x -g \1 \2/") + eval $nexpr + end; + + set -g -x BROWSER "iceweasel" + set -g -x XDG_DOWNLOAD_DIR "$HOME/store" + + set -g -x EDITOR "zile" + set -g -x LC_ALL "en_ZA.UTF-8" + set -g -x PATH /usr/local/bin $PATH {$HOME}/bin . + set -g -x SUDO_EDITOR "zile" + set -g -x TERMINAL "st" + set -g -x VISUAL "emacs" + + set -g -x USER_AGENT 'Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0' + + set -g -x LESS "-S -R" + set -g -x LESSCHARSET "utf-8" + set -g -x LESSHISTFILE "-" + set -g -x LS_COLORS 'rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:' + + set -g -x LESSOPEN "|/usr/bin/lesspipe.sh %s" + set -g -x LESS_ADVANCED_PREPROCESSOR 1 + + stty -ixon + umask 077 + + set fish_greeting + + set -g -x fish_color_operator cyan + set -g -x fish_color_escape green + set -g -x fish_pager_color_prefix --underline --bold 508050 + set -g -x fish_color_search_match EAFFFF + set -g -x fish_color_match EAEA9E + set -g -x fish_color_selection darkgreen + set -g -x fish_color_command 8888cc +end diff --git a/fish/functions/vcs_string.fish b/fish/functions/vcs_string.fish new file mode 100644 index 0000000..56ae1f9 --- /dev/null +++ b/fish/functions/vcs_string.fish @@ -0,0 +1,51 @@ +function vcs_string + set -l green (set_color -o 00A000) + set -l yellow (set_color -o FF9900) + set -l red (set_color -o red) + set -l blue (set_color -o blue) + set -l brown (set_color brown) + set -l normal (set_color normal) + + set -l nstr " $red●" + set -l mstr " $yellow●" + set -l rstr " $green●" + set vcs_str "" + + if begin test -d ".git"; or test -d "../.git"; or test -d "../../.git"; end; + set -l outp (git status) + set vcs_str "×" + set vcs_inf (echo $outp | head -n 1 | cut -d' ' -f 3) + + if echo $outp | grep -q "Untracked files:"; + set vcs_new $nstr; + end + if echo $outp | grep -q 'Changes not staged for commit:'; + set vcs_mod $mstr; + end + if echo $outp | grep -q 'Changes to be committed:'; + set vcs_rec $rstr + end + else if begin test -d "_darcs"; or test -d "../_darcs"; or test -d "../../_darcs"; end; + set fls (darcs show files) + set vcs_str "+" + set vcs_inf (darcs show repo | grep Default | cut -d : -f 3-) + # TODO: Find a way to use darcs to set vcs_new + # This is very inefficient, have to basically check all files in + # the current directory to see if they match the listing. + # for f in ./*; + # if not echo $fls | grep -q $f; + # set vcs_new $nstr + # break + # end + # end + if not darcs what | grep -q "No changes"; + set vcs_rec $rstr + end + end + + if not [ "$vcs_str" = "" ]; + echo -ne "$normal$vcs_str$normal{$blue$vcs_inf$vcs_rec$vcs_mod$vcs_new$normal}" + end + return 0 +end + diff --git a/ghci.conf b/ghci.conf new file mode 100644 index 0000000..f98243a --- /dev/null +++ b/ghci.conf @@ -0,0 +1,6 @@ +-- :set -Wall +:set prompt "λ> " +:m Data.Functor Control.Applicative Data.List Control.Monad Data.Maybe Control.Arrow +:set -XGADTs -XArrows -XUnicodeSyntax +:def hoogle \s -> return $ ":! hoogle --count=15 " ++ show s +:def pf \s -> return $ ":! pointfree " ++ show s diff --git a/keymap_custom.c b/keymap_custom.c new file mode 100644 index 0000000..7042704 --- /dev/null +++ b/keymap_custom.c @@ -0,0 +1,43 @@ +#include "keymap_common.h" + +/* This layout implements colemak in the firmware, so you don't have to + set the OS configuration into colemak layout. Useful if you don't have + a laptop with an internal keyboard, or if you use other peoples' computers + a lot. */ + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: colemak */ + KEYMAP(KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_QUOT, \ + KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, \ + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_TAB, KC_ESC, KC_F18, KC_LSFT, KC_BSPC, KC_LCTL, KC_LALT, \ + KC_SPC, KC_FN0, KC_MINUS, KC_SCLN, KC_ENT), \ + /* 1: punctuation and numbers */ + KEYMAP(SHIFT(KC_1), SHIFT(KC_2), SHIFT(KC_LBRC), SHIFT(KC_RBRC), SHIFT(KC_GRAVE), KC_PGUP, KC_7, KC_8, KC_9, SHIFT(KC_EQUAL), \ + KC_EQUAL, SHIFT(KC_4), SHIFT(KC_9), KC_BSLS, KC_GRAVE, KC_PGDN, KC_4, KC_5, KC_6, SHIFT(KC_0), \ + SHIFT(KC_5), SHIFT(KC_6), KC_LBRC, KC_RBRC, SHIFT(KC_BSLS), SHIFT(KC_7), KC_1, KC_2, KC_3, SHIFT(KC_8), \ + KC_FN1, SHIFT(KC_INS), KC_LGUI, KC_LSFT, KC_BSPC, KC_LCTL, KC_LALT, KC_SPC, KC_FN0, KC_DOT, KC_0, SHIFT(KC_3)), \ + /* 2: arrows and function keys */ + KEYMAP(KC_INS, KC_HOME, KC_UP, KC_END, KC_PGUP, \ + KC_UP, KC_F7, KC_F8, KC_F9, KC_F10, \ + KC_DEL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_PGDN, \ + KC_DOWN, KC_F4, KC_F5, KC_F6, KC_F11, \ + KC_NO, KC__VOLUP, KC_NO, KC_NO, KC_PAUSE, \ + KC_NO, KC_F1, KC_F2, KC_F3, KC_F12, \ + KC_NO, KC__VOLDOWN, KC_LGUI, KC_LSFT, KC_BSPC, KC_LCTL, \ + KC_LALT, KC_SPC, KC_FN2, KC_PSCREEN, KC_SLCK, KC_FN3) +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay + [1] = ACTION_LAYER_ON(2, 1), // switch to layer 2 + [2] = ACTION_LAYER_OFF(2, 1), // switch back to layer 0 + [3] = ACTION_FUNCTION(BOOTLOADER) +}; + +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + if (id == BOOTLOADER) { + bootloader(); + } +} diff --git a/stumpwm/init.lisp b/stumpwm/init.lisp new file mode 100644 index 0000000..3436f06 --- /dev/null +++ b/stumpwm/init.lisp @@ -0,0 +1,236 @@ +;; Time-stamp: <2018-06-24 23:12:19 (tslil)> +(IN-PACKAGE STUMPWM) + +;; Startup stuff +(SETF *STARTUP-MESSAGE* NIL) +(RUN-COMMANDS "exec $TERMINAL -e $HOME/bin/tma") +(SET-PREFIX-KEY (KBD "XF86Launch9")) + +;; Window decorations +(SETF *MESSAGE-WINDOW-GRAVITY* :CENTER + *INPUT-WINDOW-GRAVITY* :CENTER) +(SETF *TIMEOUT-WAIT* 5) +(SETF *MAXSIZE-BORDER-WIDTH* 1) +(SETF *NORMAL-BORDER-WIDTH* 1) +(SETF *TRANSIENT-BORDER-WIDTH* 1) +(SETF *WINDOW-BORDER-STYLE* :THIN) +(SET-FRAME-OUTLINE-WIDTH 1) +(SET-MSG-BORDER-WIDTH 3) + +;; Groups +(GRENAME "def") +(GNEWBG "one") +(GNEWBG "two") + +(SETF *FRAME-NUMBER-MAP* "neioarst123456789" + *FRAME-INDICATOR-TEXT* " This frame has focus. ") + +;; ============================================================================= +;; Functions +;; Dropwhile +(DEFUN DROPWHILE (PREDICATE LIST) + (LOOP :WHILE (FUNCALL PREDICATE (CAR LIST)) + :DO (POP LIST)) + LIST) + +;; Notifications +(DEFUN MY-MESSAGE (LOCATION STRING) + (LET ((OLD-LOCATION *message-window-gravity*)) + (SETF *message-window-gravity* LOCATION) + (ECHO STRING) + (SETF *message-window-gravity* OLD-LOCATION))) + +;; Volume +(DEFUN VOLUME-MODIFY (MIXER ACTION) + (LET* ((OUTPUT (RUN-PROG-COLLECT-OUTPUT "/usr/bin/amixer" "set" + MIXER + (CASE ACTION + (:INC "2%+") + (:DEC "2%-") + (:MUT "toggle")))) + (PARSED (DROPWHILE #'(LAMBDA (F) + (NOT (EQ #\: (CHAR F (1- (LENGTH F)))))) + (SPLIT-STRING (CAR (LAST (SPLIT-STRING + OUTPUT))) "[ \[]+")))) + (MY-MESSAGE :TOP-RIGHT + (FORMAT NIL "~A: ~A [~A]" + MIXER (NTH 3 PARSED) (NTH 5 PARSED))))) + +(DEFUN MAIL-INFO () + (LET ((NUM (PARSE-INTEGER + (RUN-PROG-COLLECT-OUTPUT "/usr/bin/notmuch" "count" "tag:unread")))) + (IF (>= 0 NUM) "^7no unread emails^n" + (FORMAT NIL "~r^7 unread ~[email~:;emails~]^n" NUM (1- NUM))))) + +(DEFUN BATTERY-INFO () + (LET* ((RAW (RUN-PROG-COLLECT-OUTPUT "/usr/bin/acpi")) + (BAT0 (FIRST (SPLIT-STRING RAW))) + (PARSED (CDR (DROPWHILE #'(LAMBDA (F) (NOT (EQ #\: (CHAR F (1- (LENGTH F)))))) + (SPLIT-STRING BAT0 "[ ,]+")))) + (STAT (NTH 0 PARSED)) + (PERC (NTH 1 PARSED)) + (PNUM (PARSE-INTEGER (SUBSEQ PERC 0 (1- (LENGTH PERC))))) + (TIME (NTH 2 PARSED))) + (FORMAT NIL "~[^1~;^3~:;^2~]~c ~d%, ~a" + (FLOOR (* 4 (/ PNUM 100))) + (CHAR STAT 0) + PNUM + (OR TIME "not charging")))) + + +;; ============================================================================= +;; Commands + +;; Volume +(DEFCOMMAND VOLUME-INC (MIXER) (:REST) (volume-modify MIXER :INC)) +(DEFCOMMAND VOLUME-DEC (MIXER) (:REST) (volume-modify MIXER :DEC)) +(DEFCOMMAND VOLUME-MUT (MIXER) (:REST) (volume-modify MIXER :MUT)) + +;; Switch to stuff +(DEFCOMMAND SELECT-GROUP-FROM-LIST () (:REST) + ;; lifted from group.lisp source because there weren't any nice + ;; wrappers like in the case of windows (below) + (LET* ((GROUPS (SORT-GROUPS (CURRENT-SCREEN))) + (NAMES (MAPCAR (LAMBDA (G) + `(,(FORMAT-EXPAND *GROUP-FORMATTERS* "%t" G) + . ,G)) + (IF *LIST-HIDDEN-GROUPS* + GROUPS (NON-HIDDEN-GROUPS GROUPS)))) + (CHOICE (CDR (SELECT-FROM-MENU (CURRENT-SCREEN) NAMES + "Switch to which group?")))) + (WHEN CHOICE (SWITCH-TO-GROUP CHOICE)))) + +(DEFCOMMAND MY-PULL-FROM-WINDOWLIST () (:REST) ; I wanted a prompt... + (LET ((CHOICE (SELECT-WINDOW-FROM-MENU (ALL-WINDOWS) "%n %t" + "Pull which window to this frame?"))) + (WHEN CHOICE (PULL-WINDOW CHOICE)))) + +;; Email +(DEFCOMMAND CHECK-NEW-MAIL () (:REST) + (MY-MESSAGE :CENTER (MAIL-INFO))) +;; Battery +(DEFCOMMAND BATTERY-STATS () (:REST) + (MY-MESSAGE :CENTER (BATTERY-INFO))) + +;; ============================================================================= +;; Bindings + +;; Free stuff -- where are all these other keys being bound? +(setf *root-map* (make-sparse-keymap)) + +;; Volume +(DEFINE-KEY *TOP-MAP* (KBD "XF86AudioRaiseVolume") "volume-inc Master") +(DEFINE-KEY *TOP-MAP* (KBD "XF86AudioLowerVolume") "volume-dec Master") +(DEFINE-KEY *TOP-MAP* (KBD "XF86Launch1") "volume-mut Master") +(DEFINE-KEY *TOP-MAP* (KBD "S-XF86AudioRaiseVolume") "volume-inc Headphone") +(DEFINE-KEY *TOP-MAP* (KBD "S-XF86AudioLowerVolume") "volume-dec Headphone") +(DEFINE-KEY *TOP-MAP* (KBD "S-XF86Launch1") "volume-mut Headphone") + +;; Misc +(DEFINE-KEY *TOP-MAP* (KBD "XF86ScreenSaver") "exec lock") +(DEFINE-KEY *TOP-MAP* (KBD "XF86Battery") "battery-stats") +(DEFINE-KEY *TOP-MAP* (KBD "XF86WebCam") "check-new-mail") +(DEFINE-KEY *TOP-MAP* (KBD "XF86MonBrightnessUp") "exec xbacklight -inc 10") +(DEFINE-KEY *TOP-MAP* (KBD "XF86MonBrightnessDown") "exec xbacklight -dec 10") + +;; ============================================================================= +;; Root bindings +(DEFINE-KEY *ROOT-MAP* (KBD "C-Q") "quit") +(DEFINE-KEY *ROOT-MAP* (KBD "C-g") "abort") + +(DEFINE-KEY *ROOT-MAP* (KBD "g") "gmove") +(DEFINE-KEY *ROOT-MAP* (KBD "G") "gmerge") +(DEFINE-KEY *ROOT-MAP* (KBD "TAB") "select-group-from-list") +(DEFINE-KEY *ROOT-MAP* (KBD "l") "gselect def") +(DEFINE-KEY *ROOT-MAP* (KBD "u") "gselect one") +(DEFINE-KEY *ROOT-MAP* (KBD "y") "gselect two") +(DEFINE-KEY *ROOT-MAP* (KBD "M-l") "gmove def") +(DEFINE-KEY *ROOT-MAP* (KBD "M-u") "gmove one") +(DEFINE-KEY *ROOT-MAP* (KBD "M-y") "gmove two") + +(DEFINE-KEY *ROOT-MAP* (KBD "s") "exec") +(DEFINE-KEY *ROOT-MAP* (KBD "S") "swank-toggle") +(DEFINE-KEY *ROOT-MAP* (KBD "'") "time") +(DEFINE-KEY *ROOT-MAP* (KBD ";") "eval") +(DEFINE-KEY *ROOT-MAP* (KBD ":") "colon") +(DEFINE-KEY *ROOT-MAP* (KBD "K") "delete") +(DEFINE-KEY *ROOT-MAP* (KBD "C-K") "kill") +(DEFINE-KEY *ROOT-MAP* (KBD "q") "exec $BROWSER") +(DEFINE-KEY *ROOT-MAP* (KBD "E") "emacs") +(DEFINE-KEY *ROOT-MAP* (KBD "c") "exec $TERMINAL -e tmux") +(DEFINE-KEY *ROOT-MAP* (KBD "C") "exec $TERMINAL") + +(DEFINE-KEY *ROOT-MAP* (KBD "h") "hsplit") +(DEFINE-KEY *ROOT-MAP* (KBD "v") "vsplit") +(DEFINE-KEY *ROOT-MAP* (KBD "r") "remove") +(DEFINE-KEY *ROOT-MAP* (KBD "a") "iresize") +(DEFINE-KEY *ROOT-MAP* (KBD "x") "exchange-direction") +(DEFINE-KEY *ROOT-MAP* (KBD "b") "banish") + +(DEFINE-KEY *ROOT-MAP* (KBD "space") "my-pull-from-windowlist") +(DEFINE-KEY *ROOT-MAP* (KBD "C-w") "select-window") +(DEFINE-KEY *ROOT-MAP* (KBD "W") "pull-window-by-number") + +(DEFINE-KEY *ROOT-MAP* (KBD "P") "prev-in-frame") +(DEFINE-KEY *ROOT-MAP* (KBD "N") "next-in-frame") +(DEFINE-KEY *ROOT-MAP* (KBD "p") "pull-hidden-previous") +(DEFINE-KEY *ROOT-MAP* (KBD "n") "pull-hidden-next") + +(DEFINE-KEY *ROOT-MAP* (KBD "O") "only") + +(DEFINE-KEY *ROOT-MAP* (KBD ",") "move-focus left") +(DEFINE-KEY *ROOT-MAP* (KBD ".") "move-focus right") +(DEFINE-KEY *ROOT-MAP* (KBD "i") "move-focus up") +(DEFINE-KEY *ROOT-MAP* (KBD "o") "move-focus down") +(DEFINE-KEY *ROOT-MAP* (KBD "M-.") "move-window right") +(DEFINE-KEY *ROOT-MAP* (KBD "M-,") "move-window left") +(DEFINE-KEY *ROOT-MAP* (KBD "M-i") "move-window up") +(DEFINE-KEY *ROOT-MAP* (KBD "M-o") "move-window down") + +;; ============================================================================= +;; Visual + +;; Set the font +(REQUIRE 'CLX-TRUETYPE) +(LOAD-MODULE "ttf-fonts") +(XFT:CACHE-FONTS) +(SET-FONT (MAKE-INSTANCE 'XFT:FONT :FAMILY "DejaVu Sans Mono" :SUBFAMILY "Book" :SIZE 12)) + +;; Modeline +(LOAD-MODULE "fuzzytime") +(SETF *MODE-LINE-TIMEOUT* 60 + *SCREEN-MODE-LINE-FORMAT* '("%F ^>" (:EVAL (MAIL-INFO)) " " (:EVAL (BATTERY-INFO))) + *MODE-LINE-FOREGROUND-COLOR* "black" + *MODE-LINE-BACKGROUND-COLOR* "#EAFFFF" + FUZZYTIME:*MINUTE-GRANULARITY* 5 + FUZZYTIME:*FUZZYTIME-FORMAT* '(:MINUTES :HOURS "^7 in the ^n" :PERIOD "^7 on ^n" :DOW "^7 the ^n" :DAY)) +(TOGGLE-MODE-LINE (CURRENT-SCREEN) (CURRENT-HEAD)) + +;; Colours +;; TODO: Fix colours +(SET-FOCUS-COLOR "darkred") +(SET-UNFOCUS-COLOR "#32302f") +(SET-WIN-BG-COLOR "black") +(SET-BORDER-COLOR "grey30") +(SET-FG-COLOR "black") +(SET-BG-COLOR "#FFFFEA") + +;; ============================================================================= +;; Swank + +(QL:QUICKLOAD :SWANK) +(REQUIRE 'SWANK) + +(DEFVAR *SWANK-SERVER-RUNNING* NIL) + +(DEFCOMMAND SWANK-TOGGLE () () + (IF *SWANK-SERVER-RUNNING* + (PROGN + (SWANK:STOP-SERVER 4005) + (MY-MESSAGE :CENTER "Stopping swank.") + (SETF *SWANK-SERVER-RUNNING* NIL)) + (PROGN + (SWANK:CREATE-SERVER :DONT-CLOSE T + :PORT 4005) + (MY-MESSAGE :CENTER "Starting swank.") + (SETF *SWANK-SERVER-RUNNING* T)))) diff --git a/stumpwm/modules/modeline/fuzzytime/README.org b/stumpwm/modules/modeline/fuzzytime/README.org new file mode 100644 index 0000000..fbfc14f --- /dev/null +++ b/stumpwm/modules/modeline/fuzzytime/README.org @@ -0,0 +1,9 @@ +** Usage +Put: +#+BEGIN_SRC lisp +(load-module "fuzzytime") +#+END_SRC +in =~/.stumpwmrc= and then use =%F= in the mode-line format string. + +The output format and granularity may be customised by changing +~*fuzzytime-format*~ and ~*minute-granularity*~ respectively. diff --git a/stumpwm/modules/modeline/fuzzytime/fuzzytime.asd b/stumpwm/modules/modeline/fuzzytime/fuzzytime.asd new file mode 100644 index 0000000..82a630b --- /dev/null +++ b/stumpwm/modules/modeline/fuzzytime/fuzzytime.asd @@ -0,0 +1,11 @@ +;;;; fuzzytime.asd + +(asdf:defsystem #:fuzzytime + :description "A module to display a fuzzy date and time in the modeline of StumpWM" + :author "Tslil Clingman <tslil@posteo.de>" + :license "GPLv3" + :depends-on (#:stumpwm) + :serial t + :components ((:file "package") + (:file "fuzzytime"))) + diff --git a/stumpwm/modules/modeline/fuzzytime/fuzzytime.lisp b/stumpwm/modules/modeline/fuzzytime/fuzzytime.lisp new file mode 100644 index 0000000..9a703a3 --- /dev/null +++ b/stumpwm/modules/modeline/fuzzytime/fuzzytime.lisp @@ -0,0 +1,84 @@ +;;;; fuzzytime.lisp + +(IN-PACKAGE #:FUZZYTIME) + +(EXPORT '(*FUZZYTIME-FORMAT* *MINUTE-GRANULARITY*)) + +(PUSHNEW '(#\F LOCAL-TIME-TO-FUZZY) *SCREEN-MODE-LINE-FORMATTERS* :TEST 'EQUAL) + +(DEFPARAMETER *MINUTE-GRANULARITY* 10 + "Minutes are rounded to the nearest multiple of *minute-granularity*") + +(DEFPARAMETER *FUZZYTIME-FORMAT* + '(:MINUTES :HOURS " in the " :PERIOD " on " :DOW + " the " :DAY " of " :MONTH) + "Format of the output, a list of strings and keywords. Valid keywords are: +:minutes +:hours +:period +:dow (name of the day of the week) +:udow (name of the day of the week, capitalised) +:dn (number of the day of the week) +:day (day of the month) +:mnum (number of the month) +:month (name of the month, capitalised) +:umonth (name of the month)") + +(DEFVAR *MONTH-NAMES* + (MAKE-ARRAY '(12) :INITIAL-CONTENTS + '("january" "february" "march" "april" "may" "june" "july" + "august" "september" "october" "november" "december"))) + +(DEFVAR *DOW-NAMES* + (MAKE-ARRAY '(7) :INITIAL-CONTENTS + '("monday" "tuesday" "wednesday" + "thursday" "friday" "saturday" + "sunday"))) + +(DEFUN MINUTES-TO-WORDS (MIN) + (IF (OR (<= MIN 0) (>= MIN 60)) "" + (FLET ((FRAC (M) (COND + ((= M 30) "half") + ((= M 15) "quarter") + (T (FORMAT NIL "~r" M))))) + (FORMAT NIL "~a ~a " (FRAC (IF (> MIN 30) (- 60 MIN) MIN)) + (IF (> MIN 30) "to" "past"))))) + +(DEFUN HOUR-TO-WORDS (HOUR MIN) + (LET ((H (MOD + (IF (> MIN 30) (1+ HOUR) HOUR ) + 12))) + (FORMAT NIL "~r~a" + (IF (= H 0) 12 H) + (IF (OR (= MIN 0) (= MIN 60)) " o'clock" "")))) + +(DEFUN PERIOD-INDICATOR (HOUR) + (IF (< HOUR 12) "morning" + (IF (< HOUR 17) "afternoon" "evening"))) + +(DEFUN LOCAL-TIME-TO-FUZZY (ML) + (DECLARE (IGNORE ML)) + (MULTIPLE-VALUE-BIND (SECONDS MINUTES HOUR DAY MONTH YEAR DOW) + (GET-DECODED-TIME) + (DECLARE (IGNORE SECONDS) (IGNORE YEAR)) + (LET* ((MIN (* *MINUTE-GRANULARITY* + (ROUND (/ MINUTES *MINUTE-GRANULARITY*)))) + (MS (MINUTES-TO-WORDS MIN)) + (HS (HOUR-TO-WORDS HOUR MIN)) + (PS (PERIOD-INDICATOR HOUR)) + (DN (ELT *DOW-NAMES* DOW)) + (MN (ELT *MONTH-NAMES* (1- MONTH)))) + (APPLY #'CONCATENATE 'STRING + (LOOP FOR E IN *FUZZYTIME-FORMAT* COLLECT + (CASE E + (:MINUTES MS) + (:HOURS HS) + (:PERIOD PS) + (:DOW DN) + (:UDOW (STRING-CAPITALIZE DN)) + (:MONTH MN) + (:UMONTH (STRING-CAPITALIZE MN)) + (:DNUM (FORMAT NIL "~a" DOW)) + (:DAY (FORMAT NIL "~:r" DAY)) + (:MNUM (FORMAT NIL "~a" MONTH)) + (OTHERWISE E))))))) diff --git a/stumpwm/modules/modeline/fuzzytime/package.lisp b/stumpwm/modules/modeline/fuzzytime/package.lisp new file mode 100644 index 0000000..944e195 --- /dev/null +++ b/stumpwm/modules/modeline/fuzzytime/package.lisp @@ -0,0 +1,5 @@ +;;;; package.lisp + +(defpackage #:fuzzytime + (:use #:cl :stumpwm)) + |
