help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to automatically write *Messages" buffer to a file?


From: Joe Corneli
Subject: Re: How to automatically write *Messages" buffer to a file?
Date: Wed, 24 Nov 2004 22:56:20 -0600

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"))




reply via email to

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