ksqsf / emacs-config

Moderately personalized Emacs config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My Emacs Config

This is my personal, “slightly configured” Emacs.

There are some packages written by me for my own convenience. See the last section.

Supported Platforms

This configuration is mainly developed on macOS. It also works on Linux and Windows (for the most part).

NOTE: This configuration only targets Emacs 29. (For one thing, it relies on the bundled use-package.) No guarantee about forward/backward compatibility. You can comment out the first paragraph in init.el if you do want to try.

Structure

There are two kinds of configuration, Module and Volatile. The distinction is (in my mind) very successful.

Module

Modules make up the functionality and keybindings. They are stable and can be byte compiled safely and cleanly. Ideally, they use lexical scoping.

Volatile

Volatile configuration files are more fragile and personal. They are mainly temporary tests or (let’s hope not) ugly hacks. A volatile Lisp file should never be byte compiled. Typically, it’s dynamically scoped.

Fonts

The following fonts are “blessed” in this configuration.

FontPointUsage
(Any monospace font)14General use (non-Chinese)
Sarasa Mono14For perfect Chinese alignment

Better Defaults

These modifications are generally in prelude-core.el and prelude-ui.el, and a few other files. They are loaded before anything else.

Prominent user-visible modifications are listed below.

UI

Mode line

Any of the following looks pretty good:

  • Default
  • Doom mode line
  • Moody

Modal editing (Evil)

I’m not fully invested in Evil, so currently it can be disabled completely by commenting out (require 'prelude-evil) in init.el.

I use Evil, because the Vi-style editing commands are the de facto standard right now, and evil-collection is great, and I still retain some muscle memory (I used to be a Vim user). Though, conceptually, I like Meow better.

Evil-collection offers a large collection of consistent, pre-configured keybindings for a variety of major modes. See its readme.

I use a hybrid editing style, i.e. in the insert mode, most Emacs commands are still available, so I can keep my muscle memory as much as possible. This is done by customizing evil-disable-insert-state-bindings. The conflicts are resolved depending on which is most familiar to me.

Completion

I use Vertico, Prescient, and Orderless.

Vertico offers a lightweight yet versatile frontend to completion-at-point.

Orderless significantly enhances the default completion algorithms, though its sorting is less than ideal.

Side windows

Many temporary buffers pop up in the side windows.

C-TAB toggles whether or not side windows are displayed.

Editing

Expand region

C-SPC C-SPC to expand the current region meaningfully. It supports tree-sitter-based expansion.

Zap up to char

M-z was assigned to zap-up-to-char. You can easily achieve what zap-to-char does with M-z <char> C-d.

At first, I thought M-z t and M-z f would be cool, but it turned out to be a horrible idea, because one must stop to think which key to press.

Structured Editing

Structured editing operates on the level of syntactical structures, be it identifiers, expressions, or statements.

I use paredit for the Lisp family. For tree-sitter-powered major modes, use combobulate-mode.

Programming

LSP

I’ve fully embraced LSP! (Used to be a skeptic.)

  • eglot as the LSP client. (Easier to hack than lsp-mode.)
  • corfu as the universal completion frontend.

Language servers can be installed via Homebrew or Nix. Eglot is intelligent enough to work with any server without special configuration.

REPL

Many major modes support REPL, but their keybindings are often very different. The following keychords are adopted by Emacs itself, so they are preferred when possible.

KeyFunction
C-c C-cSend buffer
C-c C-lSend file
C-x C-eSend this expression
C-M-xSend this function
Haskell, Idris

Haskell-mode has Interactive Haskell mode supporting ghci. Due to Haskell’s specialness, all you can do is C-c C-l.

Python

Elpy defined a bunch of send functions, but they turn out to be not so helpful.

Coq

Coq is an interactive proof assistant, whose Emacs interface is Proof General, which defines its own set of commands.

Unlimited Lisp Works

This repo hosts some other Emacs Lisp works made by me for my own convenience. It might be useful for you, too, so I made a list here for better discoverability.

WhoWhereWhat
pest-modegithub ksqsf/pest-modeMajor mode for Pest files
treefold./lisp/treefold.elFold any tree-like text
smtlib2-mode./lisp/smtlib2-mode.elMajor mode for SMT scripts
lojban./lisp/lojban.elZbalermorna input and rendering
bionic-reading./lisp/bionic-reading.elA (sort of) bionic reader in Emacs
clipboard./lisp/clipboard.elclipboard inspector
clipmgr./lisp/clipmgr.el(WIP) a clipboard manager
region-mark./lisp/region-mark.el
fish-protector./lisp/fish-protector.el魚の護衛者
logseq./lisp/logseq.elLogseq HTTP API
leitner./lisp/leitner.elThe Leitner system (a kind of SRS)
org-xlatexgithub ksqsf/org-xlatexinstant latex preview
flygpt./lisp/flygpt.elsemantic flymake based on GPT

About

Moderately personalized Emacs config


Languages

Language:Emacs Lisp 96.8%Language:YASnippet 3.1%Language:Shell 0.1%