emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 2304bc9: Add option to cleanup buffers to jsonrpc-s


From: João Távora
Subject: [Emacs-diffs] master 2304bc9: Add option to cleanup buffers to jsonrpc-shutdown
Date: Sat, 11 Aug 2018 12:02:30 -0400 (EDT)

branch: master
commit 2304bc9b9748db481ee1e5cff6f51709eb625394
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    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 691e7b2..29a3de4 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -6,7 +6,7 @@
 ;; Maintainer: João Távora <address@hidden>
 ;; 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]