New feature: toggle visibility of mime buttons.
[more-wl.git] / utils / wl-mailto.el
blobab95f8582ece0cb45b6f5d5d702a30829aee4e3b
1 ;;; wl-mailto.el -- some mailto support for wanderlust
3 ;;; Copyright (C) 1999 Sen Nagata
5 ;; Author: Sen Nagata <sen@eccosys.com>
6 ;; Version: 0.5
7 ;; License: GPL 2
8 ;; Warning: not optimized at all
10 ;; This file is not a part of GNU Emacs.
12 ;;; Commentary:
14 ;; required elisp packages:
16 ;; -wl (>= 0.9.6?)
18 ;; -rfc2368.el
19 ;; -thingatpt.el or browse-url.el
21 ;; installation:
23 ;; -put this file (and rfc2368.el) in an appropriate directory (so Emacs
24 ;; can find it)
26 ;; <necessary>
27 ;; -put:
29 ;; (add-hook 'wl-init-hook (lambda () (require 'wl-mailto)))
31 ;; in .emacs or .wl
33 ;; details:
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
46 ;; usage:
48 ;; -invoke wl
49 ;; -try out the commands mentioned above in 'details'
51 ;;; History:
53 ;; 0.5
55 ;; wl-user-agent functionality merged into wl-draft.el, so removed
56 ;; dependency
58 ;; 1999-06-24:
60 ;; incorporated a patch from Kenichi OKADA for
61 ;; wl-mailto-compose-message-from-mailto-url-at-point
63 ;; 1999-06-11:
65 ;; fixed a typo
67 ;; 0.4
69 ;; 1999-06-01:
71 ;; checkdoc checking
72 ;; xemacs compatibility
74 ;; 1999-05-31:
76 ;; rewrote to use rfc2368.el and wl-user-agent.el
78 ;;; Code:
79 (defconst wl-mailto-version "wl-mailto.el 0.5")
81 ;; how should we handle the dependecy on wl?
82 ;; will this work?
83 (eval-when-compile
84 (require 'wl)
85 (defun wl-mailto-url-at-point ()))
88 ;; use rfc2368 support -- should be usable for things other than wl too
89 (require 'rfc2368)
91 ;; yucky compatibility stuff -- someone help me w/ this, please...
92 (if (and (string-match "^XEmacs \\([0-9.]+\\)" (emacs-version))
93 (< (string-to-number (match-string 1 (emacs-version))) 21))
94 ;; for xemacs versions less than 21, use browse-url.el
95 (progn
96 (require 'browse-url)
97 (fset 'wl-mailto-url-at-point
98 'browse-url-url-at-point))
99 ;; for everything else, use thingatpt.el
100 (progn
101 (require 'thingatpt)
102 (fset 'wl-mailto-url-at-point
103 (lambda ()
104 (thing-at-point 'url)))))
106 (defun wl-mailto-compose-message-from-mailto-url (url &optional dummy)
107 "Compose a message from URL (RFC 2368).
108 The optional second argument, DUMMY, exists to match the interface
109 provided by `browse-url-mail' (w3) -- DUMMY does not do anything."
110 (interactive "sURL: ")
111 (if (string-match rfc2368-mailto-regexp url)
112 (let* ((other-headers (rfc2368-parse-mailto-url url))
113 (to (cdr (assoc-ignore-case "to" other-headers)))
114 (subject (cdr (assoc-ignore-case "subject" other-headers))))
116 (wl-user-agent-compose to subject other-headers))
117 (message "Not a mailto: url.")))
119 ;; prepare a message from a mailto: url at point
120 (defun wl-mailto-compose-message-from-mailto-url-at-point ()
121 "Draft a new message based on URL (RFC 2368) at point."
122 (interactive)
123 (let ((url (wl-mailto-url-at-point)))
124 (if (and url (string-match rfc2368-mailto-regexp url))
125 (wl-mailto-compose-message-from-mailto-url url)
126 ;; tell the user that we didn't find a mailto: url at point
127 (message "No mailto: url detected at point."))))
129 ;; since this will be used via 'require'...
130 (provide 'wl-mailto)
132 ;;; wl-mailto.el ends here