tale@pawl.rpi.edu (David C Lawrence) (05/12/89)
A few months ago (December maybe?) Ashwin posted a patch to mh-e.el
that took care of the word " Mail" still appearing in the global mode
string if display-time is running. Well, I trashed that patch about
two months ago when we upgraded to 18.53 (now 18.54) and today, after
repeated typing of "i" when I really had no new mail, I got frustrated
enough to go back and write the patch for it again. Lo and behold,
there is now and mh-inc-folder-hook! (It if was there before I never
noticed it and Ashin's patch didn't use it.)
Well, anyway, I figured some people might find this useful in their
.emacs files. If you already have an inc-folder-hook that does
something else you will have to merge this around/into your existing hook.
(BTW, echoing someone else's (I forget whose) opinion, why can't
match-data be global? This extra code around each random
string-match/re-search seems to be somewhat of a kludge when simply
(let (VAR) ...) is sufficient in other cases when you want to preserve VAR.)
(setq mh-inc-folder-hook
'(lambda ()
(if (and (boundp (quote display-time-process))
(eq (quote run) (process-status display-time-process)))
(let ((real-match-data (match-data)))
(unwind-protect
(setq display-time-string
(concat
(substring display-time-string 0
(string-match " Mail" display-time-string))
(substring display-time-string (match-end 0))))
(store-match-data real-match-data))
(set-buffer-modified-p (buffer-modified-p))))))
Dave
--
tale@rpitsmts.bitnet, tale%mts@itsgw.rpi.edu, tale@pawl.rpi.edutale@pawl.rpi.edu (David C Lawrence) (05/16/89)
In <TALE.89May11183939@imagine.pawl.rpi.edu> I gave a hook to clobber
the " Mail" string when new mail is incorporated by mh-e. I
overlooked the fact that " Mail" might not be part of the
display-time-string because you are either a) don't have any mail or
b) have mail but Emacs hasn't told you yet. Mark D. Baushke
<mdb@kosciusko.ESD.3Com.COM> pointed this out to me and he asked that
I post the revised version as a bug-fix/enhancement.
(setq mh-inc-folder-hook
'(lambda ()
(if (and (boundp 'display-time-process)
(eq 'run (process-status display-time-process)))
(let ((real-match-data (match-data)))
(unwind-protect
(setq display-time-string
(let ((loc
(string-match " Mail" display-time-string)))
(if loc
(concat
(substring display-time-string 0 loc)
(substring display-time-string (match-end 0)))
display-time-string)))
(store-match-data real-match-data))
(set-buffer-modified-p (buffer-modified-p))))))
A couple people have said that protecting the match-data like that was
a good idea so I have this little function now:
(defun save-match-data (&rest forms)
"Save the match-data while &rest FORMS do some miscellaneous matching.
This is similar in principle to save-excursion and save-restriction."
(let ((original-match-data (match-data)))
(unwind-protect
(while forms
(eval (car forms))
(setq forms (cdr forms)))
(store-match-data original-match-data))))
(put 'save-match-data 'lisp-indent-hook 0)
If you decide to keep that around as being handy, then the hook shortens a
little to this:
(setq mh-inc-folder-hook
'(lambda ()
(if (and (boundp 'display-time-process)
(eq 'run (process-status display-time-process)))
(save-match-data
(setq display-time-string
(let ((loc (string-match " Mail" display-time-string)))
(if loc
(concat
(substring display-time-string 0 loc)
(substring display-time-string (match-end 0)))
display-time-string)))
(set-buffer-modified-p (buffer-modified-p))))))
Ashwin informs me that as of 18.52 the hook for inc-folder was not
there, so this won't work for anyone running 18.52 or earlier. You
have to either code in the hook or redefine mh-inc-folder to do the
stripping by itself.
Dave
--
(setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))
(error "UUCP not spoken here. Long bang paths unlikely to get mail replies.")Ram-Ashwin@cs.yale.edu (Ashwin Ram) (05/16/89)
In article <TALE.89May15161530@imagine.pawl.rpi.edu>, tale@pawl.rpi.edu (David C Lawrence) writes: > Ashwin informs me that as of 18.52 the hook for inc-folder was not > there, so this won't work for anyone running 18.52 or earlier. You > have to either code in the hook or redefine mh-inc-folder to do the > stripping by itself. Actually, what I said (or meant to say) was that mh-inc-folder-hook does exist in 18.52, but there is no corresponding hook in rmail.el as of 18.52 :-( -- Ashwin.
jr@bbn.com (John Robinson) (05/16/89)
In article <TALE.89May15161530@imagine.pawl.rpi.edu>, tale@pawl (David C Lawrence) writes: >A couple people have said that protecting the match-data like that was >a good idea so I have this little function now: > >(defun save-match-data (&rest forms) ... And the suggestion I recently posted to beep when "Mail" appears, in the time.el function that updates the mode-line, needs this function to avoid clobbering match-data. Talk about timing. Thanks to Wolfgang Rupprecht for pointing this out. -- /jr jr@bbn.com or bbn!jr C'mon big money!