diff options
| author | João Távora | 2018-08-11 16:53:26 +0100 |
|---|---|---|
| committer | João Távora | 2018-08-11 17:02:23 +0100 |
| commit | 2304bc9b9748db481ee1e5cff6f51709eb625394 (patch) | |
| tree | 06e4ffc850957cf7c386374c45449b11a24fe161 | |
| parent | 1d8fa1c9810dc78fe29449d865e9a5fb705284b9 (diff) | |
| download | emacs-2304bc9b9748db481ee1e5cff6f51709eb625394.tar.gz emacs-2304bc9b9748db481ee1e5cff6f51709eb625394.zip | |
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.
| -rw-r--r-- | lisp/jsonrpc.el | 30 |
1 files 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 @@ | |||
| 6 | ;; Maintainer: João Távora <joaotavora@gmail.com> | 6 | ;; Maintainer: João Távora <joaotavora@gmail.com> |
| 7 | ;; Keywords: processes, languages, extensions | 7 | ;; Keywords: processes, languages, extensions |
| 8 | ;; Package-Requires: ((emacs "25.2")) | 8 | ;; Package-Requires: ((emacs "25.2")) |
| 9 | ;; Version: 1.0.4 | 9 | ;; Version: 1.0.5 |
| 10 | 10 | ||
| 11 | ;; This is an Elpa :core package. Don't use functionality that is not | 11 | ;; This is an Elpa :core package. Don't use functionality that is not |
| 12 | ;; compatible with Emacs 25.2. | 12 | ;; compatible with Emacs 25.2. |
| @@ -415,19 +415,23 @@ connection object, called when the process dies .") | |||
| 415 | "Return non-nil if JSONRPC connection CONN is running." | 415 | "Return non-nil if JSONRPC connection CONN is running." |
| 416 | (process-live-p (jsonrpc--process conn))) | 416 | (process-live-p (jsonrpc--process conn))) |
| 417 | 417 | ||
| 418 | (cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection)) | 418 | (cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection) |
| 419 | &optional cleanup) | ||
| 419 | "Wait for JSONRPC connection CONN to shutdown and return t. | 420 | "Wait for JSONRPC connection CONN to shutdown and return t. |
| 420 | If the server wasn't running, do nothing and return nil." | 421 | If the server wasn't running, do nothing and return nil. With |
| 421 | (when (jsonrpc-running-p conn) | 422 | optional CLEANUP, kill any associated buffers. " |
| 422 | (cl-loop | 423 | (unwind-protect |
| 423 | with proc = (jsonrpc--process conn) | 424 | (when (jsonrpc-running-p conn) |
| 424 | do | 425 | (cl-loop |
| 425 | (delete-process proc) | 426 | with proc = (jsonrpc--process conn) |
| 426 | (accept-process-output nil 0.1) | 427 | do |
| 427 | while (not (process-get proc 'jsonrpc-sentinel-done)) | 428 | (delete-process proc) |
| 428 | do (jsonrpc--warn | 429 | (accept-process-output nil 0.1) |
| 429 | "Sentinel for %s still hasn't run, deleting it!" proc) | 430 | while (not (process-get proc 'jsonrpc-sentinel-done)) |
| 430 | finally return t))) | 431 | do (jsonrpc--warn |
| 432 | "Sentinel for %s still hasn't run, deleting it!" proc) | ||
| 433 | finally return t)) | ||
| 434 | (when cleanup (kill-buffer (process-buffer conn))))) | ||
| 431 | 435 | ||
| 432 | (defun jsonrpc-stderr-buffer (conn) | 436 | (defun jsonrpc-stderr-buffer (conn) |
| 433 | "Get CONN's standard error buffer, if any." | 437 | "Get CONN's standard error buffer, if any." |