Mercurial > emacs
annotate lisp/mail/rfc2368.el @ 67788:114d965dfb60
Don't include sys/param.h.
(init_coercion_handler): Add extern.
[MAC_OS8] (main): Call init_coercion_handler.
(mac_initialize) [MAC_OSX]: Likewise.
[TARGET_API_MAC_CARBON] (mac_do_receive_drag): Use coercion of
Apple event data for translation from/to file names.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Sat, 24 Dec 2005 02:50:45 +0000 |
parents | fafd692d1e40 |
children | 067115a6e738 2d92f5c9d6ae |
rev | line source |
---|---|
28496 | 1 ;;; rfc2368.el --- support for rfc2368 |
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 | 4 ;; Keywords: mail |
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, |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
7 ;; 2005 Free Software Foundation, Inc. |
28496 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
28496 | 25 |
26 ;;; Commentary: | |
27 ;; | |
28 ;; notes: | |
29 ;; | |
30 ;; -repeat after me: "the colon is not part of the header name..." | |
31 ;; -if w3 becomes part of emacs, then it may make sense to have this | |
32 ;; file depend on w3 -- the maintainer of w3 says merging w/ Emacs | |
33 ;; is planned! | |
34 ;; | |
35 ;; historical note: | |
36 ;; | |
37 ;; this is intended as a replacement for mailto.el | |
38 ;; | |
39 ;; acknowledgements: | |
40 ;; | |
41 ;; the functions that deal w/ unhexifying in this file were basically | |
42 ;; taken from w3 -- i hope to replace them w/ something else soon OR | |
43 ;; perhaps if w3 becomes a part of emacs soon, use the functions from w3. | |
44 | |
45 ;;; History: | |
46 ;; | |
47 ;; 0.3: | |
48 ;; | |
49 ;; added the constant rfc2368-version | |
50 ;; implemented first potential fix for a bug in rfc2368-mailto-regexp | |
51 ;; implemented first potential fix for a bug in rfc2368-parse-mailto | |
52 ;; (both bugs reported by Kenichi OKADA) | |
53 ;; | |
54 ;; 0.2: | |
55 ;; | |
56 ;; started to use checkdoc | |
57 ;; | |
58 ;; 0.1: | |
59 ;; | |
60 ;; initial implementation | |
61 | |
62 ;;; Code: | |
63 | |
64 ;; only an approximation? | |
65 ;; see rfc 1738 | |
66 (defconst rfc2368-mailto-regexp | |
67 "^\\(mailto:\\)\\([^?]+\\)*\\(\\?\\(.*\\)\\)*" | |
68 "Regular expression to match and aid in parsing a mailto url.") | |
69 | |
70 ;; describes 'mailto:' | |
71 (defconst rfc2368-mailto-scheme-index 1 | |
72 "Describes the 'mailto:' portion of the url.") | |
73 ;; i'm going to call this part the 'prequery' | |
74 (defconst rfc2368-mailto-prequery-index 2 | |
75 "Describes the portion of the url between 'mailto:' and '?'.") | |
76 ;; i'm going to call this part the 'query' | |
77 (defconst rfc2368-mailto-query-index 4 | |
78 "Describes the portion of the url after '?'.") | |
79 | |
80 (defun rfc2368-unhexify-string (string) | |
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 | 87 |
88 (defun rfc2368-parse-mailto-url (mailto-url) | |
89 "Parse MAILTO-URL, and return an alist of header-name, header-value pairs. | |
90 MAILTO-URL should be a RFC 2368 (mailto) compliant url. A cons cell w/ a | |
91 key of 'Body' is a special case and is considered a header for this purpose. | |
92 The returned alist is intended for use w/ the `compose-mail' interface. | |
93 Note: make sure MAILTO-URL has been 'unhtmlized' (e.g. & -> &), before | |
94 calling this function." | |
95 (let ((case-fold-search t) | |
96 prequery query headers-alist) | |
97 | |
98 (if (string-match rfc2368-mailto-regexp mailto-url) | |
99 (progn | |
100 | |
101 (setq prequery | |
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 | 104 (setq query |
105 (match-string rfc2368-mailto-query-index mailto-url)) | |
106 | |
107 ;; build alist of header name-value pairs | |
108 (if (not (null query)) | |
109 (setq headers-alist | |
110 (mapcar | |
111 (lambda (x) | |
112 (let* ((temp-list (split-string x "=")) | |
113 (header-name (car temp-list)) | |
114 (header-value (cadr temp-list))) | |
115 ;; return ("Header-Name" . "header-value") | |
116 (cons | |
117 (capitalize (rfc2368-unhexify-string header-name)) | |
118 (rfc2368-unhexify-string header-value)))) | |
119 (split-string query "&")))) | |
120 | |
121 ;; deal w/ multiple 'To' recipients | |
122 (if prequery | |
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 | 125 (if (assoc "To" headers-alist) |
126 (let* ((our-cons-cell | |
127 (assoc "To" headers-alist)) | |
128 (our-cdr | |
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 | 131 (setq headers-alist |
132 (cons (cons "To" prequery) headers-alist))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
28520
diff
changeset
|
133 |
28496 | 134 headers-alist) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
28520
diff
changeset
|
135 |
28496 | 136 (error "Failed to match a mailto: url")) |
137 )) | |
138 | |
139 (provide 'rfc2368) | |
140 | |
52401 | 141 ;;; arch-tag: ea804934-ad96-4f69-957b-857a76e4fd95 |
28496 | 142 ;;; rfc2368.el ends here |