Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!csd4.milw.wisc.edu!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.emacs Subject: Re: Need help with hook in init file Summary: Wayne babbles and then gets around to answering the question. What else is new. Keywords: hooks, .emacs, init Message-ID: <41817@bbn.COM> Date: 22 Jun 89 13:26:06 GMT References: <22487@iuvax.cs.indiana.edu> Sender: news@bbn.COM Reply-To: mesard@BBN.COM (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 48 In article <22487@iuvax.cs.indiana.edu> templon@silver.bacs.indiana.edu (jeffrey templon) writes: > >I want to have the variable find-file-hooks set so that when I find a >file, the buffer automatically gets set to truncate-line mode. I tried >something like > >(setq find-file-hooks 'set-variable truncate-lines t) Find-file-hook's documentation (available via Ctrl-H V) says that it is a "list of functions..." So the syntax would be: (setq find-file-hooks '(func1 func2)) Where func1 and func2 are functions (written by you or someone else) which take no arguments. So you could do: (defun set-truncate-lines () (setq truncate-lines t)) and sub "set-truncate-lines" for "func1 func2" above. Or to really wow you're friends, define an "anonymous" function using a lambda expression: (setq find-file-hooks '((lambda () (setq truncate-lines t)))) [For more information on lambda expressions, see _Practical_Jokes_Played on_the_LISP_Community_ by Guy Steele.] But I don't think this is what you want. This hook is for >making something happen< each time a file is loaded. What you want is >for something to be true< all the time. (Right?) The setq-default function is designed for this porpoise. (See the documentation available via Ctrl-H F.) Put the following in your .emacs file: (setq-default truncate-lines t) Thus all buffers which don't explicitly have the value of truncate-lines set will use the default value. Disclaimer: All code in this article is untested. -- unsigned *Wayne_Mesard(); "I have to go. My cat has a hard-on." MESARD@BBN.COM BBN, Cambridge, MA -Patty