jeffreyadams / atlasofliegroups

Automatically exported from code.google.com/p/atlasofliegroups
Other
31 stars 8 forks source link

Paste a block of commands and excuate it line by line #16

Open jiajunma opened 1 year ago

jiajunma commented 1 year ago

https://github.com/jeffreyadams/atlasofliegroups/blob/413c1cf45187b4e2afc84f9d71f59b8db5c0e9f1/sources/interpreter/main.w#L794

The new versions of readline library have "bracketed-paste" mode on by default. This prevents pasted codes to be executed correctly.

The feature can be switched off by the following patch:

diff --git a/sources/interpreter/main.w b/sources/interpreter/main.w
index 8e1c8305..289a9613 100644
--- a/sources/interpreter/main.w
+++ b/sources/interpreter/main.w
@@ -793,6 +793,8 @@ lack of space in the buffer.
 #ifndef NOT_UNIX
 working_directory_name = getcwd(cwd_buffer,cwd_size);
 #endif
+if (RL_VERSION_MAJOR >= 8)
+    rl_variable_bind ("enable-bracketed-paste", "off");

 @ After the lexical scanner is reset (and therefore |readline| certainly has
 returned) and before parsing starts, we ensure any temporary change to the
davidvogan commented 1 year ago

Dear Jiajun,

Marc van Leeuwen has looked at this comment. It appears that pasting a block of commands into atlas DOES work: the only slightly surprising feature we can find is that even if the pasted block of commands ends with a "RETURN" character, atlas will not execute the block (more precisely, readline will not pass the block to atlas) until a second "RETURN" is typed. In this state, it is possible to edit the pasted command block.

To us this behavior appears to be entirely reasonable, so we propose NOT to make your suggested change in main.w If you encounter some problem with a particular version of readline, please let us know about it.

Yours, David

On Wed, Mar 22, 2023 at 11:05 PM Ma Jia-Jun @.***> wrote:

https://github.com/jeffreyadams/atlasofliegroups/blob/413c1cf45187b4e2afc84f9d71f59b8db5c0e9f1/sources/interpreter/main.w#L794

The new versions of readline library have "bracketed-paste" mode on by default. This prevents pasted codes to be executed correctly.

The feature can be switched off by the following patch:

diff --git a/sources/interpreter/main.w b/sources/interpreter/main.w index 8e1c8305..289a9613 100644 --- a/sources/interpreter/main.w +++ b/sources/interpreter/main.w @@ -793,6 +793,8 @@ lack of space in the buffer.

ifndef NOT_UNIX

working_directory_name = getcwd(cwd_buffer,cwd_size);

endif

+if (RL_VERSION_MAJOR >= 8)

  • rl_variable_bind ("enable-bracketed-paste", "off");

    @ After the lexical scanner is reset (and therefore |readline| certainly has returned) and before parsing starts, we ensure any temporary change to the

— Reply to this email directly, view it on GitHub https://github.com/jeffreyadams/atlasofliegroups/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIDPY2ZHN7W5UQBRDBAE73W5O4YTANCNFSM6AAAAAAWET5TYI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jiajunma commented 1 year ago

Although the atlas shell supports multiline input, only one command can be executed at a time. For instance, if I paste the following code into atlas:

set G = GL(4,C)
set x = G.KGB[0]
x.involution

The current atlas shell will only execute the first command, giving the following output:

atlas> set G = GL(4,C)
set x = G.KGB[0]
x.involution
Variable G: RealForm (overriding previous instance, which had type RealForm)
atlas>

Applying the patch. it gave the following output:

atlas> set G = GL(4,C)
Variable G: RealForm (overriding previous instance, which had type RealForm)
atlas> set x = G.KGB[0]
Variable x: KGBElt (overriding previous instance, which had type KGBElt)
atlas> x.involution
Value: 
| 0, 0, 0, 0, 1, 0, 0, 0 |
| 0, 0, 0, 0, 0, 1, 0, 0 |
| 0, 0, 0, 0, 0, 0, 1, 0 |
| 0, 0, 0, 0, 0, 0, 0, 1 |
| 1, 0, 0, 0, 0, 0, 0, 0 |
| 0, 1, 0, 0, 0, 0, 0, 0 |
| 0, 0, 1, 0, 0, 0, 0, 0 |
| 0, 0, 0, 1, 0, 0, 0, 0 |

It might be a matter of choice. It may be necessary to edit the main loop to allow multiple commands, and this is really what I am expecting:

atlas> set G = GL(4,C)
set x = G.KGB[0]
x.involution
Value: 
| 0, 0, 0, 0, 1, 0, 0, 0 |
| 0, 0, 0, 0, 0, 1, 0, 0 |
| 0, 0, 0, 0, 0, 0, 1, 0 |
| 0, 0, 0, 0, 0, 0, 0, 1 |
| 1, 0, 0, 0, 0, 0, 0, 0 |
| 0, 1, 0, 0, 0, 0, 0, 0 |
| 0, 0, 1, 0, 0, 0, 0, 0 |
| 0, 0, 0, 1, 0, 0, 0, 0 |

I am currently using libreadline-8.1.2, which is the default in Ubuntu Jammy.

davidvogan commented 1 year ago

Dear Jia-Jun,

We agree with you that the change in readline is unfortunate, and that the old default was better. I think the online community seems to share this view, and we hope that the situation will be corrected in future releases of readline.

