[comp.emacs] Updated mailalias.el

montnaro@sprite.UUCP (10/01/87)

Here are the diffs for a version of mailalias.el that we use locally.
One of our users converts our entire organization's mail database into
Berk mail aliases (nearly 2000 names) that we can then "source" from
~/.mailrc. (There are still some problems with using them as sendmail
aliases, otherwise we'd probably do it that way.) The convenience of
using mailnames is substantial, so I added code to build-mail-alias
and define-mail-alias to understand mail's "source" command. 

I also removed the assoc/replacd in define-mail-alias which prevented
duplicate aliases. It takes too long to load all those aliases, even
on a Sun-3/260. Instead, I look for "aource" commands before "alias"
commands, so that aliases in ~/.mailrc will override those found in
"source"d files.

Here's the diffs. We're running 18.49, although our local mailalias.el
was derived from something more like 18.47.

----------cut----------cut----------cut----------cut----------cut----------
*** mailalias.el-	Thu Oct  1 09:08:37 1987
--- mailalias.el	Thu Oct  1 09:09:07 1987
***************
*** 105,111 ****
--- 102,118 ----
  	    (if (= (preceding-char) ?\\)
  		(progn (delete-char -1) (delete-char 1) (insert ?\ ))
  	        (forward-char 1)))
+ 	  ; recurse on "source" commands
+ 	  ; do this first so that aliases directly in ~/.mailrc are added
+ 	  ; last => at the beginning of the a-list & therefore override
+ 	  ; definitions in other files
  	  (goto-char (point-min))
+ 	  (while (re-search-forward "^source[ 	]+" nil t)
+ 	    (end-of-line)
+ 	    (let* ((file (buffer-substring (match-end 0) (point))))
+ 	      (build-mail-aliases file)))
+ 	  ; now get alias commands
+ 	  (goto-char (point-min))
  	  (while (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t)
  	    (re-search-forward "[^ \t]+")
  	    (let* ((name (buffer-substring (match-beginning 0) (match-end 0)))
***************
*** 140,146 ****
  				 ", "
  				 (substring definition
  					    (setq tem (match-end 0)))))))
!     (setq tem (assoc name mail-aliases))
!     (if tem
! 	(rplacd tem definition)
!       (setq mail-aliases (cons (cons name definition) mail-aliases)))))
--- 141,144 ----
  				 ", "
  				 (substring definition
  					    (setq tem (match-end 0)))))))
!       (setq mail-aliases (cons (cons name definition) mail-aliases))))
----------cut----------cut----------cut----------cut----------cut----------
Skip (montanaro@ge-crd.arpa or uunet!steinmetz!sprite!montanaro)