1 ;;; std11.el --- STD 11 parser for GNU Emacs
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, RFC 822, STD 11
7 ;; Version: $Id: std11.el,v 0.2 1996-08-28 12:32:17 morioka Exp $
9 ;; This file is part of tl (Tiny Library).
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with This program; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
31 (defconst std11-field-name-regexp "[!-9;-~]+")
32 (defconst std11-field-head-regexp
33 (concat "\\(" std11-field-name-regexp "\\):"))
34 (defconst std11-next-field-head-regexp
35 (concat "\n" std11-field-head-regexp))
37 (defun std11-field-end ()
38 (if (re-search-forward std11-next-field-head-regexp nil t)
39 (goto-char (match-beginning 0))
40 (if (re-search-forward "^$" nil t)
41 (goto-char (1- (match-beginning 0)))
51 (defun std11-header-string (pat &optional boundary)
52 (let ((case-fold-search t))
55 (std11-narrow-to-header boundary)
56 (goto-char (point-min))
58 (while (re-search-forward std11-field-head-regexp nil t)
60 (buffer-substring (match-beginning 0) (std11-field-end)))
61 (if (string-match pat field)
62 (setq header (concat header field "\n"))
67 (defun std11-header-string-except (pat &optional boundary)
68 (let ((case-fold-search t))
71 (std11-narrow-to-header boundary)
72 (goto-char (point-min))
74 (while (re-search-forward std11-field-head-regexp nil t)
76 (buffer-substring (match-beginning 0) (std11-field-end)))
77 (if (not (string-match pat field))
78 (setq header (concat header field "\n"))
83 (defun std11-narrow-to-header (&optional boundary)
85 (goto-char (point-min))
86 (if (re-search-forward
87 (concat "^\\(" (regexp-quote (or boundary "")) "\\)?$")
99 ;;; std11.el ends here