The Complete Computing Environment

Emacs Session Startup

(provide 'cce/startup)
(setq custom-file "~/.emacs.d/custom.el")

I almost always want Emacs's server running. There's no reason not to, especially when I am using EXWM. The ability to be able to attach to Emacs to edit files from the command line, or to rescue a broken X11 session, or to do batch operations using Emacs's text-processing libraries are all super powerful, and it makes little sense to not use this.

(unless (boundp 'server-process)

Desktop Save Mode is the session management system for Emacs; it holds state of open buffers and session variables across instantiation of Emacs, which is super useful in mobile setups like laptops which reboot a lot. To make startup sane, I'm choosing to eagerly restore the 10 most recently used buffers on startup, and then in Idle the system will restore the remaining buffers.

(desktop-save-mode 1)
(setq desktop-restore-eager 25)
(setq desktop-load-locked-desktop t)
(setq desktop-files-not-to-save "\\(^/[^/:]*:\\|(ftp)$\\|KILL\\)")
(setq desktop-restore-frames nil)
(setq desktop-lazy-verbose nil)

Emacs should automatically save my state, and does so every five minutes.

(defun cce/desktop-save ()
  "Write the desktop save file to ~/.emacs.d"
  (desktop-save user-emacs-directory))
(if (not (boundp 'cce/desktop-save-timer))
    (setq cce/desktop-save-timer
          (run-with-idle-timer 300 t 'cce/desktop-save)))

The splashscreen is useful if you've never used Emacs before, but I'd rather just drop straight in to the Scratch buffer.

(setq inhibit-splash-screen t)

savehist mode simply persists the state of a bunch of user-input fields, allowing history of minibuffer input, my kill ring, etc. This is a simple quality of life fix.

(require 'savehist)
(setq savehist-file (concat user-emacs-directory "savehist"))
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
(savehist-mode 1)

recentf gives me a "Recent Files" menu and also some pretty neat Projectile integration. consult-recentf in my Consult configuration benefits from this thing well.

(recentf-mode 1)

Use ibuffer instead of list-buffers; someday I'd like to move this to use sbuffer.el

(global-set-key (kbd "C-x C-b") 'ibuffer)
(with-eval-after-load "ibuffer"
  (add-to-list 'ibuffer-hook #'ibuffer-set-filter-groups-by-mode))