mesard@bbn.com (Wayne Mesard) (02/08/89)
In article <Feb.7.23.07.46.1989.14746@topaz.rutgers.edu> 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
steiner@rutgers.rutgers.edu (Dave Steiner) (02/12/89)
In article <35723@bbn.COM> mesard@bbn.com (Wayne Mesard) writes: > In article <Feb.7.23.07.46.1989.14746@topaz.rutgers.edu> 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
eric@snark.uu.net (Eric S. Raymond) (02/13/89)
In article <Feb.7.23.07.46.1989.14746@topaz.rutgers.edu> 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. I have written a super-sendmail which rms has and which may be included in version 19. It uses a plain old ordinary mark object (remember, marks are moved by insert/deletes) to define two `intervals'; the header region and the body region. The code for the various mail-specific major-mode functions has lots of conditionals that check on which interval you're in -- and no bogus separator string. This mode also has all the profile features of SVr2 mailx(1) supported, and smarter aliasing with exclusions. Email copies on request. -- Eric S. Raymond (the mad mastermind of TMN-Netnews) Email: eric@snark.uu.net CompuServe: [72037,2306] Post: 22 S. Warren Avenue, Malvern, PA 19355 Phone: (215)-296-5718