2001-11-07 Simon Josefsson <jas@extundo.com>
[gnus] / texi / sieve.texi
1 \input texinfo                  @c -*-texinfo-*-
2
3 @setfilename sieve
4 @settitle Emacs Sieve Manual
5 @synindex fn cp
6 @synindex vr cp
7 @synindex pg cp
8 @dircategory Emacs
9 @direntry
10 * Sieve: (sieve).               Managing Sieve scripts in Emacs.
11 @end direntry
12 @iftex
13 @finalout
14 @end iftex
15 @setchapternewpage odd
16
17 @ifnottex
18
19 This file documents the Emacs Sieve package.
20
21 Copyright (C) 2001 Free Software Foundation, Inc.
22
23 Permission is granted to copy, distribute and/or modify this document
24 under the terms of the GNU Free Documentation License, Version 1.1 or
25 any later version published by the Free Software Foundation; with no
26 Invariant Sections, with the Front-Cover texts being ``A GNU
27 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
28 license is included in the section entitled ``GNU Free Documentation
29 License'' in the Emacs manual.
30
31 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
32 this GNU Manual, like GNU software.  Copies published by the Free
33 Software Foundation raise funds for GNU development.''
34
35 This document is part of a collection distributed under the GNU Free
36 Documentation License.  If you want to distribute this document
37 separately from the collection, you can do so by adding a copy of the
38 license to the document, as described in section 6 of the license.
39 @end ifnottex
40
41 @tex
42
43 @titlepage
44 @title Emacs Sieve Manual
45
46 @author by Simon Josefsson
47 @page
48
49 @vskip 0pt plus 1filll
50 Copyright @copyright{} 2001 Free Software Foundation, Inc.
51
52 Permission is granted to copy, distribute and/or modify this document
53 under the terms of the GNU Free Documentation License, Version 1.1 or
54 any later version published by the Free Software Foundation; with the
55 Invariant Sections being none, with the Front-Cover texts being ``A GNU
56 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
57 license is included in the section entitled ``GNU Free Documentation
58 License'' in the Emacs manual.
59
60 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
61 this GNU Manual, like GNU software.  Copies published by the Free
62 Software Foundation raise funds for GNU development.''
63
64 This document is part of a collection distributed under the GNU Free
65 Documentation License.  If you want to distribute this document
66 separately from the collection, you can do so by adding a copy of the
67 license to the document, as described in section 6 of the license.
68 @end titlepage
69 @page
70
71 @end tex
72
73 @node Top
74 @top Sieve Support for Emacs
75
76 This manual documents the Emacs Sieve package.
77
78 It is intended as a users manual for Sieve Mode and Manage Sieve, and
79 as a reference manual for the @samp{sieve-manage} protocol Emacs Lisp
80 API.
81
82 Sieve is a language for server-side filtering of mail.  The language
83 is documented in RFC 3028.  This manual does not attempt to document
84 the language, so keep RFC 3028 around.
85
86 @menu
87 * Installation::          Getting ready to use the package.
88 * Sieve Mode::            Editing Sieve scripts.
89 * Managing Sieve::        Managing Sieve scripts on a remote server.
90 * Examples ::             A few Sieve code snippets.
91 * Manage Sieve API ::     Interfacing to the Manage Sieve Protocol API.
92 * Standards::             A summary of RFCs and working documents used.
93 * Index::                 Function and variable index.
94 @end menu
95
96
97 @node Installation
98 @chapter Installation
99 @cindex Install
100 @cindex Setup
101
102 The Sieve package should come with your Emacs version, and should be
103 ready for use directly.
104
105 However, to manually set up the package you can put the following
106 commands in your @code{~/.emacs}:
107
108 @lisp
109 (autoload 'sieve-mode "sieve-mode")
110 @end lisp
111 @lisp
112 (setq auto-mode-alist (cons '("\\.si\\(v\\|eve\\)\\'" . sieve-mode)
113                             auto-mode-alist))
114 @end lisp
115
116
117 @node Sieve Mode
118 @chapter Sieve Mode
119
120 Sieve mode provides syntax-based indentation, font-locking support and
121 other handy functions to make editing Sieve scripts easier.
122
123 Use @samp{M-x sieve-mode} to switch to this major mode.  This command
124 runs the hook @code{sieve-mode-hook}.
125
126 @vindex sieve-mode-map
127 @vindex sieve-mode-syntax-table
128 Sieve mode is derived from @code{c-mode}, and is very similar except
129 for the syntax of comments.  The keymap (@code{sieve-mode-map}) is
130 inherited from @code{c-mode}, as are the the variables for customizing
131 indentation.  Sieve mode has its own abbrev table
132 (@code{sieve-mode-abbrev-table}) and syntax table
133 (@code{sieve-mode-syntax-table}).
134
135 In addition to the editing utility functions, Sieve mode also contains
136 bindings to manage Sieve scripts remotely. @pxref{Managing Sieve}.
137
138 @table @kbd
139
140 @item C-c RET
141 @kindex C-c RET
142 @findex sieve-manage
143 @cindex manage remote sieve script
144 Open a connection to a remote server using the Managesieve protocol.
145
146 @item C-c C-l
147 @kindex C-c C-l
148 @findex sieve-upload
149 @cindex upload sieve script
150 Upload the Sieve script to the currently open server.
151
152 @end table
153
154
155 @node Managing Sieve
156 @chapter Managing Sieve
157
158 Manage Sieve is a special mode used to display Sieve scripts available
159 on a remote server.  It can be invoked with @kbd{M-x sieve-manage
160 RET}, which queries the user for a server and if necessary, user
161 credentials to use.
162
163 When a server has been succesfully contacted, the Manage Sieve buffer
164 looks something like:
165
166 @example
167 Server  : mailserver:2000
168
169 2 scripts on server, press RET on a script name edits it, or
170 press RET on <new script> to create a new script.
171         <new script>
172  ACTIVE .sieve
173         template.siv
174 @end example
175
176 One of the scripts are highlighted, and standard point navigation
177 commands (@kbd{<up>}, @kbd{<down>} etc) can be used to navigate the
178 list.
179
180 The following commands are available in the Manage Sieve buffer:
181
182 @table @kbd
183
184 @item m
185 @kindex m
186 @findex sieve-activate
187 Activates the currently highlighted script.
188
189 @item u
190 @kindex u
191 @findex sieve-deactivate
192 Deactivates the currently highlighted script.
193
194 @item C-M-?
195 @kindex C-M-?
196 @findex sieve-deactivate-all
197 Deactivates all scripts.
198
199 @item r
200 @kindex r
201 @findex sieve-remove
202 Remove currently highlighted script.
203
204 @item RET
205 @item mouse-2
206 @item f
207 @kindex RET
208 @kindex mouse-2
209 @kindex f
210 @findex sieve-edit-script
211 Bury the server buffer and download the currently highlighted script
212 into a new buffer for editing in Sieve mode (@pxref{Sieve Mode}).
213
214 @item o
215 @kindex o
216 @findex sieve-edit-script-other-window
217 Create a new buffer in another window containing the currently
218 highlighted script for editing in Sieve mode (@pxref{Sieve Mode}).
219
220 @item q
221 @kindex q
222 @findex sieve-bury-buffer
223 Bury the Manage Sieve buffer without closing the connection.
224
225 @item ?
226 @item h
227 @kindex ?
228 @kindex h
229 @findex sieve-help
230 Displays help in the minibuffer. 
231
232 @end table
233
234 @node Examples
235 @chapter Examples
236
237 If you are not familiar with Sieve, this chapter contains a few simple
238 code snippets that you can cut'n'paste and modify at will, until you
239 feel more comfortable with the Sieve language to write the rules from
240 scratch.
241
242 The following complete Sieve script places all messages with a matching
243 @samp{Sender:} header into the given mailbox.  Many mailing lists uses
244 this format.  The first line makes sure your Sieve server understands
245 the @code{fileinto} command.
246
247 @example
248 require "fileinto";
249
250 if address "sender" "owner-w3-beta@@xemacs.org" @{
251         fileinto "INBOX.w3-beta";
252 @}
253 @end example
254
255 A few mailing lists do not use the @samp{Sender:} header, but does
256 contain some unique identifier in some other header.  The following is
257 not a complete script, it assumes that @code{fileinto} has already been
258 required.
259
260 @example
261 if header :contains "Delivered-To" "auc-tex@@sunsite.dk" @{
262         fileinto "INBOX.auc-tex";
263 @}
264 @end example
265
266 At last, we have the hopeless mailing lists that does not have any
267 unique identifier and you are forced to match on the @samp{To:} and
268 @samp{Cc} headers.  As before, this snippet assumes that @code{fileinto}
269 has been required.
270
271 @example
272 if address ["to", "cc"] "kerberos@@mit.edu" @{
273         fileinto "INBOX.kerberos";
274 @}
275 @end example
276
277 @node Manage Sieve API
278 @chapter Manage Sieve API
279
280 The @file{sieve-manage.el} library contains low-level functionality
281 for talking to a server with the @sc{managesieve} protocol.
282
283 A number of user-visible variables exist, which all can be customized
284 in the @code{sieve} group (@kbd{M-x customize-group RET sieve RET}):
285
286 @table @code
287
288 @item sieve-manage-default-user
289 @vindex sieve-manage-default-user
290 Sets the default username.
291
292 @item sieve-manage-default-port
293 @vindex sieve-manage-default-port
294 Sets the default port to use, the suggested port number is @code{2000}.
295
296 @item sieve-manage-log
297 @vindex sieve-manage-log
298 If non-nil, should be a string naming a buffer where a protocol trace
299 is dumped (for debugging purposes).
300
301 @end table
302
303 The API functions include:
304
305 @table @code
306
307 @item sieve-manage-open
308 @findex sieve-manage-open
309 Open connection to managesieve server, returning a buffer to be used
310 by all other API functions.
311
312 @item sieve-manage-opened
313 @findex sieve-manage-opened
314 Check if a server is open or not.
315
316 @item sieve-manage-close
317 @findex sieve-manage-close
318 Close a server connection.
319
320 @item sieve-manage-authenticate
321 @findex sieve-manage-authenticate
322 Authenticate to the server.
323
324 @item sieve-manage-capability
325 @findex sieve-manage-capability
326 Return a list of capabilities the server support.
327
328 @item sieve-manage-listscripts
329 @findex sieve-manage-listscripts
330 List scripts on the server.
331
332 @item sieve-manage-havespace
333 @findex sieve-manage-havespace
334 Returns non-nil iff server have roam for a script of given size.
335
336 @item sieve-manage-getscript
337 @findex sieve-manage-getscript
338 Download script from server.
339
340 @item sieve-manage-putscript
341 @findex sieve-manage-putscript
342 Upload script to server.
343
344 @item sieve-manage-setactive
345 @findex sieve-manage-setactive
346 Indicate which script on the server should be active.
347
348 @end table
349
350 @node Standards
351 @chapter Standards
352
353 The Emacs Sieve package implements all or parts of a small but
354 hopefully growing number of RFCs and drafts documents.  This chapter
355 lists the relevant ones.  They can all be fetched from
356 @samp{http://quimby.gnus.org/notes/}.
357
358 @table @dfn
359
360 @item RFC3028
361 Sieve: A Mail Filtering Language.
362
363 @item draft-martin-managesieve-03
364 A Protocol for Remotely Managing Sieve Scripts
365
366 @end table
367
368
369 @node Index
370 @chapter Index
371 @printindex cp
372
373 @summarycontents
374 @contents
375 @bye
376
377 @c End: