Open Flink opened 4 years ago
It doesn't look like your regexp matches the actual prompt examples.
Try it in M-x re-builder
to see.
Try this one: "[[:digit:]]\\.[[:digit:]]\\.[[:digit:]] ?([^(]+):[[:digit:]]+ ?\\(*\\|>\\)"
.
Or the shorter version: "[0-9]\\.[0-9]\\.[0-9] ?([^(]+):[0-9]+ ?\\(*\\|>\\)"
.
Ah yes indeed :man_facepalming: Thanks, I’m currently trying different things with M-x re-builder
, I have one that seems to match now but still it doesn’t seem to work as expected in the compilation buffer. I guess it’s just a matter of tweaking it (double-escaping proper things I hope…).
Any idea about the echo back thingy?
And still not working for the regex. I think I don’t get what characters and how it should be double escaped, it doesn’t make sense compared to what I’m used to (not lisp :sweat_smile:). Sometimes it’s \\(
where it should just be (
as it’s to group something and sometimes it seems there is nothing but it should be escaped normally… (checking the source code of the package trying to make sense of how are made the regexps for other prompts). Any advice on this please? :slightly_smiling_face:
(by the way this one is working in re-builder
: "[0-9]\.[0-9]\.[0-9] ?\([^(]+\):[0-9]+ ?>|*"
but not once I put it in my config. Don’t understand what to escape and how)
As far as I can tell, either of the regexps I showed should match the prompt. If that still doesn't help, of course, we'll have to investigate further.
About what to escape or not, Emacs regexps are based on the "basic" syntax. Here you can see some documentation: https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Backslash.html#Regexp-Backslash
Copied/pasted your last regexp, tried others but the compilation buffer doesn’t switch automatically to ruby inf :confused:
This is what I’m using now, tried to make it similar to the one in the wiki:
(add-hook 'inf-ruby-mode-hook
(lambda() (let ((p "\\|\\(^[0-9]\\.[0-9]\\.[0-9] ?([^(]+):[0-9]+ ?> *\\)"))
(setq inf-ruby-first-prompt-pattern (concat inf-ruby-first-prompt-pattern p))
(setq inf-ruby-prompt-pattern (concat inf-ruby-prompt-pattern p)))))
When I try with the standard pry prompt, it’s automatically detected though. And this isn’t resolving the problem of having the output a bit garbled.
This is what I’m using now, tried to make it similar to the one in the wiki:
Which wiki? The extra grouping and alternation and the beginning don't seem to be useful, going by your examples.
And this isn’t resolving the problem of having the output a bit garbled.
That's too bad. But I can't reproduce the problem.
Any chance you can post a sample project, with Gemfile.lock and a spec file which triggers this problem for you?
For the wiki I was trying to follow this one: https://github.com/nonsequitur/inf-ruby/wiki/Adding-new-prompt-patterns
Otherwise I did some tests and the problem with the commands being echoed (and having no completion) seems to be related to docker. Completely forgot to say that I’m working with containers, I just didn’t think it could mess up the completion buffer/inf-ruby as it doesn’t make a difference in neovim (using a terminal though that’s surely why).
So I used an existing rails project and make the config similar to the one I’m working on. I managed to reduce the biggest annoyances by setting TERM
to dumb
and PAGER
to cat
but still that command that is echoed back each time and no completion (it seems to put some ruby code when pressing on TAB and some garbage). Also I’m using Spacemacs as stated in my initial post, my config file is available here: https://gist.github.com/Flink/dcb5783b177a826ab901a29a2cd151cf (I’m using the develop
branch otherwise LSP is not available)
The project is available here: https://github.com/Flink/sample_rails_app
To set it up, just run docker-compose build app
(you might have to have direnv
installed and do a direnv allow
before that to export UID/GID to the build process) and then docker-compose run --rm app bash
, bundle
and everything should be ready to be used.
I’ve included a .dir-locals.el
file which configures rspec-mode
to run the proper commands when using SPC m t t
. I’ve left a binding.pry
statement in the user model spec too.
I think that’s all :sweat_smile: And thanks again for your time! :blush:
Do you think I will be able to repro without Spacemacs? :cold_sweat:
I’m not sure since I haven’t a big experience with emacs but I’d say it should be possible :sweat_smile: The main thing I think is rspec-mode
and inf-ruby
since SPC m t t
is bound to rspec mode verify (something like that) and this one invokes the commands customized in .dir-locals.el
through the compilation buffer. I don’t think spacemacs does anything regarding the problem at hand (I mean in the compilation buffer specifically).
OK, I found the time to repro.
Indeed, this happens. There are too many layers involved for me to quickly understand where this is coming from, but you can observe the difference in behavior by evaluating `stty -echo`
in the Pry REPL.
To counteract it on the side of Emacs instead, set comint-process-echoes
to t
.
@micdahl Have you seen this before, maybe?
Hi again! :grimacing:
Some very late investigation results:
=>
marker (which we rely on). Commenting AwesomePrint.pry!
out in .pryrc
makes it appear again.(setq comint-process-echoes t)
seems to be necessary as well. As pointed out by @bo-tato https://github.com/nonsequitur/inf-ruby/issues/49#issuecomment-1734440828, the REPL echoes when it thinks it's not being run interactively. The set up docker-compose incantation (docker-compose run --rm -e TERM=dumb -e PAGER=cat app
) seems to have that result. I see your docker-compose.yml
already includes tty: true
and stdin_open: true
suggested for similar cases on SO, and apparently they do not help. Further investigation needed. But setting comint-process-echoes
in the same hook (inf-ruby-mode-hook
) drops the echoes. A call to `stty -echo`
does that too.(let ((p "[0-9]\\.[0-9]\\.[0-9] ?([^(]+):[0-9]+ ?"))
(setq inf-ruby-first-prompt-pattern (concat p ">"))
(setq inf-ruby-prompt-pattern (concat p "\\(*\\|>\\)")))
But it's not really a healthy solution, to ask everyone to fiddle with their regexps. First I would try to make them more "regular" in that project (does including the Ruby version help much?), but if this format is popular enough, we should look into updating our regexps here.
With the above tweaks, both input history navigation and completion seem to work. The latter is pretty sluggish, though (EDIT: with the updated prompt regexps above -- not sluggish anymore).
One more thing. Starting with Emacs 29, Tramp supports docker as one of the connection methods (and for earlier versions, there is a 3rd party package).
Logging into an existing container and running the tests in there through Tramp takes care of the echoing as well (alternative solution for item number 2).
First I would try to make them more "regular" in that project
This is done by commenting out the Pry.config.prompt =
assignment in the same .pryrc
. But of course if an existing team has settled on a particular prompt, a more complex solution can be required.
Hi!
I’m trying Spacemacs a second time, trying to use it instead of my neovim config and I have a hard time making things work as I want them regarding specs and
binding.pry
.First I found that I had to do
C-x C-q
in the compilation buffer to make it work withruby-inf
but then I have another problem:It seems characters are echoed back by the buffer/ruby-inf/whatever instead of being displayed normally. I have a custom Pry prompt but even when reverting it it still behaves in the same way.
By the way I tried to add a customization for my prompt but to no avail (documentation is a bit hard to follow on this :sweat_smile:). I’ve put this in my
.spacemacs
config file but it doesn’t work (regex should be valid so it’s weird):Anyone able to help me with these please? :slightly_smiling_face: