[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode eb7183e47b 101/162: Merge pull request #25 fro
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode eb7183e47b 101/162: Merge pull request #25 from tninja/master |
Date: |
Sat, 29 Jan 2022 08:25:26 -0500 (EST) |
branch: elpa/kotlin-mode
commit eb7183e47b67a3f777b078290388ecac3254435a
Merge: 1ed0c5589e b2085f5315
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #25 from tninja/master
Adding REPL support
---
README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++
kotlin-mode.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+)
diff --git a/README.md b/README.md
index 783ec534f3..43a7ffc167 100644
--- a/README.md
+++ b/README.md
@@ -16,3 +16,52 @@ with package management so you can use package management to
install the mode fr
(*) As at 2016-06-20 this mode is only in MELPA and not in MELPA stable, a
release will be made when a
version is ready to be declared.
+
+## Kotlin REPL key binding
+
+<table border="2" cellspacing="0" cellpadding="6" rules="groups"
frame="hsides">
+
+
+<colgroup>
+<col class="org-left" />
+
+<col class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-left">Key</th>
+<th scope="col" class="org-left">Function</th>
+</tr>
+</thead>
+
+<tbody>
+<tr>
+<td class="org-left">C-c C-z</td>
+<td class="org-left">Start REPL</td>
+</tr>
+
+
+<tr>
+<td class="org-left">C-c C-n</td>
+<td class="org-left">Send current line to REPL</td>
+</tr>
+
+
+<tr>
+<td class="org-left">C-c C-r</td>
+<td class="org-left">Send selected region to REPL</td>
+</tr>
+
+
+<tr>
+<td class="org-left">C-c C-c</td>
+<td class="org-left">Send current code block to REPL</td>
+</tr>
+
+
+<tr>
+<td class="org-left">C-c C-b</td>
+<td class="org-left">Send whole buffer to REPL</td>
+</tr>
+</tbody>
+</table>
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 34947b6b35 045/162: Added 'data class' as a keyword, (continued)
- [nongnu] elpa/kotlin-mode 34947b6b35 045/162: Added 'data class' as a keyword, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode b2c51ab7ba 057/162: Merge pull request #2 from gergoerdi/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e45a8f73e7 061/162: Declare dependency on Emacs 24.3, for setq-local, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode a02410bc5d 067/162: adds better indentation support for kotlin, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 80f51689bf 074/162: add readme, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 865e55fb4b 072/162: Merge pull request #2 from syohex/fix-package, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode c35ef85b0a 079/162: Merge pull request #2 from rexim/package-improvements, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode c65c96a51a 086/162: fixes close bracket indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e5ee4c4bd2 094/162: Merge pull request #20 from Thrip/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 6d679ed0da 097/162: Treat use of make as redundant, assume people will use 'cask exec ert-runner' to run the tests., ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode eb7183e47b 101/162: Merge pull request #25 from tninja/master,
ELPA Syncer <=
- [nongnu] elpa/kotlin-mode 0e542ae2f7 114/162: Merge pull request #37 from cjfuller/fix-star-projected-types, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 2467eceee3 118/162: Properly indent multi-line comment blocks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 3c48b34e0d 127/162: Delete unused function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 1f57bb5a92 135/162: Fix test runner in .travis.yml, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 96b37d211c 139/162: Merge pull request #45 from taku0/add_backup_to_gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode d9d77ed459 069/162: indentation logic handling lambdas, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 82db4dce0c 077/162: basic indentation test, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 49ef724e96 076/162: additional keywords and smarter highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 257647d5d6 083/162: handle chained method calls on multiple lines, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e1540a5ddf 087/162: Merge pull request #10 from gregghz/master, ELPA Syncer, 2022/01/29