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):


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.