When I open an image in Emacs, there is a message constantly showing in the minibuffer: "Type C-c C-c to view the image as text." which I cleary don't want.

When switching between images, the message is constanting asking for my attention, which bothers me. So I need to figure out how I could supress this message only. I tried alternatives like

(let ((inhibit-message t))
(message "Type C-c C-c to view the image as text."))

Or message-surpression.el, without any result at all. The message is still popping in my minibuffer when I open an image, and I couldn't figure out which function is calling that message.

  • Do you know what line produces this message? If you do, I can produce a more focused advice.
    – PythonNut
    Commented Oct 4, 2015 at 3:15
  • I get it when I open a image, which called the image-mode. But this answer seems solved now, but thanks for your help.
    – ReneFroger
    Commented Oct 4, 2015 at 10:29

1 Answer 1


The function in question is image-mode, and this seems to do what you want (if a little inelegantly):

(defun my/image-unwanted-message-p (msg &rest objects)
  "Return non-nil if MSG is unwanted.
For these purposes, a MSG is unwanted if (after formatting) it is
exactly the string \"Type C-c C-c to view the image as text.\"."
  (let ((msg (apply #'format (cons msg objects))))
    (string-equal msg "Type C-c C-c to view the image as text.")))

(defun my/image-suppress-messages (fn)
  "Suppress unwanted `message' calls in FN."
      ((#'message :before-until #'my/image-unwanted-message-p))
    (funcall fn)))

(advice-add #'image-mode :around #'my/image-suppress-messages)

Here my/with-advice is this macro that I wrote for a previous problem; it's proven to be very handy for a lot of different tasks. I'm using it here because I'm a little leery about applying permanent advice to something as ubiquitous as message, even if that advice doesn't do anything most of the time.

(defmacro my/with-advice (adlist &rest body)
  "Execute BODY with temporary advice in ADLIST.

Each element of ADLIST should be a list of the form
suitable for passing to `advice-add'.  The BODY is wrapped in an
`unwind-protect' form, so the advice will be removed even in the
event of an error or nonlocal exit."
  (declare (debug ((&rest (&rest form)) body))
           (indent 1))
     ,@(mapcar (lambda (adform)
                 (cons 'advice-add adform))
     (unwind-protect (progn ,@body)
       ,@(mapcar (lambda (adform)
                   `(advice-remove ,(car adform) ,(nth 2 adform)))

Note that the manual cautions not to advise primitives (including message), but I think it's okay here because (1) all the calls we want to suppress are from lisp anyway; (2) any extraneous calls should pass through transparently; and (3) the advice machinery can't be calling message here, because you'd be getting messages about it.

  • Thanks for your anwer, it's really appreciated. Your snippet contains some Lisp that I never seen before, and it seems you're relatively new on Emacs Stackexchange... I'm impressed! I'm now looking into the documentation of some things here that you created, in order to learn from it. Thanks for that....
    – ReneFroger
    Commented Oct 4, 2015 at 10:43
  • what does (declare (debug ((&rest (&rest form)) body)) (indent 1)) do?
    – RNA
    Commented Dec 10, 2023 at 4:28
  • @RNA - It tells the Emacs debugger about the structure of the macro--see gnu.org/software/emacs/manual/html_node/elisp/… Commented Jan 29 at 14:52

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.