3

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.

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}|

Is this a bug or do I need to set another variable to a certain value for it to work? I at least tried the variables stated in this question, but they did not have any effect at all for this issue.

3
  • 1
    I can replicate that. Please M-x report-emacs-bug Commented Jun 30, 2019 at 21:56
  • @phils, thanks. I reported it now to the GNU Emacs maintainers. Commented Jul 2, 2019 at 18:54
  • 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 (” Commented Jul 2, 2019 at 22:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.