1 ;;; muse-message.el --- Publish a file as an email message.
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 ;; This file is not part of GNU Emacs.
7 ;; This is free software; you can redistribute it and/or modify it under
8 ;; the terms of the GNU General Public License as published by the Free
9 ;; Software Foundation; either version 2, or (at your option) any later
12 ;; This is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 ;; MA 02111-1307, USA.
24 ;; To make use of this file, put (require 'muse-message) in your .emacs.
26 ;; By default, the way to mark up an email message is to do the
29 ;; - Enter Message mode. This is usually done automatically when you
30 ;; compose an email message using your Emacs mail client of choice.
32 ;; - Use standard Muse markup instead of plain text for your message.
34 ;; - When you are ready to see what the email message will look like,
35 ;; do `M-x muse-message-markup'. This will make two versions of
36 ;; your message: plaintext and HTML.
38 ;; - If you want to do further editing, simply undo your changes,
39 ;; edit some more, and run `muse-message-markup' when you're ready
42 ;; - Send the message.
44 ;; If you wish the markup to be automatic at the time of sending you
45 ;; message (a risky proposition), just add `muse-message-markup' to
46 ;; `message-send-hook'.
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54 ;; Muse E-Mail Publishing (via alternative/html)
56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
61 (require 'muse-publish
)
64 (defgroup muse-message nil
65 "Options controlling the behaviour of Emacs Wiki Mail Markup."
69 (defcustom muse-message-publishing-style
"message"
70 "Style used for publishing the alternative/text section of a message."
74 (defcustom muse-message-html-publishing-style
"message-html"
75 "Style used for publishing the alternative/html section of a message."
79 (defcustom muse-message-indent
" "
80 "String used to pad indentend text."
84 (defcustom muse-message-style-sheet
86 background: white; color: black;
87 margin-left: 3%; margin-right: 7%;
91 p.verse { margin-left: 3% }
93 .example { margin-left: 3% }
99 h3 { margin-bottom: 0px; }"
100 "Text to prepend to a Muse mail message being published.
101 This text may contain <lisp> markup tags."
103 :group
'muse-message
)
105 (defcustom muse-message-html-header
106 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
109 <title><lisp>(muse-publishing-directive \"title\")</lisp></title>
110 <meta name=\"generator\" content=\"muse-message.el\">
111 <link rev=\"made\" href=\"<lisp>user-mail-address</lisp>\">
112 <style type=\"text/css\">
113 <lisp>muse-message-style-sheet</lisp>
117 <!-- Mail published by Emacs Muse begins here -->\n"
118 "Text to prepend to a Muse mail message being published.
119 This text may contain <lisp> markup tags."
121 :group
'muse-message
)
123 (defcustom muse-message-html-footer
124 "\n <!-- Mail published by Emacs Muse ends here -->
127 "Text to append to a Muse mail message being published.
128 This text may contain <lisp> markup tags."
130 :group
'muse-message
)
132 (defcustom muse-message-markup-functions
133 '((link . muse-message-markup-link
))
134 "An alist of style types to custom functions for that kind of text.
135 For more on the structure of this list, see
136 `muse-publish-markup-functions'."
137 :type
'(alist :key-type symbol
:value-type function
)
138 :group
'muse-message
)
140 (defcustom muse-message-markup-strings
141 '((rule .
" * * * *")
143 (end-verse-line .
"\n ")
146 (begin-underline .
"_")
147 (end-underline .
"_")
148 (begin-literal .
"`")
152 (begin-more-emph .
"*")
153 (end-more-emph .
"*")
154 (begin-most-emph .
"*/")
155 (end-most-emph .
"/*"))
156 "Strings used for marking up message text."
157 :type
'(alist :key-type symbol
:value-type string
)
158 :group
'muse-message
)
160 (defcustom muse-message-markup-tags
161 '(("example" t nil muse-message-example-tag
)
162 ("contents" nil t muse-message-contents-tag
))
163 "A list of tag specifications, for specially marking up text.
164 See the documentation for `muse-publish-markup-tags'."
165 :type
'(repeat (list (string :tag
"Markup tag")
166 (boolean :tag
"Expect closing tag" :value t
)
167 (boolean :tag
"Parse attributes" :value nil
)
169 :group
'muse-message
)
171 (defcustom muse-message-markup-specials nil
172 "A table of characters which must be represented specially."
173 :type
'(alist :key-type character
:value-type string
)
174 :group
'muse-message
)
176 (defun muse-message-markup-link ()
177 (let ((desc (match-string 2))
178 (url (match-string 1)))
180 (delete-region (match-beginning 0) (match-end 0))
181 (when desc
(insert desc
))
183 (Footnote-add-footnote)
187 (defun muse-message-example-tag (beg end
)
188 "Mark up example and code by simply indenting them."
189 (muse-publish-escape-specials beg end
)
193 (string-rectangle beg
(point) muse-message-indent
)
194 (muse-publish-mark-read-only beg
(point)))
197 (defun muse-message-markup ()
198 "Markup a wiki-ish e-mail message as HTML alternative e-mail.
199 This step is manual by default, to give the author a chance to review
200 the results and ensure they are appropriate.
201 If you wish it to be automatic (a risky proposition), just add this
202 function to `message-send-hook'."
206 (let ((text (buffer-substring-no-properties (point) (point-max)))
207 (subject (message-fetch-field "subject"))
208 (encoding (muse-html-encoding)))
209 (delete-region (point) (point-max))
211 "<#multipart type=alternative>\n"
212 "<#part type=text/plain charset=\"" encoding
"\" nofile=yes>\n"
215 (muse-publish-markup-buffer
216 subject muse-message-publishing-style
)
217 (buffer-substring-no-properties (point-min) (point-max)))
218 "\n<#part type=text/html charset=\"" encoding
"\" nofile=yes>\n"
221 (muse-publish-markup-buffer
222 subject muse-message-html-publishing-style
)
223 (buffer-substring-no-properties (point-min) (point-max)))
224 "<#/multipart>\n"))))
226 (unless (assoc "message" muse-publishing-styles
)
227 (muse-define-style "message"
228 :functions
'muse-message-markup-functions
229 :strings
'muse-message-markup-strings
230 :tags
'muse-message-markup-tags
)
232 (muse-derive-style "message-html" "html"
233 :header
'muse-message-html-header
234 :footer
'muse-message-html-footer
)
236 (muse-derive-style "message-xhtml" "xhtml"
237 :header
'muse-message-html-header
238 :footer
'muse-message-html-footer
))
240 (provide 'muse-message
)
242 ;;; muse-message.el ends here