Opened 8 years ago
Closed 7 years ago
#12503 closed enhancement (fixed)
Convenient history fetch commands
Reported by: | klee | Owned by: | was |
---|---|---|---|
Priority: | minor | Milestone: | sage-5.3 |
Component: | user interface | Keywords: | |
Cc: | Merged in: | sage-5.3.beta0 | |
Authors: | Kwankyu Lee | Reviewers: | Dmitrii Pasechnik |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Using Sage, you are missing a feature of the Magma command line interface. In Magma, if you enter a line found in history using up arrow key and then press down arrow key, then the next line in history is fetched. This feature allows you to fetch as many successive lines in history as you like. However, Sage does not have a similar feature. The IPython command prompt uses the readline library (via pyreadline), which evidently does not support this feature. Magma has its own custom “readline-like” library, which does support this feature. (Since so many people have requested this feature, if anybody can figure out how to implement it, then such an implementation would certainly be welcome!)
This ticket addresses the above implementation.
apply trac_12503_v4.patch
Attachments (7)
Change History (37)
comment:1 follow-up: ↓ 2 Changed 8 years ago by
comment:2 in reply to: ↑ 1 ; follow-up: ↓ 4 Changed 8 years ago by
Replying to jhpalmieri:
Is this a duplicate of #10289?
Yes. I created this because I found no way to trigger the patchbot for the patch in #10289. I hope the patchbot works for this duplicate ticket.
I will add a comment on #10289 right now.
comment:3 Changed 8 years ago by
- Status changed from new to needs_review
comment:4 in reply to: ↑ 2 Changed 8 years ago by
Replying to klee:
Replying to jhpalmieri:
Is this a duplicate of #10289?
Yes. I created this because I found no way to trigger the patchbot for the patch in #10289. I hope the patchbot works for this duplicate ticket.
Just FYI, we can still give patches positive review even if the patchbot is screwing up. Maybe you should give #10289 positive review with milestone sage-duplicate? (Or maybe this one should be the duplicate, since it's a later-opened ticket.)
Also, you might want to rename the patch and change the commit message :-)
comment:5 Changed 8 years ago by
I think I am paranoic with the patchbot! Anyway the last patch would pass the patchbot. How can I remove the first patch, and trigger the patchbot with the new patch? :-)
Please someone review this patch.
comment:6 Changed 8 years ago by
The three patches are the same with different names. Sorry.
comment:7 Changed 8 years ago by
apply trac_12503.patch
comment:8 Changed 8 years ago by
Apply trac_12503.patch
comment:9 Changed 8 years ago by
comment:10 Changed 8 years ago by
Apply trac_12503_v2.patch
comment:11 Changed 7 years ago by
apply trac_12503_v3.patch
comment:12 Changed 7 years ago by
abra cadabra!
apply trac_12503_v3.patch
voila!
comment:13 Changed 7 years ago by
- Milestone changed from sage-5.1 to sage-5.2
comment:14 Changed 7 years ago by
apply trac_12503_v3.patch
comment:15 follow-up: ↓ 18 Changed 7 years ago by
I tried using this a few times before but could never bind it to Control-o so I gave up. I have an inputrc
file and several other customizations that I thought might be interfering, but could never figure it out. Today I finally took the time and so I'm putting it here in case others have the same problem. Below is what happens as best I understand it. I'm on OS X 10.6.
Before readline gets a character sequence it's interpreted by the terminal emulator and can be used to do things like turn flow control on and off. These are generally bound to Control-s and Control-q and is, I think, fairly well known (at least I knew it). However, there are other actions as well which can be determined by running stty -a
and reading the cchars
section. In my case control-o was bound to discard. These extra bindings can be turned of by running
# Enable Ctrl-o stty -iexten # Enable Ctrl-s and Ctrl-q stty -ixon
or by unbinding them individually like
stty discard undef ...
comment:16 follow-ups: ↓ 17 ↓ 19 Changed 7 years ago by
I just have to ask whether this would change current behavior in the command line. That is, would anything change for someone who didn't bind any metakeys, or didn't even really know what it was all about and was afraid of things like Emacs?
comment:17 in reply to: ↑ 16 Changed 7 years ago by
Replying to kcrisman:
I just have to ask whether this would change current behavior in the command line. That is, would anything change for someone who didn't bind any metakeys, or didn't even really know what it was all about and was afraid of things like Emacs?
The current patch doesn't bind them, though I think it should. If they were bound by default (to whatever Magma uses) then they would be more discoverable, and I think the only difference (beyond perhaps a minuscule performance penalty) would be Ctl-o
, which I think isn't used for anything right now. It would be good to have it confirmed that Ctl-n
and Ctl-p
are backwards compatible and Ctl-o
is unused.
I skimmed the code and documentation and I noticed that on line 245 unbounded should be unbound. Sadly, I don't know Cython well enough to feel comfortable reviewing it, though I can say it has been working fine for me (after I got my issues sorted out). I think it would be nice to add a sentence to the documentation about stty -iexten
etc.
comment:18 in reply to: ↑ 15 ; follow-ups: ↓ 20 ↓ 24 Changed 7 years ago by
Replying to iandrus:
I tried using this a few times before but could never bind it to Control-o so I gave up. I have an
inputrc
file and several other customizations that I thought might be interfering, but could never figure it out. Today I finally took the time and so I'm putting it here in case others have the same problem. Below is what happens as best I understand it. I'm on OS X 10.6.
Did you add the relevant lines into the "ipythonrc" as indicated in the documentation? You don't modify inputrc
file in your home folder.
To bind these commands with keys, insert the relevant lines into the ``$DOT_SAGE/ipython/ipythonrc`` file. Note that ``$DOT_SAGE`` is ``$HOME/.sage`` by default. For example, :: readline_parse_and_bind "\C-o": operate-and-get-next readline_parse_and_bind "\e[A": history-search-backward-and-save readline_parse_and_bind "\e[B": history-search-forward-and-save binds the three commands with the control-o key, the up arrow key, and the down arrow key, respectively.
comment:19 in reply to: ↑ 16 ; follow-up: ↓ 26 Changed 7 years ago by
Replying to kcrisman:
I just have to ask whether this would change current behavior in the command line. That is, would anything change for someone who didn't bind any metakeys, or didn't even really know what it was all about and was afraid of things like Emacs?
This patch does not chanage anything before you put some relevant lines to the "ipythonrc" file in your dot_sage folder.
comment:20 in reply to: ↑ 18 ; follow-up: ↓ 21 Changed 7 years ago by
Replying to klee:
I can confirm that this (GAP history settings) works on OSX 10.6. Shouldn't this go into documentation?
comment:21 in reply to: ↑ 20 Changed 7 years ago by
- Status changed from needs_review to positive_review
comment:22 Changed 7 years ago by
Apply trac_12503_v4.patch
Thank you for all reviews!
comment:23 Changed 7 years ago by
- Description modified (diff)
comment:24 in reply to: ↑ 18 Changed 7 years ago by
Replying to klee:
Replying to iandrus:
I tried using this a few times before but could never bind it to Control-o so I gave up. I have an
inputrc
file and several other customizations that I thought might be interfering, but could never figure it out. Today I finally took the time and so I'm putting it here in case others have the same problem. Below is what happens as best I understand it. I'm on OS X 10.6.Did you add the relevant lines into the "ipythonrc" as indicated in the documentation? You don't modify
inputrc
file in your home folder.
Yes. I tried both and several other variations as well. My problem was due entirely to the fact that somewhere stty iexten
(or the equivalent) was being called and so it was impossible to get the C-o
binding to work in any terminal application.
comment:25 Changed 7 years ago by
- Milestone changed from sage-5.2 to sage-5.3
- Reviewers set to Dmitrii Pasechnik
comment:26 in reply to: ↑ 19 Changed 7 years ago by
I just have to ask whether this would change current behavior in the command line. That is, would anything change for someone who didn't bind any metakeys, or didn't even really know what it was all about and was afraid of things like Emacs?
This patch does not chanage anything before you put some relevant lines to the "ipythonrc" file in your dot_sage folder.
Sweet, thanks for confirming. Of course, now I might be tempted to do so...
comment:27 Changed 7 years ago by
- Description modified (diff)
comment:28 Changed 7 years ago by
- Description modified (diff)
comment:29 Changed 7 years ago by
- Description modified (diff)
comment:30 Changed 7 years ago by
- Merged in set to sage-5.3.beta0
- Resolution set to fixed
- Status changed from positive_review to closed
Is this a duplicate of #10289?