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

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

[nongnu] elpa/j-mode ebf94ae 03/56: Added the beginning of j-console int


From: ELPA Syncer
Subject: [nongnu] elpa/j-mode ebf94ae 03/56: Added the beginning of j-console integration
Date: Sun, 29 Aug 2021 11:20:43 -0400 (EDT)

branch: elpa/j-mode
commit ebf94aec7639019eec27a27c631a448e095dc0f8
Author: Zachary Elliott <zach@nyu.edu>
Commit: Zachary Elliott <zach@nyu.edu>

    Added the beginning of j-console integration
---
 j-mode.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/j-mode.el b/j-mode.el
index 96ebd61..b473e15 100644
--- a/j-mode.el
+++ b/j-mode.el
@@ -33,6 +33,9 @@
 
 ;;; Code:
 
+(require 'comint)
+
+
 (defconst j-mode-version "0.0.1"
   "`j-mode' version")
 
@@ -213,4 +216,74 @@
   (run-mode-hooks 'j-mode-hook))
 
 
+
+
+(defcustom j-command "jconsole"
+  ""
+  :type 'string
+  :group 'j-)
+
+(defcustom j-command-args '()
+  ""
+  :type 'string
+  :group 'j-)
+
+(defcustom j-command-conf nil
+  ""
+  :type 'string
+  :group 'j-)
+
+
+(defun j-create-interpreter ()
+  (apply 'make-comint "J" j-command j-command-conf j-command-args))
+
+(defun j-ensure-interpreter ()
+  (or (get-process "J")
+      (progn
+        (j-create-interpreter)
+        (get-process "J"))))
+
+
+;; with process
+(defmacro w-p ( binding &rest body )
+  `(let* ((,binding (j-ensure-interpreter)))
+     ,@body))
+
+
+(defun j-execute-line ()
+  (interactive)
+  (w-p interpreter
+       (let* ((line (buffer-substring-no-properties (point-at-bol)
+                                                    (point-at-eol))))
+         (pop-to-buffer (process-buffer interpreter))
+         (goto-char (point-max))
+         (insert-string line)
+         (comint-send-input))))
+
+(defun j-execute-region (start end)
+  (interactive "r")
+  (w-p interpreter
+       (and (= start end) (error "Region is empty"))
+       (let* ((region (buffer-substring-no-properties start end))
+              (block-size (if (and (= start (point-min)) (= end (point-max)))
+                              "buffer" "region"))
+              (region (concat "\nNB. Sending " block-size "...\n" region)))
+         (pop-to-buffer (process-buffer interpreter))
+         (insert-string (concat "\n" region))
+         (dolist (line (split-string region "[\r\n]" nil))
+           (comint-send-string interpreter (concat line "\n"))))))
+
+(defun j-execute-buffer ()
+  (interactive)
+  (j-execute-region (point-min) (point-max)))
+
+;;(add-hook 'comint-mode-hook
+;;          (lambda ()
+;;            (setq comint-process-echoes t)))
+
+;;;###autoload
+(defun j-console ()
+  (interactive)
+  (switch-to-buffer-other-window (process-buffer (j-ensure-interpreter))))
+
 (provide 'j-mode)



reply via email to

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