Oops, here is hook-advice.el:

;;; insert-hooks using v19 advice.el
;;; Roland McGrath 6/8/93

(require 'advice)

;;;###autoload
(defun insert-hooks (function head-hook &optional tail-hook)
  "Rewrite the function specified by the first argument FUNCTION to
run hooks. 

If second argument HEAD-HOOK, a symbol referring to a named hook, is
non-nil, insert a form in FUNCTION that will run that hook before
anything else is done. 

If optional third argument TAIL-HOOK is non-nil, insert a form in
FUNCTION that will run the hook as the last thing done.

Return value is new definition of FUNCTION.

FUNCTION may be an autoloaded function, subr, or lambda-expression, but may
not be a macro."  
  (if head-hook
      (ad-add-advice function 
                     (ad-make-advice head-hook nil t
                                     (` (advice lambda ()
                                                (, (format "\
Runs hook %s before all else."
                                                           head-hook))
                                                (run-hooks '(, head-hook)))))
                     'before 'first))
  (if tail-hook
      (ad-add-advice function 
                     (ad-make-advice tail-hook nil t
                                     (` (advice lambda ()
                                                (, (format "\
Runs hook %s after all else."
                                                           tail-hook))
                                                (run-hooks '(, tail-hook)))))
                     'after 'last))
  (ad-activate function (byte-code-function-p (indirect-function function))))

(provide 'hook-advice)


--- eof

If you want everything so automatic, why not just use vm-auto-folder-alist?
Maybe you would like my hairy code which takes all the interned mail
aliases (whether from bbdb or .mailrc or whatever) and produces a
vm-auto-folder-alist value to correlate a sender's net address with a
default folder that is the same as the mail alias name you have for them?

Reply via email to