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

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

[nongnu] elpa/idris-mode 103f1e5fbf 2/8: Add ability to quickly switch f


From: ELPA Syncer
Subject: [nongnu] elpa/idris-mode 103f1e5fbf 2/8: Add ability to quickly switch from Idris repl to
Date: Fri, 11 Nov 2022 06:58:58 -0500 (EST)

branch: elpa/idris-mode
commit 103f1e5fbfcddce4cabd02da19eff5eac69edc5c
Author: Marek L <nospam.keram@gmail.com>
Commit: Marek Labos <marek@syftapp.com>

    Add ability to quickly switch from Idris repl to
    
    last Idris source code file using:
    `M-x idris-switch-to-last-idris-buffer` or key binding
     used to jump from a file to repl (`C-c C-z` by default).
    
    This is simplified version of `cider-switch-to-last-clojure-buffer` from
    https://github.com/clojure-emacs/cider/blob/master/cider-mode.el#L122-L145
---
 idris-commands.el | 18 ++++++++++++++++++
 idris-repl.el     |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/idris-commands.el b/idris-commands.el
index 6e0f7485db..9e77008042 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -949,6 +949,24 @@ type-correct, so loading will fail."
         (pop-to-buffer buf)
       (error "No Idris REPL buffer is open."))))
 
+(defun idris-switch-to-last-idris-buffer ()
+  "Switch to the last Idris buffer.
+The default keybinding for this command is
+the same as variable `idris-pop-to-repl',
+so that it is very convenient to jump between a
+Idris buffer and the REPL buffer.
+
+Inspired by `cider-switch-to-last-clojure-buffer'
+https://github.com/clojure-emacs/cider";
+  (interactive)
+  (if (derived-mode-p 'idris-repl-mode)
+      (if-let* ((a-buf (seq-find
+                        (lambda (b) (eq 'idris-mode (buffer-local-value 
'major-mode b)))
+                        (buffer-list))))
+          (pop-to-buffer a-buf `(display-buffer-reuse-window))
+        (user-error "No Idris buffer found"))
+    (user-error "Not in a Idris REPL buffer")))
+
 (defun idris-quit ()
   "Quit the Idris process, cleaning up the state synchronized with Emacs."
   (interactive)
diff --git a/idris-repl.el b/idris-repl.el
index bf081eb9c4..509fd1c93d 100644
--- a/idris-repl.el
+++ b/idris-repl.el
@@ -187,6 +187,9 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the 
end of the buffer."
                   idris-define-general-keys
                   idris-define-active-term-keys)
              do (funcall keyer map))
+    (substitute-key-definition 'idris-pop-to-repl
+                               'idris-switch-to-last-idris-buffer
+                               map)
     map)
   "Keymap used in Idris REPL mode.")
 



reply via email to

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