Marc van Leeuwen is reluctant to change atlas to address defects in other software; since this one can be addressed by writing scripts which are then read into atlas, there seems to be no damage that cannot be overcome.

Here is a way to recover the old behavior immediately. In your home directory, make a file .inputrc with a single line

set enable-bracketed-paste off

(or add this line to your existing .inputrc file). This file will be read whenever you start a new terminal. In such a terminal, atlas should work in the way that you want. (Actually, my experiments indicate that after the .inputrc file has been read once, all terminals that are already open will inherit the change.)

David

On Fri, Mar 24, 2023 at 10:43 PM Ma Jia-Jun @.***> wrote:

Although the atlas shell supports multiline input, only one command can be executed at a time. For instance, if I paste the following code into atlas:

set G = GL(4,C) set x = G.KGB[0]

The current atlas shell will only execute the first command, giving the following output:

atlas> set G = GL(4,C) set x = G.KGB[0] x.involution Variable G: RealForm (overriding previous instance, which had type RealForm) atlas>

However, I am expecting the following output after applying the patch:

atlas> set G = GL(4,C) Variable G: RealForm (overriding previous instance, which had type RealForm) atlas> set x = G.KGB[0] Variable x: KGBElt (overriding previous instance, which had type KGBElt) atlas> x.involution Value: | 0, 0, 0, 0, 1, 0, 0, 0 | | 0, 0, 0, 0, 0, 1, 0, 0 | | 0, 0, 0, 0, 0, 0, 1, 0 | | 0, 0, 0, 0, 0, 0, 0, 1 | | 1, 0, 0, 0, 0, 0, 0, 0 | | 0, 1, 0, 0, 0, 0, 0, 0 | | 0, 0, 1, 0, 0, 0, 0, 0 | | 0, 0, 0, 1, 0, 0, 0, 0 |

It might be a matter of choice. It may be necessary to edit the main loop to allow multiple commands. I am currently using libreadline-8.1.2, which is the default in Ubuntu Jammy.

— Reply to this email directly, view it on GitHub https://github.com/jeffreyadams/atlasofliegroups/issues/16#issuecomment-1483690671, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIDPY5IMBX63APKAHTRT4TW5ZLUNANCNFSM6AAAAAAWET5TYI . You are receiving this because you commented.Message ID: @.***>

davidvogan commented 1 year ago

Dear Jia-Jun,

Marc van Leeuwen has come to agree with you that atlas should itself be able to handle the behavior of readline (without changing that behavior). He knows how to modify atlas, but the work is a bit complicated, and will not happen very soon (perhaps in a few months???). Meanwhile I recommend the .inputrc file.

Yours, David

David Vogan @.***> wrote:

Dear Jia-Jun,

We agree with you that the change in readline is unfortunate, and that the old default was better. I think the online community seems to share this view, and we hope that the situation will be corrected in future releases of readline.

Marc van Leeuwen is reluctant to change atlas to address defects in other software; since this one can be addressed by writing scripts which are then read into atlas, there seems to be no damage that cannot be overcome.

Here is a way to recover the old behavior immediately. In your home directory, make a file .inputrc with a single line

set enable-bracketed-paste off

(or add this line to your existing .inputrc file). This file will be read whenever you start a new terminal. In such a terminal, atlas should work in the way that you want. (Actually, my experiments indicate that after the .inputrc file has been read once, all terminals that are already open will inherit the change.)

David

On Fri, Mar 24, 2023 at 10:43 PM Ma Jia-Jun @.***> wrote:

Although the atlas shell supports multiline input, only one command can be executed at a time. For instance, if I paste the following code into atlas:

set G = GL(4,C) set x = G.KGB[0]

The current atlas shell will only execute the first command, giving the following output:

atlas> set G = GL(4,C) set x = G.KGB[0] x.involution Variable G: RealForm (overriding previous instance, which had type RealForm) atlas>

However, I am expecting the following output after applying the patch:

atlas> set G = GL(4,C) Variable G: RealForm (overriding previous instance, which had type RealForm) atlas> set x = G.KGB[0] Variable x: KGBElt (overriding previous instance, which had type KGBElt) atlas> x.involution Value: | 0, 0, 0, 0, 1, 0, 0, 0 | | 0, 0, 0, 0, 0, 1, 0, 0 | | 0, 0, 0, 0, 0, 0, 1, 0 | | 0, 0, 0, 0, 0, 0, 0, 1 | | 1, 0, 0, 0, 0, 0, 0, 0 | | 0, 1, 0, 0, 0, 0, 0, 0 | | 0, 0, 1, 0, 0, 0, 0, 0 | | 0, 0, 0, 1, 0, 0, 0, 0 |

It might be a matter of choice. It may be necessary to edit the main loop to allow multiple commands. I am currently using libreadline-8.1.2, which is the default in Ubuntu Jammy.

— Reply to this email directly, view it on GitHub https://github.com/jeffreyadams/atlasofliegroups/issues/16#issuecomment-1483690671, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIDPY5IMBX63APKAHTRT4TW5ZLUNANCNFSM6AAAAAAWET5TYI . You are receiving this because you commented.Message ID: @.***>

jiajunma commented 1 year ago

Dear David,

Thank you very much for the detailed explanations. One needs to change the main loop and maybe even some parts of the buffers to handle the problem. It would be complicated. I will use the .inputrc file to resolve the problem.

Looking forward to Marc van Leeuwen's new update.

Best Regards, Jia-Jun