1 ;;; ietf-drums.el --- Functions for parsing RFC822bis headers
2 ;; Copyright (C) 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
25 ;; DRUMS is an IETF Working Group that works (or worked) on the
26 ;; successor to RFC822, "Standard For The Format Of Arpa Internet Text
27 ;; Messages". This library is based on
28 ;; draft-ietf-drums-msg-fmt-05.txt, released on 1998-08-05.
35 (defvar ietf-drums-no-ws-ctl-token "\001-\010\013\014\016-\037\177"
36 "US-ASCII control characters excluding CR, LF and white space.")
37 (defvar ietf-drums-text-token "\001-\011\013\014\016-\177"
38 "US-ASCII characters exlcuding CR and LF.")
39 (defvar ietf-drums-specials-token "()<>[]:;@\\,.\""
40 "Special characters.")
41 (defvar ietf-drums-quote-token "\\"
43 (defvar ietf-drums-wsp-token " \t"
45 (defvar ietf-drums-fws-regexp
46 (concat "[" ietf-drums-wsp-token "]*\n[" ietf-drums-wsp-token "]+")
47 "Folding white space.")
48 (defvar ietf-drums-atext-token "-^a-zA-Z0-9!#$%&'*+/=?_`{|}~"
50 (defvar ietf-drums-dot-atext-token "-^a-zA-Z0-9!#$%&'*+/=?_`{|}~."
51 "Textual token including full stop.")
52 (defvar ietf-drums-qtext-token
53 (concat ietf-drums-no-ws-ctl-token "\041\043-\133\135-\177")
54 "Non-white-space control characaters, plus the rest of ASCII excluding backslash and doublequote.")
55 (defvar ietf-drums-tspecials "][()<>@,;:\\\"/?="
58 (defvar ietf-drums-syntax-table
59 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
60 (modify-syntax-entry ?\\ "/" table)
61 (modify-syntax-entry ?< "(" table)
62 (modify-syntax-entry ?> ")" table)
63 (modify-syntax-entry ?@ "w" table)
64 (modify-syntax-entry ?/ "w" table)
65 (modify-syntax-entry ?= " " table)
66 (modify-syntax-entry ?* " " table)
67 (modify-syntax-entry ?\; " " table)
68 (modify-syntax-entry ?\' " " table)
71 (defun ietf-drums-token-to-list (token)
72 "Translate TOKEN into a list of characters."
75 (while (< i (length token))
76 (setq c (mm-char-int (aref token i)))
79 ((eq c (mm-char-int ?-))
85 (push (mm-make-char 'ascii b) out)
89 (push (mm-make-char 'ascii c) out))
92 (push (mm-make-char 'ascii b) out))
96 (defsubst ietf-drums-init (string)
97 (set-syntax-table ietf-drums-syntax-table)
99 (ietf-drums-unfold-fws)
100 (goto-char (point-min)))
102 (defun ietf-drums-remove-comments (string)
103 "Remove comments from STRING."
106 (ietf-drums-init string)
108 (setq c (char-after))
113 (delete-region (point) (progn (forward-sexp 1) (point))))
118 (defun ietf-drums-remove-whitespace (string)
119 "Remove whitespace from STRING."
121 (ietf-drums-init string)
124 (setq c (char-after))
130 ((memq c '(? ?\t ?\n))
136 (defun ietf-drums-get-comment (string)
137 "Return the first comment in STRING."
139 (ietf-drums-init string)
142 (setq c (char-after))
150 (progn (forward-sexp 1) (1- (point))))))