Created
August 28, 2023 17:28
-
-
Save samueltwallace/ebd5569e93b945f8a2c8b3eaa324ddf7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(message "Applying Package and display settings...") | |
(require 'package) | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("melpa" . "http://melpa.org/packages/") | |
("nongnu" . "https://elpa.nongnu.org/nongnu/"))) | |
(menu-bar-mode -1) | |
(tool-bar-mode -1) | |
(scroll-bar-mode -1) | |
(load-theme 'dracula t) | |
(setq frame-resize-pixelwise t) | |
(display-battery-mode 1) | |
(display-time-mode 1) | |
(package-initialize) | |
(package-refresh-contents t) | |
(setq inhibit-startup-screen t) | |
(defun hdmi-screen-on () (interactive) (call-process-shell-command "xrandr --output HDMI-1 --mode 1920x1080 --right-of eDP-1 --rotate left")) | |
(defun hdmit-screen-normal () (interactive) (call-process-shell-command "xrandr --output HDMI-1 --mode 1920x1080 --right-of eDP-1")) | |
(defun hdmi-screen-off () (interactive) (call-process-shell-command "xrandr --output HDMI-1 --off")) | |
(defun pdf-store () (interactive) (find-dired "~/pdfs/" "-name '*.pdf'")) | |
(defun game-store () (interactive) (find-dired "~/games-pdfs/" "-name '*.pdf'")) | |
(defun xmonad-tree-navigator (tree) | |
(if (windowp tree) tree | |
(if (listp tree) (xmonad-tree-navigator (car (last tree))) | |
(error "Encountered a non-list or non window argument")))) | |
(defun xmonad-tall (curr-win) | |
(if (one-window-p) (split-window-right) | |
(progn | |
(select-window (xmonad-tree-navigator (car (window-tree)))) | |
(split-window-below)))) | |
(defun bsp-tree-navigator (tree) | |
(if (windowp tree) tree | |
(if (listp tree) (bsp-tree-navigator (car (last tree))) | |
(error "Encountered a non-list or non-window argument")))) | |
(defun bspwm (curr-win) | |
(let ((to-window (bsp-tree-navigator (car (window-tree))))) | |
(progn | |
(select-window to-window) | |
(if (window-combined-p to-window t) | |
(split-window-below) | |
(split-window-right))))) | |
(defun bspwm-vert (curr-win) | |
(let ((to-window (bsp-tree-navigator (car (window-tree))))) | |
(progn | |
(select-window to-window) | |
(if (window-combined-p to-window) | |
(split-window-right) | |
(split-window-below))))) | |
(setq layout-list '(split-window-sensibly xmonad-tall bspwm bspwm-vert)) | |
(defun select-window-layout (symbol) (interactive "Slayout: ") | |
(if (member symbol layout-list) (setq split-window-preferred-function symbol) | |
(error "Not a layout in layout-list"))) | |
(defun current-window-layout () (interactive) | |
(message split-window-preferred-function)) | |
(select-window-layout #'bspwm) | |
(message "Applying menu settings...") | |
(defun add-menu-item (key command) | |
(global-set-key (kbd (concat "C-; " key)) command)) | |
(defun find-init-file () (interactive) (find-file user-init-file)) | |
(add-menu-item "i" 'find-init-file) | |
(add-menu-item "p" 'proced) | |
(setq external-pdf-viewer "firefox") | |
(defun machine-uptime () (interactive) (shell-command "uptime")) | |
(defun pacman-update () (interactive) (async-shell-command "sudo pacman -Syu")) | |
(defun get-weather () (interactive) | |
(async-shell-command "curl -s 'https://wttr.in/Somerville?0p'" "*wttr.in*" nil)) | |
(setq custom-file "~/.emacs.d/custom.el") | |
(load-file custom-file) | |
(defun neofetch () (interactive) (async-shell-command "neofetch" "*Neofetch*")) | |
(neofetch) | |
(message "Applying LaTeX settings...") | |
(defun latex-init-settings () | |
(setq TeX-parse-self t) | |
(add-to-list 'TeX-command-list | |
'("latexmk lualatex compile" "latexmk -lualatex %s" TeX-run-command nil t)) | |
(add-to-list 'TeX-command-list | |
'("latexmk lualatex preview" "latexmk -lualatex -pvc -view=none %s" TeX-run-command nil t)) | |
(add-to-list 'TeX-command-list | |
'("latexindent" "latexindent -w %s" TeX-run-command nil t)) | |
(setq TeX-view-program-selection '((output-pdf "firefox"))) ;; how to splice external-pdf-viewer here? | |
(setq cdlatex-math-modify-alist | |
'((98 "\\mathbb" nil t nil nil) | |
(102 "\\mathfrak" nil t nil nil))) | |
(setq cdlatex-math-symbol-alist | |
'((120 "\\chi" "\\otimes") | |
(62 "\\geq" "\\gtrsim") | |
(60 "\\leq" "\\lesssim")))) | |
(defun latex-hook () | |
(cdlatex-mode 1) | |
(reftex-mode 1) | |
(prettify-symbols-mode 1)) | |
(use-package latex | |
:defer t | |
:ensure auctex | |
:config (latex-init-settings)) | |
(add-hook 'LaTeX-mode-hook 'latex-hook) | |
(setq bibtex-completion-pdf-field "file" | |
bibtex-completion-bibliography "~/zoterolib.bib" | |
bibtex-completion-pdf-open-function | |
(lambda (fpath) (call-process external-pdf-viewer nil 0 nil fpath)) | |
bibtex-completion-library-path '("~/pdfs")) | |
(add-menu-item "b" 'ivy-bibtex) | |
(message "Applying editing commands...") | |
(defun smart-kill-word () (interactive) | |
(forward-word) | |
(kill-word -1)) | |
(defun my-editing-keybindings () (interactive) | |
(setq sentence-end-double-space nil) | |
(global-set-key (kbd "M-d") 'smart-kill-word) | |
(unbind-key "C-z") | |
(global-set-key (kbd "C-z p") 'ping) | |
(global-set-key (kbd "C-z t") 'machine-uptime) | |
(global-set-key (kbd "C-z b") 'battery) | |
(global-set-key (kbd "C-z u") 'pacman-update) | |
(global-set-key (kbd "C-z w") 'get-weather) | |
) | |
(repeat-mode) | |
(my-editing-keybindings) | |
(defvar make-window-repeat-map | |
(let ((map (make-sparse-keymap))) | |
(define-key map "2" 'split-window-below) | |
(define-key map "3" 'split-window-right) | |
(define-key map "0" 'delete-window) | |
(define-key map "=" 'balance-windows) | |
(define-key map "b" 'switch-to-buffer) map) | |
"making, breaking, and switching window. for use in repeat-mode") | |
(put 'split-window-below 'repeat-map 'make-window-repeat-map) | |
(put 'split-window-right 'repeat-map 'make-window-repeat-map) | |
(put 'delete-window 'repeat-map 'make-window-repeat-map) | |
(put 'balance-windows 'repeat-map 'make-window-repeat-map) | |
(put 'switch-to-buffer 'repeat-map 'make-window-repeat-map) | |
(defvar move-map | |
(let ((map (make-sparse-keymap))) | |
(define-key map "n" 'next-line) | |
(define-key map "p" 'previous-line) | |
(define-key map "a" 'beginning-of-line-text) | |
(define-key map "e" 'end-of-line) | |
(define-key map "f" 'forward-word) | |
(define-key map "g" 'keyboard-quit) | |
(define-key map "b" 'backward-word) | |
(define-key map (kbd "SPC") 'set-mark-command) | |
(define-key map "w" 'kill-region) | |
(define-key map "y" 'yank) map) | |
"movement and editing commands. tiny vim normal mode.") | |
(put 'next-line 'repeat-map 'move-map) | |
(put 'previous-line 'repeat-map 'move-map) | |
(put 'beginning-of-line-text 'repeat-map 'move-map) | |
(put 'end-of-line 'repeat-map 'move-map) | |
(put 'set-mark-command 'repeat-map 'move-map) | |
(put 'kill-region 'repeat-map 'move-map) | |
(put 'yank 'repeat-map 'move-map) | |
(put 'forward-word 'repeat-map 'move-map) | |
(put 'backward-word 'repeat-map 'move-map) | |
(icomplete-mode 1) | |
(message "Loading project & directory settings...") | |
(use-package dired-x | |
:config (progn | |
(setq dired-listing-switches "-ahl") | |
(setq dired-guess-shell-alist-user | |
`(("\\.pdf$" ,(concat external-pdf-viewer " *")))))) | |
(message "Applying misc settings...") | |
(defun open-firefox () (interactive) (async-shell-command "firefox" nil nil)) | |
(global-set-key (kbd "C-x f") 'open-firefox) | |
(global-set-key (kbd "M-o") 'other-window) | |
(global-set-key (kbd "M-s b") 'ibuffer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment