Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!snorkelwacker!mit-eddie!bbn!jr@bbn.com From: jr@bbn.com (John Robinson) Newsgroups: comp.emacs Subject: Re: text-mode-hook Message-ID: <54664@bbn.COM> Date: 9 Apr 90 20:13:53 GMT References: Sender: news@bbn.COM Reply-To: jr@bbn.com (John Robinson) Organization: BBN Systems and Technologies Corporation, Cambridge MA Lines: 33 In-reply-to: Damon.Lipparelli@CS.CMU.EDU In article , Damon.Lipparelli@CS writes: >Hello. I'm having trouble with the text-mode-hook feature. I'd like to >set things so that when I enter text mode, I'm automatically put into >auto-fill mode as well. I tried setting the variable text-mode-hook to >be auto-fill-mode (ie, "(setq text-mode-hook 'auto-fill-mode)"), but I >get the error "Wrong number of arguments" and then a lambda expression. >I assume that this means that auto-fill-mode is expecting arguments (as >documented it can take one), but I can just type auto-fill-mode to the >mode-line and it toggles auto-fill. What am I missing? Functions called interactively (i.e. with M-x, or by being bound to a key you type) can take their arguments in a number of ways, and may default them. All this is explained in the documentation for the "function" called interactive. When they're called from a program, however, the lisp interpreter has to match arguments and formals. The sepecification for the function auto-fill-mode is: (interactive "P") which means "pick up the prefix argument, if any, in raw form". When there is no prefix argument, the argument to auto-fill-mode defaults to nil. One could plausibly argue that the argument to auto-fill-mode ought to be &optional, but it ain't. Fortunately, emacs provides you with [in simple.el]: (defun turn-on-auto-fill () "Unconditionally turn on Auto Fill mode." (auto-fill-mode 1)) which serves just fine for your text-mode-hook (and whatever else). -- /jr, nee John Robinson Life did not take over the globe by combat, jr@bbn.com or bbn!jr but by networking -- Lynn Margulis