diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-10-27 13:58:05 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-10-29 21:47:37 -0700 |
commit | 1ce37c45ba673715250002bb5324ca76e600619a (patch) | |
tree | 2b4f82820d5ecb48181feaa4c01dd985a1b997cc | |
parent | 5090bc3b08123b79897662ff69eb48874df5ccde (diff) | |
download | dotfiles-1ce37c45ba673715250002bb5324ca76e600619a.tar.gz |
try out starting an instance of flock(1) early in kill-emacs-hook
-rw-r--r-- | .emacs.d/init.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index dbe06590..02185e93 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -2342,6 +2342,22 @@ Called by '~/src/dotfiles/bin/emacsclient --spw/update-environment'." (funcall orig-fun))) (advice-add 'comint-stop-subjob :around #'spw/comint-stop-subjob) +;; flock(1) starting daemons named the same as us so that instances of my +;; emacsclient(1) wrapper wait on us completing our exit before trying to +;; start us again. +(defun spw/daemon-lock-self () + (when (and (daemonp) (executable-find "flock") (executable-find "sleep")) + (let ((file + (file-name-concat + (or (getenv "XDG_RUNTIME_DIR") (format "/run/user/%d" (user-uid))) + "spw_emacsclient" + (cl-etypecase (daemonp) (string (daemonp)) (t "server"))))) + (set-process-query-on-exit-flag + (start-process "spw_emacsclient" nil + "flock" "-E" "0" "-n" file "sleep" "infinity") + nil)))) +(add-hook 'kill-emacs-hook #'spw/daemon-lock-self -99) + ;; open a frame on a new workspace with only the relevant dired buffer open, ;; eval this form: (global-set-key "\C-cG" #'spw/grading-advance) ;; and then use C-c G to open the first item (will need C-c f t after just |