Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.7.0.5 $; site waltz
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!inuxc!pur-ee!uiucdcs!convex!waltz!buehring
From: buehring@waltz
Newsgroups: net.emacs
Subject: Re: find-file-hook problem (gnuemacs)
Message-ID: <34300005@waltz>
Date: Fri, 5-Jul-85 01:27:00 EDT
Article-I.D.: waltz.34300005
Posted: Fri Jul  5 01:27:00 1985
Date-Received: Sun, 7-Jul-85 06:04:20 EDT
References: <218@sdcarl.UUCP>
Lines: 66
Nf-ID: #R:sdcarl.UUCP:-21800:waltz:34300005:000:2099
Nf-From: waltz!buehring    Jul  5 00:27:00 1985


[No, no, you don't understand how radio works...]

To make *scratch* start out in a certain mode, just put the commands
to do it at the end of your .emacs file -- I do this...

;;; initial mode for *scratch*
(text-mode)
(auto-fill-mode 1)

A word about "hooks" -- a hook holds the SYMBOL for a function to be
called at a later time (see FUNCALL).  For instance.

	(setq find-file-hook 'fundamental-mode)

or you can use lambda to contruct a short function for the hook...

	(setq text-mode-hook '(lambda ()
				(auto-fill-mode 1)
				(setq fill-column 78)))

But doing this...

(setq find-file-hook
      (progn
	(if (string-equal (eval mode-name) "C")
	    (fundamental-mode))
	(if (string-equal (buffer-name) "*scratch*")
	    (fundamental-mode))
	)
)

causes the mode to be set NOW and mearly assigns the hook the value of
the result (probably nil).

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).

(defvar auto-mode-alist
	'(("\\.text$" . text-mode)
	  ("\\.text~$" . text-mode)
	  ("\\.texinfo$" . texinfo-mode)
	  ("\\.texinfo~$" . texinfo-mode)
	  ;; Mailer puts message to be edited in /tmp/Re.... or Message
	  ("^/tmp/Re" . text-mode)
 	  ("/Message[0-9]*$" . text-mode)
          ("\\.c$" . c-mode) ("\\.c~$" . c-mode)
          ("\\.h$" . c-mode) ("\\.h~$" . c-mode)
          ("\\.y$" . c-mode) ("\\.y~$" . c-mode)
          ("\\.scm$" . lisp-mode) ("\\.scm~$" . lisp-mode)
	  ("\\..*emacs" . lisp-mode)
          ("\\.el$" . lisp-mode) ("\\.el~$" . lisp-mode)
          ("\\.ml$" . lisp-mode) ("\\.ml~$" . lisp-mode)
	  ("\\.l$" . lisp-mode) ("\\.l~$" . lisp-mode))
  "Alist of filename patterns vs corresponding major mode functions.
Each element looks like (REGEXP . FUNCTION).
Visiting a file whose name matches REGEXP causes FUNCTION to be called.")


Ain't Lisp Grand?
/Walt/

ARPA:  Buehring%Waltz%TI-CSL@CSNet-Relay
UUCP:  {convex!smu, texsun, ut-sally, rice} ! waltz ! buehring