From 641b10845f445fa3d877e5221ffc70261dac82a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Jan 2026 06:26:05 +0000 Subject: [PATCH] Fix Emacs socket path to match server-socket-dir defaults The EMACS_SOCKET_NAME paths were not matching what Emacs actually creates by default: - Darwin: Emacs uses $TMPDIR/emacs (no UID), but shell had UID - Linux fallback: Emacs uses /tmp/emacs, but shell was missing UID This caused emacsclient to fail with "server not running" since it was looking for sockets at the wrong paths. --- .config/zsh/tools.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.config/zsh/tools.zsh b/.config/zsh/tools.zsh index 67b32ff..9cc758b 100644 --- a/.config/zsh/tools.zsh +++ b/.config/zsh/tools.zsh @@ -70,11 +70,18 @@ if [[ -z "$XDG_RUNTIME_DIR" ]]; then fi # Configure Emacs socket name based on platform +# These paths must match Emacs's default server-socket-dir behavior if [[ "$CURRENT_OS" = "Darwin" ]]; then - EMACS_SOCKET_NAME="${TMPDIR:-/tmp}emacs$(id -u)/server" + # Emacs on Darwin uses $TMPDIR/emacs (no UID in path) + EMACS_SOCKET_NAME="${TMPDIR%/}/emacs/server" export EMACS_SOCKET_NAME elif [[ "$CURRENT_OS" = "Linux" ]]; then - EMACS_SOCKET_NAME="${XDG_RUNTIME_DIR:-/tmp}/emacs/server" + # Emacs on Linux uses XDG_RUNTIME_DIR if available, otherwise /tmp/emacs + if [[ -n "$XDG_RUNTIME_DIR" ]]; then + EMACS_SOCKET_NAME="${XDG_RUNTIME_DIR}/emacs/server" + else + EMACS_SOCKET_NAME="/tmp/emacs$(id -u)/server" + fi export EMACS_SOCKET_NAME fi