Subject: Re: bug#36480: 26.2; Using a sh-basic-offset value with a multiple of tab-width has side effects when building function using “C-c (”

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 08 Jul 2019 23:30:36 +0200

Phoenix <[email-masked]> writes:

> When using a multiple of the "tab-width" value for "sh-basic-offset",
> creating a function using the built-in command "C-c (" removes
> characters from the expected result. That being said, I can create a
> shell function by manually typing it. It is just this built-in
> command, which causes odd behavior.
>
> When "tab-width" and/or "sh-basic-offset" are not set inside the
> ".emacs" file or the latter is not a multiple of the former, it works
> as expected.

I was not able to reproduce it with the recipe above, and it's strange
that that should have any effect -- `tab-width' is automatically
buffer-local.

But I'm able to reproduce it with "emacs -Q /tmp/a.sh" and then
`M-: (setq tab-width 4 sh-basic-offset 4) RET'.

> Here are the tests I did:
> In the below examples I use "asdf" as the function name and the pipe character ("|") is the visualization of where point is located after I completed the built-in command.
>
> With either variables not defined or not a multiple of one another, the (default) result is:
> function asdf() {
>     |
> }
>
> With both set to 4, the result is:
> function asdf() {}|
>
> With tab-width set to 4 and sh-basic-offset to 8, the result is:
> function asdf()}|
>
> With both set to 8, the result is:
> function asdf}|
>
> With both set to 16 (just for a test), the result is (semantically a rather amusing):
> fu}|

I don't get exactly what you're getting, but I'm getting something very
close to it.  For instance, with 16, the buffer becomes completely blank.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no