Fax notifying flag for Emacs
Ralph Schleicher (rs@purple.IN-Ulm.DE)
Tue, 16 Jan 1996 23:40:04 +0100
Hi,
here is yet another argument for using Emacs. ;-)
,,,
(o o)
---------------------------oOO-(_)-OOo---------------------------
(setq display-time-24hr-format t
display-time-day-and-date t)
(display-time)
(defvar fax-notify-file (concat "/var/spool/fax/" user-login-name)
"*File name of user's fax spool file or spool directory;
`nil' means don't check for incoming fax messages.")
(defconst fax-notify-string ""
"String to display in the mode line.")
(defvar fax-notify-interval 5
"*Multiples of `display-time-interval' after which the mode line will
be updated.")
(defconst fax-notify-counter 0)
(defun fax-notify-function ()
"Check for new incoming fax messages."
(if (< fax-notify-counter fax-notify-interval)
(setq fax-notify-counter (1+ fax-notify-counter))
(setq fax-notify-counter 0
fax-notify-string "")
(if (and (stringp fax-notify-file) (file-readable-p fax-notify-file))
(let ((fax-file (file-truename fax-notify-file)))
(if (file-directory-p fax-file)
(let ((orig-buf (current-buffer))
(temp-buf nil))
(unwind-protect
(progn
(setq temp-buf (generate-new-buffer " ls"))
(buffer-disable-undo temp-buf)
(set-buffer temp-buf)
(or (zerop (call-process "/bin/ls" nil t nil fax-file))
(error))
(goto-char (point-min))
(if (search-forward "\n" nil t)
(setq fax-notify-string " Fax")))
(if temp-buf
(kill-buffer temp-buf))
(set-buffer orig-buf)))
(if (not (= 0 (nth 7 (file-attributes fax-file))))
(setq fax-notify-string " Fax")))))))
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'fax-notify-string global-mode-string)
(setq global-mode-string
(append global-mode-string '(fax-notify-string))))
(add-hook 'display-time-hook 'fax-notify-function)
----------------------------oOo---oOo----------------------------
Has anybody an idea of how to clear the flag without removing all files
from the spool directory? That would be nice for those who don't remove
their fax messages after reading.
--
Ralph