Skip to content

Instantly share code, notes, and snippets.

@cdegroot
Created July 19, 2023 14:22
Show Gist options
  • Save cdegroot/04b75c5fac2f9bcd886d26402139df9c to your computer and use it in GitHub Desktop.
Save cdegroot/04b75c5fac2f9bcd886d26402139df9c to your computer and use it in GitHub Desktop.
StumpWM + spatial groups + Emacs-per-group-z-index = bliss.
;;;
;;; We run a server per z-index.
;;;
(defparameter *xdg-runtime-dir* (getenv "XDG_RUNTIME_DIR"))
(defparameter *emacs-socket-dir* (concatenate 'string *xdg-runtime-dir* "/emacs/"))
(defun cur-z ()
(third (split-string (group-name (current-group)) ",")))
(defun cur-socket ()
(concatenate 'string *emacs-socket-dir* (cur-z)))
(defun maybe-start-emacs-server ()
(unless (probe-file (cur-socket))
(run-shell-command (concatenate 'string "emacs --bg-daemon=" (cur-z)))
(echo "Started Emacs server, sleeping a bit before starting client...")
(sleep 10)
(echo "Starting client")))
(defcommand emacs () ()
"Start Emacs client with a z-index specific server"
(maybe-start-emacs-server)
(run-shell-command (concatenate 'string "emacsclient -c -s " (cur-socket))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment