[comp.emacs] rmail suggestion

straz@MEDIA-LAB.MEDIA.MIT.EDU (Steve Strassmann) (05/14/87)

A suggestion:

When you do a "g" in rmail, and if you have (display-time) running,
you should update the mode line so the "Mail" flag goes away.

Sometimes, it still claims you have new mail a minute or more after
you've read it.

israel@BRILLIG.UMD.EDU.UUCP (05/14/87)

   From: Steve Strassmann <straz@MEDIA-LAB.MEDIA.MIT.EDU>

   A suggestion:

   When you do a "g" in rmail, and if you have (display-time) running,
   you should update the mode line so the "Mail" flag goes away.

   Sometimes, it still claims you have new mail a minute or more after
   you've read it.

Yeah, I always found this annoying as well, so a while ago I did exactly
what you are suggesting.  Here's the code for it:

I put the following bit right after the "(interactive" call in the body of
the rmail-get-new-mail function:

  ; remove the string " Mail" from display-time-string if it
  ; is there.
  (and (boundp 'display-time-string)
       (stringp display-time-string)
       (setq display-time-string (remove-string " Mail" display-time-string)))

and then defined the following function as well.

(defun remove-string (substring string)
  "Remove the first occurrence of SUBSTRING from STRING."
  (let ((loc (string-match substring string)))
    (if loc
	(concat (substring string 0 loc)
		(substring string  (+ (length substring) loc)))
      string)))

However, there is a minor bug ( problem?) with it.

After I log on, to read mail I run 'gnumacs -e rmail'.  Since the 'rmail'
function is being run from the invocation line, it runs quickly, and the
display-time process has not yet set the variable display-time-string to
the process invocation.  So when 'rmail' is run, display-time-string is set
to "time and load", and the "Mail" gets inserted just *after*
'rmail-get-new-mail' is run.  As a result, if you read mail the way I do,
the first minute will have a "Mail" string anyway, even though you're
reading mail.  Running gnumacs and then doing a M-x rmail immediately
works though.