From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: How to automatically write *Messages" buffer to a file? Date: Wed, 24 Nov 2004 20:55:15 GMT Message-ID: References: <87sm6zl4sx.fsf@thalassa.informatimago.com> <01c4d23d$Blat.v2.2.2$c2b81b20@zahav.net.il> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1101330508 4990 80.91.229.6 (24 Nov 2004 21:08:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 24 Nov 2004 21:08:28 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 24 22:08:22 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CX4GV-0000xP-00 for ; Wed, 24 Nov 2004 22:01:36 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CX4P2-0006Zc-Kg for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Nov 2004 16:10:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:52NflX1FwmKSQnXIn9GmfUy1trQ= Original-Lines: 36 Original-NNTP-Posting-Host: 132.204.24.84 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1101329715 132.204.24.84 (Wed, 24 Nov 2004 15:55:15 EST) Original-NNTP-Posting-Date: Wed, 24 Nov 2004 15:55:15 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:126885 Original-To: help-gnu-emacs@gnu.org 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: main.gmane.org gmane.emacs.help:22286 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:22286 >> (setq after-change-functions nil) > Never use `setq' on a hook. Use `add-hook' or `remove-hook'. > I didn't know it was a hook (though I did think to myself that it was > very hook-like). The variable name is not descriptive. Maybe it > should be aliased to or renamed `after-change-hook'. Normal hooks have names that end in `-hook'. Special hooks (e.g. hooks whose functions take arguments, or whose return value is not ignored) have names that end in `-functions'. It's all explained in the elisp manual, of course. > As for your question, don't use `append-to-file', use `write-region' > instead, and pass `quiet' as the VISIT argument to prevent the message. > Shouldn't advice to `write-region' be sufficient? You can't put "advice" and "sufficient" together like that without adding a smiley somewhere. `advice' is a sledghammer: it's the last resort before modifying the source code. `append-to-file' is only defined so as to make appending possible interactively. From elisp you should jsut call `write-region' directly. > `append-to-file' just calls this function. True, using `write-region' is > more transparent (and I had an error in my advice to this function), but > I don't see why advising `write-region' and then calling `append-to-file' > wouldn't work. Advising is a source of major headaches because of unexpected interactions with other pieces of code which do not expect write-region to behave differently. Advice have to be written *extremely* carefully. I.e. if you can do it without `advice', then don't use `advice'. Stefan