Commit 4e0ad4617ccd

Vincent Demeester <vincent@sbr.pm>
2026-05-21 09:39:52
feat(emacs): switch to Emacs 31 branch
Added custom overlay based on emacs-git-pgtk with source pinned to the upstream emacs-31 branch. Also improved vc-dir, vc-git, log-edit and diff-mode configuration with better defaults and keybindings.
1 parent c07d643
Changed files (4)
dots
config
emacs
home
common
overlays
systems
dots/config/emacs/init.el
@@ -912,6 +912,7 @@ minibuffer, even without explicitly focusing it."
 			     (?d "Dired" project-dired)
 			     (?b "Buffer" project-switch-to-buffer)
 			     (?q "Query replace" project-query-replace-regexp)
+			     (?v "VC dir" project-vc-dir)
 			     (?m "Magit" vde/project-magit-status)
 			     (?e "Eshell" project-eshell)
 			     (?E "Eat" vde/project-eat)
@@ -1039,12 +1040,37 @@ minibuffer, even without explicitly focusing it."
 ;;       (vc-git-grep symbol "*" (vc-git-root default-directory)))))
 ;; (global-set-key (kbd "C-c p s") 'tkj/vc-git-grep-symbol)
 
+(use-package vc
+  :custom
+  (vc-allow-rewriting-published-history nil "safety guard for history rewriting")
+  (vc-async-checkin t "async commits for git/hg")
+  (vc-no-confirm-moving-changes nil "ask before moving changes between worktrees"))
+
 (use-package vc-dir
   :bind (("C-x v D" . project-vc-dir)
          :map vc-dir-mode-map
          ("=" . vc-diff)
          ("v" . vc-next-action)
-         ("C-c C-c" . vc-next-action)))
+         ("C-c C-c" . vc-next-action))
+  :custom
+  (vc-dir-hide-up-to-date-on-revert t "hide up-to-date files after refresh"))
+
+(use-package vc-git
+  :custom
+  (vc-git-diff-switches '("--histogram" "--stat"))
+  (vc-git-print-log-follow t "follow renames in file log"))
+
+(use-package log-edit
+  :custom
+  (log-edit-hook '(log-edit-insert-cvs-template
+                   log-edit-show-files
+                   log-edit-maybe-show-diff))
+  :bind (:map log-edit-mode-map
+         ("C-c C-d" . log-edit-show-diff)))
+
+(use-package diff-mode
+  :bind (:map diff-mode-map
+         ("v" . vc-next-action)))
 
 (use-package magit
   :unless noninteractive
home/common/dev/emacs.nix
@@ -1,6 +1,6 @@
 {
   pkgs,
-  desktop ? null,
+
   ...
 }:
 let
@@ -211,16 +211,7 @@ in
     enable = true;
     # Build Emacs with GUI support (GTK3/PGTK/X11) only on desktop systems
     # On servers, use terminal-only build to avoid D-Bus dependency
-    package = pkgs.emacs-unstable.override {
-      withTreeSitter = true;
-      withNativeCompilation = true;
-      # Only enable GUI features when desktop is configured
-      withX = false; # Never enable X
-      withPgtk = desktop != null;
-      withWebP = desktop != null;
-      withGTK3 = desktop != null;
-      withSQLite3 = true;
-    };
+    package = pkgs.emacs-31;
     extraPackages = myExtraPackages;
   };
   # services.emacs = {
overlays/default.nix
@@ -10,6 +10,20 @@ in
       pkgs = final;
       inherit globals;
     };
+  # Emacs 31 from the emacs-31 branch (not yet in emacs-overlay as a release)
+  # Must be applied after emacs-overlay which provides emacs-unstable
+  emacs-31 = final: prev: {
+    emacs-31 = prev.emacs-git-pgtk.overrideAttrs (_old: {
+      pname = "emacs-31";
+      version = "31.0.50";
+      src = final.fetchgit {
+        url = "https://git.savannah.gnu.org/git/emacs.git";
+        rev = "1754015c6034d65b047d0ada23a406f114d7850d"; # emacs-31 branch, 2026-05-20
+        hash = "sha256-hSDMwhl4uVPy6NNyaPPmpu3swQfjE18S3XFgDtX3+BE=";
+      };
+    });
+  };
+
   modifications = final: prev: {
     # Pin SearXNG to latest commit for critical engine fixes:
     # - Google useragent bypass (#5892, 2026-03-23)
@@ -24,7 +38,7 @@ in
           hash = "sha256-ehSMsSpE+0k8r+2Vseu8kangsYxToZv3vinynsDp9zs=";
         };
       in
-      prev.niri.overrideAttrs (old: {
+      prev.niri.overrideAttrs (_old: {
         version = "26.04";
         inherit src;
         postPatch = ''
systems/default.nix
@@ -35,6 +35,7 @@
 
       # And from other flakes
       inputs.emacs-overlay.overlay
+      outputs.overlays.emacs-31
       inputs.chapeau-rouge.overlays.openshift
       inputs.chick-group.overlays.default
       inputs.go-org-readwise.overlays.default