I open shell files at startup and often get this in *Messages*:

Setting up indent for shell type sh
Indentation variables are now local.
Indentation setup for shell type sh

All my files cause this warning, even if they have indentation, e.g.:

source /path/to/file.sh


foo() {
   exit 0 

When Emacs open Python files, it guesses the indentation from the file and does not produce these messages.

How can I avoid these messages when opening files with shell scripts?

1 Answer 1


This is hardcoded into the function sh-set-shell which is called when sh-mode is invoked.

It's probably better to not touch that behaviour as it will also not display messages if it was not possible to set up indentation correctly.

You can hide the message in the minibuffer (will still be displayed in Messages) by placing an advice around that function.

(advice-add 'sh-set-shell :around
            (lambda (orig-fun &rest args)
              (let ((inhibit-message t))
                (apply orig-fun args))))

Or hide it completely by lexically overwritting the message function:

(require cl-lib)
(advice-add 'sh-set-shell :around
            (lambda (orig-fun &rest args)
              (cl-letf (((symbol-function 'message) #'ignore))
                (apply orig-fun args))))

Your Answer

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

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