changeset 26: |
51a8370766f7 |
parent 25: |
94253682df1f |
child 27: |
1142c97f92ab |
author: |
ellis <ellis@rwest.io> |
date: |
Thu, 02 Nov 2023 19:51:07 -0400 |
files: |
emacs/default.el emacs/early-init.el emacs/init.el emacs/keys.el emacs/makefile emacs/util.el |
description: |
emacs config |
1.1--- a/emacs/default.el Tue Oct 31 00:16:50 2023 -0400
1.2+++ b/emacs/default.el Thu Nov 02 19:51:07 2023 -0400
1.3@@ -1,35 +1,76 @@
1.4 ;;; default.el --- default config -*- lexical-binding: t -*-
1.5 (load-theme 'modus-vivendi)
1.6 (put 'upcase-region 'disabled nil)
1.7-(repeat-mode 1)
1.8+(setq package-archives
1.9+ '(("gnu" . "https://elpa.gnu.org/packages/")
1.10+ ("nongnu" . "https://elpa.nongnu.org/nongnu/")
1.11+ ("melpa" . "https://melpa.org/packages/"))
1.12+ use-package-always-ensure t
1.13+ use-package-expand-minimally t)
1.14+(package-initialize)
1.15+;;; Packages
1.16+(with-eval-after-load 'package
1.17+ (mapc (lambda (x) (cl-pushnew x package-selected-packages))
1.18+ '(org-web-tools
1.19+ citeproc
1.20+ all-the-icons all-the-icons-dired all-the-icons-ibuffer)))
1.21+
1.22 ;;; VC
1.23 ;; use rhg, fallback to hg. see hgrc
1.24 (if (file-exists-p "~/.local/bin/rhg")
1.25 (setq hg-binary "~/.local/bin/rhg"))
1.26
1.27 ;;; Dired
1.28-(when (display-graphic-p)
1.29- (add-hook 'dired-mode-hook 'all-the-icons-dired-mode))
1.30+(when (and (display-graphic-p) (package-installed-p 'all-the-icons-dired))
1.31+ (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
1.32+ (add-hook 'ibuffer-mode-hook 'all-the-icons-ibuffer-mode))
1.33+
1.34+;;; Treesitter
1.35+(require 'treesit)
1.36+(mapc (lambda (x) (add-to-list 'treesit-language-source-alist x))
1.37+ '((python . ("https://github.com/tree-sitter/tree-sitter-python"))
1.38+ (commonlisp . ("https://github.com/theHamsta/tree-sitter-commonlisp"))))
1.39+
1.40+(mapc (lambda (x) (add-to-list 'treesit-load-name-override-list x))
1.41+ '((common-lisp "libtree-sitter-commonlisp" "tree_sitter_commonlisp")))
1.42+
1.43+(mapc (lambda (x) (add-to-list 'major-mode-remap-alist x))
1.44+ '((c-mode . c-ts-mode)
1.45+ (c++-mode . c++-ts-mode)
1.46+ (bash-mode . bash-ts-mode)
1.47+ (rust-mode . rust-ts-mode)
1.48+ (python-mode . python-ts-mode)
1.49+ (css-mode . css-ts-mode)
1.50+ (html-mode . html-ts-mode)
1.51+ (js-mode . js-ts-mode)
1.52+ (toml-mode . toml-ts-mode)
1.53+ (json-mode . json-ts-mode)
1.54+ (dockerfile-mode . dockerfile-ts-mode)))
1.55
1.56 ;;; Lisp
1.57-(defvar slime-toggle nil)
1.58-(defun slime-toggle ()
1.59- "toggle between lisp file and slime-repl"
1.60- (interactive)
1.61- (if (eq major-mode 'slime-repl-mode)
1.62- (setq slime-toggle (pop-to-buffer (or slime-toggle (read-buffer "lisp file: "))))
1.63+(use-package lisp-mode
1.64+ :ensure nil
1.65+ :config
1.66+ (setq inferior-lisp-program "sbcl"
1.67+ scheme-program-name "gsi"
1.68+ guile-program "guile"
1.69+ cmulisp-program "lisp"
1.70+ scsh-program "scsh"))
1.71+
1.72+(use-package slime
1.73+ :config
1.74+ (defvar slime-toggle nil)
1.75+ (defun slime-toggle ()
1.76+ "toggle between lisp file and slime-repl"
1.77+ (interactive)
1.78+ (if (eq major-mode 'slime-repl-mode)
1.79+ (setq slime-toggle (pop-to-buffer (or slime-toggle (read-buffer "lisp file: "))))
1.80 (progn
1.81 (setq slime-toggle (current-buffer))
1.82- (slime-repl))))
1.83-
1.84-(setq inferior-lisp-program "sbcl")
1.85-(setq scheme-program-name "gsi")
1.86-(setq guile-program "guile")
1.87-(setq cmulisp-program "lisp")
1.88-(setq scsh-program "scsh")
1.89+ (slime-repl)))))
1.90
1.91 ;; paredit-map
1.92-(defvar edit-map
1.93+(defvar paredit-map
1.94 (let ((map (make-sparse-keymap)))
1.95 (pcase-dolist (`(,k . ,f)
1.96 '(("u" . backward-up-list)
1.97@@ -57,14 +98,15 @@
1.98
1.99 (map-keymap
1.100 (lambda (_ cmd)
1.101- (put cmd 'repeat-map 'edit-map))
1.102- edit-map)
1.103+ (put cmd 'repeat-map 'paredit-map))
1.104+ paredit-map)
1.105
1.106 ;;; Rust
1.107 (add-to-list 'exec-path (expand-file-name "~/.cargo/bin/"))
1.108 (add-hook 'rust-mode-hook 'eglot-ensure)
1.109-(add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer")))
1.110 (setq rust-rustfmt-switches nil)
1.111+(with-eval-after-load 'eglot
1.112+ (add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer"))))
1.113
1.114 ;;; Keyboard Macros
1.115 (defun toggle-macro-recording ()
1.116@@ -175,7 +217,6 @@
1.117 (delete-dups
1.118 (ring-elements eshell-history-ring)))))
1.119 ;;; Org
1.120-(add-to-list 'package-selected-packages 'org-web-tools 'citeproc)
1.121 ;; todos
1.122 (setq org-todo-keywords
1.123 '((type "TBD(0!)" "TODO(t!)" "|")
1.124@@ -447,9 +488,6 @@
1.125 (keymap-set scratch-keys "n" #'new-scratch)
1.126 (keymap-set scratch-keys "SPC" #'default-scratch-buffer)
1.127
1.128-(with-eval-after-load 'default
1.129- (keymap-set keys-map "C-c i" #'scratch-keys))
1.130-
1.131 ;; Adapted from the `scratch.el' package by Ian Eure.
1.132 (defun default-scratch-list-modes ()
1.133 "List known major modes."
1.134@@ -526,3 +564,5 @@
1.135 (switch-to-buffer (get-buffer-create bufname))
1.136 (insert initial-scratch-message)
1.137 (lisp-interaction-mode)))
1.138+
1.139+(provide 'default)
2.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2+++ b/emacs/early-init.el Thu Nov 02 19:51:07 2023 -0400
2.3@@ -0,0 +1,43 @@
2.4+;;; early-init.el --- pre-init configuration -*- lexical-binding: t; -*-
2.5+
2.6+;; Copyright (C) 2021 The Compiler Company, LLC
2.7+
2.8+;; Author: Richard Westhaver <ellis@rwest.io>
2.9+;; Keywords: local
2.10+
2.11+;; This program is free software; you can redistribute it and/or modify
2.12+;; it under the terms of the GNU General Public License as published by
2.13+;; the Free Software Foundation, either version 3 of the License, or
2.14+;; (at your option) any later version.
2.15+;;
2.16+;; This program is distributed in the hope that it will be useful,
2.17+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2.18+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.19+;; GNU General Public License for more details.
2.20+;;
2.21+;; You should have received a copy of the GNU General Public License
2.22+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
2.23+;;
2.24+;; Commentary:
2.25+;;
2.26+;; A few snippets are added here that need to be loaded ASAP on
2.27+;; startup, such as UI elements that would otherwise be loaded for a
2.28+;; second and then disappear when the `init.el` file is loaded.
2.29+;;
2.30+;; If any of the below settings are in your `init.el`, I suggest
2.31+;; migrating them to `early-init.el`.
2.32+;;
2.33+;;; Code:
2.34+(setq frame-inhibit-implied-resize t
2.35+ inhibit-startup-buffer-menu nil
2.36+ initial-buffer-choice t
2.37+ use-dialog-box t
2.38+ use-file-dialog nil
2.39+ tool-bar-mode nil
2.40+ menu-bar-mode nil
2.41+ scroll-bar-mode t)
2.42+(when (and (fboundp 'native-comp-available-p)
2.43+ (native-comp-available-p))
2.44+ (setq native-comp-async-report-warnings-errors nil
2.45+ comp-deferred-compilation t
2.46+ package-native-compile t))
3.1--- a/emacs/init.el Tue Oct 31 00:16:50 2023 -0400
3.2+++ b/emacs/init.el Thu Nov 02 19:51:07 2023 -0400
3.3@@ -3,8 +3,7 @@
3.4 ;; default init file for GNU Emacs.
3.5
3.6 ;;; Code:
3.7-(require 'init/util)
3.8-
3.9+(load-file "util.el")
3.10 (add-to-load-path (join-paths user-emacs-directory "lib/"))
3.11-
3.12-(require 'default)
3.13+(load-file "default.el")
3.14+(package-install-selected-packages)
4.1--- a/emacs/keys.el Tue Oct 31 00:16:50 2023 -0400
4.2+++ b/emacs/keys.el Thu Nov 02 19:51:07 2023 -0400
4.3@@ -0,0 +1,12 @@
4.4+;;; keys.el --- emacs keys -*- lexical-binding: t -*-
4.5+
4.6+;; default keybinds
4.7+
4.8+;;; Commentary:
4.9+
4.10+;; I encourage you to remap these keys as you see fit. Where possible,
4.11+;; wrap your custom bindings in a keymap instead of redefining the
4.12+;; global defaults defined here.
4.13+
4.14+;;; Code:
4.15+
5.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2+++ b/emacs/makefile Thu Nov 02 19:51:07 2023 -0400
5.3@@ -0,0 +1,8 @@
5.4+DOTEMACS:=$(HOME)/.emacs.d
5.5+
5.6+.PHONY: c
5.7+
5.8+install:$(wildcard *.el) lib
5.9+ cp -rf $^ $(DOTEMACS)/
5.10+
5.11+clean:;rm -rf $(DOTEMACS)/{*.el,lisp,site-lisp}
6.1--- a/emacs/util.el Tue Oct 31 00:16:50 2023 -0400
6.2+++ b/emacs/util.el Thu Nov 02 19:51:07 2023 -0400
6.3@@ -3,6 +3,58 @@
6.4 ;;; Code:
6.5 (require 'cl-lib)
6.6
6.7+(defun group (source n)
6.8+ "This is Paul Graham's group utility from 'On Lisp'.
6.9+
6.10+Group a list of arguments SOURCE by any provided grouping amount
6.11+N.
6.12+
6.13+For example:
6.14+(group '(foo 2 bar 4) 2) ;=> ((foo 2) (bar 4))
6.15+(group '(a b c d e f) 3) ;=> ((a b c) (d e f))
6.16+"
6.17+ (when (zerop n) (error "zero length"))
6.18+ (cl-labels ((rec (source acc)
6.19+ (let ((rest (nthcdr n source)))
6.20+ (if (consp rest)
6.21+ (rec rest (cons
6.22+ (cl-subseq source 0 n)
6.23+ acc))
6.24+ (nreverse
6.25+ (cons source acc))))))
6.26+ (when source (rec source nil))))
6.27+
6.28+(defun flatten (x)
6.29+ "Paul Graham's flatten utility from 'On Lisp'.
6.30+
6.31+Given a tree X, return all the 'leaves' of the tree."
6.32+ (cl-labels ((rec (x acc)
6.33+ (cond ((null x) acc)
6.34+ ((atom x) (cons x acc))
6.35+ (t (rec
6.36+ (car x)
6.37+ (rec (cdr x) acc))))))
6.38+ (rec x nil)))
6.39+
6.40+(defun mkstr (&rest args)
6.41+ "Paul Graham's mkstr utility from 'On Lisp'.
6.42+
6.43+Coerce ARGS into a single string and return it."
6.44+ (let* ((s ""))
6.45+ (dolist (a args)
6.46+ (cond
6.47+ ((null a) nil)
6.48+ ((sequencep a) (setq s (concat s a)))
6.49+ ((numberp a) (setq s(concat s (number-to-string a))))
6.50+ ((symbolp a) (setq s(concat s (symbol-name a))))))
6.51+ s))
6.52+
6.53+(defun symb (&rest args)
6.54+ "Paul Graham's symb utility from 'On Lisp'.
6.55+
6.56+Concat ARGS and return a newly interned symbol."
6.57+ (intern (apply #'mkstr args)))
6.58+
6.59 (defmacro when-sys= (name body)
6.60 "(when (string= (system-name) NAME) BODY)"
6.61 `(when ,(string= (system-name) name) ,body))
6.62@@ -22,4 +74,4 @@
6.63 (setq result (concat (file-name-as-directory result) dir)))
6.64 result))
6.65
6.66-(provide 'init/util)
6.67+(provide 'util)