Skip to content
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

ctrl-r not working for reverse search on OS X 10.10.5 with Python 3.5 #394

Closed
corbinbs opened this issue Sep 27, 2015 · 20 comments
Closed

Comments

@corbinbs
Copy link
Contributor

I've not been able to get ctrl-r to work for reverse search on OS X 10.10.5 with Python 3.5.
I pip installed the latest xonsh release (0.2.0) and I've also tried with the latest master code.
I'll post a pull request if I figure out what's going on but I wanted to file an issue in case others encountered the same behavior.

Thanks,

Brian

@scopatz
Copy link
Member

scopatz commented Sep 27, 2015

Hi @corbinbs - do you know if you have GNU readline or libedit? This seems like it could be a Mac specific issue...

@scopatz scopatz added the bug label Sep 27, 2015
@scopatz scopatz added this to the v0.3 milestone Sep 27, 2015
@corbinbs
Copy link
Contributor Author

Looks like I might have libedit in the mix

$ ls -l /usr/lib/libreadline.dylib
lrwxr-xr-x  1 root  wheel  15 Oct 20  2014 /usr/lib/libreadline.dylib -> libedit.3.dylib

I'm running with the latest Python 3.5 install from python.org

@scopatz
Copy link
Member

scopatz commented Sep 29, 2015

OK - then I bet that this is a libedit issue. I don't have a good way of testing this personally, so if you are anyone comes up with a fix, I'll gladly merge it.

@blarghmatey
Copy link

I am having a similar issue using prompt-toolkit on Manjaro Linux (an Arch derivative) using Python 3.5. I am unable to use Ctl-R, Ctl-D, Ctl-C, Ctl-Z at all unless I am using readline mode.

@scopatz
Copy link
Member

scopatz commented Oct 2, 2015

I am not even sure that prompt-toolkit supports that (though it probably does). @jonathanslenders or @melund would know :)

@scopatz
Copy link
Member

scopatz commented Oct 2, 2015

Thanks for reporting @blarghmatey

@blarghmatey
Copy link

Looking here, it appears that it does support control sequences. I'm not sure why it would fail given my setup. I will try running everything on Python 3.4 and see if that works any different.

@blarghmatey
Copy link

So, it started working again. I'm not sure what I may have changed, sorry I can't be more help on that front :)

@corbinbs
Copy link
Contributor Author

I stumbled across this recently:
http://hints.macworld.com/article.php?story=20080313113705760

adding a line to your .editrc file:

$ cat ~/.editrc
bind "^R" em-inc-search-prev

ctrl-r works but still doesn't display quite like I'd expect. (sometimes long commands get wrapped or the first part of them is chopped off with no way to go back to edit, etc)

I'll keep looking for a decent solution that will work for folks "out of the box" when they install xonsh

@scopatz
Copy link
Member

scopatz commented Oct 16, 2015

Thanks @corbinbs - I wonder if this looks weird because of the order it is loaded in. Could you try adding a additional line here in readline_shell.py that looks like:

readline.parse_and_bind("bind ^R em-inc-search-prev")

@jonathanslenders
Copy link
Contributor

Hi all,
Sorry for the late reply. prompt_toolkit does support reverse-i-search. Ctrl-C and Ctrl-D should also be handled correctly. I can have a look this weekend.

By the way, I get a lot of "UnboundLocalError: local variable 'p0' referenced before assignment" errors when running Xonsh. (latest master.)

@scopatz
Copy link
Member

scopatz commented Oct 16, 2015

I can have a look this weekend.

Thanks!

By the way, I get a lot of "UnboundLocalError: local variable 'p0' referenced before assignment" errors when running Xonsh. (latest master.)

Weird. Can you post a full traceback? Also what version of Python are you on?

@jonathanslenders
Copy link
Contributor

This one is Python 3.4.0. But looking at the code, there is a code path in p_power that does not assign to p0, but uses it anyway. Maybe other functions have the same issue.

@scopatz
Copy link
Member

scopatz commented Oct 16, 2015

So we were seeing this issue in #399, but that code path should be impossible to access. I wonder if it is a PLY version issue. Do you know what PLY you are on?

@jonathanslenders
Copy link
Contributor

Traceback (most recent call last):
  File "/home/jonathan/git/xonsh/xonsh/base_shell.py", line 158, in push
    locs=self.ctx)
  File "/home/jonathan/git/xonsh/xonsh/execer.py", line 94, in compile
    tree = self.parse(input, ctx, mode=mode)
  File "/home/jonathan/git/xonsh/xonsh/execer.py", line 69, in parse
    tree = self._parse_ctx_free(input, mode=mode)
  File "/home/jonathan/git/xonsh/xonsh/execer.py", line 150, in _parse_ctx_free
    debug_level=self.debug_level)
  File "/home/jonathan/git/xonsh/xonsh/parser.py", line 263, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/home/jonathan/git/xonsh/.eggs/ply-3.6-py3.4.egg/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/home/jonathan/git/xonsh/.eggs/ply-3.6-py3.4.egg/ply/yacc.py", line 1106, in parseopt_notrack
    p.callable(pslice)
  File "/home/jonathan/git/xonsh/xonsh/parser.py", line 1625, in p_power
    p[0] = p0
UnboundLocalError: local variable 'p0' referenced before assignment

@scopatz
Copy link
Member

scopatz commented Oct 16, 2015

And this happens with any command? I am not able to reproduce this on Python 3.4 on Ubuntu on PLY v3.6

@jonathanslenders
Copy link
Contributor

Yes. p has length 3. It is [None, <_ast.Name object at 0xb5e9a3ac>, None].

@scopatz
Copy link
Member

scopatz commented Oct 16, 2015

Woah! That definitely looks like a ply bug. Are you on ply 3.5? From the website:

4/26/2015. PLY-3.6 is released. A fair bit of cleanup and a few new features. Note: PLY-3.5 had some critical bugs and has been withdrawn.

http://www.dabeaz.com/ply/

@gforsyth gforsyth modified the milestones: v0.3, v0.4.0 Jun 5, 2016
@santagada
Copy link
Contributor

Tested this today on:

xonfig
+------------------+----------------+
| xonsh            | 0.4.4          |
| Git SHA          | None           |
| Python           | 3.5.2          |
| PLY              | 3.7            |
| have readline    | True           |
| prompt toolkit   | 1.0.3          |
| shell type       | prompt_toolkit |
| pygments         | 2.2a0          |
| on posix         | True           |
| on linux         | False          |
| on darwin        | True           |
| on windows       | False          |
| on cygwin        | False          |
| is superuser     | False          |
| default encoding | utf-8          |
+------------------+----------------+

and ctrl+r seems to be working fine (I think it was broken for me on xonsh 0.4.3 too)

@scopatz
Copy link
Member

scopatz commented Jul 27, 2016

Ok I am going to go ahead and close. Please feel free to reopen.

@scopatz scopatz closed this as completed Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants