Code Monkey home page Code Monkey logo

eval-in-repl's Introduction

Table of Contents

  1. Test

Test

test

eval-in-repl's People

Contributors

actondev avatar akirak avatar arichiardi avatar jcai849 avatar kaz-yos avatar naupaka avatar nicolas-graves avatar stardiviner avatar syohex avatar tarsius avatar terlar avatar theldoria avatar wentasah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eval-in-repl's Issues

Blank lines in python functions don't work

Given the function:

def foo():
    x = 1

    y = x + 1

eir-eval-in-python makes python/ipython thinks that the function ends after x = 1, and tries to evaluate y = x + 1, producing NameError.

Looks like eir-send-to-python is getting the whole string, but it's being misunderstood by the inferior python process. It is possible to send whole functions to *Python* buffers, python-shell-send-defun does the right thing, so I'm not sure what needs changing.

Deselect region after eval

Currently, mark is always active after an expression is evaluated. We should restore the mark to its original state. That is, when mark-active is nil at the beginning, always restore it back afterward.

add support for JavaScript

there is a package called js-comint can do inferior-js-mode and run-js.
Hope you can support JavaScript.

eval-in-repl-ruby error

When I execute M-x eir-eval-in-ruby in a ruby buffer with an inf-ruby mode, it gives the following error.

