-
Notifications
You must be signed in to change notification settings - Fork 37
Add ghostel backend
#162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add ghostel backend
#162
Changes from all commits
d52d160
7460d4c
5c06b1f
400e715
2e96e74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,6 +268,57 @@ When PASTE-P, “bracketed paste” mode will be used. When RET-P, terminate wit | |
| (when ret-p | ||
| (eat-term-send-string eat-terminal "\^M"))))) | ||
|
|
||
|
|
||
| ;;; ghostel term | ||
|
|
||
| (with-eval-after-load 'ghostel | ||
|
|
||
| ;; this variables are defined by ghostel.el and are only locally changed. | ||
| (defvar ghostel--process) | ||
| (defvar ghostel-use-native-pty) | ||
| (defvar ghostel-buffer-name-function) | ||
|
Comment on lines
+278
to
+279
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, what are these for? You are just setting them to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are also variables from
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also added a short comment for this |
||
|
|
||
| (cl-defstruct julia-repl--buffer-ghostel | ||
| "Terminal backend using ‘ghostel’, which needs to be installed and loaded.") | ||
|
|
||
| (defun julia-repl--ghostel-scroll-to-bottom () | ||
| "Scroll visible windows displaying the current ghostel buffer to the bottom." | ||
| (dolist (window (get-buffer-window-list (current-buffer) nil t)) | ||
| (ghostel--anchor-window window))) | ||
|
|
||
| (cl-defmethod julia-repl--locate-live-buffer ((_terminal-backend julia-repl--buffer-ghostel) | ||
| name) | ||
| (if-let ((inferior-buffer (get-buffer (julia-repl--add-earmuffs name)))) | ||
| (with-current-buffer inferior-buffer | ||
| (cl-assert (eq major-mode 'ghostel-mode) nil "Expected ghostel-mode. Changed mode or backends?") | ||
| (when (process-live-p ghostel--process) ; check if Julia sessions is still live | ||
| inferior-buffer)))) | ||
|
|
||
| (cl-defmethod julia-repl--make-buffer ((_terminal-backend julia-repl--buffer-ghostel) | ||
| name executable-path switches) | ||
| (let ((inferior-buffer (get-buffer-create (julia-repl--add-earmuffs name)))) | ||
| (with-current-buffer inferior-buffer | ||
| (let ((ghostel-use-native-pty nil) ; use Emacs process machinery | ||
| (ghostel-buffer-name-function nil)) ; avoid ghostel's renaming | ||
| (ghostel-exec inferior-buffer executable-path switches)) | ||
| (setq-local ghostel-buffer-name-function nil) | ||
| (mapc (lambda (k) | ||
| (define-key ghostel-semi-char-mode-map k (global-key-binding k))) | ||
| julia-repl-captures) | ||
| (local-set-key (kbd "C-c C-z") #'julia-repl--switch-back)) | ||
| inferior-buffer)) | ||
|
|
||
| (cl-defmethod julia-repl--send-to-backend ((_terminal-backend julia-repl--buffer-ghostel) | ||
| buffer string paste-p ret-p) | ||
| (with-current-buffer buffer | ||
| (julia-repl--ghostel-scroll-to-bottom) | ||
| (if paste-p | ||
| (ghostel-paste-string string) | ||
| (ghostel-send-string string)) | ||
| (when ret-p | ||
| (ghostel-send-key "return"))))) | ||
|
|
||
|
|
||
| ;;; compiler output regexps for navigation | ||
|
|
||
| (defconst julia-repl--CR-path | ||
|
|
@@ -330,7 +381,9 @@ Valid backends are currently: | |
|
|
||
| - ‘vterm’, which requires that vterm is installed. See URL ‘https://github.com/akermu/emacs-libvterm’. | ||
|
|
||
| - ‘eat’, which requires that eat is installed. See URL ‘https://codeberg.org/akib/emacs-eat’." | ||
| - ‘eat’, which requires that eat is installed. See URL ‘https://codeberg.org/akib/emacs-eat’. | ||
|
|
||
| - ‘ghostel’, which requires that ghostel is installed. See URL ‘https://github.com/dakra/ghostel’." | ||
| (interactive "S") | ||
| (cl-case backend | ||
| (ansi-term | ||
|
|
@@ -342,6 +395,9 @@ Valid backends are currently: | |
| (eat | ||
| (require 'eat) | ||
| (setq julia-repl--terminal-backend (make-julia-repl--buffer-eat))) | ||
| (ghostel | ||
| (require 'ghostel) | ||
| (setq julia-repl--terminal-backend (make-julia-repl--buffer-ghostel))) | ||
| (otherwise | ||
| (error "Unrecognized backend “%s”." backend)))) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain what this is for? You are not setting it anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to see if the Julia process is still alive. I've added a comment.
This is a bit dirty because it is an internal variable of ghostel.el but I didn't figure out a better way.