Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcvax!ukc!icdoc!qmc-cs!harlqn!jung!andrew From: andrew@jung.harlqn.uucp (Andrew Watson) Newsgroups: comp.emacs Subject: Removing the pain of editing .mailrc Message-ID: <1848@harlqn.UUCP> Date: 1 Jun 89 17:52:30 GMT Sender: news@harlqn.UUCP Lines: 43 Being the popular chap that I am (:-), I find that I constantly need to edit my .mailrc file to add aliases for new mail correspondents. Given that I use GNU Emacs both to edit the .mailrc and send the mail, I have to remember to tell the Emacs mailalias mechanism that I've been changing the world under its feet by (setq mail-aliases t) every time. Eventually I got bored with this, and so (with some help from John Sturdy) I put together the following few lines of code to do the job automatically: Define a couple of functions (in your .emacs, for example): ------------------------------------------------------------------------- ;;; Write hook function to do the job (defun mailrc-reset () (message "Reset aliases variable") (sit-for 1) (setq mail-aliases t) nil) ; this is rather important! ;;; Small function to place the hook (defun setup-mailrc-hook () (make-local-variable 'write-file-hooks) ; make it have a separate value here (setq write-file-hooks (cons 'mailrc-reset write-file-hooks))) -------------------------------------------------------------------------- And then add the following lines at the end of the .mailrc to setup the hook when the file is first visited ... -------------------------------------------------------------------------- # # Local Variables: # eval: (setup-mailrc-hook) # End: Regards, Andrew. +-----------------------------------------------------------------------------+ | Andrew Watson, andrew@uk.co.harlqn -or- | | Harlequin Limited, mcvax!ukc!harlqn!andrew | | Barrington Hall, Barrington, Tel: +44 223 872522 | | Cambridge CB2 5RG, UK Fax: +44 223 872519 | +-----------------------------------------------------------------------------+