Configuration_Files/misc/init.el

354 lines
10 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;;; package --- Summary
;;;; Commentary:
;;;; Index:
;;; Section One - Packageless Configurations
;;; Subsection 1.1 - Basic includes
;;; Subsection 1.2 - GUI
;;; Subsection 1.3 - Functions and Bindings
;;; Subsection 1.4 - Backend
;;;
;;; Section Two - Package-required Configurations
;;; Subsection 2.1 - GUI
;;; Subsection 2.2 - Functions and Bindings
;;; Subsection 2.3 - Backend
;;;; Code:
;; Section One
;; Subsection 1.1
(use-package eww)
(use-package help-mode)
(use-package woman)
(use-package org)
;; Subsection 1.2
;; Default theme.
;;(load-theme `modus-operandi t)
(add-hook 'server-after-make-frame-hook '(lambda () (load-theme 'modus-operandi t))) ;This is a workaround for Solaire Mode.
;; Fonts and faces.
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Iosevka" :foundry "UKWN" :slant normal :weight normal :height 120 :width normal)))))
;; y or n is fine
(fset 'yes-or-no-p 'y-or-n-p)
;; Override x-popup-menu
(fset `x-popup-menu `ace-popup-menu)
;; Inhibit the GNU information startup dialog.
(setq inhibit-startup-message t)
;; Set the default geometry of the frame in GUI mode.
(setq default-frame-alist
'((top . 200) (left . 400)
(width . 80) (height . 25)))
;; Hide the toolbar in GUI mode.
(tool-bar-mode 0)
;; Hide the scrollbar.
(scroll-bar-mode 0)
;; Set fringe style.
(set-fringe-mode '(0 . 0))
;; Enable frame dividers.
(setq window-divider-default-places t)
(window-divider-mode 1)
;; Subsection 1.2
;; Set up our environment packages.
(defun install-if-not-avail (x) "Check if X installed. if not, install."
(if (package-installed-p x)
(print (concat (symbol-name x) " is already installed"))
(print (concat (symbol-name x) " is not installed, installing."))))
(defun setup-packages (sequence) "Check if the packages in SEQUENCE are available. If not, install them."
(mapc `install-if-not-avail sequence))
(setup-packages `())
;; Simple functions to control modes."
(defun set-on (mode) "Set MODE to on if it's off."
(if (not (eval mode))
(set mode 1)
()))
(defun toggle (x) "If X is disabled, enable it. Otherwise disable it."
(if (not (eval x))
(set x 1)
(set x nil)))
;; Allow for multiple Wowsers.
(eval-after-load "eww"
(progn `(defun xah-rename-eww-hook () "Rename eww buffers on the fly."
(rename-buffer "eww" t))))
(add-hook 'eww-mode-hook #' xah-rename-eww-hook)
;; Kill the current buffer.
(global-set-key (kbd "C-x k") 'kill-this-buffer)
;; Subsection 1.3
;; Disable TLS 1.3.
(eval-after-load "gnutls" (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
;; Set the Web Wowser as the default in-Emacs browser.
(eval-after-load "eww"
`(setq
browse-url-browser-function 'eww-browse-url
shr-use-fonts nil
shr-use-colors nil
shr-indentation 2
eww-search-prefix "https://duckduckgo.com/lite"))
;; Byte-compile ELisp when saving.
(auto-compile-on-save-mode t)
;; Increase the garbage collectors threshold.
(setq gc-cons-threshold 100000000)
(setq large-file-warning-threshold 1000000000)
;; Store temporary files in a backup directory.
(eval-after-load "tramp.el" (progn
(setq temporary-file-directory "~/.config/emacs/.backup/temp/")
(progn (defvar auto-save-directory) (setq auto-save-directory "~/.config/emacs/.backup/autosave/"))
(setq tramp-auto-save-directory "~/.config/emacs/.backup/autosave/")
(make-directory temporary-file-directory t)
(make-directory auto-save-directory t)
(setq auto-save-file-name-transforms
`(("\\(?:[^/]*/\\)*\\(.*\\)" ,(concat auto-save-directory "\\1") t)))))
;; Automatically reload files as needed.
(global-auto-revert-mode t)
;; Remove unneeded whitespace when exiting.
(add-hook 'before-save-hook 'whitespace-cleanup)
;; Subsection 2.1
;; Good-scroll improves Emacs scrolling abilities.
(good-scroll-mode 1)
;; Golden Ratio resizes the current buffer according to the golden ratio.
(use-package golden-ratio
:ensure t
:demand
:config
(golden-ratio-mode 1))
;; Dim inactive buffers.
(use-package dimmer
:ensure t
:demand
:config
(dimmer-mode 1))
;; Goggles adds pulsing effects to region edits.
(use-package goggles
:ensure t
:demand
:config
(setq-default goggles-pulse t))
;; Focus dims non-relevant text.
(use-package focus
:ensure t
:demand
:config
'((prog-mode . defun) (text-mode . sentence)))
;; Solaire alters background colors to indicate "real" versus "unreal" buffers.
(use-package solaire-mode
:ensure t
:demand
:config
(dolist (face `(mode-line mode-line-inactive))))
;; Powerline allows for modeline tweaks.
(use-package powerline
:ensure t
:demand
:config
(powerline-nano-theme))
;; Popwin forces informational, educational, fantasticational buffers into a temporary window. Thank god.
(use-package popwin
:ensure t
:demand
:config
;; Meta commands
(eval-after-load "popwin"
`(progn (setq anything-samewindow nil)
(push `("*anything*" :height 20) popwin:special-display-config)
(push `("*Completions*" :height 20) popwin:special-display-config)
(push `("*Messages*" :height 20) popwin:special-display-config)
(push `("*compilation*" :height 20) popwin:special-display-config)
(push `("*Help*" :height 20) popwin:special-display-config)
(push `("*Warnings*" :height 20) popwin:special-display-config)
(push `("*Backtrace*" :height 20) popwin:special-display-config)
(push `("*Buffer List*" :height 20) popwin:special-display-config)
(push "*slime-apropos*" popwin:special-display-config) ; SLIME commands
(push "*slime-macroexpansion*" popwin:special-display-config)
(push "*slime-description*" popwin:special-display-config)
(push '("*slime-compilation*" :noselect t)
popwin:special-display-config)
(push "*slime-xref*" popwin:special-display-config)
(push '(sldb-mode :stick t) popwin:special-display-config)
(push 'slime-repl-mode popwin:special-display-config)
(push 'slime-connection-list-mode popwin:special-display-config)
(popwin-mode 1))))
;; Subsection 2.2
;; Allow us to easily get around using the Ace packages.
(use-package ace-window
:ensure t
:demand
:config
(global-set-key (kbd "M-o") `ace-window))
(use-package ace-jump-mode
:ensure t
:demand
:config
(eval-after-load "ace-jump-mode" `(global-set-key (kbd "C-c SPC") 'ace-jump-mode)))
(use-package ace-link
:ensure t
:demand
:config
(define-key eww-mode-map (kbd "C-c f") 'ace-link)
(define-key Info-mode-map (kbd "C-c f") 'ace-link)
(define-key org-mode-map (kbd "C-c f") 'ace-link)
(define-key help-mode-map (kbd "C-c f") 'ace-link)
(define-key woman-mode-map (kbd "C-c f") 'ace-link))
;; Add SLY, a Lisp REPL.
(use-package sly
:ensure t
:defer
:config
(setq inferior-lisp-program "sbcl"))
;; Configure the fuzzy-pattern matching engine, Helm
(use-package helm
:ensure t
:demand
:bind
:config
(require 'helm-config)
(helm-mode 1)
(setq helm-split-window-inside-p t
helm-move-to-line-cycle-in-source t)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(helm-autoresize-mode 1)
(define-key helm-map (kbd "<tab>")
`helm-execute-persistent-action)
(define-key helm-map (kbd "C-i")
'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z")
`helm-select-action)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-x b") 'helm-mini)
(setq helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t)
(global-set-key (kbd "C-x C-f") 'helm-find-files) ; Set Helm up to provide meta-x suggestions and others.
(defun pl/helm-alive-p () "Prevent golden-ratio from interefering with Helm."
(if (boundp 'helm-alive-p)
(symbol-value 'helm-alive-p)))
(add-to-list 'golden-ratio-inhibit-functions 'pl/helm-alive-p))
;; Add Helm support to the web wowser
(use-package helm-eww
:ensure t)
;; Add on-the-fly syntax linting
(use-package flycheck
:ensure t)
;; Integrate Helm recommendations and Flycheck linting
(use-package helm-flycheck
:ensure t
:demand
:config
(define-key flycheck-mode-map (kbd "C-c ! h") 'helm-flycheck))
;; Add an SRFI browser.
(use-package srfi
:ensure t)
;; Enable development features in certain modes.
(defvar proghook-active 0)
(defun proghook () "Function for prog-mode hook."
(progn
(clean-aindent-mode)
(aggressive-indent-mode)
(global-ede-mode)
(semantic-mode)
(flycheck-mode)
(electric-pair-mode)
(electric-quote-mode)
(electric-indent-mode)
(solaire-mode)
(rainbow-blocks-mode)
(rainbow-mode)
(goggles-mode)
(focus-mode)
(mapcar `set-on `(display-line-numbers))))
(add-hook `prog-mode-hook `proghook)
;; Add cwarn-mode to cc-mode later on
(defvar texthook-active 0)
(add-hook 'text-mode-hook 'texthook)
(defun texthook () "Function for text-mode hook."
(progn
(solaire-mode)
(rainbow-mode)
(goggles-mode)
(focus-mode)
(mapcar `set-on `(display-line-numbers))))
(add-hook `text-mode-hook `texthook)
(provide 'init)
;;; init.el ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("2f93ebb862a9d50fee9c1b3302d858e2d2c0bba9d4e1be9bb3b08b7373f1710c" default))
'(package-selected-packages
'(aggressive-indent muse auctex beacon ac-ispell ac-rtags dimmer rainbow-blocks rainbow-identifiers rainbow-mode solaire-mode modus-themes xpm ws-butler use-package stripes srfi speed-type sly-asdf sed-mode schrute powerline popwin pcache paren-face macrostep link jammer helm-sly helm-mode-manager helm-flycheck helm-eww guru-mode good-scroll golden-ratio goggles gnuplot focus flyspell-lazy flyspell-correct-ivy electric-operator company-c-headers comment-tags clean-aindent-mode cframe auto-compile ace-window ace-popup-menu ace-link ace-jump-helm-line ace-flyspell ac-sly ac-html ac-helm ac-haskell-process ac-etags ac-c-headers)))