emacs/init.el

104 lines
3.8 KiB
EmacsLisp
Raw Normal View History

2022-06-19 19:05:40 -08:00
;;; init.el --- basic initial declarations
;;; Commentary:
;; _ _ _ _
;; (_) _ __ (_)| |_ ___ | |
;; | || '_ \ | || __| / _ \| |
;; | || | | || || |_ _| __/| |
;; |_||_| |_||_| \__|(_)\___||_|
;;
;; '((above text graphic generated with command `figlet -k "init.el"'))
;;; Code:
2024-01-23 18:44:23 -09:00
(setq gc-cons-threshold (* 8 5000 5000))
(setq load-prefer-newer t) ; why ever use stale code, ever?
;; Load the files that I put my settings in...
(defvar mir-directory
(directory-file-name
(concat user-emacs-directory
(convert-standard-filename "lisp/"))))
(add-to-list 'load-path mir-directory t)
(require 'mir-defuns)
;; minify yes/no prompts
2023-01-04 13:20:47 -09:00
(if (>= (string-to-number emacs-version) 28)
(defvar use-short-answers t)
(defalias 'yes-or-no-p 'y-or-n-p))
;; do the things
(add-hook 'server-after-make-frame-hook #'mir/graphical-setup)
2024-01-23 18:44:23 -09:00
(if (display-graphic-p)
(add-hook 'elpaca-after-init-hook #'mir/graphical-setup))
;; Control backups/swapfiles
(defvar backup-directory
(expand-file-name "emacs-backups"
(or (getenv "XDG_CACHE_HOME")
(expand-file-name
".cache" "~"))))
(if (not (file-exists-p backup-directory))
(make-directory backup-directory t))
(setq backup-directory-alist `(("." . ,backup-directory)))
;; auto-save-mode doesn't create the path automatically!
(defvar auto-save-directory
(expand-file-name "tmp/auto-saves/" backup-directory))
(make-directory auto-save-directory t)
(setq auto-save-list-file-prefix
(expand-file-name "sessions/" auto-save-directory)
auto-save-file-name-transforms
`((".*" ,auto-save-directory t)))
(setq create-lockfiles nil)
;; remove auto-generated bits
(setq custom-file (expand-file-name "custom.el" backup-directory))
(if (not (file-exists-p custom-file))
(make-empty-file custom-file t))
(load custom-file)
;; Suppress advice warnings on startup
;; https://andrewjamesjohnson.com/suppressing-ad-handle-definition-warnings-in-emacs/
(setq ad-redefinition-action 'accept)
;; straight.el: the better package manager?
;; minified bootstrap (split lines if you want) (or not)
;; (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (straight-use-package 'use-package) (setq straight-use-package-by-default t)
;; actually, use elpaca instead
;; (require 'elpaca-bootstrap)
(setq elpaca-bootstrap-file (expand-file-name "elpaca-bootstrap.el"
user-emacs-directory))
(unless (file-exists-p elpaca-bootstrap-file)
(with-current-buffer
(pop-to-buffer
(url-retrieve-synchronously "https://raw.githubusercontent.com/progfolio/elpaca/master/README.md"))
(re-search-forward (rx "### Installer\n"))
(let ((start (1+ (re-search-forward "```emacs-lisp")))
(end (- (re-search-forward "\n```") 3)))
2024-01-23 18:45:31 -09:00
(write-region start end elpaca-bootstrap-file))))
(load-file elpaca-bootstrap-file)
2023-02-23 12:50:19 -09:00
(elpaca elpaca-use-package
(elpaca-use-package-mode)
(setq elpaca-use-package-by-default t))
2024-01-23 18:45:31 -09:00
;; (message "%s" elpaca--queues)
(elpaca-process-queues)
(require 'mir-packages)
;; Absolute line numbers. Relative ones are an annoyance to set up, sadly.
;; (global-display-line-numbers-mode)
;; (defvar display-line-numbers-width-start t)
;; Don't barf out emacs errors as they are encountered
(setq debug-on-error nil)
2022-06-19 19:05:40 -08:00
;; lower gc threshold again
2024-01-23 18:44:23 -09:00
(setq gc-cons-threshold (* 2 100 1000))
2022-06-25 10:59:43 -08:00
;; (add-function :before #'after-focus-change-function #'garbage-collect)
2022-06-19 19:05:40 -08:00
;;; init.el ends here