Demacs is a personal Emacs configuration built with a modular architecture, managed via Nix flakes, and optimized for performance. It features the latest Emacs with IGC (Improved Garbage Collection) support, custom patches for macOS, and a curated selection of packages for programming, writing, and daily workflows.
- 🚀 Nix-managed - Reproducible builds with Nix flakes
- ⚡ IGC Support - Latest Emacs with Improved Garbage Collection
- 🍎 macOS Optimized - Custom patches for rounded frames, system appearance, smooth cursor
- 📦 Modular Design - Clean separation of concerns with
modules/,lib/, andsite-lisp/ - 🎨 Rosé Pine Theme - Beautiful day/night themes with system appearance sync
# Enter development shell
nix develop
# Run Emacs (default: IGC build)
nix run .#demacs
# Alternative builds
nix run .#demacs-igc # IGC without patches
nix run .#demacs-igc-patched # IGC with macOS patches
nix run .#demacs-git # Git master without patches
nix run .#demacs-git-patched # Git master with patches~/.emacs.d/ ├── init.el # Main entry point ├── early-init.el # Pre-initialization (GC, UI) ├── flake.nix # Nix flake configuration ├── modules/ # Feature modules (init-*.el) ├── lib/ # Shared helper libraries (lib-*.el) ├── site-lisp/ # Standalone packages ├── themes/ # Custom themes (Rosé Pine) ├── patches/ # Emacs patches for macOS ├── snippets/ # YASnippet templates └── templates/ # Tempel templates
The early-init.el handles pre-initialization settings for optimal startup performance.
;; Maximize GC threshold during startup, restore after
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.5)
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold (* 20 1024 1024))));; Prefer newer compiled files
(setq load-prefer-newer t)
;; Increase process read chunk size
(setq read-process-output-max (* 1024 1024)) ; 1mb
;; Reduce rendering work
(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil)
;; Disable bidirectional text for performance
(setq-default bidi-display-reordering 'left-to-right
bidi-paragraph-direction 'left-to-right);; Disable GUI elements via frame parameters (faster than mode functions)
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
(push '(undecorated-round . t) default-frame-alist) ; macOS rounded corners
(push '(fullscreen . maximized) default-frame-alist)The init.el bootstraps the configuration and loads modules in order.
;; Personal information
(setq user-full-name "Desmond Wang")
(setq user-mail-address "desmond.wang@netint.ca")
;; Font configuration
(defconst *default-font* "Maple Mono NF")
(defconst *zh-default-font* "Maple Mono NF CN")
(defconst *symbol-default-font* "Symbols Nerd Font Mono")
;; Paths
(defconst *org-path* "~/Documents/Org/");; Load paths
(dolist (dir '("modules" "lib" "site-lisp" "themes"))
(add-to-list 'load-path (expand-file-name dir user-emacs-directory)))
;; Core setup
(require 'setup)
(require 'init-setup)
;; Platform-specific
(when *is-mac* (require 'init-mac))
;; UI and editing
(require 'init-ui)
(require 'init-editing)
(require 'init-vc)
(require 'init-minibuffer)
(require 'init-completion)
;; Programming
(require 'init-prog)
(require 'init-util)
(require 'init-transient)
(require 'init-bitstream)
;; Org and documents
(require 'init-org)
(require 'init-reader)
(require 'init-social)
;; Shell and AI
(require 'init-shell)
(require 'init-ai)
;; Local customizations
(require 'init-local)Visual customization and window management.
;; Rosé Pine theme with automatic light/dark switching
(:option custom-enabled-themes '(rose-pine-night)
light-theme 'rose-pine-day
dark-theme 'rose-pine-night)
;; Sync with macOS system appearance
(when *is-mac*
(apply-theme-based-on-appearance)
(:with-hook ns-system-appearance-change-functions
(:hook apply-theme-based-on-appearance)))popper- Popup window management (shells, help, compilation)tabspaces- Session/workspace management
;; Custom tab bar configuration
(:option tab-bar-separator ""
tab-bar-close-button-show nil
tab-bar-new-button-show nil
tab-bar-tab-hints t
tab-bar-select-tab-modifiers '(super))Custom startup panel with weather, image, and quote display.
Enhanced editing experience with modal editing and smart features.
;; Meow as the modal editing system
(require 'meow)
(meow-global-mode 1)
(meow-setup)
;; Use system clipboard
(:option meow-use-clipboard t)
;; Undo system
(undo-fu-session-global-mode)
(:option undo-limit 67108864
undo-strong-limit 100663296
undo-outer-limit 1006632960)Automatic input source switching for CJK support.
;; Switch to English on mode exit
(:hooks meow-insert-exit-hook sis-set-english)
;; Context-aware input switching for org-mode, telega
(sis-global-cursor-color-mode t)
(sis-global-respect-mode t)
(sis-global-context-mode t)| Package | Purpose |
|---|---|
move-dup | Move/duplicate lines |
rainbow-delimiters | Colorful parentheses |
symbol-overlay | Highlight symbols |
vundo | Visual undo tree |
goggles | Pulse modified regions |
ultra-scroll | Smooth scrolling |
Git integration with Magit and related tools.
;; Full-screen magit status
(:advice magit-status :around #'magit-fullscreen)
;; Key bindings
(keymap-global-set "C-x g" 'magit-status)
(keymap-global-set "C-x M-g" 'magit-dispatch)
;; Refined diff highlighting
(:option magit-diff-refine-hunk t)Support for GitHub and GitLab forges, including custom GitLab instance.
diff-hl- Fringe indicators for changesblame-reveal- Interactive git blame
Modern completion framework with Vertico ecosystem.
;; Vertico for vertical completion
(vertico-mode)
(:option vertico-cycle t)
;; Vertico-posframe for floating completion
(vertico-posframe-mode 1)
;; Consult commands
(keymap-global-set "C-c f l" 'consult-line)
(keymap-global-set "C-c f i" 'consult-imenu)
(keymap-global-set "C-c f f" 'consult-fd)
(keymap-global-set "C-c f r" 'consult-ripfd)
(keymap-global-set "C-c f b" 'consult-buffer)Context-aware actions on completion candidates.
(keymap-global-set "C-c ." 'embark-act)
(keymap-global-set "M-n" 'embark-next-symbol)
(keymap-global-set "M-p" 'embark-previous-symbol)Rich annotations in the minibuffer.
Custom overlay-based mode-line in the echo area.
In-buffer completion with Corfu ecosystem.
(global-corfu-mode)
(:option corfu-cycle t
corfu-auto t
corfu-auto-prefix 2
corfu-preselect 'prompt)Completion-at-point extensions.
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)Flexible matching styles with pinyin support.
Template expansion system.
Language support and development tools.
Automatic file associations for tree-sitter major modes:
| Extension | Mode |
|---|---|
.py | python-ts-mode |
.js | js-ts-mode |
.ts | typescript-ts-mode |
.tsx | tsx-ts-mode |
.json | json-ts-mode |
.yaml | yaml-ts-mode |
.nix | nix-ts-mode |
.rs | rust-ts-mode |
.go | go-ts-mode |
.java | java-ts-mode |
.vue | vue-mode |
.lpy | basilisp-ts-mode |
;; Auto-start for specific modes
(:with-mode (python-ts-mode js-ts-mode tsx-ts-mode vue-mode latex-mode)
(:hook eglot-ensure))
;; Custom server configurations
(add-to-list 'eglot-server-programs
'((python-mode python-ts-mode) . ("rass" "basedruff")))
(add-to-list 'eglot-server-programs
`((vue-mode vue-ts-mode typescript-ts-mode)
. ("vue-language-server" "--stdio"
:initializationOptions ,(vue-eglot-init-options))))Automatic code formatting on save.
;; Format on save in prog-mode
(:hook-into prog-mode)
;; Custom formatters
(setf (alist-get 'python-ts-mode apheleia-mode-alist) 'ruff)
(setf (alist-get 'typescript-ts-mode apheleia-mode-alist) 'prettier);; Show diagnostics at end of line (Emacs 31+)
(when (version<= "31" emacs-version)
(setopt flymake-show-diagnostics-at-end-of-line t));; Extra project markers
(setopt project-vc-extra-root-markers
'("package.json" "deps.edn" "project.clj"
"Package.swift" ".envrc" ".tags" ".project"))Directory-local environment with direnv integration.
Comprehensive org-mode configuration for GTD and writing.
(:option org-directory *org-path*
org-log-done t
org-startup-indented t
org-hide-emphasis-markers t
org-image-actual-width nil);; TODO keywords
org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
(sequence "PROJECT(p)" "|" "DONE(d!/!)" "CANCELLED(c/!)")
(sequence "WAITING(w/!)" "DELEGATED(e!)" "HOLD(h)" "|" "CANCELLED(c/!)"))Custom agenda views for GTD workflow:
- g - Main GTD view (agenda, next actions, projects, waiting)
- v - Orphaned tasks and inbox
- N - Notes
| Package | Purpose |
|---|---|
org-modern | Modern styling |
org-modern-indent | Indented blocks |
org-appear | Reveal markup on cursor |
org-tidy | Clean property display |
valign | Table alignment |
visual-fill-column | Centered, wrapped text |
Zettelkasten-style note-taking.
(keymap-global-set "C-c n n" 'denote-open-or-create)
(keymap-global-set "C-c n l" 'denote-link)
(keymap-global-set "C-c n b" 'denote-backlinks)Code execution in org documents.
(org-babel-do-load-languages
'org-babel-load-languages '((python . t)
(shell . t)
(verb . t)
(latex . t)))Terminal emulation and shell integration.
Full-featured terminal emulator.
Ghostty-powered terminal emulator with automatic native module download on first launch.
(:option ghostel-shell "zsh"
ghostel-module-auto-install 'download)Emacs-native shell with custom prompt and eat integration.
(keymap-global-set "<f8>" 'eshell)
(:option eshell-prompt-function 'eshell-prompt-multiline
eshell-highlight-prompt nil
eshell-banner-message "")
;; Eat for better terminal emulation in eshell
(:with-hook eshell-load-hook
(:hook eat-eshell-mode)
(:hook eat-eshell-visual-command-mode))LLM and AI-powered features.
(:option gptel-default-mode 'org-mode
gptel-model "openrouter/auto")Claude Code and other AI agent integration with sidebar support.
(keymap-global-set "C-c a s" 'agent-shell-sidebar-toggle)
(keymap-global-set "C-c a f" 'agent-shell-sidebar-toggle-focus)Code generation and review with Magit integration.
Shared helper functions used across modules:
| Library | Purpose |
|---|---|
lib-appearance | Theme switching, opacity adjustment |
lib-consult | Consult extensions |
lib-eglot | LSP server configurations |
lib-env | Environment variable loading |
lib-eshell | Eshell prompt and aliases |
lib-face | Font setup |
lib-gptel | GPTel backend configuration |
lib-hs | Hideshow cycling |
lib-lisp | Elisp evaluation helpers |
lib-magit | Magit enhancements |
lib-meow | Meow keybinding setup |
lib-org | Org-mode utilities |
lib-tabbar | Tab bar formatting |
lib-telega | Telegram helpers |
lib-transient | Transient menu definitions |
lib-treesit | Tree-sitter grammar sources |
lib-vterm | Vterm keybindings |
lib-window | Window manipulation |
Custom/local packages:
| Package | Description |
|---|---|
miniline | Overlay-based mode-line in echo area |
miniline-segments | Segments for miniline |
gptel-quick | Quick GPTel interactions |
fpga-manager | FPGA development tools |
A soothing color theme with day and night variants.
rose-pine-night- Dark variant (default)rose-pine-day- Light variant
Automatically switches based on macOS system appearance.
| Package | Description |
|---|---|
demacs / demacs-igc | Default IGC build |
demacs-igc-patched | IGC with macOS patches |
demacs-git | Git master build |
demacs-git-patched | Git master with macOS patches |
round-undecorated-frame- Rounded window cornerssystem-appearance- OS light/dark mode detectionns-alpha-background- Transparent frame backgroundsmooth-cursor- Smooth cursor animation
Packages fetched from GitHub:
telega- Telegram client (custom fork)setup-el- Setup.el macro libraryeglot-x- Eglot extensionsorg-modern-indent- Org indentationagent-shell-sidebar- AI agent sidebar- And more…
| Key | Command |
|---|---|
C-c g | Magit status |
C-c f l | Consult line |
C-c f b | Consult buffer |
C-c f f | Consult fd |
C-c . | Embark act |
C-; | Avy goto word |
C-c n n | Denote open/create |
C-c e e | Emacs access transient |
C-c a s | Agent shell sidebar |
C-c t | Telega prefix |
<f8> | Eshell |
| Key | Command |
|---|---|
C-c L | Store link |
C-c C-o | Open at point |
C-M-up | Up element |
| Key | Command |
|---|---|
C-c e p | Prog commands transient |
C-c C-x C-f | Format buffer |
This is a personal configuration, but suggestions are welcome! Please open an issue or pull request on GitHub.
This configuration is released under the GPL-3.0 license. See LICENSE for details.
—
Generated for demacs - Desmond’s Emacs Configuration