[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporarily turning message logging off

From: Katsumi Yamaoka
Subject: Re: Temporarily turning message logging off
Date: Thu, 24 May 2007 14:03:41 +0900
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

>>>>> In <address@hidden>
>>>>>   Davin Pearson wrote:

> I would like to temporarily undefine the function message so that
> messages are temporarily turned off.  Here is some Elisp code that I
> have written to achieve this:

> ;;;
> ;;; (progn (message "hello") (sit-for 1))
> ;;;

> (defun my-message--turn-messages-off ()
>   (progn
>     (fset 'message-old (symbol-function 'message))
>     (defun message (string &rest arguments)
>       ))
>   )

> (defun my-message--turn-messages-on ()
>   (progn
>     (fset 'message (symbol-function 'message-old)))
>  )

> Unfortunately it does not appear to work.  For example
> when you save a file with messages turned off, it still
> generates the message "Wrote <filename>"

> What do I have to do to turn message logging off?

It seems that `write-region', which is a built-in function,
issues such messages.  How about this?

;; off
(fset 'write-region-old (symbol-function 'write-region))
(fset 'write-region
      (lambda (start end filename &optional append visit &rest args)
        (apply 'write-region-old start end filename append 'silent args)))

;; on
(fset 'write-region (symbol-function 'write-region-old))

Use this with care, since it also prevents programs from doing
something using the 5th argument VISIT[1].  In other words,
there is no way to do it entirely safely except for modifying
the C source code.

[1] See the documentation of the `write-region' function.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]