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

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

[nongnu] elpa/kotlin-mode 734b08408c 103/162: Add send-{block, buffer, l


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode 734b08408c 103/162: Add send-{block, buffer, line, region}-and-focus functions
Date: Sat, 29 Jan 2022 08:25:27 -0500 (EST)

branch: elpa/kotlin-mode
commit 734b08408c547fafbeaea575cf522b04aabb2b0c
Author: Trevor Summers Smith <trevorsummerssmith@gmail.com>
Commit: Trevor Summers Smith <trevorsummerssmith@gmail.com>

    Add send-{block,buffer,line,region}-and-focus functions
    
    These are all exactly like their counterparts, except they
    execute then put the focus into the REPL
    
    Closes #26
---
 kotlin-mode.el | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 2183f4998a..8b6e68e872 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -54,17 +54,31 @@
   :type 'string
   :group 'kotlin)
 
+(defun kotlin-do-and-repl-focus (f &rest args)
+  (apply f args)
+  (pop-to-buffer kotlin-repl-buffer))
+
 (defun kotlin-send-region (start end)
   "Send current region to Kotlin interpreter."
   (interactive "r")
   (comint-send-region kotlin-repl-buffer start end)
   (comint-send-string kotlin-repl-buffer "\n"))
 
+(defun kotlin-send-region-and-focus (start end)
+  "Send current region to Kotlin interpreter and switch to it."
+  (interactive "r")
+  (kotlin-do-and-repl-focus 'kotlin-send-region start end))
+
 (defun kotlin-send-buffer ()
   "Send whole buffer to Kotlin interpreter."
   (interactive)
   (kotlin-send-region (point-min) (point-max)))
 
+(defun kotlin-send-buffer-and-focus ()
+  "Send whole buffer to Kotlin interpreter and switch to it."
+  (interactive)
+  (kotlin-do-and-repl-focus 'kotlin-send-buffer))
+
 (defun kotlin-send-block ()
   (interactive)
   (let* ((p (point)))
@@ -72,12 +86,22 @@
     (kotlin-send-region (region-beginning) (region-end))
     (goto-char p)))
 
+(defun kotlin-send-block-and-focus ()
+  "Send block to Kotlin interpreter and switch to it."
+  (interactive)
+  (kotlin-do-and-repl-focus 'kotlin-send-block))
+
 (defun kotlin-send-line ()
   (interactive)
   (kotlin-send-region
    (line-beginning-position)
    (line-end-position)))
 
+(defun kotlin-send-line-and-focus ()
+  "Send current line to Kotlin interpreter and switch to it."
+  (interactive)
+  (kotlin-do-and-repl-focus 'kotlin-send-line))
+
 (defun kotlin-repl ()
   "Launch a Kotlin REPL using `kotlin-command' as an inferior mode."
   (interactive)



reply via email to

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