From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.help Subject: Re: Temporarily turning message logging off Date: Thu, 24 May 2007 14:03:41 +0900 Organization: Emacsen advocacy group Message-ID: References: <1179979000.784693.89720@b40g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1179985248 30525 80.91.229.12 (24 May 2007 05:40:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 24 May 2007 05:40:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 24 07:40:44 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hr642-0003Ib-NP for geh-help-gnu-emacs@m.gmane.org; Thu, 24 May 2007 07:40:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hr643-0000Xe-Lx for geh-help-gnu-emacs@m.gmane.org; Thu, 24 May 2007 01:40:43 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-X-Trace: individual.net FkKTIchCSt0OKxY50XkzZwypOrAJpkuVWUWNktbtuVSNXucks= X-Face: #kKnN,xUnmKia.'[pp`; Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu; B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:Y9KFVc0AMUQbUGogaQ2+LEww5l8= Original-Xref: shelby.stanford.edu gnu.emacs.help:148774 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:44363 Archived-At: >>>>> In <1179979000.784693.89720@b40g2000prd.googlegroups.com> >>>>> 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 " > 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.