[erlang-questions] How to disable parentheses matching in Erlang shell?

Grzegorz Junka <>
Sun May 15 23:45:18 CEST 2016


I just realized what is likely causing the problem. When I start the 
shell with erl and type in this testing string (with spaces so it's 
longer) it all works fine:

lists:sort([{a, 1}, {b, 2}, {c, 3}, {d, 4}, {e, 5}, {f, 6}, {g, 7}, {h, 
8}, {i, 9}, {j, 10}]).

But I very rarely use Erlang shell in this way. Most of the time I am 
connecting to running Erlang nodes using to_erl specifying the shell's 
PID. Then it breaks, probably because my terminal size doesn't match the 
default terminal size with which the shell has been originally started.

When I then try to type in the same example the shell will match each {} 
correctly but as soon as I type ']' to close the list the cursor jumps 
to the line above, then some other place when I type ')'.

So it's not related to the environment but to the way I am using Erlang 
shell. Is there any solution to that?

Grzegorz


On 15/05/2016 20:28, Joshua Barney wrote:
> Grzegorz,
>
> that’s a long list of environments!
>
> I took some time to reproduce the “Ubuntu ssh to CentOS” (and vice 
> versa) using vmware. on two fresh installs of ubuntu and centos, the 
> paren matching worked correctly. On ubuntu, If I resized the window 
> halfway through it would jump backwards to the wrong point and then 
> forwards to the correct point—centos xterm re-flowed the text so this 
> did not happen. This worked with $TERM set to 'xterm' or ‘konsole’ or 
> ‘putty’.
>
> you said earlier:
>>>> I don't have such environment variables (LINES and COLUMNS) in my 
>>>> system and I don't remember having them on Ubuntu or Red Hat 
>>>> (however I can't double-check that now)
>
> These variables are set by your terminal in response to resize events 
> and are communicated over ssh as you can read about here: 
> http://unix.stackexchange.com/a/207802
> If your system does not have those variables, I would strongly suspect 
> that the nurses library would not function in the way you desire.
>
> At this point I can only wildly speculate about ways your erlang 
> install (or terminfo database, or ncurses library) is broken, and I 
> don’t think you’re really looking for that.
>
> Josh
>
>> On May 15, 2016, at 8:00 AM, Grzegorz Junka < 
>> <mailto:>> wrote:
>>
>> Joshua,
>>
>> This is what I said, it isn't broken only for me. I saw it being 
>> broken on other people's computers as well.
>>
>> It's unlikely for any scripts to set COLUMNS since I don't see that 
>> environment variable being set when running shell.
>>
>> I am running Konsole on the same system on which I am running Erlang, 
>> both on FreeBSD. I don't need to SSH anywhere. But the behaviour was 
>> the same no matter from where or to where I was SSH-ing or not (or 
>> someone I saw doing it), e.g.:
>>
>> Windows putty SSH to FreeBSD
>>
>> Windows putty SSH to Ubuntu
>>
>> Windows putty SSH to Red Hat
>>
>> Windows putty SSH to CentOS
>>
>> Windows xterm cygwin SSH to FreeBSD
>>
>> Windows xterm cygwin SSH To Ubuntu
>>
>> Windows xterm cygwin SSH to Red Hat
>>
>> Windows xterm cygwin SSH to CentOS
>>
>> FreeBSD xterm SSH to Ubuntu
>>
>> FreeBSD Konsole SSH to Ubuntu
>>
>> FreeBSD xterm SSH to FreeBSD
>>
>> FreeBSD Konsole SSH to Ubuntu
>>
>> FreeBSD xterm SSH to CentOS
>>
>> FreeBSD Konsole SSH to CentOS
>>
>> FreeBSD Konsole and Erlang shell on the same system (no SSH)
>>
>> FreeBSD xterm end Erlang shell on the same system (no SSH)
>>
>> Ubuntu SSH to CentOS
>>
>> It's fair to say that I haven't see a system on which this feature 
>> worked fine, I just learned to not type commands that are too long or 
>> copy-paste longer commands, and I bet most people who experience it 
>> do the same and don't bother complaining. I wonder if maybe this has 
>> something to do with escape codes and for example support for 256 
>> colors in the terminal.
>>
>> Grzegorz
>>
>>
>> On 14/05/2016 22:49, Joshua Barney wrote:
>>> It seems unlikely that erlang shell is broken only for you on all 
>>> these systems.
>>> Have you checked that your shell scripts are not setting COLUMNS? 
>>> Perhaps you are ssh-ing from a client that is doing something not 
>>> quite right?
>>>
>>> Sent from my iPhone
>>>
>>>> On May 14, 2016, at 6:39 PM, Grzegorz Junka < 
>>>> <mailto:>> wrote:
>>>>
>>>>
>>>>> On 14/05/2016 21:19, Kenneth Lakin wrote:
>>>>>> On 05/14/2016 03:32 AM, Grzegorz Junka wrote:
>>>>>> Fixing my terminal to 80 characters only seems like taken 
>>>>>> straight from
>>>>>> the Windows world. I hope Erlang can do better ;)
>>>>> If ncurses can't determine your terminal size, then falling back to
>>>>> 80x24 makes a lot of sense. Do other ncurses-based programs behave
>>>>> incorrectly?
>>>> No. Everything else is fine. This problem is not related to my 
>>>> system, as I have seen the same behaviour in Erlang running on 
>>>> FreeBSD, Ubuntu, Red Hat and CentOS in different terminals, like 
>>>> putty, cygwin and Konsole.
>>>>
>>>>>> Is there any way of
>>>>>> telling the Erlang terminal how wide is my terminal, e.g. an 
>>>>>> environment
>>>>>> variable?
>>>>> On my system, it looks like the environment variables LINES and 
>>>>> COLUMNS
>>>>> correspond to the current size of my terminal window. When I set 
>>>>> COLUMNS
>>>>> to a value that does not match the window's current size, then the
>>>>> Erlang shell's paren matching bounces the cursor backwards to the 
>>>>> wrong
>>>>> place (but back forwards to the right place). Maybe this will be the
>>>>> band-aid you need.
>>>> I don't have such environment variables in my system and I don't 
>>>> remember having them on Ubuntu or Red Hat (however I can't 
>>>> double-check that now)
>>>>
>>>>> However, it might be more useful to fix whatever is preventing ncurses
>>>>> from determining the terminal size.
>>>> Yeah, and even more useful if the Erlang shell allowed me to 
>>>> disable a feature that isn't really necessary especially if it 
>>>> isn't working correctly.
>>>>
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>>  <mailto:>
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> erlang-questions mailing list
>>  <mailto:>
>> http://erlang.org/mailman/listinfo/erlang-questions
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160515/e2f24b77/attachment-0001.html>


More information about the erlang-questions mailing list