Mercurial > emacs
annotate lisp/url/url-mailto.el @ 64988:94244c068735
Remove reference to UDP server processes hanging on Windows
(fixed by Kim F. Storm).
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 15 Aug 2005 13:54:37 +0000 |
parents | 875dcc490074 |
children | 915d671fef52 |
rev | line source |
---|---|
54695 | 1 ;;; url-mail.el --- Mail Uniform Resource Locator retrieval code |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
5 |
54695 | 6 ;; Keywords: comm, data, processes |
7 | |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
9 ;; |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
13 ;; any later version. |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
14 ;; |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
18 ;; GNU General Public License for more details. |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
19 ;; |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64084 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
24 |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
25 ;;; Commentary: |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
26 |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
27 ;;; Code: |
54695 | 28 |
29 (require 'url-vars) | |
30 (require 'url-parse) | |
31 (require 'url-util) | |
32 | |
33 ;;;###autoload | |
34 (defun url-mail (&rest args) | |
35 (interactive "P") | |
36 (if (fboundp 'message-mail) | |
37 (apply 'message-mail args) | |
38 (or (apply 'mail args) | |
39 (error "Mail aborted")))) | |
40 | |
41 (defun url-mail-goto-field (field) | |
42 (if (not field) | |
43 (goto-char (point-max)) | |
44 (let ((dest nil) | |
45 (lim nil) | |
46 (case-fold-search t)) | |
47 (save-excursion | |
48 (goto-char (point-min)) | |
49 (if (re-search-forward (regexp-quote mail-header-separator) nil t) | |
50 (setq lim (match-beginning 0))) | |
51 (goto-char (point-min)) | |
52 (if (re-search-forward (concat "^" (regexp-quote field) ":") lim t) | |
53 (setq dest (match-beginning 0)))) | |
54 (if dest | |
55 (progn | |
56 (goto-char dest) | |
57 (end-of-line)) | |
58 (goto-char lim) | |
59 (insert (capitalize field) ": ") | |
60 (save-excursion | |
61 (insert "\n")))))) | |
62 | |
63 ;;;###autoload | |
64 (defun url-mailto (url) | |
65 "Handle the mailto: URL syntax." | |
66 (if (url-user url) | |
58139
9eeb05e27d32
url-mailto.el (url-mailto): Fix a typo in the comment.
Masatake YAMATO <jet@gyve.org>
parents:
57511
diff
changeset
|
67 ;; malformed mailto URL (mailto://wmperry@gnu.org) instead of |
54695 | 68 ;; mailto:wmperry@gnu.org |
69 (url-set-filename url (concat (url-user url) "@" (url-filename url)))) | |
70 (setq url (url-filename url)) | |
71 (let (to args source-url subject func headers-start) | |
72 (if (string-match (regexp-quote "?") url) | |
73 (setq headers-start (match-end 0) | |
74 to (url-unhex-string (substring url 0 (match-beginning 0))) | |
75 args (url-parse-query-string | |
76 (substring url headers-start nil) t)) | |
77 (setq to (url-unhex-string url))) | |
78 (setq source-url (url-view-url t)) | |
79 (if (and url-request-data (not (assoc "subject" args))) | |
80 (setq args (cons (list "subject" | |
81 (concat "Automatic submission from " | |
82 url-package-name "/" | |
83 url-package-version)) args))) | |
84 (if (and source-url (not (assoc "x-url-from" args))) | |
85 (setq args (cons (list "x-url-from" source-url) args))) | |
86 | |
87 (if (assoc "to" args) | |
57511 | 88 (push (cdr (assoc "to" args)) to) |
54695 | 89 (setq args (cons (list "to" to) args))) |
90 (setq subject (cdr-safe (assoc "subject" args))) | |
91 (if (fboundp url-mail-command) (funcall url-mail-command) (mail)) | |
92 (while args | |
93 (if (string= (caar args) "body") | |
94 (progn | |
95 (goto-char (point-max)) | |
96 (insert (mapconcat 'identity (cdar args) "\n"))) | |
97 (url-mail-goto-field (caar args)) | |
98 (setq func (intern-soft (concat "mail-" (caar args)))) | |
99 (insert (mapconcat 'identity (cdar args) ", "))) | |
100 (setq args (cdr args))) | |
101 ;; (url-mail-goto-field "User-Agent") | |
102 ;; (insert url-package-name "/" url-package-version " URL/" url-version) | |
103 (if (not url-request-data) | |
104 (progn | |
105 (set-buffer-modified-p nil) | |
106 (if subject | |
107 (url-mail-goto-field nil) | |
108 (url-mail-goto-field "subject"))) | |
109 (if url-request-extra-headers | |
110 (mapconcat | |
111 (lambda (x) | |
112 (url-mail-goto-field (car x)) | |
113 (insert (cdr x))) | |
114 url-request-extra-headers "")) | |
115 (goto-char (point-max)) | |
116 (insert url-request-data) | |
117 ;; It seems Microsoft-ish to send without warning. | |
118 ;; Fixme: presumably this should depend on a privacy setting. | |
119 (if (y-or-n-p "Send this auto-generated mail? ") | |
120 (cond ((eq url-mail-command 'compose-mail) | |
121 (funcall (get mail-user-agent 'sendfunc) nil)) | |
122 ;; otherwise, we can't be sure | |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
123 ((fboundp 'message-send-and-exit) |
54695 | 124 (message-send-and-exit)) |
125 (t (mail-send-and-exit nil))))) | |
126 nil)) | |
127 | |
128 (provide 'url-mailto) | |
54699 | 129 |
54800
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
130 ;; arch-tag: 7b7ad52e-8760-497b-9444-75fae14e34c5 |
bab00fb32e72
(url-mailto): Avoid warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
131 ;;; url-mailto.el ends here |