Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site topaz.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!columbia!topaz!vijay
From: vijay@topaz.ARPA (P. Vijay)
Newsgroups: net.emacs
Subject: Re: find-file-hook problem (gnuemacs)
Message-ID: <2508@topaz.ARPA>
Date: Mon, 8-Jul-85 09:45:58 EDT
Article-I.D.: topaz.2508
Posted: Mon Jul  8 09:45:58 1985
Date-Received: Tue, 9-Jul-85 07:07:23 EDT
References: <218@sdcarl.UUCP> <34300005@waltz>
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 45
Summary: Better way to set auto-mode-alist

In article <34300005@waltz>, buehring@waltz writes:
> 
> If you want to override C mode on files that end in ".c", the right
> place to do it is the auto mode list.  You could snarf the following
> from "loaddefs.el" and modify it for your .emacs file (change
> "defvar" to "setq" and delete the doc string).
> 
>  [Lists the auto-mode-list definition]
>
	
	It is better to write a function that zaps your pattern/mode
combination in place, in the variable. This way, if the emacs
maintainer on site decides to change the mode settings for various
patterns, you don't have to update your .emacs. I use the following
function to do my customization.

;;; Set up my own auto-mode assoc. list.....
;;; Major differences from the system defaults are for Mailer generated
;;; file names like /tmp/Re..., etc. Instead of text-mode, I want 
;;; Mail-mode
;;;
(defun Fix-Auto-Mode-Alist (File-Name-Pattern Major-Mode-Function)

"Searches auto-mode-alist for a cons pair with FILE-NAME-PATTERN
as its car. If found, MAJOR-MODE-FUNCTION is rplacd in place. If
not found, (FILE-NAME-PATTERN . MAJOR-MODE-FUNCTION) is added
to auto-mode-alist."

  (interactive "sFile name pattern (regexp): \nSMajor mode function: \n")
  (let ((temp (assoc File-Name-Pattern auto-mode-alist)))
    (if temp
	(rplacd temp Major-Mode-Function)
        (setq auto-mode-alist
	           (nconc auto-mode-alist 
			  (list (cons File-Name-Pattern Major-Mode-Function))
)))))

;; Vnews/PostNews stuff
(Fix-Auto-Mode-Alist "^/tmp/rep[0-9]+$" 'mail-mode)
(Fix-Auto-Mode-Alist "^/tmp/post[0-9]+$" 'text-mode)

	As I noted above, I don't have to worry about anyone changing
the default auto-mode-alist, by adding more patterns, etc...

							--Vijay--