1 ;;; wl-mailto.el -- some mailto support for wanderlust
3 ;;; Copyright (C) 1999 Sen Nagata
5 ;; Author: Sen Nagata <sen@eccosys.com>
8 ;; Warning: not optimized at all
10 ;; This file is not a part of GNU Emacs.
14 ;; required elisp packages:
19 ;; -thingatpt.el or browse-url.el
23 ;; -put this file (and rfc2368.el) in an appropriate directory (so Emacs
29 ;; (add-hook 'wl-init-hook (lambda () (require 'wl-mailto)))
35 ;; this package provides a number of interactive functions
36 ;; (commands) for the user. each of the commands ultimately creates a
37 ;; draft message based on some information. the names of the commands
38 ;; and brief descriptions are:
40 ;; 1) wl-mailto-compose-message-from-mailto-url
41 ;; make a draft message from a user-specified mailto: url
43 ;; 2) wl-mailto-compose-message-from-mailto-url-at-point
44 ;; make a draft message from a mailto: url at point
49 ;; -try out the commands mentioned above in 'details'
55 ;; wl-user-agent functionality merged into wl-draft.el, so removed
60 ;; incorporated a patch from Kenichi OKADA for
61 ;; wl-mailto-compose-message-from-mailto-url-at-point
72 ;; xemacs compatibility
76 ;; rewrote to use rfc2368.el and wl-user-agent.el
79 (defconst wl-mailto-version "wl-mailto.el 0.5")
81 ;; how should we handle the dependecy on wl?
86 ;; use rfc2368 support -- should be usable for things other than wl too
89 ;; yucky compatibility stuff -- someone help me w/ this, please...
90 (if (and (string-match "^XEmacs \\([0-9.]+\\)" (emacs-version))
91 (< (string-to-int (match-string 1 (emacs-version))) 21))
92 ;; for xemacs versions less than 21, use browse-url.el
95 (fset 'wl-mailto-url-at-point
96 'browse-url-url-at-point))
97 ;; for everything else, use thingatpt.el
100 (fset 'wl-mailto-url-at-point
102 (thing-at-point 'url)))))
104 (defun wl-mailto-compose-message-from-mailto-url (url &optional dummy)
105 "Compose a message from URL (RFC 2368).
106 The optional second argument, DUMMY, exists to match the interface
107 provided by `browse-url-mail' (w3) -- DUMMY does not do anything."
108 (interactive "sURL: ")
109 (if (string-match rfc2368-mailto-regexp url)
110 (let* ((other-headers (rfc2368-parse-mailto-url url))
111 (to (cdr (assoc-ignore-case "to" other-headers)))
112 (subject (cdr (assoc-ignore-case "subject" other-headers))))
114 (wl-user-agent-compose to subject other-headers))
115 (message "Not a mailto: url.")))
117 ;; prepare a message from a mailto: url at point
118 (defun wl-mailto-compose-message-from-mailto-url-at-point ()
119 "Draft a new message based on URL (RFC 2368) at point."
121 (let ((url (wl-mailto-url-at-point)))
122 (if (and url (string-match rfc2368-mailto-regexp url))
123 (wl-mailto-compose-message-from-mailto-url url)
124 ;; tell the user that we didn't find a mailto: url at point
125 (message "No mailto: url detected at point."))))
127 ;; since this will be used via 'require'...
130 ;;; wl-mailto.el ends here