3

Open the code below with emacs -q, do set-variable sh-basic-offset 2, then indent-region. All lines are indented with 2, while the echo line is indented with 4. Is this a bug in Emacs, or how do I configure it to indent consistently with 2? (When setting to 8, echo is still indented with 4.)

Using latest release GNU Emacs 25.3.1 on macOS installed with Homebrew.

#!/bin/bash

hello() {
  while true; do
    if [ true ]; then
    ····echo true
    fi
  done
}
  • FWIW, I don't see this problem in my local Emacs, so maybe it's a bug that was fixed since the release you're using? – Stefan Mar 16 '18 at 15:57
  • @Stefan: Added version information. Did you try this with emacs -q to make sure none of your .emacs settings interfere with testing? If the bug happens with -q and doesn't without, I'd be interested in hearing which .emacssetting of your makes things work. – forthrin Mar 16 '18 at 19:49
  • I was able to reproduce. – Nsukami _ Mar 17 '18 at 10:12
5

It is bug, fixed in version 26.1. As a workaround you can set both the variables sh-indentation and sh-basic-offset to 2.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.