Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ukma!rutgers!steiner From: steiner@rutgers.rutgers.edu (Dave Steiner) Newsgroups: comp.emacs Subject: Re: The right way to do headers (Was Re: Sections in Gnu Emacs Buffers?) Message-ID: Date: 11 Feb 89 20:25:51 GMT References: <2846@hplabsz.HPL.HP.COM> <4300032@m.cs.uiuc.edu> <49769@yale-celray.yale.UUCP> <35723@bbn.COM> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 79 To: mesard@labs-n.bbn.com Cc: steiner In article <35723@bbn.COM> mesard@bbn.com (Wayne Mesard) writes: > 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. > Nah, you just need a smarter mail mode. Here's a fragment from mine. > [code deleted...-ds] Yup, that's what I wanted but I didn't give it much thought since I assumed (wrongly) that the overhead would be to great. I haven't rebound RETURN yet but here is my diffs. Changes I made were: I didn't automatically go into auto-fill mode and I also look for the head-separator since checking for 2 NLs doesn't work in all cases (ie, you don't need a blank line after the header-separator). [Actually, I just noticed that I don't need to concat the separator everytime, just bind it at the top of the function.] Anyway, here's my diffs to 18.51: *** sendmail.el.ORIG Wed May 25 23:56:10 1988 --- sendmail.el Fri Feb 10 17:52:59 1989 *************** *** 387,392 (progn (re-search-forward "\n[^ \t]") (forward-char -1) (point)))))))) ;; Put these last, to reduce chance of lossage from quitting in middle of loading the file. --- 408,451 ----- (progn (re-search-forward "\n[^ \t]") (forward-char -1) (point)))))))) + + (defun in-headers-p () + (and (/= (point) (point-max)) + (save-excursion + (beginning-of-line) + (while (and (/= (point) (point-min)) + (not (looking-at + (concat "^" mail-header-separator "\n"))) + (zerop (forward-line -1)))) + (= (point) (point-min))))) + + (defun mail-auto-fill-hook () + (if (in-headers-p) + (setq fill-prefix ?\t) + (setq fill-prefix nil)) + (do-auto-fill)) + ;; Put these last, to reduce chance of lossage from quitting in middle of loading the file. *************** *** 422,427 (setq default-directory (expand-file-name "~/")) (auto-save-mode auto-save-default) (mail-mode) (and (not noerase) (or (not (buffer-modified-p)) (y-or-n-p "Unsent message being composed; erase it? ")) --- 483,492 ----- (setq default-directory (expand-file-name "~/")) (auto-save-mode auto-save-default) (mail-mode) + ; only change auto-fill if it's the real auto-fill, ie if the user is doing + ; something funky, don't mess with it. + (if (equal auto-fill-hook 'do-auto-fill) + (setq auto-fill-hook 'mail-auto-fill-hook)) (and (not noerase) (or (not (buffer-modified-p)) (y-or-n-p "Unsent message being composed; erase it? ")) -- arpa: Steiner@TOPAZ.RUTGERS.EDU uucp: ...{ames, cbosgd, harvard, moss}!rutgers!topaz.rutgers.edu!steiner