Configuration_Files/user/configdir/emacs/init.el

540 lines
16 KiB
EmacsLisp

;;;; package --- Summary
;;;; Commentary:
;;; Code:
;;; TODO:
;; 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
;; 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.
;; 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
;; Replace flyspell with flycheck-aspell? I don't really want to do this, though,
;; since it makes me more reliant on GNU...
;;; 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
;; Section Zero - Function Definitions
(defun mpack-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!"))))
;; 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)))))
;; Section One - Initialization Settings and Routines
;; Make Emacs start more quickly by reducing the frequency of garbage collection
(setq gc-cons-threshold (* 1000 1000 1000 1000 1000 1000))
;; Prevent "cl" from being considered obsolete.
(setq byte-compile-warnings '(cl-functions))
;;; Package manager options.
;; TLS and networking configuration.
(progn 'require '(package gnutls))
(setq-default
gnutls-verify-error t
gnutls-min-prime-bits 4096
gnutls-trustfiles '("/etc/ssl/cert.pem")
gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; 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
(require 'async-bytecomp)
(async-bytecompile-package-mod 1)))
;;; Section Two - Package Initialization
;; Where do we look for ELisp on the local filesystem?
(setq-default
load-path (flatten-list
(list load-path
(mapcar 'directory-file-name
(list (concat (car (split-string user-init-file "init.el")) "local-lisp/"))))))
;; user-init-file holds location of init.el - use this with split-string, flatten-list and concat
(mapc 'mpack-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
citre
clhs
column-enforce-mode
comment-tags
crux
deft
dimmer
disable-mouse
drag-stuff
elforth
elpl
elsa
erefactor
flycheck-elsa
flyspell-correct-helm
flyspell-lazy
focus
folding
forth-mode
geiser-mit
god-mode
goggles
golden-ratio
golden-ratio-scroll-screen
hardcore-mode
helm-eww
helm-flycheck
helm-flyspell
helpful
immortal-scratch
indent-guide
modus-themes
paredit
popwin
powerline
rainbow-blocks
rainbow-mode
rc-mode
schrute
sly
solaire-mode
srfi
undo-fu
zoom-window))
;; 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))
;; 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)
(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-2)))
("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))))
(push
'pl/helm-alive-p
golden-ratio-inhibit-functions)))
("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
))
;; Same as above. Like, with hooks, y'know?
("lisp-mode" . '(progn
(setq inferior-lisp-program "sbcl")))
;; 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)
(flyspell-lazy-mode 1)
(auto-complete-mode 1)
(ac-ispell-ac-setup)
(solaire-mode 1)
(goggles-mode 1)
(focus-mode 1)
(setq 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")
(defun filename () "Return filename current buffer is viewing." (replace-regexp-in-string ".c" "" buffer-file-name))
(setq compile-command (concatenate 'string "cc -o " (filename) " " (concat (filename) ".c") ";" (filename))))))
;; 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" :height 1.0)
;; y-or-no-p is fine
(fset 'yes-or-no-p 'y-or-n-p)
;; 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)
;;; Reset the GC threshold to something more reasonable.
(setq gc-cons-threshold (* 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.
'(package-selected-packages
'(hardcore-mode smartparens 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.
'(variable-pitch ((t (:height 1.0 :family "Iosevka")))))
(provide 'init)
;;; init.el ends here