Rewrite init.el

This commit is contained in:
Mid Favila 2022-03-16 19:14:22 -04:00
parent 65765db517
commit 47ffb289ea
2 changed files with 1008 additions and 499 deletions

View File

@ -1,135 +1,472 @@
;;;; package --- Summary
;;;; Commentary:
;;; Code:
;;; TODO:
;; Figure out why clean-aindent doesn't show up in my default config's repos any more
;; Integrate flyspell
;; Work on setting up org-mode for publishing (using Muse, AuCTeX, gnuplot, etc)
;; Set up ctxmenu to provide right-click menus
;; Work on improving aggressive-indent's abilities and integrating with clean-aindent-mode, potentially
;; Work on improving aggressive-indent's abilities and integrating with
;; clean-aindent-mode
;; Look into programming with the names libraries - adds namespaces.
;; Configure jammer and schrute to prevent using inefficient tactics and teach
;; Maybe configure paren-face and integrate it with rainbow-blocks?
;; Look into powerline more.
;; Integrate SLY and your extensions more.
;; Replace the standard EWW functions with Helm ones. Also configure EWW more in general.
;; Investigate buffer-manage, comment-tags, company, guru-mode, ivy.
;; Integrate avy, helm and flycheck
;; Expand avy capabilities - avy-zap?
;; Replace the standard EWW functions with Helm ones. Also configure EWW more in
;; general.
;; Investigate buffer-manage, comment-tags, guru-mode.
;; Integrate GDB?
;; Remove reliance on use-package - write own package management facilities,
;; perhaps with support for ELisp scattered around the Internet instead of
;; just package-archives. Could be trivial with a lookup table.
;; Integrate ispell
;;; Index:
;; Section Zero - Function Definitions
;; Section One - Initialization Settings and Routines
;; Section Two - Package Initialization
;; Section Three - Hooks
;; Section Four - Packageless Customizations and Custom.el
(setq-default package-native-compile t)
(require 'package)
(add-to-list 'package-archives
`("melpa-unstable" . "https://melpa.org/packages/"))
;; Section Zero - Function Definitions
(if (fboundp `use-package)
()
(progn (package-refresh-contents) (package-install `use-package)))
(defun install-if-not-avail (x)
"Install a package X if and only if it's not available."
(if (not (package-installed-p x))
(progn
(message (concat "Installing package " (symbol-name x) "..."))
(package-refresh-contents)
(package-install x))
(message (concat (symbol-name x) " is already installed!"))))
;; Make startup faster by reducing the frequency of garbage
;; collection. The default is 800 kilobytes. Measured in bytes.
(setq gc-cons-threshold (* 1000 1000 1000))
;; This is the prototype for package bundles. '("eww" . (message "EWW test"))
(defun mpack-unpack-bundle (mode bundle)
"Unpack the car or cdr of BUNDLE based on MODE."
(if (= mode 0)
(car bundle)
(eval (cdr bundle))))
(defun mpack-initialize-packages (list)
"Initialize each package in LIST recursively."
(if (null list)
(message "Package initialization complete.")
(progn
(eval-after-load
(mpack-unpack-bundle 0 (car list))
(mpack-unpack-bundle 1 (car list)))
(mpack-initialize-packages (cdr list)))))
;;;; Index:
;; Section One - Initialization Settings and Routines
;;; 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
;; Make Emacs start more quickly by reducing the frequency of garbage collection
(setq gc-cons-threshold (* 1000 1000 1000 1000 1000 1000))
;;;; Code:
;; Prevent "cl" from being considered obsolete.
(setq byte-compile-warnings '(cl-functions))
;; Section One
;;; Package manager options.
;; Subsection 1.1
;; TLS and networking configuration.
(progn 'require '(package gnutls))
(setq-default load-path
(flatten-list
(list load-path
(mapcar `directory-file-name `("/usr/share/emacs/site-lisp/quack.el")))))
(setq-default
gnutls-verify-error t
gnutls-min-prime-bits 4096
gnutls-trustfiles '("/etc/ssl/cert.pem")
gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(use-package eww
:defer t
:config
;; TODO: See if we can get package.el to prefer MELPA over ELPA.
(setq-default package-archives
'(("melpa-unstable" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
;; Compiler options. If you're running the latest beta, you can native-compile
;; ELisp for massive performance gains. Otherwise, byte-compile packages.
(if (>= emacs-major-version 28 )
(setq-default package-native-compile t)
(progn
(define-key eww-mode-map (kbd "C-c f") 'ace-link)
(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")
(require 'async-bytecomp)
(async-bytecompile-package-mod 1)))
;; Allow for multiple Wowsers.
(defun eww-hook () "Reconfigure eww buffers on the fly."
(progn (rename-buffer "eww" t)
(variable-pitch-mode)))
(add-hook 'eww-mode-hook 'eww-hook)))
;;; Section Two - Package Initialization
(use-package help-mode
:defer t
:config
(define-key help-mode-map (kbd "C-c f") 'ace-link))
;; Where do we look for ELisp on the local filesystem?
(setq-default
load-path (flatten-list
(list load-path
(mapcar 'directory-file-name
'("/usr/share/emacs/site-lisp/quack.el")))))
(use-package woman
:defer t
:config
(define-key woman-mode-map (kbd "C-c f") 'ace-link))
(mapc 'install-if-not-avail '(
ac-c-headers
ac-etags
ac-geiser
ac-haskell-process
ac-html
ac-ispell
ace-link
ace-window
aggressive-indent
beacon
centered-cursor-mode
crux
dimmer
disable-mouse
focus
geiser-mit
goggles
golden-ratio
golden-ratio-scroll-screen
helm-eww
helm-flycheck
helpful
immortal-scratch
indent-guide
modus-themes
paredit
popwin
powerline
rainbow-blocks
rainbow-mode
rc-mode
sly
solaire-mode
srfi
zoom-window))
(use-package org
:defer t
:config
(define-key org-mode-map (kbd "C-c f") 'ace-link))
;; Only require things you ABSOLUTELY NEED at init time (e.g for *scratch*).
(mapc 'require '(
ac-ispell
ace-window
auto-complete
avy
dimmer
focus
goggles
golden-ratio
golden-ratio-scroll-screen
helm
immortal-scratch
modus-themes
popwin
powerline
rainbow-blocks
rainbow-mode
solaire-mode
zoom-window))
;; Subsection 1.2
;; Define your packages and their configurations here.
;; Prototype is as follows: ("package-name" . (functions to initialize package))
;; Packages that have a "global" use-case will be configured on their own;
;; extensions to particular modes, or "integrative" packages, will be
;; configured in conjunction with relevant packages (e.g ace-link with
;; eww, woman, etc)
;; Default theme.
(use-package modus-themes
:ensure t
:init
;; Add all your customizations prior to loading the themes
(setq-default modus-themes-success-deuteranopia t
modus-themes-bold-constructs t
modus-themes-syntax '(faint yellow-comments green-strings)
modus-themes-mixed-fonts t ; available for 1.7
modus-themes-links '(faint bold italic)
modus-themes-prompts '(gray intense)
modus-themes-mode-line '(3d accented)
modus-themes-completions 'opinionated
modus-themes-fringes 'intense
modus-themes-lang-checkers '(text-also background intense)
modus-themes-hl-line '(accented)
modus-themes-paren-match '(bold intense)
modus-themes-variable-pitch-ui t)
(modus-themes-load-themes)
:config
(modus-themes-load-operandi))
(progn (setq-default package-bundle
'(("auto-complete" . '(progn
(require 'ac-ispell)
(ac-config-default)
(ac-ispell-setup)
(setq
ac-ispell-requires 4
ac-ispell-fuzzy-limit 3
ispell-alternate-dictionary "/usr/lib/aspell-0.60/en-common.rws")
;; Sources
(defun list-sources (SOURCES)
"Produce a list containing the contents of SOURCES."
(flatten-list
(list (list SOURCES) ac-sources)))
(setq ac-sources
(list-sources '(ac-ispell)))
(ac-set-trigger-key "TAB")))
("ace-window" . '(progn
(global-set-key (kbd "M-o") 'ace-window)))
("avy" . '(progn
(keymap-global-set "C-c SPC" 'avy-goto-char)))
("aggressive-indent" . '(progn
))
("beacon" . '(progn
))
("centered-cursor-mode" . '(progn
))
("crux" . '(progn
))
;; Still need to integrate this with Helm in the new config.
;; Should also make all fundamental-mode derived modes
;; trigger dimmer-mode, instead of just dimmer-mode
;; 1'ing in the config...
("dimmer" . '(progn
(setq-default
dimmer-adjustment-mode :both
dimmer-fraction .40)))
("disable-mouse" . '(progn
))
("eww" . '(progn
(require 'helm-eww)
(define-key eww-mode-map (kbd "C-c f") 'ace-link)
(define-key eww-mode-map (kbd "B") 'helm-eww-bookmarks)
(define-key eww-mode-map (kbd "H") 'helm-eww-history)
(define-key eww-mode-map (kbd "E") 'helm-eww-buffers)
(define-key eww-mode-map (kbd "G") '(lambda ()
(interactive
(helm-eww-new-buffer (helm-read-string "URL: ")))))
(setq-default
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")
(add-hook 'eww-mode-hook
(lambda ()
(progn (rename-buffer "eww" 1)
(variable-pitch-mode))))))
;; Integrate this with text-mode and prog-mode
;; instead of doing clunky configure-time stuff.
("focus" . '(progn
))
("goggles" . '(progn
(setq-default goggles-pulse t)))
("golden-ratio" . '(progn
(golden-ratio-mode 1)
(setq golden-ratio-recenter 1)
(defun pl/helm-alive-p ()
"Prevent golden-ratio from interefering with Helm."
(if (boundp 'helm-alive-p)
(symbol-value 'helm-alive-p)))
;; Interop with other libraries.
(setq golden-ratio-extra-commands
(flatten-list (list 'golden-ratio-extra-commands '(ace-window ace-jump-move))))
(add-to-list
'golden-ratio-inhibit-functions
'pl/helm-alive-p)))
("golden-ratio-scroll-screen" . '(progn
(global-set-key (kbd "<prior>") 'golden-ratio-scroll-screen-down)
(global-set-key (kbd "<next>") 'golden-ratio-scroll-screen-up)
(global-set-key (kbd "C-v") 'golden-ratio-scroll-screen-up)
(global-set-key (kbd "M-v") 'golden-ratio-scroll-screen-down)
;; The built-in support for recentering seems broken...
;; It would be trivial to write a wrapper function to achieve the same effect, though.
;; Basically, just write your own scroll function that calls the golden-scroll function
;; and then recenters the screen. It would be nice to combine this with centered-cursor-mode,
;; too - only problem is that it stutters a bit at the end of buffers when using golden-scroll functions.
(setq golden-ratio-scroll-recenter 1)))
("helm" . '(progn
(require 'helm-config)
(setq
helm-split-window-inside-p t
helm-move-to-line-cycle-in-source t
helm-autoresize-max-height 0
helm-autoresize-min-height 20
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t)
(define-key helm-map (kbd "<tab>")
'helm-execute-persistent-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)
(global-set-key (kbd "C-x C-f") 'helm-find-files)))
("helm-pages" . '(progn
))
("help-mode" . '(progn
))
("immortal-scratch" . '(progn
))
("modus-themes" . '(progn
;; Add customizations before loading.
(setq-default
modus-themes-success-deuteranopia t
modus-themes-bold-constructs t
modus-themes-syntax '(faint yellow-comments green-strings)
modus-themes-mixed-fonts t ; available for 1.7
modus-themes-links '(faint bold italic)
modus-themes-prompts '(gray intense)
modus-themes-mode-line '(3d accented)
modus-themes-completions 'opinionated
modus-themes-fringes 'intense
modus-themes-lang-checkers '(text-also background intense)
modus-themes-hl-line '(accented)
modus-themes-paren-match '(bold intense)
modus-themes-variable-pitch-ui t)
(modus-themes-load-themes)
(modus-themes-load-operandi)))
("helpful" . '(progn
))
("org" . '(progn
(define-key org-mode-map (kbd "C-c f") 'ace-link)))
("popwin" . '(progn
(setq anything-samewindow nil)
(setq-default popwin:special-display-config
'( ("*Completions*" )
("*Messages*" )
("*compilation*" )
("*Help*" :stick t)
("*Warnings*" :height 20)
("*Backtrace*" )
("*Buffer List*" )
("*Compile-Log*" )
("*Warnings*" )
("\*helm.*" :regexp t :position bottom)
("*slime-apropos*" )
("*slime-macroexpansion*" )
("*slime-description*" )
("*slime-compilation*" :noselect t)
("*slime-xref*" )
(sldb-mode :stick t )
(slime-repl-mode )
(slime-connection-list-mode )))))
("powerline" . '(progn
(powerline-nano-theme)))
("rainbow-mode" . '(progn
))
;; Make this a mode configuration.
("scheme-mode" . '(progn
))
(add-hook 'server-after-make-frame-hook `(lambda () (load-theme 'modus-operandi t))) ;This is a workaround for Solaire Mode.
;; Same as above. Like, with hooks, y'know?
("lisp-mode" . '(progn
(setq inferior-lisp-program "sbcl")))
;; Fonts and faces.
;; Integrate this with fundamental-mode?
("solaire-mode" . '(progn
(dolist
(face
'(mode-line mode-line-inactive)))))
("woman" . '(progn
(define-key woman-mode-map (kbd "C-c f") 'ace-link)))
("zoom-window" . '(progn
(global-set-key (kbd "C-z") 'zoom-window-zoom)))
;; End of package bundle.
))
(mpack-initialize-packages package-bundle))
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
(add-hook 'text-mode-hook
(lambda ()
(progn
(buffer-face-set 'variable-pitch-text)
(popwin-mode 1)
(helm-mode 1)
(helm-autoresize-mode 1)
(flyspell-mode 1)
(auto-complete-mode 1)
(ac-ispell-ac-setup)
(solaire-mode 1)
(goggles-mode 1)
(focus-mode 1)
(display-line-numbers 1))))
(add-hook 'prog-mode-hook
(lambda ()
(progn
(buffer-face-set 'fixed-pitch)
(popwin-mode 1)
(helm-mode 1)
(helm-autoresize-mode 1)
(global-ede-mode 1)
(semantic-mode 1)
(flycheck-mode 1)
(auto-complete-mode 1)
(solaire-mode 1)
(goggles-mode 1)
(focus-mode 1)
(display-line-numbers-mode 1)
(indent-guide-mode 1)
(aggressive-indent-mode 1)
(rainbow-blocks-mode 1)
(show-paren-mode 1))))
(add-hook 'lisp-data-mode-hook
(lambda ()
(progn
(paredit-mode 1))))
(add-hook 'scheme-mode-hook
(lambda ()
(progn
(paredit-mode 1)
(add-hook 'geiser-mode-hook 'ac-geiser-setup)
(add-hook 'geiser-repl-mode-hook 'ac-geiser-setup)
(setq
ac-sources (list-sources '(ac-source-geiser))
inferior-scheme-program "mit"))))
(add-hook 'common-lisp-mode-hook
(lambda ()
(progn
())))
(add-hook 'c-mode-hook
(lambda ()
(progn
(require 'ac-c-headers)
(ac-etags-setup)
(setq
ac-sources (list-sources
'(ac-source-etags
ac-source-c-headers
ac-source-c-header-symbols)))
(c-set-style "whitesmith"))))
;; Section Four - Packageless Customizations and Custom.el
;; Suppress non-urgent warnings.
(setq warning-minimum-level :emergency)
(set-face-attribute 'default nil :family "Clear Sans" :height 125)
(set-face-attribute 'variable-pitch nil :family "FreeSerif" :height 1.0)
(set-face-attribute 'fixed-pitch nil :family "Iosevka Light" :height 1.25)
(set-face-attribute 'fixed-pitch nil :family "Iosevka Mono" :height 1.0)
;; y-or-no-p 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)
@ -152,426 +489,21 @@
(window-divider-mode 1)
;; Subsection 1.3
;; 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)))
;; Kill the current buffer.
(global-set-key (kbd "C-x k") 'kill-this-buffer)
;; Subsection 1.4
;; Give us stats during startup.
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time))) gcs-done)))
;; We want to treat documents as ASCII by default.
(prefer-coding-system 'us-ascii-unix)
;; Disable TLS 1.3.
(eval-after-load "gnutls" (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
;; Store temporary files in a backup directory.
(progn
(setq temporary-file-directory "~/.config/emacs/.backup/temp/")
(setq auto-save-directory "~/.config/emacs/.backup/autosave/"))
(eval-after-load "tramp.el" (progn
(setq tramp-auto-save-directory "~/.config/emacs/.backup/autosave/")
(make-directory temporary-file-directory t)
(make-directory auto-save-directory 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
(use-package xterm-color
:ensure t
:demand)
(use-package rainbow-blocks
:ensure t
:demand)
(use-package rainbow-mode
:ensure t
:demand)
;; ;; Good-scroll improves Emacs' scrolling abilities.
;; (use-package good-scroll
;; :ensure t
;; :demand
;; :config
;; (progn (good-scroll-mode 1)
;; (global-set-key [next] #'good-scroll-up-full-screen)
;; (global-set-key [prior] #'good-scroll-down-full-screen)
;; (setq good-scroll-render-rate .16)))
;; Golden Ratio resizes the current buffer according to the golden ratio.
;; TODO: Make it recenter on switch.
(use-package golden-ratio
:ensure t
:demand
:config
(progn
(golden-ratio-mode 1)
;; Interop with other libraries.
(setq golden-ratio-extra-commands
(flatten-list (list 'golden-ratio-extra-commands '(ace-window ace-jump-move))))
(setq golden-ratio-recenter 1)))
;; Golden Scroll forces scrolling to adhere to the golden ratio.
;; TODO: Recenter on scroll.
(use-package golden-ratio-scroll-screen
:ensure t
:demand
:config
(progn
(global-set-key (kbd "<prior>") `golden-ratio-scroll-screen-down)
(global-set-key (kbd "<next>") `golden-ratio-scroll-screen-up)
(global-set-key (kbd "C-v") `golden-ratio-scroll-screen-up)
(global-set-key (kbd "M-v") `golden-ratio-scroll-screen-down)
;; The built-in support for recentering seems broken...
;; It would be trivial to write a wrapper function to achieve the same effect, though.
;; Basically, just write your own scroll function that calls the golden-scroll function
;; and then recenters the screen. It would be nice to combine this with centered-cursor-mode,
;; too - only problem is that it stutters a bit at the end of buffers when using golden-scroll functions.
(setq golden-ratio-scroll-recenter 1)))
;; zoom-window allows for temporarily "full-screening" a window.
(use-package zoom-window
:ensure t
:demand
:config
(progn
(global-set-key (kbd "C-z") `zoom-window-zoom)))
;; Dim inactive buffers.
(use-package dimmer
:ensure t
:demand
:config
(progn
(dimmer-mode 1)
(dimmer-configure-helm)
(setq-default
dimmer-adjustment-mode :both
dimmer-fraction .40)))
;; 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
(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 '("*Compile-Log*" :height 20) popwin:special-display-config)
(push '("*Warnings*" :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 Avy and Ace packages.
(use-package avy
:ensure t
:demand
:config
(global-set-key (kbd "C-c SPC") 'avy-goto-char))
(use-package ace-window
:ensure t
:demand
:config
(global-set-key (kbd "M-o") 'ace-window))
(use-package ace-link
:defer t
:ensure t
:demand)
;;; Subsection 2.3
(use-package aggressive-indent
:ensure t
:defer t)
;; Add SLY, a Common Lisp REPL.
(use-package sly
:ensure t
:defer t
:config
(setq inferior-lisp-program "sbcl"))
;; Add Geiser, a Scheme REPL.
(use-package geiser
:ensure t
:defer t
:config
(setq-default inferior-lisp-program "mit-scheme-native"))
(use-package geiser-mit
:ensure t
:defer t)
(use-package ac-sly
:ensure t
:defer t)
(use-package ac-geiser
:ensure t
:defer t)
(use-package ac-html
:ensure t)
(use-package ac-etags
:ensure t)
(use-package ac-ispell
:ensure t)
(use-package ac-c-headers
:ensure t)
(use-package ac-ispell
:ensure t
:defer t)
(use-package auto-complete
:ensure t
:demand
:config
(progn
(ac-config-default)
(ac-set-trigger-key "TAB")
;; Sources.
(defun list-sources (SOURCES) "Produce a list containing the contents of SOURCES."
(flatten-list
(list (list SOURCES) ac-sources)))
(add-hook 'c-mode-hook
(lambda ()
(progn
(ac-etags-setup)
(setq ac-sources
(list-sources `(ac-source-etags ac-source-c-headers ac-source-c-header-symbols))))))
(add-hook 'scheme-mode-hook
(lambda ()
(progn
(setq ac-sources
(list-sources `(ac-source-geiser))))))
(add-hook 'geiser-mode-hook 'ac-geiser-setup)
(add-hook 'geiser-repl-mode-hook 'ac-geiser-setup)))
;; Configure the fuzzy-pattern matching engine, Helm
(use-package helm
:ensure t
:demand
:bind
:config
(progn (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
:defer t
:ensure t
:after eww helm
:config
(progn
()))
;; Flycheck provides on-the-fly syntax linting
(use-package flycheck
:defer t
:ensure t
:config
(progn (global-flycheck-mode)))
;; Integrate Helm recommendations and Flycheck linting
(use-package helm-flycheck
:defer t
:after helm flycheck
:ensure t
:demand
:config
(define-key flycheck-mode-map (kbd "C-c ! h") 'helm-flycheck))
;; Add an SRFI browser.
(use-package srfi
:defer t
:ensure t)
;; Enable development features in certain modes.
(defvar proghook-active 0)
(defun proghook () "Function for 'prog-mode' hook."
(progn
(aggressive-indent-mode)
(global-ede-mode)
(semantic-mode)
(flycheck-mode)
(electric-pair-mode)
(electric-indent-mode)
(solaire-mode)
(rainbow-blocks-mode)
(rainbow-mode)
(goggles-mode)
(focus-mode)
(show-paren-mode)
(mapcar 'set-on '(display-line-numbers))))
(add-hook 'prog-mode-hook 'proghook)
;; Add cwarn-mode to cc-mode later on
(defvar chook-active 0)
(defun chook () "Function for 'c-mode' hook."
(progn
(c-set-style "whitesmith")))
(add-hook 'c-mode-hook 'chook)
(defvar texthook-active 0)
(add-hook 'text-mode-hook 'texthook)
(defun texthook () "Function for 'text-mode' hook."
(progn
(variable-pitch-mode 1)
(solaire-mode 1)
(goggles-mode 1)
(focus-mode 1)))
(add-hook 'text-mode-hook 'texthook)
;; The rest of the init file.
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
(provide 'init)
;;; init.el ends here
;;; Reset the GC threshold to something more reasonable.
(setq gc-cons-threshold (* 1000 1000 1000))
(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.
'(beacon-mode t)
'(custom-safe-themes
'("2f93ebb862a9d50fee9c1b3302d858e2d2c0bba9d4e1be9bb3b08b7373f1710c" default))
'(helm-completion-style 'helm)
'(package-selected-packages
'(ac-geiser centered-cursor-mode golden-ratio-scroll-screen helpful indent-guide zoom-window dimmer god-mode paredit geiser-mit ctxmenu aggressive-indent-mode xpm ws-butler web-completion-data use-package srfi solarized-theme solaire-mode sly rainbow-mode rainbow-blocks powerline popwin paren-face parchment-theme names helm-slime helm-mode-manager helm-flycheck helm-eww good-scroll goggles gnuplot focus flyspell-correct-helm flymake-haskell-multi flymake flycheck-haskell flycheck-aspell eww-lnum electric-operator context-coloring clean-buffers aggressive-indent ace-window ace-link ace-jump-mode ac-slime ac-html ac-haskell-process ac-etags))
'(quack-default-program "scheme")
'(quack-newline-behavior 'newline)
'(quack-programs
'("s9" "bigloo" "csi" "csi -hygienic" "gosh" "gracket" "gsi" "gsi ~~/syntax-case.scm -" "guile" "kawa" "mit-scheme" "racket" "racket -il typed/racket" "rs" "scheme" "scheme48" "scsh" "sisc" "stklos" "sxi"))
'(quack-run-scheme-always-prompts-p nil)
'(quack-smart-open-paren-p nil)
'(warning-suppress-log-types '((use-package) (comp)))
'(warning-suppress-types '((emacs) (comp))))
'(esup dumb-jump zoom-window use-package srfi solaire-mode sly-macrostep rc-mode rainbow-mode rainbow-blocks powerline popwin paredit modus-themes macrostep-geiser indent-guide immortal-scratch helpful helm-pages helm-flycheck helm-eww golden-ratio-scroll-screen golden-ratio goggles geiser-mit focus disable-mouse dimmer crux column-enforce-mode centered-cursor-mode beacon aggressive-indent ace-window ace-link ace-jump-mode ac-sly ac-ispell ac-html ac-haskell-process ac-geiser ac-etags ac-c-headers)))
(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.
)
(provide 'init)
;;; init.el ends here

View File

@ -0,0 +1,577 @@
;;;; package --- Summary
;;;; Commentary:
;;; TODO:
;; Figure out why clean-aindent doesn't show up in my default config's repos any more
;; Integrate flyspell
;; Work on setting up org-mode for publishing (using Muse, AuCTeX, gnuplot, etc)
;; Set up ctxmenu to provide right-click menus
;; Work on improving aggressive-indent's abilities and integrating with clean-aindent-mode, potentially
;; Look into programming with the names libraries - adds namespaces.
;; Configure jammer and schrute to prevent using inefficient tactics and teach
;; Maybe configure paren-face and integrate it with rainbow-blocks?
;; Look into powerline more.
;; Integrate SLY and your extensions more.
;; Replace the standard EWW functions with Helm ones. Also configure EWW more in general.
;; Investigate buffer-manage, comment-tags, company, guru-mode, ivy.
;; Integrate GDB?
(setq-default package-native-compile t)
(require 'package)
(add-to-list 'package-archives
`("melpa-unstable" . "https://melpa.org/packages/"))
(if (fboundp `use-package)
()
(progn (package-refresh-contents) (package-install `use-package)))
;; Make startup faster by reducing the frequency of garbage
;; collection. The default is 800 kilobytes. Measured in bytes.
(setq gc-cons-threshold (* 1000 1000 1000))
;;;; 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
(setq-default load-path
(flatten-list
(list load-path
(mapcar `directory-file-name `("/usr/share/emacs/site-lisp/quack.el")))))
(use-package eww
:defer t
:config
(progn
(define-key eww-mode-map (kbd "C-c f") 'ace-link)
(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")
;; Allow for multiple Wowsers.
(defun eww-hook () "Reconfigure eww buffers on the fly."
(progn (rename-buffer "eww" t)
(variable-pitch-mode)))
(add-hook 'eww-mode-hook 'eww-hook)))
(use-package help-mode
:defer t
:config
(define-key help-mode-map (kbd "C-c f") 'ace-link))
(use-package woman
:defer t
:config
(define-key woman-mode-map (kbd "C-c f") 'ace-link))
(use-package org
:defer t
:config
(define-key org-mode-map (kbd "C-c f") 'ace-link))
;; Subsection 1.2
;; Default theme.
(use-package modus-themes
:ensure t
:init
;; Add all your customizations prior to loading the themes
(setq-default modus-themes-success-deuteranopia t
modus-themes-bold-constructs t
modus-themes-syntax '(faint yellow-comments green-strings)
modus-themes-mixed-fonts t ; available for 1.7
modus-themes-links '(faint bold italic)
modus-themes-prompts '(gray intense)
modus-themes-mode-line '(3d accented)
modus-themes-completions 'opinionated
modus-themes-fringes 'intense
modus-themes-lang-checkers '(text-also background intense)
modus-themes-hl-line '(accented)
modus-themes-paren-match '(bold intense)
modus-themes-variable-pitch-ui t)
(modus-themes-load-themes)
:config
(modus-themes-load-operandi))
(add-hook 'server-after-make-frame-hook `(lambda () (load-theme 'modus-operandi t))) ;This is a workaround for Solaire Mode.
;; Fonts and faces.
(set-face-attribute 'default nil :family "Clear Sans" :height 125)
(set-face-attribute 'variable-pitch nil :family "FreeSerif" :height 1.0)
(set-face-attribute 'fixed-pitch nil :family "Iosevka Light" :height 1.25)
;; y-or-no-p 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 dimensions (but not geometry) of the frame in GUI mode.
(setq default-frame-alist
'(() ()
(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.3
;; 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)))
;; Kill the current buffer.
(global-set-key (kbd "C-x k") 'kill-this-buffer)
;; Subsection 1.4
;; Give us stats during startup.
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time))) gcs-done)))
;; We want to treat documents as ASCII by default.
(prefer-coding-system 'us-ascii-unix)
;; Disable TLS 1.3.
(eval-after-load "gnutls" (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
;; Store temporary files in a backup directory.
(progn
(setq temporary-file-directory "~/.config/emacs/.backup/temp/")
(setq auto-save-directory "~/.config/emacs/.backup/autosave/"))
(eval-after-load "tramp.el" (progn
(setq tramp-auto-save-directory "~/.config/emacs/.backup/autosave/")
(make-directory temporary-file-directory t)
(make-directory auto-save-directory 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
(use-package xterm-color
:ensure t
:demand)
(use-package rainbow-blocks
:ensure t
:demand)
(use-package rainbow-mode
:ensure t
:demand)
;; ;; Good-scroll improves Emacs' scrolling abilities.
;; (use-package good-scroll
;; :ensure t
;; :demand
;; :config
;; (progn (good-scroll-mode 1)
;; (global-set-key [next] #'good-scroll-up-full-screen)
;; (global-set-key [prior] #'good-scroll-down-full-screen)
;; (setq good-scroll-render-rate .16)))
;; Golden Ratio resizes the current buffer according to the golden ratio.
;; TODO: Make it recenter on switch.
(use-package golden-ratio
:ensure t
:demand
:config
(progn
(golden-ratio-mode 1)
;; Interop with other libraries.
(setq golden-ratio-extra-commands
(flatten-list (list 'golden-ratio-extra-commands '(ace-window ace-jump-move))))
(setq golden-ratio-recenter 1)))
;; Golden Scroll forces scrolling to adhere to the golden ratio.
;; TODO: Recenter on scroll.
(use-package golden-ratio-scroll-screen
:ensure t
:demand
:config
(progn
(global-set-key (kbd "<prior>") `golden-ratio-scroll-screen-down)
(global-set-key (kbd "<next>") `golden-ratio-scroll-screen-up)
(global-set-key (kbd "C-v") `golden-ratio-scroll-screen-up)
(global-set-key (kbd "M-v") `golden-ratio-scroll-screen-down)
;; The built-in support for recentering seems broken...
;; It would be trivial to write a wrapper function to achieve the same effect, though.
;; Basically, just write your own scroll function that calls the golden-scroll function
;; and then recenters the screen. It would be nice to combine this with centered-cursor-mode,
;; too - only problem is that it stutters a bit at the end of buffers when using golden-scroll functions.
(setq golden-ratio-scroll-recenter 1)))
;; zoom-window allows for temporarily "full-screening" a window.
(use-package zoom-window
:ensure t
:demand
:config
(progn
(global-set-key (kbd "C-z") `zoom-window-zoom)))
;; Dim inactive buffers.
(use-package dimmer
:ensure t
:demand
:config
(progn
(dimmer-mode 1)
(dimmer-configure-helm)
(setq-default
dimmer-adjustment-mode :both
dimmer-fraction .40)))
;; 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
(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 '("*Compile-Log*" :height 20) popwin:special-display-config)
(push '("*Warnings*" :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 Avy and Ace packages.
(use-package avy
:ensure t
:demand
:config
(global-set-key (kbd "C-c SPC") 'avy-goto-char))
(use-package ace-window
:ensure t
:demand
:config
(global-set-key (kbd "M-o") 'ace-window))
(use-package ace-link
:defer t
:ensure t
:demand)
;;; Subsection 2.3
(use-package aggressive-indent
:ensure t
:defer t)
;; Add SLY, a Common Lisp REPL.
(use-package sly
:ensure t
:defer t
:config
(setq inferior-lisp-program "sbcl"))
;; Add Geiser, a Scheme REPL.
(use-package geiser
:ensure t
:defer t
:config
(setq-default inferior-lisp-program "mit-scheme-native"))
(use-package geiser-mit
:ensure t
:defer t)
(use-package ac-sly
:ensure t
:defer t)
(use-package ac-geiser
:ensure t
:defer t)
(use-package ac-html
:ensure t)
(use-package ac-etags
:ensure t)
(use-package ac-ispell
:ensure t)
(use-package ac-c-headers
:ensure t)
(use-package ac-ispell
:ensure t
:defer t)
(use-package auto-complete
:ensure t
:demand
:config
(progn
(ac-config-default)
(ac-set-trigger-key "TAB")
;; Sources.
(defun list-sources (SOURCES) "Produce a list containing the contents of SOURCES."
(flatten-list
(list (list SOURCES) ac-sources)))
(add-hook 'c-mode-hook
(lambda ()
(progn
(ac-etags-setup)
(setq ac-sources
(list-sources `(ac-source-etags ac-source-c-headers ac-source-c-header-symbols))))))
(add-hook 'scheme-mode-hook
(lambda ()
(progn
(setq ac-sources
(list-sources `(ac-source-geiser))))))
(add-hook 'geiser-mode-hook 'ac-geiser-setup)
(add-hook 'geiser-repl-mode-hook 'ac-geiser-setup)))
;; Configure the fuzzy-pattern matching engine, Helm
(use-package helm
:ensure t
:demand
:bind
:config
(progn (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
:defer t
:ensure t
:after eww helm
:config
(progn
()))
;; Flycheck provides on-the-fly syntax linting
(use-package flycheck
:defer t
:ensure t
:config
(progn (global-flycheck-mode)))
;; Integrate Helm recommendations and Flycheck linting
(use-package helm-flycheck
:defer t
:after helm flycheck
:ensure t
:demand
:config
(define-key flycheck-mode-map (kbd "C-c ! h") 'helm-flycheck))
;; Add an SRFI browser.
(use-package srfi
:defer t
:ensure t)
;; Enable development features in certain modes.
(defvar proghook-active 0)
(defun proghook () "Function for 'prog-mode' hook."
(progn
(aggressive-indent-mode)
(global-ede-mode)
(semantic-mode)
(flycheck-mode)
(electric-pair-mode)
(electric-indent-mode)
(solaire-mode)
(rainbow-blocks-mode)
(rainbow-mode)
(goggles-mode)
(focus-mode)
(show-paren-mode)
(mapcar 'set-on '(display-line-numbers))))
(add-hook 'prog-mode-hook 'proghook)
;; Add cwarn-mode to cc-mode later on
(defvar chook-active 0)
(defun chook () "Function for 'c-mode' hook."
(progn
(c-set-style "whitesmith")))
(add-hook 'c-mode-hook 'chook)
(defvar texthook-active 0)
(add-hook 'text-mode-hook 'texthook)
(defun texthook () "Function for 'text-mode' hook."
(progn
(variable-pitch-mode 1)
(solaire-mode 1)
(goggles-mode 1)
(focus-mode 1)))
(add-hook 'text-mode-hook 'texthook)
;; The rest of the init file.
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
(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.
'(beacon-mode t)
'(custom-safe-themes
'("2f93ebb862a9d50fee9c1b3302d858e2d2c0bba9d4e1be9bb3b08b7373f1710c" default))
'(helm-completion-style 'helm)
'(package-selected-packages
'(ac-geiser centered-cursor-mode golden-ratio-scroll-screen helpful indent-guide zoom-window dimmer god-mode paredit geiser-mit ctxmenu aggressive-indent-mode xpm ws-butler web-completion-data use-package srfi solarized-theme solaire-mode sly rainbow-mode rainbow-blocks powerline popwin paren-face parchment-theme names helm-slime helm-mode-manager helm-flycheck helm-eww good-scroll goggles gnuplot focus flyspell-correct-helm flymake-haskell-multi flymake flycheck-haskell flycheck-aspell eww-lnum electric-operator context-coloring clean-buffers aggressive-indent ace-window ace-link ace-jump-mode ac-slime ac-html ac-haskell-process ac-etags))
'(quack-default-program "scheme")
'(quack-newline-behavior 'newline)
'(quack-programs
'("s9" "bigloo" "csi" "csi -hygienic" "gosh" "gracket" "gsi" "gsi ~~/syntax-case.scm -" "guile" "kawa" "mit-scheme" "racket" "racket -il typed/racket" "rs" "scheme" "scheme48" "scsh" "sisc" "stklos" "sxi"))
'(quack-run-scheme-always-prompts-p nil)
'(quack-smart-open-paren-p nil)
'(warning-suppress-log-types '((use-package) (comp)))
'(warning-suppress-types '((emacs) (comp))))
(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.
)