[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode b91bab57b6 099/162: Adding REPL support, credi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode b91bab57b6 099/162: Adding REPL support, credit to https://github.com/sarvex/kotlin-mode |
Date: |
Sat, 29 Jan 2022 08:25:26 -0500 (EST) |
branch: elpa/kotlin-mode
commit b91bab57b689d5eabcbf139962d3359c27f2c4e2
Author: Kang Tu <tninja@Pengs-MacBook-Pro.local>
Commit: Kang Tu <tninja@Pengs-MacBook-Pro.local>
Adding REPL support, credit to https://github.com/sarvex/kotlin-mode
---
kotlin-mode.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/kotlin-mode.el b/kotlin-mode.el
index 90be5ed6b4..17300e9ddd 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'comint)
(require 'rx)
(require 'cc-cmds)
@@ -38,8 +39,71 @@
:group 'kotlin-mode
:safe 'integerp)
+(defcustom kotlin-command "kotlinc"
+ "The Kotlin command used for evaluating code."
+ :type 'string
+ :group 'kotlin)
+
+(defcustom kotlin-args-repl '()
+ "The arguments to pass to `kotlin-command' to start a REPL."
+ :type 'list
+ :group 'kotlin)
+
+(defcustom kotlin-repl-buffer "*KotlinREPL*"
+ "The name of the KotlinREPL buffer."
+ :type 'string
+ :group 'kotlin)
+
+(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-buffer ()
+ "Send whole buffer to Kotlin interpreter."
+ (interactive)
+ (kotlin-send-region (point-min) (point-max)))
+
+(defun kotlin-send-block ()
+ (interactive)
+ (let* ((p (point)))
+ (mark-paragraph)
+ (kotlin-send-region (region-beginning) (region-end))
+ (goto-char p)))
+
+(defun kotlin-send-line ()
+ (interactive)
+ (kotlin-send-region
+ (line-beginning-position)
+ (line-end-position)))
+
+(defun kotlin-repl ()
+ "Launch a Kotlin REPL using `kotlin-command' as an inferior mode."
+ (interactive)
+
+ (unless (comint-check-proc kotlin-repl-buffer)
+ (set-buffer
+ (apply 'make-comint "KotlinREPL"
+ "env"
+ nil
+ "NODE_NO_READLINE=1"
+ kotlin-command
+ kotlin-args-repl))
+
+ (set (make-local-variable 'comint-preoutput-filter-functions)
+ (cons (lambda (string)
+ (replace-regexp-in-string "\x1b\\[.[GJK]" "" string)) nil)))
+
+ (pop-to-buffer kotlin-repl-buffer))
+
(defvar kotlin-mode-map
(let ((map (make-keymap)))
+ (define-key map (kbd "C-c C-z") 'kotlin-repl)
+ (define-key map (kbd "C-c C-n") 'kotlin-send-line)
+ (define-key map (kbd "C-c C-r") 'kotlin-send-region)
+ (define-key map (kbd "C-c C-c") 'kotlin-send-block)
+ (define-key map (kbd "C-c C-b") 'kotlin-send-buffer)
(define-key map (kbd "<tab>") 'c-indent-line-or-region)
map)
"Keymap for kotlin-mode")
- [nongnu] elpa/kotlin-mode cd4901acc6 080/162: Merge pull request #6 from jasonm23/patch-1, (continued)
- [nongnu] elpa/kotlin-mode cd4901acc6 080/162: Merge pull request #6 from jasonm23/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode f54da34b3f 088/162: Merge pull request #11 from russel/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode c051947e27 041/162: kotlin-mode: Highlight string interpolations, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode a659099864 037/162: kotlin-mode: Add kotlin-mode--syntax-propertize-interpolation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode c40557c411 053/162: Merge pull request #1 from gergoerdi/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 2f3d991159 060/162: Remove redundant declaration of hook and keymap, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 953bb91328 151/162: Merge pull request #50 from taku0/fix-comment-at-bob, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode ab61099682 152/162: use 4 for defualt tab width, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e5c6d845e6 093/162: Merge pull request #19 from gregghz/fixes-closing-bracket-indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 72a2bf2347 096/162: Add a file to get Travis-CI to run the test suite., ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode b91bab57b6 099/162: Adding REPL support, credit to https://github.com/sarvex/kotlin-mode,
ELPA Syncer <=
- [nongnu] elpa/kotlin-mode 1ed0c5589e 098/162: Merge pull request #22 from russel/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 8574583b30 105/162: Fix highlighting escaped identifiers in interpolations, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode eb3704e0e2 106/162: Set adaptive-fill-regexp to comment-start-skip, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 77d709ab54 107/162: Merge pull request #30 from CyberShadow/pull-20180624-142858, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode f08724b978 115/162: Improve handling of bracket-based indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 9fa0d75997 119/162: Tidy up bracked-based indentation into a class, and fix bugs, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 76921927de 117/162: Add a test for correct indentation of sample.kt, and get it to pass (with a few tweaks), ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 511e0a4ee3 121/162: Add in more kotlin keywords and indent get/set methods for properties, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 21ae667561 126/162: Add highlighted keywords, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode b2d5ff65fc 125/162: Highlight single quotes and back quotes, ELPA Syncer, 2022/01/29