From c0b41030213c9275def25bb4c87e0bc897fd4442 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Thu, 11 May 2023 11:25:28 -0400 Subject: [PATCH] Automatically kill stale mu servers --- global.org | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/global.org b/global.org index 7403578..49ffefb 100644 --- a/global.org +++ b/global.org @@ -958,7 +958,32 @@ (propertize (format "\u200B[%d]" num) 'face 'mu4e-url-number-face)))))))))) #+end_src - + This one kills servers attached to mu4e instances in other + activities + #+begin_src emacs-lisp + (defun mu4e--server-sentinel (proc _msg) + "Function called when the server process PROC terminates with MSG." + (let ((status (process-status proc)) (code (process-exit-status proc))) + (setq mu4e--server-process nil) + (setq mu4e--server-buf "") ;; clear any half-received sexps + (cond + ((eq status 'signal) + (cond + ((or(eq code 9) (eq code 2)) (message nil)) + ;;(message "the mu server process has been stopped")) + (t (error (format "mu server process received signal %d" code))))) + ((eq status 'exit) + (cond + ((eq code 0) + (message nil)) ;; don't do anything + ((eq code 19) + (when (string-equal (kde-current-activity-name) server-name) + (start-process "killer" nil "killall" "mu")) + (error "Database is locked by another process; try again")) + (t (error "Mu server process ended with exit code %d" code)))) + (t + (error "Something bad happened to the mu server process"))))) + #+end_src ** org-mode *** Require Require the ~org~ package; I also occasionally use org-pomodoro