erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.15k stars 2.92k forks source link

erlang-shell for Emacs gives "Unbalanced parenthesis" error #8569

Open aathn opened 2 weeks ago

aathn commented 2 weeks ago

Describe the bug Pressing tab in the erlang-shell for Emacs directly after startup produces an "Unbalanced parenthesis" error.

To Reproduce Start Emacs, run M-x erlang-shell, press tab (or run indent-for-tab-command).

Expected behavior No error should pop up. Nothing in particular should happen, provided erlang-tab-always-indent is t.

Affected versions I tried this with OTP 27 and the accompanying erlang-mode, on Emacs 29.1.

Additional context This bug is caused by the code for erlang-calculate-indent, which calls erlang-beginning-of-clause to move to the beginning of the previous clause in order to calculate the appropriate indentation. If erlang-shell was just started, this causes the point to move before the beginning of the first prompt, to the Eshell version string (Eshell V15.0 (press Ctrl+G to abort, type help(). for help)). Then, erlang-partial-parse is invoked, which results in a parse error giving rise to the message.

dgud commented 5 days ago

A PR solving this would be welcome :-)