[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode edccdba86f 191/253: Don't hang emacs if cannot f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode edccdba86f 191/253: Don't hang emacs if cannot find the Raku executable |
Date: |
Sat, 29 Jan 2022 08:28:57 -0500 (EST) |
branch: elpa/raku-mode
commit edccdba86f10cd79b108b19e87bc6366790f1db1
Author: Matias Linares <matiaslina@gmail.com>
Commit: Matias Linares <matiaslina@gmail.com>
Don't hang emacs if cannot find the Raku executable
---
perl6-repl.el | 116 +++++++++++++++++++++++++++++++---------------------------
1 file changed, 62 insertions(+), 54 deletions(-)
diff --git a/perl6-repl.el b/perl6-repl.el
index d05c0d2932..db78020bb6 100644
--- a/perl6-repl.el
+++ b/perl6-repl.el
@@ -10,9 +10,7 @@
;;(term-send-raw-string "\^y") ;sends a C-y, which yanks the killed line
)
-
-(setq perl6-repl--buffer-name "Perl6 REPL")
-
+(setq perl6-repl--buffer-name "Raku REPL")
(defun perl6-repl--buffer-name-earmuf ()
(concat "*" perl6-repl--buffer-name "*"))
@@ -22,10 +20,14 @@
:type 'string
:group 'perl6)
+(defun perl6-exec-path-exists-p ()
+ (or (file-executable-p perl6-exec-path)
+ (executable-find perl6-exec-path)))
+
(defun perl6-repl-other-window ()
"Runs Perl6 in a `term' buffer in another window."
(interactive)
- (let ((termbuf (apply 'make-term perl6-repl--buffer-name "perl6" nil)))
+ (let ((termbuf (apply 'make-term perl6-repl--buffer-name perl6-exec-path
nil)))
(set-buffer termbuf)
(term-mode)
(term-set-escape-char 24) ;this sets the escape char to C-x instead of C-c
@@ -33,68 +35,74 @@
(switch-to-buffer-other-window termbuf)))
+(defun perl6-repl-ready-p ()
+ (or (< (point) 2)
+ (not (equal (buffer-substring (- (point)2)
+ (point))
+ "> "))))
+
(defun perl6-create-new-repl ()
(progn (perl6-repl-other-window)
- (while (or (< (point)
- 2)
- (not (equal (buffer-substring (- (point)
- 2)
- (point))
- "> ")))
+ (while (perl6-repl-ready-p)
(sit-for 0.1))))
(defun perl6-send-line-to-repl (&optional line)
(interactive)
- (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
- (cbuf (current-buffer))
- (cwin (selected-window))
- (pos (point))
- (linecontents
- (progn (when line ;if a line is passed to the function, go there
- (goto-char (point-min))
- (forward-line (- line 1)))
- (buffer-substring (line-beginning-position)
(line-end-position))))
- ) ;save pos of start of next line
- (if jbuf (switch-to-buffer jbuf)
- ;;if there is not a perl6 REPl open, open it and wait for prompt
-
- (perl6-create-new-repl))
- (perl6-repl-send-line linecontents)
- (select-window cwin)
- (switch-to-buffer cbuf)
- (goto-char pos)))
+ (if (perl6-exec-path-exists-p)
+ (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
+ (cbuf (current-buffer))
+ (cwin (selected-window))
+ (pos (point))
+ (linecontents
+ (progn (when line ;if a line is passed to the function, go there
+ (goto-char (point-min))
+ (forward-line (- line 1)))
+ (buffer-substring (line-beginning-position)
(line-end-position))))
+ ) ;save pos of start of next line
+ (if jbuf (switch-to-buffer jbuf)
+ ;;if there is not a perl6 REPl open, open it and wait for prompt
+
+ (perl6-create-new-repl))
+ (perl6-repl-send-line linecontents)
+ (select-window cwin)
+ (switch-to-buffer cbuf)
+ (goto-char pos))
+ (message "Cannot execute %s" perl6-exec-path)))
(defun perl6-send-region-to-repl ()
(interactive)
- (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
- (cbuf (current-buffer))
- (cwin (selected-window))
- (pos (mark))
- (contents (buffer-substring (mark)
- (point))))
- (if jbuf (switch-to-buffer jbuf)
- ;;if there is not a perl6 REPl open, open it and wait for prompt
- (perl6-create-new-repl))
- (set-text-properties 0 (length contents) nil contents)
- (mapc 'perl6-repl-send-line (split-string contents "\n+"))
- (select-window cwin)
- (switch-to-buffer cbuf)
- (goto-char pos)))
+ (if (perl6-exec-path-exists-p)
+ (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
+ (cbuf (current-buffer))
+ (cwin (selected-window))
+ (pos (mark))
+ (contents (buffer-substring (mark)
+ (point))))
+ (if jbuf (switch-to-buffer jbuf)
+ ;;if there is not a perl6 REPl open, open it and wait for prompt
+ (perl6-create-new-repl))
+ (set-text-properties 0 (length contents) nil contents)
+ (mapc 'perl6-repl-send-line (split-string contents "\n+"))
+ (select-window cwin)
+ (switch-to-buffer cbuf)
+ (goto-char pos))
+ (message "Cannot execute %s" perl6-exec-path)))
(defun perl6-send-buffer-to-repl ()
(interactive)
- (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
- (cbuf (current-buffer))
- (cwin (selected-window))
- (contents (buffer-string)))
- (if jbuf (switch-to-buffer jbuf)
- (perl6-create-new-repl))
- ;; Send te line to the repl
- (set-text-properties 0 (length contents) nil contents)
- (mapc 'perl6-repl-send-line (split-string contents "\n+"))
- (select-window cwin)
- (switch-to-buffer cbuf)))
-
+ (if (perl6-exec-path-exists-p)
+ (let ((jbuf (get-buffer (perl6-repl--buffer-name-earmuf)))
+ (cbuf (current-buffer))
+ (cwin (selected-window))
+ (contents (buffer-string)))
+ (if jbuf (switch-to-buffer jbuf)
+ (perl6-create-new-repl))
+ ;; Send te line to the repl
+ (set-text-properties 0 (length contents) nil contents)
+ (mapc 'perl6-repl-send-line (split-string contents "\n+"))
+ (select-window cwin)
+ (switch-to-buffer cbuf))
+ (message "Cannot execute %s" perl6-exec-path)))
(provide 'perl6-repl)
- [nongnu] elpa/raku-mode e3bcb55be3 077/253: Highlight adverbs (:foo), (continued)
- [nongnu] elpa/raku-mode e3bcb55be3 077/253: Highlight adverbs (:foo), ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 95f6ca837c 078/253: Highlight sigil in match group ($<foo>), ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c1b2f9e112 109/253: Less aggressive syntaxification of sigils/twigils, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6553c30843 093/253: Highlight ::?CLASS and such correctly, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 861a7b469b 110/253: Highlight string delimiters like operators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 5f66f10dbe 143/253: Correctly highlight $foo.?method, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 9f07c8b52a 139/253: Highlight 'unit' keyword, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 5456e2b044 145/253: Fix highlighting of <-a -b -c>, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 81805cfa8e 154/253: remove vars (to main file) per comments from syohex, clean up some, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4b01244490 157/253: make this work for nqp also, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode edccdba86f 191/253: Don't hang emacs if cannot find the Raku executable,
ELPA Syncer <=
- [nongnu] elpa/raku-mode 88de065795 186/253: add test file for HEREDOC indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 7d006af233 187/253: Simple perl6/raku repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 9cbd9b26f9 168/253: Merge branch 'patch-1' of https://github.com/Altai-man/perl6-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ad9987e25 185/253: add TODO note for HEREDOC indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8f6804ad17 207/253: Merge pull request #26 from matiaslina/raku-rename, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 0dd62e4d1f 217/253: Add missing 's' to parent customization group name., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 13ebcd87ce 220/253: trivial change Perl 6 to Raku, plus temp change of URL meanwhile, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 98db56c6ec 212/253: Add some clarifying comments., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode acc516e76d 225/253: Uncomment code blocks in POD., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 341c898848 029/253: Add note about electricity, ELPA Syncer, 2022/01/29