Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.emacs Subject: The right way to do headers (Was Re: Sections in Gnu Emacs Buffers?) Message-ID: <35723@bbn.COM> Date: 8 Feb 89 14:22:41 GMT References: <2846@hplabsz.HPL.HP.COM> <4300032@m.cs.uiuc.edu> <49769@yale-celray.yale.UUCP> Sender: news@bbn.COM Reply-To: mesard@labs-n.bbn.com (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 46 In article steiner@topaz.rutgers.edu (Dave Steiner) writes: >>What kinds of things would you use intervals for? > >I've always wanted to use something like this for being in a different >mode when you are editing the headers in mail mode. If your To: field >gets too long and you have auto-fill on in mail-mode it auto fills but >doesn't put a TAB or something in front of the line and then sendmail >gets confused. The solution always looked too messy to try something. Nah, you just need a smarter mail mode. Here's a fragment from mine. (defun wmail-mode () (interactive) ... (auto-fill-mode 1) (setq auto-fill-hook 'wmail-auto-fill-hook) ...) Then (defun in-headersP () (and (/= (point) (point-max)) (save-excursion (beginning-of-line) (while (and (/= (point) (point-min)) (not (char-equal 10 (following-char))) (zerop (forward-line -1)))) (= (point) (point-min)))) ) (defun wmail-auto-fill-hook () (if (in-headersP) (setq fill-prefix ?\t) (setq fill-prefix nil)) (do-auto-fill)) So if it wraps in the headers, a tab gets put at the start of the next line. Otherwise, everything works as normal. I also bind Return to a function which calls in-headersP. If true it moves to the end of the next line rather than inserting a linefeed. -- void Wayne_Mesard(); Mesard@BBN.COM Edith Keillor died for your sins. BBN, Cambridge, MA