From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Joe Corneli Newsgroups: gmane.emacs.help Subject: Re: How to automatically write *Messages" buffer to a file? Date: Wed, 24 Nov 2004 22:56:20 -0600 Message-ID: References: <87sm6zl4sx.fsf@thalassa.informatimago.com> <01c4d23d$Blat.v2.2.2$c2b81b20@zahav.net.il> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1101358619 24298 80.91.229.6 (25 Nov 2004 04:56:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2004 04:56:59 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 25 05:56:54 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 1CXBgb-0001Dm-00 for ; Thu, 25 Nov 2004 05:56:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXBpm-0008DE-Cu for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Nov 2004 00:06:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CXBpc-0008C0-72 for help-gnu-emacs@gnu.org; Thu, 25 Nov 2004 00:06:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CXBpb-0008B3-DE for help-gnu-emacs@gnu.org; Thu, 25 Nov 2004 00:06:11 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXBpb-0008AY-70 for help-gnu-emacs@gnu.org; Thu, 25 Nov 2004 00:06:11 -0500 Original-Received: from [146.6.139.124] (helo=dell3.ma.utexas.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CXBg4-0005sd-SQ for help-gnu-emacs@gnu.org; Wed, 24 Nov 2004 23:56:21 -0500 Original-Received: from linux183.ma.utexas.edu (mail@linux183.ma.utexas.edu [146.6.139.172]) by dell3.ma.utexas.edu (8.11.0.Beta3/8.10.2) with ESMTP id iAP4uK812809; Wed, 24 Nov 2004 22:56:20 -0600 Original-Received: from jcorneli by linux183.ma.utexas.edu with local (Exim 3.36 #1 (Debian)) id 1CXBg4-0005KY-00; Wed, 24 Nov 2004 22:56:20 -0600 Original-To: help-gnu-emacs@gnu.org In-reply-to: (message from Stefan Monnier on Wed, 24 Nov 2004 20:55:15 GMT) 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:22297 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:22297 OK, so I tried rewriting the code without advice. But there are still a number of problems. First of all, it seems that the arguments being sent to the `after-change-functions' aren't quite right. There may be other problems too. ;; messages to log file (defun start-logging () (interactive) (set-buffer "*Messages*") (add-hook 'after-change-functions 'write-to-log) (message (concat "begin logging " (current-time-string)))) (defun write-to-log (beg end len) ;; This message reveals that the *Messages* buffer ;; and the echo area are joined at the hip. `beg' ;; and `end' are positions in the echo area! ; (message (format "%s %s" (- (point-max) (- end beg)) (point-max))) (save-excursion (set-buffer "*Messages*") (write-region ;; this region doesn't seem to include the ;; final character, but I can't change the ;; way it is written or I get error. ;; ;; the obvious choice ;; beg end ;; doesn't work either. (- (point-max) (- end beg)) (point-max) "~/LOG" t 'quiet))) (defun stop-logging () (interactive) (message (concat "stop logging " (current-time-string))) (set-buffer "*Messages*") (remove-hook 'after-change-functions 'write-to-log)) (defun test-message () (interactive) (message "hi"))