1 ;;; mew-message.el --- Message mode for Mew
3 ;; Author: Kazu Yamamoto <Kazu@Mew.org>
4 ;; Created: Oct 2, 1996
5 ;; Revised: Aug 30, 1999
9 (defconst mew-message-version "mew-message.el version 0.12")
12 (if mew-xemacs-p (require 'easymenu))
14 (defvar mew-message-mode-map nil)
16 (defvar mew-message-mode-menu-spec
18 ["Next part" mew-message-next-msg t]
19 ["Prev part" mew-message-prev-msg t]
20 ["Next page" mew-message-next-page t]
21 ["Prev page" mew-message-prev-page t]
22 ["Goto summary" mew-message-goto-summary t]
25 ["Reply" mew-message-reply t]
26 ["Reply with citation" mew-message-reply-with-citation t]
27 ["Forward" mew-message-forward t])))
29 (if mew-message-mode-map
31 (setq mew-message-mode-map (make-sparse-keymap))
32 (define-key mew-message-mode-map " " 'mew-message-next-page)
33 (define-key mew-message-mode-map "\177" 'mew-message-prev-page)
34 (define-key mew-message-mode-map "n" 'mew-message-next-msg)
35 (define-key mew-message-mode-map "p" 'mew-message-prev-msg)
36 (define-key mew-message-mode-map "h" 'mew-message-goto-summary)
37 (define-key mew-message-mode-map "a" 'mew-message-reply)
38 (define-key mew-message-mode-map "A" 'mew-message-reply-with-citation)
39 (define-key mew-message-mode-map "f" 'mew-message-forward)
40 (define-key mew-message-mode-map "r" 'mew-message-resend)
45 "Menu used in Message mode."
46 mew-message-mode-menu-spec)))
52 (defun mew-message-mode ()
53 "\\<mew-message-mode-map>
54 Mew Message mode:: major mode for display a message.
55 The keys that are defined for this mode are:
57 \\[mew-message-next-page] Scroll up this message.
58 \\[mew-message-prev-page] Back-scroll this message.
59 \\[mew-message-next-msg] Display a message or a part below.
60 \\[mew-message-prev-msg] Display a message or a part above.
61 \\[mew-message-goto-summary] Get back to Summary mode.
62 \\[mew-message-reply] Answer to this message. A new draft is prepared in Draft mode.
63 Mew automatically decides To: and Cc:.
64 \\[mew-message-reply-with-citation] Answer to this message. A new draft is prepared in Draft mode.
65 Mew automatically decides To: and Cc: and cites the body.
66 \\[mew-message-forward] Forward this message to a third person. A new draft is prepared in
67 Draft mode and this message is automatically attached.
70 (setq major-mode 'mew-message-mode)
71 (setq mode-name "Message")
72 (setq mode-line-buffer-identification mew-mode-line-id)
73 (use-local-map mew-message-mode-map)
74 (setq buffer-read-only t)
75 (make-local-variable 'page-delimiter)
76 (setq page-delimiter mew-page-delimiter)
77 (run-hooks 'mew-message-mode-hook))
79 (defun mew-message-next-page (&optional lines)
80 "Scroll up this message. Return 'nil' if more pages. Otherwise, return 't'."
82 (move-to-window-line -1)
85 (and (pos-visible-in-window-p) (eobp)))
86 ;; Nothing in this page.
87 (if (or (null mew-break-pages)
90 (widen) (forward-line) (eobp)))) ;; Real end of buffer?
92 ;; Go to the next page.
93 (mew-message-narrow-to-page 1)
99 (goto-char (point-max))
100 (message "End of buffer")))
103 (defun mew-message-prev-page (&optional lines)
104 "Back-scroll this message. Return 'nil' if more pages.
105 Otherwise, return 't'."
107 (move-to-window-line 0)
110 (and (pos-visible-in-window-p) (bobp)))
111 ;; Nothing in this page.
112 (if (or (null mew-break-pages)
114 (widen) (bobp))) ;; Real beginning of buffer?
116 ;; Go to the previous page.
117 (mew-message-narrow-to-page -1)
119 ;; More in this page.
123 (goto-char (point-min))
124 (message "Beginning of buffer")))
127 (defun mew-message-narrow-to-page (&optional arg)
129 (setq arg (if arg (prefix-numeric-value arg) 0))
132 (forward-page -1) ;; Beginning of the current page.
133 (beginning-of-buffer ()))
134 (forward-char 1) ;; for compatibility with emacs-19.28 and emacs-19.29
137 ((> arg 0) (forward-page arg))
138 ((< arg 0) (forward-page (1- arg))))
144 (if (and (eolp) (not (bobp)))
148 (defun mew-message-goto-summary ()
149 "Get back to Summary mode."
151 (let* ((sum-num (mew-current-get 'message))
154 (if (not (get-buffer sum))
155 (message "No Summary mode for %s" sum)
156 (mew-pop-to-buffer sum)
158 (mew-summary-jump-message num)))))
160 (defun mew-message-reply ()
161 "Answer to this message. A new draft is prepared in Draft mode.
162 Mew automatically decides To: and Cc:."
164 (mew-message-goto-summary)
165 (call-interactively 'mew-summary-reply))
167 (defun mew-message-reply-with-citation ()
168 "Answer to this message. A new draft is prepared in Draft mode.
169 Mew automatically decides To: and Cc: and cites the body."
171 (mew-message-goto-summary)
172 (call-interactively 'mew-summary-reply-with-citation))
174 (defun mew-message-forward ()
175 "Forward this message to a third person. A new draft is prepared in
176 Draft mode and this message is automatically attached."
178 (mew-message-goto-summary)
179 (call-interactively 'mew-summary-forward))
181 (defun mew-message-resend ()
182 "\\<mew-message-mode-map>
183 Resend this message with Resent-To:. It is strongly
184 discouraged to use this command since beginners are always
185 confused. Please use '\\[mew-message-forward]' instead."
187 (mew-message-goto-summary)
188 (call-interactively 'mew-summary-resend))
190 (defun mew-message-next-msg (&optional arg)
191 "Display a message or a part below."
193 (let* ((obuf (current-buffer))
194 (buf (window-buffer (previous-window))))
195 (mew-pop-to-buffer buf) ;; for the next forward-line
196 (if (not (or (eq major-mode 'mew-summary-mode)
197 (eq major-mode 'mew-virtual-mode)))
199 (forward-line arg) ;; minus arg results in prev
200 (mew-summary-display 'force))
202 (mew-pop-to-buffer obuf)))
204 (defun mew-message-prev-msg (&optional arg)
205 "Display a message or a part above."
207 (mew-message-next-msg (- arg)))
209 (provide 'mew-message)
211 ;;; Copyright Notice:
213 ;; Copyright (C) 1996, 1997, 1998, 1999 Mew developing team.
214 ;; All rights reserved.
216 ;; Redistribution and use in source and binary forms, with or without
217 ;; modification, are permitted provided that the following conditions
220 ;; 1. Redistributions of source code must retain the above copyright
221 ;; notice, this list of conditions and the following disclaimer.
222 ;; 2. Redistributions in binary form must reproduce the above copyright
223 ;; notice, this list of conditions and the following disclaimer in the
224 ;; documentation and/or other materials provided with the distribution.
225 ;; 3. Neither the name of the team nor the names of its contributors
226 ;; may be used to endorse or promote products derived from this software
227 ;; without specific prior written permission.
229 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
230 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
232 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
233 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
234 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
235 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
236 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
237 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
238 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
239 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
241 ;;; mew-message.el ends here