From 2304bc9b9748db481ee1e5cff6f51709eb625394 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 11 Aug 2018 16:53:26 +0100 Subject: [PATCH] Add option to cleanup buffers to jsonrpc-shutdown * lisp/jsonrpc.el (Version): Bump to 1.0.5 (jsonrpc-shutdown): Add an option to cleanup process buffer. --- lisp/jsonrpc.el | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el index 691e7b2830d..29a3de47a49 100644 --- a/lisp/jsonrpc.el +++ b/lisp/jsonrpc.el @@ -6,7 +6,7 @@ ;; Maintainer: João Távora ;; Keywords: processes, languages, extensions ;; Package-Requires: ((emacs "25.2")) -;; Version: 1.0.4 +;; Version: 1.0.5 ;; This is an Elpa :core package. Don't use functionality that is not ;; compatible with Emacs 25.2. @@ -415,19 +415,23 @@ connection object, called when the process dies .") "Return non-nil if JSONRPC connection CONN is running." (process-live-p (jsonrpc--process conn))) -(cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection)) +(cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection) + &optional cleanup) "Wait for JSONRPC connection CONN to shutdown and return t. -If the server wasn't running, do nothing and return nil." - (when (jsonrpc-running-p conn) - (cl-loop - with proc = (jsonrpc--process conn) - do - (delete-process proc) - (accept-process-output nil 0.1) - while (not (process-get proc 'jsonrpc-sentinel-done)) - do (jsonrpc--warn - "Sentinel for %s still hasn't run, deleting it!" proc) - finally return t))) +If the server wasn't running, do nothing and return nil. With +optional CLEANUP, kill any associated buffers. " + (unwind-protect + (when (jsonrpc-running-p conn) + (cl-loop + with proc = (jsonrpc--process conn) + do + (delete-process proc) + (accept-process-output nil 0.1) + while (not (process-get proc 'jsonrpc-sentinel-done)) + do (jsonrpc--warn + "Sentinel for %s still hasn't run, deleting it!" proc) + finally return t)) + (when cleanup (kill-buffer (process-buffer conn))))) (defun jsonrpc-stderr-buffer (conn) "Get CONN's standard error buffer, if any." -- 2.39.5