Is there any way to turn on (inhibit-message) only for particular modes or buffers or frames or windows? (any of those would do)


inhibit-message is a variable (added in 25.1), not a function (I mention this because you've written it like a function call).

Therefore you can set its value buffer-locally:

(setq-local inhibit-message t)

Where you would do that would depend on your specific requirements.

For a particular mode you can use the associated mode hook. For foo-mode you would use:

(add-hook 'foo-mode-hook 'my-inhibit-buffer-messages)

(defun my-inhibit-buffer-messages ()
  "Set `inhibit-message' buffer-locally."
  (setq-local inhibit-message t))

Note that a more typical use for the variable would be to let-bind it around some specific code:

(let ((inhibit-message t))
  • Thanks for this. When I add inhibit-message to a file as a local variable, it works as desired. However, defining a function and calling it via a mode-hook (as above) doesn't seem to work for me. – emacsomancer Oct 13 '16 at 16:39
  • 1
    Experimentally it works for me. Can you elaborate? – phils Oct 13 '16 at 19:26
  • Ok, I think I got it working now. Checking. – emacsomancer Oct 13 '16 at 21:06

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.