[comp.emacs] Gnu Emacs Mail Flag

sandman@hall.cray.com (Dominick M. Galang) (12/13/88)

	I remember a while back that there was a fix to get gnu emacs
to realize when mail had been read.  I use rmail from emacs and after
I'm done, my status line still tells me that I've got mail waiting for
me.  The truth is that it just hasn't updated after I've read my mail.
The message stays around for too long for it to be very meaningful.
Kind of annoying.

	Dominick M. Galang

#####		      Decaffinated Coffee:  Just Say NO!                   #####
Dominick M. Galang              Cray Research                Sun Resources Group
Telephone:  612 452-6650 Paper:  1345 Northland Drive  Mendota Heights, MN 55120
Virtual: (via Arpa): sandman@cray.com          (via UUCP): bungia\!cray\!sandman

jr@bbn.com (John Robinson) (12/14/88)

In article <12096@hall.cray.com>, sandman@hall (Dominick M. Galang) writes:
>
>	I remember a while back that there was a fix to get gnu emacs
>to realize when mail had been read.  I use rmail from emacs and after
>I'm done, my status line still tells me that I've got mail waiting for
>me.

I use mh-e, but the principle should apply.  Assuming there is a hook
that gets run after rmail has read new mail (is it the "g" key?  it's
been a long time :-), you ought to be able to hang this lambda on it
and get the effect you want.  This is from my .emacs:

(setq mh-inc-folder-hook '(lambda ()
  (if (and (boundp 'display-time-process) display-time-process)
      (start-process "update-time-display" nil
		     "/bin/sh"
		     "-c" (concat "kill -14 "
				  (int-to-string
				   (process-id display-time-process)))))))

Caveat: once in a long while, your loadst process (the thing that
provides time, loadav and "[Mail]" to the modelines) may die; simply
re-run (display-time) to resume it.

Given that you have lotsa spare cycles (running on a Cray, right? :-)
you can also set display-time's update interval parameter to something
other than its default of 60 seconds.  How about 1?  Here's its defvar:

(defvar display-time-interval 60
  "*Seconds between updates of time in the mode line.")
--
/jr
jr@bbn.com or bbn!jr

quiroz@cs.rochester.edu (Cesar Quiroz) (12/15/88)

jr@bbn.com (John Robinson) suggests a way to update the mode line so
that in doesn't say "Mail" after an inc:
:(setq mh-inc-folder-hook '(lambda ()
:  (if (and (boundp 'display-time-process) display-time-process)
:      (start-process "update-time-display" nil
:		     "/bin/sh"
:		     "-c" (concat "kill -14 "
:				  (int-to-string
:				   (process-id display-time-process)))))))

So far I have been lucky enough with a method that does not disturb
the currently running display-time process.  I expect this method is
actually faster than the one proposed above.  It goes like this:

(defun cq-mh-inc-folder () ;; This function is my mh-inc-folder-hook
  "Stuff to do after incorporating mail.
If display-time-process is not-null, change the mode line
to stop announcing this mail, without waiting first for
display-time-interval to expire."
  (cond ((and (boundp 'display-time-process)
              display-time-process      ;clean up mode line
              (stringp display-time-string)
              (string-match "\\(.*\\) Mail" display-time-string))
         (setq display-time-string 
               (substring display-time-string 
                          (match-beginning 1) (match-end 1)))
         (sit-for 0))))

It just goes and chops off the "Mail" part.

Comments welcome.
-- 
                                      Cesar Augusto Quiroz Gonzalez
                                      Department of Computer Science
                                      University of Rochester
                                      Rochester,  NY 14627

matt@oddjob.uchicago.edu (Matt Crawford) (12/16/88)

The trouble seems to be that GNU emacs does not provide a way to send an
arbitrary signal to a process.  (In this case, SIGALRM.)  To provide
such a mechanism might reduce portability, at least I suppose that's why
it isn't already there.

A somewhat more portable alternative might be to have the "loadst"
program do a select() on fd 0 with a timeout of 60 seconds (or whatever
value is given by argv).  If you want to tickle loadst sooner, send the
display-time process a byte of input.

Comments?
				Matt Crawford