Is there any way to turn on (inhibit-message) only for particular modes or buffers or frames or windows? (any of those would do)
Asked
Active
Viewed 155 times
1 Answers
5
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))
...)

phils
- 48,657
- 3
- 76
- 115
-
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
-
1Experimentally 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