annotate lisp/mail/rfc2368.el @ 90560:c443c8a56b84

(ftxfont_match): New function. (syms_of_ftxfont): Set ftxfont_driver.match to ftxfont_match.
author Kenichi Handa <handa@m17n.org>
date Tue, 01 Aug 2006 01:19:31 +0000
parents c5406394f567
children 6588c6259dfb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; rfc2368.el --- support for rfc2368
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
28520
afc8a292184c Correct author's email address.
Gerd Moellmann <gerd@gnu.org>
parents: 28500
diff changeset
3 ;; Author: Sen Nagata <sen@eccosys.com>
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 ;; Keywords: mail
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
6 ;; Copyright (C) 1998, 2000, 2002, 2003, 2004,
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64754
diff changeset
7 ;; 2005, 2006 Free Software Foundation, Inc.
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; any later version.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 55529
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 55529
diff changeset
24 ;; Boston, MA 02110-1301, USA.
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; notes:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; -repeat after me: "the colon is not part of the header name..."
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; -if w3 becomes part of emacs, then it may make sense to have this
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; file depend on w3 -- the maintainer of w3 says merging w/ Emacs
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; is planned!
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; historical note:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; this is intended as a replacement for mailto.el
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; acknowledgements:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; the functions that deal w/ unhexifying in this file were basically
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; taken from w3 -- i hope to replace them w/ something else soon OR
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; perhaps if w3 becomes a part of emacs soon, use the functions from w3.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;; History:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; 0.3:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; added the constant rfc2368-version
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; implemented first potential fix for a bug in rfc2368-mailto-regexp
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; implemented first potential fix for a bug in rfc2368-parse-mailto
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; (both bugs reported by Kenichi OKADA)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; 0.2:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; started to use checkdoc
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; 0.1:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;;
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; initial implementation
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;;; Code:
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;; only an approximation?
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; see rfc 1738
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (defconst rfc2368-mailto-regexp
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 "^\\(mailto:\\)\\([^?]+\\)*\\(\\?\\(.*\\)\\)*"
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 "Regular expression to match and aid in parsing a mailto url.")
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; describes 'mailto:'
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 (defconst rfc2368-mailto-scheme-index 1
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 "Describes the 'mailto:' portion of the url.")
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; i'm going to call this part the 'prequery'
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (defconst rfc2368-mailto-prequery-index 2
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 "Describes the portion of the url between 'mailto:' and '?'.")
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; i'm going to call this part the 'query'
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (defconst rfc2368-mailto-query-index 4
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 "Describes the portion of the url after '?'.")
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (defun rfc2368-unhexify-string (string)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 "Unhexify STRING -- e.g. 'hello%20there' -> 'hello there'."
54306
b3fd1d53ef39 (rfc2368-unhexify-char): Deleted.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
82 (replace-regexp-in-string "%[[:xdigit:]]\\{2\\}"
b3fd1d53ef39 (rfc2368-unhexify-char): Deleted.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
83 (lambda (match)
b3fd1d53ef39 (rfc2368-unhexify-char): Deleted.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
84 (string (string-to-number (substring match 1)
b3fd1d53ef39 (rfc2368-unhexify-char): Deleted.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
85 16)))
b3fd1d53ef39 (rfc2368-unhexify-char): Deleted.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
86 string t t))
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (defun rfc2368-parse-mailto-url (mailto-url)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 "Parse MAILTO-URL, and return an alist of header-name, header-value pairs.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 MAILTO-URL should be a RFC 2368 (mailto) compliant url. A cons cell w/ a
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 key of 'Body' is a special case and is considered a header for this purpose.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 The returned alist is intended for use w/ the `compose-mail' interface.
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 Note: make sure MAILTO-URL has been 'unhtmlized' (e.g. &amp; -> &), before
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 calling this function."
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (let ((case-fold-search t)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 prequery query headers-alist)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (if (string-match rfc2368-mailto-regexp mailto-url)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (progn
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (setq prequery
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (match-string rfc2368-mailto-prequery-index mailto-url))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 28520
diff changeset
103
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (setq query
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (match-string rfc2368-mailto-query-index mailto-url))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 ;; build alist of header name-value pairs
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (if (not (null query))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (setq headers-alist
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (mapcar
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (lambda (x)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (let* ((temp-list (split-string x "="))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (header-name (car temp-list))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (header-value (cadr temp-list)))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 ;; return ("Header-Name" . "header-value")
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (cons
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (capitalize (rfc2368-unhexify-string header-name))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (rfc2368-unhexify-string header-value))))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (split-string query "&"))))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 ;; deal w/ multiple 'To' recipients
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (if prequery
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (progn
55529
455a962a0dba (rfc2368-parse-mailto-url): Make the results of
Eli Zaretskii <eliz@gnu.org>
parents: 54306
diff changeset
124 (setq prequery (rfc2368-unhexify-string prequery))
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (if (assoc "To" headers-alist)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (let* ((our-cons-cell
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (assoc "To" headers-alist))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (our-cdr
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (cdr our-cons-cell)))
55529
455a962a0dba (rfc2368-parse-mailto-url): Make the results of
Eli Zaretskii <eliz@gnu.org>
parents: 54306
diff changeset
130 (setcdr our-cons-cell (concat prequery ", " our-cdr)))
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (setq headers-alist
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (cons (cons "To" prequery) headers-alist)))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 28520
diff changeset
133
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 headers-alist)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 28520
diff changeset
135
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (error "Failed to match a mailto: url"))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ))
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (provide 'rfc2368)
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
141 ;;; arch-tag: ea804934-ad96-4f69-957b-857a76e4fd95
28496
92a9591b21a2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 ;;; rfc2368.el ends here