[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode b6cca3307b 203/253: Merge pull request #25 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode b6cca3307b 203/253: Merge pull request #25 from matiaslina/repl |
Date: |
Sat, 29 Jan 2022 08:28:58 -0500 (EST) |
branch: elpa/raku-mode
commit b6cca3307b2df98d208967ab5a1bc9b9e705ffbf
Merge: 4ed7c06294 2e622f86e0
Author: Altai-man <alexander.kiryuhin@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #25 from matiaslina/repl
Add REPL support
---
README.md | 11 ++++++++-
perl6-mode.el | 25 +++++++++++++++++++-
perl6-repl.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 7556bd148d..f29a55d074 100644
--- a/README.md
+++ b/README.md
@@ -13,13 +13,13 @@ This mode needs GNU Emacs 24.4.
* Basic syntax highlighting
* Basic indentation
* Identifier index menu (variables, subs, classes, etc.)
+* REPL interaction
#### Planned
* Complete syntax highlighting
* Better indentation support (uses Emacs SMIE grammar, see the Emacs manual)
* Help system
-* REPL interaction
* ETags support
* `find-file-at-point` for module names
* Electricity (`electric-pair-mode` needs some context-sensitive help)
@@ -58,6 +58,15 @@ This includes any file with `perl6` in the shebang, as well
as any file
with a `.p6`, `.pm6`, or `.pl6` extension. It also applies to any `.pm`,
`.pl`, and `.t` files whose first line of code looks like Perl 6.
+Start the REPL with <kbd>M-x run-perl6 RET</kbd>. The following
+keybindings are available to interact with the REPL:
+
+* <kbd>C-c C-c</kbd>: Send the current line to the REPL
+* <kbd>C-c C-r</kbd>: Send the selected region to the REPL
+* <kbd>C-c C-h</kbd>: Send the whole buffer to the REPL
+
+The REPL will start if needed with this keybindings.
+
Use <kbd>M-x customize-group RET perl6</kbd> to customize Perl 6 Mode.
## Contribute
diff --git a/perl6-mode.el b/perl6-mode.el
index 0e9b6316e9..6cbe1449ce 100644
--- a/perl6-mode.el
+++ b/perl6-mode.el
@@ -42,6 +42,22 @@
(require 'perl6-font-lock)
(require 'perl6-indent)
(require 'perl6-imenu)
+(require 'perl6-repl)
+
+(defvar perl6-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "C-c C-c") 'perl6-send-line-to-repl)
+ (define-key map (kbd "C-c C-r") 'perl6-send-region-to-repl)
+ (define-key map (kbd "C-c C-h") 'perl6-send-buffer-to-repl)
+ map)
+ "Keymap for `perl6-mode'.")
+
+(easy-menu-define perl6-mode-menu perl6-mode-map
+ "Menu for `perl6-mode'"
+ '("Raku"
+ ["Send line to repl" perl6-send-line-to-repl]
+ ["Send region to repl" perl6-send-region-to-repl]
+ ["Send buffer to repl" perl6-send-buffer-to-repl]))
;;;###autoload
(define-derived-mode perl6-mode prog-mode "Perl6"
@@ -61,11 +77,18 @@
(setq-local comment-start-skip "#+ *")
(setq-local comment-use-syntax t)
(setq-local comment-end "")
+ ;; REPL
+ (setq comint-prompt-regexp perl6-prompt-regexp)
+ (setq comint-prompt-read-only t)
+ (set (make-local-variable 'paragraph-start) perl6-prompt-regexp)
;; Indentation (see SMIE in the Emacs manual)
;; TODO add rules for HEREDOC indentation
(smie-setup perl6-smie-grammar #'perl6-smie-rules
:forward-token #'perl6-smie--forward-token
- :backward-token #'perl6-smie--backward-token))
+ :backward-token #'perl6-smie--backward-token)
+ (use-local-map perl6-mode-map))
+
+
(provide 'perl6-mode)
diff --git a/perl6-repl.el b/perl6-repl.el
new file mode 100644
index 0000000000..0dab25cdf6
--- /dev/null
+++ b/perl6-repl.el
@@ -0,0 +1,73 @@
+;;; perl6-repl -- Repl for support Raku
+
+;;; Commentary:
+;; Basic repl support for Raku
+
+;;; Code:
+(require 'comint)
+
+(defcustom perl6-exec-path "raku"
+ "Raku executable path."
+ :type 'string
+ :group 'perl6)
+
+(defcustom perl6-exec-arguments ""
+ "Raku command line arguments."
+ :type 'string
+ :group 'perl6)
+
+(defvar perl6-prompt-regexp "^> "
+ "Prompt for `run-perl6'.")
+
+(defvar perl6-buffer-name "Raku REPL"
+ "Buffer name for `run-perl6.")
+
+(defun run-perl6 ()
+ "Run an inferior instance of `raku' inside Emacs."
+ (interactive)
+ (let* ((perl6-program perl6-exec-path)
+ (check-proc (comint-check-proc perl6-buffer-name))
+ (buffer (apply 'make-comint-in-buffer
+ perl6-buffer-name
+ check-proc
+ perl6-exec-path
+ '()
+ (split-string perl6-exec-arguments))))
+ (display-buffer buffer)))
+
+(defun perl6-comint-get-process ()
+ "Raku process name."
+ (get-process perl6-buffer-name))
+
+(defun perl6-send-string-to-repl (str)
+ "Send STR to the repl."
+ (comint-send-string (perl6-comint-get-process)
+ (concat str "\n")))
+
+(defun perl6-send-line-to-repl ()
+ "Send a line to the repl."
+ (interactive)
+ (run-perl6)
+ (let ((str (buffer-substring-no-properties (line-beginning-position)
(line-end-position))))
+ (perl6-send-string-to-repl str)))
+
+(defun perl6-send-region-to-repl ()
+ "Send a region to the repl."
+ (interactive)
+ (run-perl6)
+ (if (region-active-p)
+ (let ((buf (buffer-substring-no-properties (region-beginning)
+ (region-end))))
+ (perl6-send-string-to-repl buf))
+ (message "No region selected")))
+
+(defun perl6-send-buffer-to-repl ()
+ "Send a buffer to the repl."
+ (interactive)
+ (run-perl6)
+ (let ((buf (buffer-substring-no-properties (point-min)
+ (point-max))))
+ (perl6-send-string-to-repl buf)))
+
+(provide 'perl6-repl)
+;;; perl6-repl.el ends here
- [nongnu] elpa/raku-mode 44faa06bba 197/253: Use comint., (continued)
- [nongnu] elpa/raku-mode 44faa06bba 197/253: Use comint., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 9ea05bdb3e 236/253: add future desirable points in mature raku-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode fd54a7b397 231/253: add: font lock for quit, doc and close and delete start, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 155b0b7a4a 249/253: Update CHANGELOG.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 20610a83b5 247/253: Merge pull request #53 from phikal/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode fd286b2d1a 246/253: Remove pkg-info dependency, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode a316c3f195 240/253: Remove leftover debugging garbage, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 7dfe01182d 080/253: Highlight reduce operators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 57a25ccadd 142/253: Remove commented code I accidentally left in, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 7322d74a5d 169/253: Changing to my copy of cask, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b6cca3307b 203/253: Merge pull request #25 from matiaslina/repl,
ELPA Syncer <=
- [nongnu] elpa/raku-mode d474216840 223/253: Merge pull request #34 from hlissner/fix-autoloads, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e4d8b0230a 218/253: Merge pull request #31 from tmtvl/add-raku-to-languages-customization-group, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 77afbe21fe 232/253: Merge pull request #40 from Lenin1917/path-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0c480bb357 238/253: Hanging assignment support, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ee9045eeb 252/253: Bump version to have an update without pkg-info, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d8811251af 244/253: Update changelog for v0.2.0, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 5b47a0b1a2 066/253: Deal with [-'] preceded by a non-ASII identifier character, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode bf7900b286 137/253: Merge pull request #4 from Altai-man/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 07b596cab6 151/253: one more tweak to catch all forms of subs, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode fe2d579dfb 132/253: Indentation fix, ELPA Syncer, 2022/01/29