3 ;;; name: mew-mailto.el
5 ;;; description: some mailto support for mew
6 ;;; creation date: 1998-11-07
7 ;;; author: "Sen Nagata" <sen@eccosys.com>
8 ;;; warning: not optimized at all
12 ;;; -mew (1.94 and up -- uses mew-user-agent-compose)
14 ;;; -thingatpt.el (comes w/ emacs) for thing-at-pt
18 ;;; -put this file (and rfc2368.el) in an appropriate directory (so emacs
24 ;;; (add-hook 'mew-init-hook (lambda () (require 'mew-mailto)))
26 ;;; in your .emacs file.
30 ;;; this package provides a number of interactive functions
31 ;;; (commands) for the user. each of the commands ultimately creates a
32 ;;; draft message based on some information. the names of the commands
33 ;;; and brief descriptions are:
35 ;;; 1) mew-mailto-compose-message-from-mailto-url
36 ;;; make a draft message from a user-specified mailto: url
38 ;;; 2) mew-mailto-compose-message-from-mailto-url-at-point
39 ;;; make a draft message from a mailto: url at point
44 ;;; -try out the commands mentioned above in 'details'
52 ;; fixed a bug in mew-mailto-compose-message-from-mailto-url that could
53 ;; lead to duplicate headers in messages
57 ;; added compatibility garbage for xemacs -- thingatpt.el vs browse-url.el
61 ;; rewrote to use rfc2368.el
62 ;; removed a lot of functionality
68 ;; modified the interface to mew-mailto-compose-message-from-mailto-url
69 ;; as suggested by Umekichi <umekichi@bu.iij4u.or.jp>. see the interface
70 ;; to browse-url-mail in browse-url.el for details.
72 ;; how should we handle the dependecy on mew?
73 ;; doing the following seems to have catastrophic effects on my machine :-(
80 (defconst mew-mailto-version "mew-mailto.el 0.6")
82 ;; use rfc2368 support -- should be useable for things other than mew too
85 ;; yucky compatibility stuff...
86 (if (and (string-match "^XEmacs \\([0-9.]+\\)" (emacs-version))
87 (< (string-to-int (match-string 1 (emacs-version))) 21))
88 ;; for xemacs versions less than 21, use browse-url.el
91 (fset 'mew-mailto-url-at-point
92 'browse-url-url-at-point))
93 ;; for everything else, use thingatpt.el
96 (fset 'mew-mailto-url-at-point
98 (thing-at-point 'url)))))
100 (defun mew-mailto-compose-message-from-mailto-url (url &optional dummy)
101 "Compose a message from URL. The optional second argument, DUMMY, exists
102 to match the interface provided by browse-url-mail -- DUMMY does not do
104 (interactive "sURL: ")
105 (if (string-match rfc2368-mailto-regexp url)
106 (let* ((other-headers (rfc2368-parse-mailto-url url))
107 ;; the reason i'm bothering to extract To and Subject is
108 ;; because i want them to appear at reasonable places in
109 ;; the headers (not in some random order) -- i'll need to
110 ;; do the same for any other headers that work that way too...
111 (to (cdr (assoc-ignore-case "to" other-headers)))
112 (subject (cdr (assoc-ignore-case "subject" other-headers))))
114 ;; if these are not removed from other-headers, we will get duplicates
115 (remove-alist 'other-headers "To")
116 (remove-alist 'other-headers "Subject")
118 ;; mew doesn't handle specifying a message body via
119 ;; mew-user-agent-compose yet -- rms said he would support
120 ;; specifying a body via the compose-mail interface after
121 ;; emacs 20.4 is released
122 (mew-user-agent-compose to subject other-headers))
123 (message "Not a mailto: url.")))
125 ;; prepare a message from a mailto: url at point
126 (defun mew-mailto-compose-message-from-mailto-url-at-point ()
127 "Compose a message from a mailto url found at point."
129 (let ((url (mew-mailto-url-at-point)))
130 (if (string-match rfc2368-mailto-regexp url)
131 (mew-mailto-compose-message-from-mailto-url url)
132 ;; tell the user that we didn't find a mailto: url at point
133 (message "No mailto: url detected at point."))))
135 ;; since this will be used via 'require'...
136 (provide 'mew-mailto)
138 ;; end of mew-mailto.el