emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/inf-clojure 1d6260a 104/313: [Fix #29] Add a command to re


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure 1d6260a 104/313: [Fix #29] Add a command to restart a REPL
Date: Wed, 11 Aug 2021 09:59:55 -0400 (EDT)

branch: elpa/inf-clojure
commit 1d6260a6dbfdb40d307455463778b5f3e87e4571
Author: Bozhidar Batsov <bozhidar@batsov.com>
Commit: Bozhidar Batsov <bozhidar@batsov.com>

    [Fix #29] Add a command to restart a REPL
    
    This commit also tweaks `inf-clojure-quit' and makes it possible to
    pass the buffer to quit as an optional parameter.
---
 CHANGELOG.md   |  1 +
 inf-clojure.el | 27 +++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 42c829c..b537dab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 * Font-lock the code in the REPL.
 * Handle properly ANSI color escape sequences in the REPL.
 * [#41](https://github.com/clojure-emacs/inf-clojure/issues/41): Add a command 
to quit the REPL (it's bound to `C-c C-q`).
+* [#29](https://github.com/clojure-emacs/inf-clojure/issues/29): Add a command 
to restart the REPL.
 
 ### Changes
 
diff --git a/inf-clojure.el b/inf-clojure.el
index b836c4c..fd4634d 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -90,6 +90,7 @@ mode.  Default is whitespace followed by 0 or 1 single-letter 
colon-keyword
         ["Show source for var" inf-clojure-show-var-source t]
         "--"
         ["Clear REPL" inf-clojure-clear-repl-buffer]
+        ["Restart" inf-clojure-restart]
         ["Quit" inf-clojure-quit]
         "--"
         ["Version" inf-clojure-display-version]))
@@ -134,6 +135,7 @@ mode.  Default is whitespace followed by 0 or 1 
single-letter colon-keyword
         ["Apropos" inf-clojure-apropos t]
         ["Macroexpand" inf-clojure-macroexpand t]
         "--"
+        ["Restart REPL" inf-clojure-restart]
         ["Quit REPL" inf-clojure-quit]))
     map))
 
@@ -828,13 +830,30 @@ Useful for commands that can invoked outside of an 
inf-clojure buffer
        ((= (length repl-buffers) 1) (car repl-buffers))
        (t (get-buffer (completing-read "Select target inf-clojure buffer: " 
(mapcar #'buffer-name repl-buffers))))))))
 
-(defun inf-clojure-quit ()
-  "Kill the REPL buffer and its underlying process."
+(defun inf-clojure-quit (&optional buffer)
+  "Kill the REPL buffer and its underlying process.
+
+You can pass the target BUFFER as an optional parameter
+to suppress the usage of the target buffer discovery logic."
   (interactive)
-  (let ((target-buffer (inf-clojure-select-target-repl)))
-    (delete-process target-buffer)
+  (let ((target-buffer (or buffer (inf-clojure-select-target-repl))))
+    (when (get-buffer-process target-buffer)
+      (delete-process target-buffer))
     (kill-buffer target-buffer)))
 
+(defun inf-clojure-restart (&optional buffer)
+  "Restart the REPL buffer and its underlying process.
+
+You can pass the target BUFFER as an optional parameter
+to suppress the usage of the target buffer discovery logic."
+  (interactive)
+  (let* ((target-buffer (or buffer (inf-clojure-select-target-repl)))
+         (target-buffer-name (buffer-name target-buffer)))
+    ;; TODO: Try to recycle the old buffer instead of killing and recreating it
+    (inf-clojure-quit target-buffer)
+    (inf-clojure inf-clojure-program)
+    (rename-buffer target-buffer-name)))
+
 (provide 'inf-clojure)
 
 ;;; inf-clojure.el ends here



reply via email to

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