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

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

[nongnu] elpa/inf-clojure 8f295050a8: Added function for switching back


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure 8f295050a8: Added function for switching back from an inf-clojure buffer (#200)
Date: Fri, 3 Jun 2022 11:58:30 -0400 (EDT)

branch: elpa/inf-clojure
commit 8f295050a856b03d6ec14f0fd5e782e7acde6e2d
Author: Jason <jasonkdarby@gmail.com>
Commit: GitHub <noreply@github.com>

    Added function for switching back from an inf-clojure buffer (#200)
    
    * Added function for switching back from an inf-clojure buffer
    
    * set inf-clojure--recent-buffer on inf-clojure-connect
    
    * use most recent buffer instead of 'last swapped from' buffer
    
    * provide display-buffer-reuse-window
    
    one day I'll learn how to read and pass args in emacs
---
 CHANGELOG.md   |  1 +
 inf-clojure.el | 27 +++++++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index daccb3634d..4880f36d1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
 
 ### New features
 
+* [#168](https://github.com/clojure-emacs/inf-clojure/pull/197): Helper 
function `inf-clojure-switch-to-recent-buffer` to select the last buffer an 
inf-clojure process buffer was swapped to from.
 * [#187](https://github.com/clojure-emacs/inf-clojure/pull/197): Defcustom 
`inf-clojure-enable-eldoc` to disable eldoc interaction.
 
 ## 3.1.0 (2021-07-23)
diff --git a/inf-clojure.el b/inf-clojure.el
index bb07c347dc..484e2115e9 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -330,6 +330,7 @@ Either \"no process\" or \"buffer-name(repl-type)\""
     (define-key map (kbd "C-c C-S-a") #'inf-clojure-apropos)
     (define-key map (kbd "C-c M-o") #'inf-clojure-clear-repl-buffer)
     (define-key map (kbd "C-c C-q") #'inf-clojure-quit)
+    (define-key map (kbd "C-c C-z") #'inf-clojure-switch-to-recent-buffer)
     (easy-menu-define inf-clojure-mode-menu map
       "Inferior Clojure REPL Menu"
       '("Inf-Clojure REPL"
@@ -694,22 +695,36 @@ to continue it."
     (let ((comint-buffer-maximum-size 0))
       (comint-truncate-buffer))))
 
+(defun inf-clojure--swap-to-buffer-window (to-buffer)
+  "Switch to `TO-BUFFER''s window."
+  (let ((pop-up-frames
+         ;; Be willing to use another frame
+         ;; that already has the window in it.
+         (or pop-up-frames
+             (get-buffer-window to-buffer t))))
+    (pop-to-buffer to-buffer '(display-buffer-reuse-window . ()))))
+
 (defun inf-clojure-switch-to-repl (eob-p)
   "Switch to the inferior Clojure process buffer.
 With prefix argument EOB-P, positions cursor at end of buffer."
   (interactive "P")
   (if (get-buffer-process inf-clojure-buffer)
-      (let ((pop-up-frames
-             ;; Be willing to use another frame
-             ;; that already has the window in it.
-             (or pop-up-frames
-                 (get-buffer-window inf-clojure-buffer t))))
-        (pop-to-buffer inf-clojure-buffer))
+      (inf-clojure--swap-to-buffer-window inf-clojure-buffer)
     (call-interactively #'inf-clojure))
   (when eob-p
     (push-mark)
     (goto-char (point-max))))
 
+(defun inf-clojure-switch-to-recent-buffer ()
+  "Switch to the most recently used `inf-clojure-minor-mode' buffer."
+  (interactive)
+  (let ((recent-inf-clojure-minor-mode-buffer (seq-find (lambda (buf)
+                                                          (with-current-buffer 
buf (bound-and-true-p inf-clojure-minor-mode)))
+                                                        (buffer-list))))
+    (if recent-inf-clojure-minor-mode-buffer
+        (inf-clojure--swap-to-buffer-window 
recent-inf-clojure-minor-mode-buffer)
+      (message "inf-clojure: No recent buffer known."))))
+
 (defun inf-clojure-quit (&optional buffer)
   "Kill the REPL buffer and its underlying process.
 



reply via email to

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