eir-send-to-repl: Wrong number of arguments: (lambda (command &optional name) "Run an inferior Ruby process, input and output in a new buffer.

The consecutive buffer names will be:
`*NAME*', `*NAME*<2>', `*NAME*<3>' and so on.

NAME defaults to \"ruby\".

Runs the hooks `comint-mode-hook' and `inf-ruby-mode-hook'.

(Type \\[describe-mode] in the process buffer for the list of commands.)" (setq name (or name "ruby")) (let ((commandlist (split-string-and-unquote command)) (buffer (current-buffer)) (process-environment process-environment)) (setenv "PAGER" (executable-find "cat")) (set-buffer (apply (quote make-comint-in-buffer) name (generate-new-buffer-name (format "*%s*" name)) (car commandlist) nil (cdr commandlist))) (inf-ruby-mode) (ruby-remember-ruby-buffer buffer) (setq inf-ruby-buffers (cons (current-buffer) inf-ruby-buffers)) (setq inf-ruby-buffer-impl-name name inf-ruby-buffer-command command)) (pop-to-buffer (setq inf-ruby-buffer (current-buffer)))), 0

However, M-x ruby-send-region works correctly.
Has there been an incompatible update recently?

Sorry to bother, but it would be awesome if you could look into this (I will try to fix this after the new years when I get the time).

Send buffer to repl

Is there a way of using this to send the whole buffer to the REPL?

AS the switch by mode is done by setting the same key to different functions in each keymap it is not as easy to generalise as select the buffer and call an eir function.

Shell REPL not working.

Hi I am new to emacs. Here is what I have done. Thank you for any help in advance.

install eval-in-repl from melpa-stable
install essh.el by placing in load path
install eval-in-repl-shell.el in load path

relevant .emacs cutout:
;;--------------------------------------------------------------;;
(require 'essh)
(defun essh-sh-hook ()
(define-key sh-mode-map "\C-c\C-r" 'pipe-region-to-shell)
(define-key sh-mode-map "\C-c\C-b" 'pipe-buffer-to-shell)
(define-key sh-mode-map "\C-c\C-j" 'pipe-line-to-shell)
(define-key sh-mode-map "\C-c\C-n" 'pipe-line-to-shell-and-step)
(define-key sh-mode-map "\C-c\C-f" 'pipe-function-to-shell)
(define-key sh-mode-map "\C-c\C-d" 'shell-cd-current-directory))
(add-hook 'sh-mode-hook 'essh-sh-hook)
;;--------------------------------------------------------------;;

;;--------------------------------------------------------------;;
;; require the main file containing common functions
(require 'eval-in-repl)

;; Uncomment if no need to jump after evaluating current line
;; (setq eir-jump-after-eval nil)

;; Uncomment if you want to always split the script window into two.
;; This will just split the current script window into two without
;; disturbing other windows.
;; (setq eir-always-split-script-window t)

;; Uncomment if you always prefer the two-window layout.
;; (setq eir-delete-other-windows t)

;; Place REPL on the left of the script window when splitting.
(setq eir-repl-placement 'below)

;; Shell support
(require 'eval-in-repl-shell)
(add-hook 'sh-mode-hook
'(lambda()
(local-set-key (kbd "C-") 'eir-eval-in-shell)))
;; Version with opposite behavior to eir-jump-after-eval configuration
;;(defun eir-eval-in-shell2 ()
;; "eval-in-repl for shell script (opposite behavior)

;;This version has the opposite behavior to the eir-jump-after-eval
;;configuration when invoked to evaluate a line."
;; (interactive)
;; (let ((eir-jump-after-eval (not eir-jump-after-eval)))
;; (eir-eval-in-shell)))
;;(add-hook 'sh-mode-hook
;; '(lambda()
;; (local-set-key (kbd "C-M-") 'eir-eval-in-shell2)))
;;--------------------------------------------------------------;;

use *-term instead of shell?

Firstly, thank you for this excellent package!

I am brand new to both emacs and elisp, so forgive me if this is a trivial PR (or obviously a bad idea), but would it be possible to extend the package to allow the evaluation of bash code in multi-term or ansi-term as opposed to shell?

Regardless, thanks for your work!

Can't evaluate individual lines in functions

Given the Python:

def foo():
    print "hello"
    print "world"

If point is on the print "hello" line, then I'd expect it to just send that line to *Python*. Instead, it sends the whole function body.

Make "jump to the next top form" optional

As you wrote in your README, when developing, the workflow is to have code on one side and evaluate the changes of your functions in the repl.

I find not very useful to jump to the next form every time that you evaluate, and I would like to ask if possible to make it optional through a defcustom so that it can be set to false (can be left on by default so we don't break the current behaviour).

Thank you for this wonderful addition, I was waiting for and when I found it I immediately share it on my twitter @richiardiandrea ๐Ÿ˜„

Make require js3-mode conditionally

I use use-package to load eval-in-repl. Seems eval-in-repl require js3-mode explicitly. I think this should be conditionally by using if condition (featurep 'js3-mode) to detect.

Here is the error I got:

Error (use-package): eval-in-repl/:config: Cannot open load file: No such file or directory, js3-mode

do not see the command in repl

I am not able to see the executed command in the repl only the result for python. For example if I execute print("hello") I only see the result hello

I am using spacemacs with emacs 27.2 on a windows machine.

Thx.

Suggestion: Frame support?

Description

By frame support, I mean allowing the REPL buffers to show on a different "frame" (i.e. "window", in a normal term).

If this is made possible, the REPL output can be moved to a second display, which is the primary incentive for me to propose this.

Questions

I want to know what you would think.
Is this outside the scope of this library?
Would it be easy to implement this behavior?

Expose a function to just launch the REPL without evaluating something

This is already available through the eir-repl-start function, but it would be nice to not have to replicate the knowledge of how those things are setup.

So for example wrap this inside a function:
(eir-repl-start "\\*ruby\\*" #'inf-ruby t)

Like:

(defun eir-repl-start-ruby ()
  (interactive)
  (eir-repl-start "\\*ruby\\*" #'inf-ruby t))

If this is something you agree with I could make the change for all packages. Then people who want to reuse the logic to get a REPL can require/autoload that part.

First commands not send to shell (windows)

The first command (or region) I send using eir-eval-in-shell (or eir-eval-in-shell2) is not executed. Afterwards, while the buffer *shell* exists, the commands work.

Tested using windows native shell (cmd).

Suggestion: Make eir-jump-after-eval buffer local

Suggestion

Why don't we make eir-jump-after-eval a buffer local variable?

Because whether we want to move lines after evaluation depends on our workflow, and the workflows can differ among the languages. It would be great if we can toggle this setting according to the language we are in, or based on some other condition.

send word at cursor to REPL

I want to improve my Python workflow in the following way:

  • Send word at cursor to REPL
  • Send word.info() from word (variable) at cursor to REPL
  • Send type(word) from word (variable) at cursor to REPL

I do the following with Elpy but since I use spacemacs I'd rather not use it since it is big.

(defun jv-python/elpy-shell-send-word ()
  "Send word at cursor."
  (interactive)
  (elpy-shell--ensure-shell-running)
  (when (not elpy-shell-echo-input) (elpy-shell--append-to-shell-output "\n"))
    (elpy-shell--with-maybe-echo
  (python-shell-send-string (thing-at-point 'symbol)))
  )

Can someone please help me with the points above using spacemacs + eir?

function definition is void: switch-to-js (probably solved)

Dear Kazuki,

Thank you for this great package -- I wanted ``geiser for (js|ruby|python|R)'' and here they are, all in one!
I found a small issue with js support (emacs24-nox on debian) -- it does not work out of the box, complaining about switch-to-js function. Brutal (defalias 'switch-to-js 'js-comint-switch-to-repl) seems to do the trick, but I am pretty ignorant about elisp, so perhaps it's not the best solution?

Best regards!

js-comint `wrong-number-of-arguments` error

Hello,

The error is occurring part way through the code submitted. It's a JS function, and the first line that appears in the backtrace is the fifth line of the code itself. I plugged the code into node by hand to confirm it is correct, nothing hinky there. The code is being run in an org-mode source block.

Debugger entered--Lisp error: (wrong-number-of-arguments #<subr js-comint-start-or-switch-to-repl> 1)     switch-to-js(t)
#f(compiled-function () #<bytecode 0x1e820db659a472>)() eir-send-to-repl(#f(compiled-function () #<bytecode   
0x1e820db659a472>)
comint-send-input " const codeEnd = Math.ceil(Math.random()*factor);")
apply(eir-send-to-repl (#f(compiled-function () #<bytecode 0x1e820db659a472>) comint-send-input " const codeEnd =   
Math.ceil(Math.random()*factor);")) eir-send-to-javascript("  const codeEnd = Math.ceil(Math.random()*factor);")
eir-eval-in-javascript() ober-eval-in-repl()
funcall-interactively(ober-eval-in-repl)
command-execute(ober-eval-in-repl)

GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2021-10-12
org-mode version 9.5
Windows 10 Pro

some changes to eir-eval-in-repl-python and creation of eir-eval-in-perl

Hello,
I have been wanting something like this package for a very long time so that I may have the ease of ess in arbitrary languages. I was super pleased to find it.

While playing with it in python, I had some very strange and difficult-to-reproduce problems with 'Overlapping strings detected'. I eventually hunted down my problems to python-nav-forward-*. Since I know ess a bit more than python.el, I decided to yank the logic from there and implement a python version of 'ess-eval-region-or-function-or-paragraph-and-step' (eerofopas) by mostly copy/pasting from ess.

In the process of making it work, I found myself looking at eir-eval-in-python-repl/python.el and thinking that the logic should work pretty easily with perl's various REPLs. So I did a little more copy/pasting and made eir-eval-in-perl-repl.

Finally, I added a function to eval-in-repl which is just a (cond ...) to invoke the various eval flavors depending on the current buffer's major mode.

I only about 75% finished any of these tasks though, as I needed to get back to work. If any of them are of interest, I would be happy to finish them, clean them up, and send a PR, as they are currently sitting in my fork.

I hope you are doing well.

Don't hide other windows, only show two windows from eir.

I found eval-in-repl will hide other windows, only show two windows, one is the source code buffer, and the other is the repl buffer. Sometimes I open many buffers, this behavior is bad. I have to open those buffers again, and I even can't remember which buffers I opened.
It has one benifit, it's clear.
I think this might need an option to toggle this behavior?

essh is not available

I found there is one line (essh-next-code-line) in eir-eval-in-ruby definition.
But I have not found essh in Emacs library. And there there is no this package in MELPA.

inf-clojure integration

Hello again, this time with another idea !

Inf-clojure comes as a lighter alternative to cider for Clojure and it is usually triggered by calling M-x inf-clojure. People are using it because it does one thing only and well (as every tool should be!).

It would be a great fit in eval-in-repl imho ๐Ÿ˜€

As usual, thanks for your work, I use this package a lot.

Tagging releases

Hi,

please tag the latest release 0.2.0 as such in git, so that melpa-stable will also be able to pick it up.

Thanks!!

Allow passing arguments downstream eval-in-repl

It would be handy to have a fully transparent eir-eval-in-repl-lisp facade.

For example, we could pass arguments to it that would go directly downstream to the correct "implementation" (-cider, ...).
Another use case, in lisp I am often instrumenting edebug according to the following:

With a prefix argument, C-M-x instruments the function definition for Edebug, the Emacs Lisp Debugger. See Instrumenting for Edebug in the Emacs Lisp Reference Manual. 

Do you think it would be hard to accomplish?

Racket-mode support uses unavailable function

eval-in-repl-racket.el uses the function racket--repl-show-and-move-to-end from racket-mode. However, this function is no longer available. I'm not sure what it has been replaced with, but the issue can be fixed by replacing the function with it's previous implementation. That is

(defalias 'eir-send-to-racket
  (apply-partially 'eir-send-to-repl
                   ;; fun-change-to-repl
                   #'(lambda ()
                       ;; Show Racket REPL (focus comes back)
                       (racket--repl-show-and-move-to-end)
                       ;; Go to the other window
                       (other-window 1))
                   ;; fun-execute
                   #'comint-send-input)
  "Send expression to *Racket REPL* and have it evaluated.")

Can be rewritten as

(defalias 'eir-send-to-racket
  (apply-partially 'eir-send-to-repl
                   ;; fun-change-to-repl
                   #'(lambda ()
                       ;; Show Racket REPL (focus comes back)
                       (display-buffer racket-repl-buffer-name)
                       (save-selected-window
			  (select-window (get-buffer-window racket-repl-buffer-name))
			  (comint-show-maximum-output))
                       ;; Go to the other window
                       (other-window 1))
                   ;; fun-execute
                   #'comint-send-input)
  "Send expression to *Racket REPL* and have it evaluated.")

Probably not the prettiest solution but it fixes the issue.

Supress split buffer when running C-<return>

Hi,
I'm playing around with the python eval-in-repl and was wondering if there is a possibility to configure it so that when you press the key combo C- the line is sent but if you don't have the inferor mode buffer open the the buffer configuration will just stay as it is.
I usually have the buffers as I want them and this is changing that somewhat.

Byte-compile warnings

Hi,

Thanks for this nice package. FYI, there are many byte-compile warnings when installing this package, if you don't have all of the supported modes installed:

Leaving directory `/home/me/.emacs.d/elpa/eval-in-repl-20160418.1843'

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-cider.el at Tue Nov  8 01:57:03 2016
Entering directory `/home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/'
eval-in-repl-cider.el:36:1:Error: Cannot open load file: no such file or directory, cider

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-geiser.el at Tue Nov  8 01:57:03 2016
eval-in-repl-geiser.el:36:1:Error: Cannot open load file: no such file or directory, geiser-mode

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-hy.el at Tue Nov  8 01:57:03 2016

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-ielm.el at Tue Nov  8 01:57:03 2016

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-javascript.el at Tue Nov  8 01:57:04 2016
eval-in-repl-javascript.el:37:1:Error: Cannot open load file: no such file or directory, js3-mode

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-ocaml.el at Tue Nov  8 01:57:04 2016
eval-in-repl-ocaml.el:36:1:Error: Cannot open load file: no such file or directory, tuareg

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-prolog.el at Tue Nov  8 01:57:04 2016

In end of data:
eval-in-repl-prolog.el:87:1:Warning: the function `prolog-consult-region' is
    not known to be defined.

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-python.el at Tue Nov  8 01:57:04 2016

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-racket.el at Tue Nov  8 01:57:04 2016
eval-in-repl-racket.el:36:1:Error: Cannot open load file: no such file or directory, racket-mode

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-ruby.el at Tue Nov  8 01:57:04 2016
eval-in-repl-ruby.el:37:1:Error: Cannot open load file: no such file or directory, inf-ruby

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-scheme.el at Tue Nov  8 01:57:04 2016

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-shell.el at Tue Nov  8 01:57:04 2016

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-slime.el at Tue Nov  8 01:57:05 2016
eval-in-repl-slime.el:36:1:Error: Cannot open load file: no such file or directory, slime

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl-sml.el at Tue Nov  8 01:57:05 2016
eval-in-repl-sml.el:36:1:Error: Cannot open load file: no such file or directory, sml-mode

Compiling file /home/me/.emacs.d/elpa/eval-in-repl-20160418.1843/eval-in-repl.el at Tue Nov  8 01:57:05 2016
eval-in-repl.el:136:1:Warning: Unused lexical variable `name-repl-buffer'
eval-in-repl.el:136:1:Warning: Unused lexical variable `name-script-buffer'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.