Article View: gnu.epoch.misc
Article #2077Re: Auto-fill for GNUServer buffers
From: Alan M. Carroll
Date: Thu, 18 Apr 1991 14:13
Date: Thu, 18 Apr 1991 14:13
91 lines
3848 bytes
3848 bytes
In article <8411@idunno.Princeton.EDU>, chase@olympus.princeton.edu (Chris Chase) writes:
> I use gnuservX.el from my mail program to edit and create messages. I would like
> the buffers that are created to automatically have auto-fill turned on. Could
> someone please explain how to do this?
What I would do is use a mode for that. Here's an example XRn mode,
which should be easily adaptable for your mail program. You'd just
have to change the auto-mode name, and add a command to the mode to
set auto-fill. You might also change the header RE's, so that the To:
and Subject: fields are highlighted.
;;; The mode keymap
(defvar xrn-mode-map (make-sparse-keymap) "XRN mode keymap")
;;; This is the only key currently in the key map. I use it because it's the
;;; same as for MH-e.
(define-key xrn-mode-map "\C-c\C-c" 'server-edit)
;;; We want to mark "interesting" headers, and need a default style and
;;; attribute to mark them with (although things are set up so that other
;;; attributes can be used if desired.
;;; This is the attribute
(defvar xrn-header-attribute (reserve-attribute)
"Default Xrn attribute for headers"
)
;;; Create a style for the default attribute. If we're color, then set up
;;; foreground and background, otherwise just let it default to reverse
;;; video.
(defvar xrn-header-style
(let ((s (make-style)))
(when (< 2 (number-of-colors))
(set-style-foreground s "red")
(set-style-background s (background))
)))
;;; Put the style into the attribute so that it can be used.
(set-attribute-style xrn-header-attribute xrn-header-style)
(defvar xrn-mode-headers
(list
(cons "^[fF]ollowup-To:" xrn-header-attribute)
(cons "^Newsgroups:" xrn-header-attribute)
)
"*A list of (re . attribute) pairs for marking headers in the Xrn buffer"
)
;;; Inhibit mode inheritance
(put 'xrn-mode 'mode-class 'special)
;;; Set up the auto mode stuff, but try to avoid putting it in twice if we
;;; have to reload this file.
(let ((re "/tmp/xrn[A-Za-z]+[0-9]+$"))
(setq auto-mode-alist
(cons
(cons re 'xrn-mode) ; our mode
(delete-if ; get rid of any previous version
(eval (` '(lambda (x) (equal (, re) (car x)))))
auto-mode-alist
))))
;;; The actual mode itself.
(defun xrn-mode ()
"Switch into XRN editing mode
\\[server-edit] : Finish the edit and post"
(use-local-map xrn-mode-map)
(setq major-mode 'xrn-mode)
(setq mode-name "Xrn")
;; deal with the headers
(dolist (h xrn-mode-headers)
(let
(
(re (car h)) ;the RE to find
(attr (or (cdr h) xrn-header-attribute)) ;the attribute to use
)
(goto-char (point-min))
(while (re-search-forward re nil t)
(end-of-line)
(add-button (match-end 0) (point) attr (list 'xrn))
)))
(run-hooks 'xrn-mode-hooks)
)
--
Alan M. Carroll <-- Another victim of applied metaphysics
Epoch Development Team
Urbana Il. "I hate shopping with the reality-impaired" - Susan
Technical Details
Message-ID:
<1991Apr18.141337.23349@m.cs.uiuc.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!fauern!ira.uka.de!sol.ctr.columbia.edu!samsung!usc!wuarchive!m.cs.uiuc.edu!uiucdcs!carrollReferences:
<8411@idunno.Princeton.EDU>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,4d3bd5e36fb5b3d1 X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1991-04-18 15:31:17 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!fauern!ira.uka.de!sol.ctr.columbia.edu!samsung!usc!wuarchive!m.cs.uiuc.edu!uiucdcs!carroll From: carroll@cs.uiuc.edu (Alan M. Carroll) Newsgroups: gnu.epoch.misc Subject: Re: Auto-fill for GNUServer buffers Keywords: gnuservX.el auto-fill Message-ID: <1991Apr18.141337.23349@m.cs.uiuc.edu> Date: 18 Apr 91 14:13:37 GMT References: <8411@idunno.Princeton.EDU> Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager)) Reply-To: carroll@cs.uiuc.edu (Alan M. Carroll) Organization: Technophiles Inc. - Engineers with Attitude Lines: 91 Nntp-Posting-Host: ash.cs.uiuc.edu