home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / mail-beep.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  4.0 KB  |  113 lines

  1. ;From ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!cs.utexas.edu!samsung!think!leander.think.com!fad Wed Dec  6 12:17:44 1989
  2. ;Article 766 of gnu.emacs:
  3. ;Path: ark1!nems!mimsy!haven!purdue!tut.cis.ohio-state.edu!cs.utexas.edu!samsung!think!leander.think.com!fad
  4. ;>From fad@leander.think.com (Franklin A Davis)
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: Re: Notify on mail arrival (biff) in mode-line
  7. ;Keywords: emacs, mail, mode line
  8. ;Message-ID: <31755@news.Think.COM>
  9. ;Date: 21 Nov 89 22:21:00 GMT
  10. ;References: <1989Nov20.182913.23723@athena.mit.edu>
  11. ;Sender: news@Think.COM
  12. ;Reply-To: fad@leander.think.com.UUCP (Franklin A Davis)
  13. ;Organization: Thinking Machines Corporation
  14. ;Lines: 95
  15. ;
  16. ;In article <1989Nov20.182913.23723@athena.mit.edu> boaz@lcs.mit.edu writes:
  17. ;>
  18. ;>
  19. ;>Has someone hacked up a way to signal in the mode line 
  20. ;>that new mail has arrived ?? I guess it take a process
  21. ;>to run and check periodically the size of
  22. ;>/usr/spool/mail/$user .
  23. ;>Can the display-time process be modified to do that ??
  24. ;>
  25. ;>-- Boaz Ben-Zvi  (boaz@lcs.mit.edu)
  26. ;
  27. ;
  28. ;Yes.  Here's a hack from Mark Ardis, now of SEI, CMU, Pittsburgh.  It
  29. ;displays the word "Mail" in the mode line whenever you have mail
  30. ;waiting.  It beeps when mail first arrives.
  31. ;
  32. ;Note that the emacs/etc/loadst program must have the correct
  33. ;ownership, group, and setuid for it to work:
  34. ;
  35. ;-rwxr-sr-x  1 root     kmem        24576 Mar  6  1989 loadst*
  36. ;
  37. ;This is accomplished by root executing the following three commands
  38. ;in the emacs/etc directory (wherever that is on your machine):
  39. ;"chgrp kmem loadst" 
  40. ;"chown root loadst"
  41. ;"chmod 2755 loadst"
  42. ;
  43. ;Here's mail-beep.el.  Remember to run "M-X byte-compile" on it.
  44. ;Put the file wherever you want and load it in your .emacs file:
  45. ;
  46. ;(load "wherever/mail-beep")
  47. ;
  48. ;Then, to turn it on, include the following in your .emacs file:
  49. ;
  50. ;(display-time)
  51. ;
  52. ;Enjoy!
  53. ;
  54. ;--Franklin
  55.  
  56.  
  57. ;;; cut here
  58. ;;; $Header: /tmp_mnt/am/p7/utility/gmacs/f3/RCS/mail-beep.el,v 1.1 88/12/27 17:06:42 fad Exp $
  59.  
  60. ;; 10/20/87 Franklin Davis, Thinking Machines Corp. (fad@think.com) 
  61. ;; Modified display-time-filter to beep and display message when new mail 
  62. ;; arrives.  Idea and implementation from Mark Ardis (maa@sei.cmu.edu)
  63.  
  64. (defvar display-time-process nil)
  65. (defvar seen-mail nil)  
  66.  
  67. (defun display-time-filter (proc string)
  68.   ;; Desired data can't need more than the last 30 chars,
  69.   ;; so save time by flushing the rest.
  70.   ;; This way, if we have many different times all collected at once,
  71.   ;; we can discard all but the last few very fast.
  72.   (let (idx mail-idx mail-notice)
  73.     (setq mail-idx (string-match "\\[" string))
  74.     (setq mail-notice (substring string (- mail-idx 4) mail-idx))
  75.     (while (setq idx (string-match "]." string))
  76.       (setq string (substring string (1+ idx))))
  77.     (if (> (length string) 30)
  78.     (setq string (substring string -30)))
  79.     ;; Now discard all but the very last one.
  80.     (while (and (> (length string) 4)
  81.         (string-match "[0-9]+:[0-9][0-9].." string 4))
  82.       (setq string (substring string (match-beginning 0))))
  83.     (if (string-match "[^0-9][0-9]+:" string)
  84.     (setq string (substring string 0 (1+ (match-beginning 0)))))
  85.     ;; Append the date if desired.
  86.     (if display-time-day-and-date
  87.     (setq string (concat (substring (current-time-string) 0 11) string)))
  88.     (if (string-equal mail-notice "Mail")
  89.     (if (not seen-mail)
  90.         (progn
  91.           (ding)
  92.           (ding)
  93.           (message "You have new mail.")
  94.           (setq seen-mail t)
  95.           )                ; progn
  96.       )                ; if
  97.       (setq seen-mail nil)
  98.       )                    ; if
  99.  
  100.     ;; Install the new time for display.
  101.     (setq display-time-string string)
  102.     ;; Force redisplay of all buffers' mode lines to be considered.
  103.     (save-excursion (set-buffer (other-buffer)))
  104.     (set-buffer-modified-p (buffer-modified-p))
  105.     ;; Do redisplay right now, if no input pending.
  106.     (sit-for 0)))
  107.  
  108. ;  franklin a davis  Thinking Machines Corp. Cambridge, MA 02142   617-876-1111
  109. ;  <fad@think.com>   {ames, harvard, mit-eddie, uunet}!think!fad 
  110. ;                Let the four winds blow you safely home!
  111.  
  112.  
  113.