File: mew-message.el

package info (click to toggle)
mew 1.93b33-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 2,072 kB
  • ctags: 1,720
  • sloc: lisp: 13,877; ansic: 2,325; sh: 305; makefile: 174; perl: 23
file content (260 lines) | stat: -rw-r--r-- 8,674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
;;; mew-message.el --- Message mode for Mew

;; Author:  Kazu Yamamoto <Kazu@Mew.org>
;; Created: Oct  2, 1996
;; Revised: Oct 25, 1997

;;; Code:

(defconst mew-message-version "mew-message.el version 0.10")

(require 'mew)
(if mew-xemacs-p (require 'easymenu))

(defvar mew-message-mode-map nil)

(defvar mew-message-mode-menu-spec
  '("Mew/message"
    ["Next part"    mew-message-next-msg t]
    ["Prev part"    mew-message-prev-msg t]
    ["Next page"    mew-message-next-page t]
    ["Prev page"    mew-message-prev-page t]
    ["Goto summary" mew-message-goto-summary t]
    "---"
    ("Reply/Forward"
     ["Reply"               mew-message-reply t]
     ["Reply with citation" mew-message-reply-with-citation t]
     ["Forward"             mew-message-forward t]
     ["Redistribute"        mew-message-redist t]
     )
    )
  )

(if mew-message-mode-map
    ()
  (setq mew-message-mode-map (make-sparse-keymap))
  (define-key mew-message-mode-map " "    'mew-message-next-page)
  (define-key mew-message-mode-map "\177" 'mew-message-prev-page)
  (define-key mew-message-mode-map "n"    'mew-message-next-msg)
  (define-key mew-message-mode-map "p"    'mew-message-prev-msg)
  (define-key mew-message-mode-map "h"    'mew-message-goto-summary)
  (define-key mew-message-mode-map "a"    'mew-message-reply)
  (define-key mew-message-mode-map "A"    'mew-message-reply-with-citation)
  (define-key mew-message-mode-map "f"    'mew-message-forward)
  (define-key mew-message-mode-map "r"    'mew-message-redist)
  (if mew-temacs-p
      (easy-menu-define
       mew-message-mode-menu
       mew-message-mode-map
       "Menu used in Mew message mode."
       mew-message-mode-menu-spec)
    )
  )

;;;
;;; Message mode
;;;

(defun mew-message-mode ()
  "Major mode for display a message.
The keys that are defined for this mode are:

SPC	Scroll up this message.
DEL	Back-scroll this message.
n	Display a message or a part below.
p	Display a message or a part above.
h	Get back to Summary mode.
a	Answer to this message. A new draft is prepared in Draft mode. 
	Mew automatically decides To: and Cc:.
A	Answer to this message. A new draft is prepared in Draft mode. 
	Mew automatically decides To: and Cc: and cites the body.
f	Forward this message to a third person. A new draft is prepared in 
	Draft mode and this message is automatically attached.
r	Re-distribute this message with Resent-To:. It is strongly 
	discouraged to use this command since beginners are always 
	confused. Please use 'f' instead.
"
  (interactive)
  (setq major-mode 'mew-message-mode)
  (setq mode-name "Message")
  (setq mode-line-buffer-identification mew-mode-line-id)
  (use-local-map mew-message-mode-map)
  (setq buffer-read-only t)
  (setq mew-message-citation 'header)
  (make-local-variable 'page-delimiter)
  (setq page-delimiter mew-page-delimiter)
  (run-hooks 'mew-message-mode-hook)
  )

(defun mew-message-next-page (&optional lines)
  "Scroll up this message. Return nil if more pages. Otherwise, return t."
  (interactive)
  (move-to-window-line -1)
  (if (save-excursion
        (end-of-line)
        (and (pos-visible-in-window-p) (eobp)))
      ;; Nothing in this page.
      (if (or (null mew-break-pages)
	      (save-excursion
		(save-restriction
		  (widen) (forward-line) (eobp)))) ;; Real end of buffer?
	  t
	;; Go to the next page.
	(mew-message-narrow-to-page 1)
	nil
	)
    ;; More in this page.
    (condition-case nil
	(scroll-up lines)
      (end-of-buffer
       (goto-char (point-max))
       (message "End of buffer")))
    nil
    ))

(defun mew-message-prev-page (&optional lines)
  "Back-scroll this message. Return nil if more pages. Otherwise, return t."
  (interactive)
  (move-to-window-line 0)
  (if (save-excursion
	(beginning-of-line)
	(and (pos-visible-in-window-p) (bobp)))
      ;; Nothing in this page.
      (if (or (null mew-break-pages)
	      (save-restriction
		(widen) (bobp))) ;; Real beginning of buffer?
	  t
	;; Go to the previous page.
	(mew-message-narrow-to-page -1)
	nil
	)
    ;; More in this page.
    (condition-case nil
	(scroll-down lines)
      (beginning-of-buffer
       (goto-char (point-min))
       (message "Beginning of buffer")))
    nil
    ))

(defun mew-message-narrow-to-page (&optional arg)
  (interactive "P")
  (setq arg (if arg (prefix-numeric-value arg) 0))
  (save-excursion
    (forward-page -1) ;;Beginning of the current page.
    (forward-char 1)  ;; for compatibility with emacs-19.28 and emacs-19.29
    (widen)
    (cond
     ((> arg 0)	(forward-page arg))
     ((< arg 0) (forward-page (1- arg)))
     )
    (forward-page)
    (narrow-to-region
     (point)
     (progn
       (forward-page -1)
       (if (and (eolp) (not (bobp)))
	   (forward-line))
       (point)))))

(defun mew-message-goto-summary ()
  "Get back to Summary mode."
  (interactive)
  (let* ((sum-num (mew-current-get 'message))
	 (sum (car sum-num))
	 (num (cdr sum-num)))
    (if (not (get-buffer sum))
	(message "No Summary mode for %s" sum)
      (mew-pop-to-buffer sum)
      (if num
	  (mew-summary-jump-message num)))))

(defun mew-message-reply ()
  "Answer to this message. A new draft is prepared in Draft mode. 
Mew automatically decides To: and Cc:."
  (interactive)
  (mew-message-goto-summary)
  (call-interactively 'mew-summary-reply))

(defun mew-message-reply-with-citation ()
  "Answer to this message. A new draft is prepared in Draft mode. 
Mew automatically decides To: and Cc: and cites the body."
  (interactive)
  (mew-message-goto-summary)
  (call-interactively 'mew-summary-reply-with-citation))

(defun mew-message-forward ()
  "Forward this message to a third person. A new draft is prepared in 
Draft mode and this message is automatically attached."
  (interactive)
  (mew-message-goto-summary)
  (call-interactively 'mew-summary-forward))

(defun mew-message-redist ()
  "Re-distribute this message with Resent-To:. It is strongly 
discouraged to use this command since beginners are always 
confused. Please use 'f' instead."
  (interactive)
  (mew-message-goto-summary)
  (call-interactively 'mew-summary-redist))
 
;;; hack hack 
;;; Now folder name and buffer name is different

(defun mew-message-next-msg (&optional arg)
  "Display a message or a part below."
  (interactive "p")
  (let* ((obuf (current-buffer))
	 (buf (window-buffer (previous-window)))
	 (buffer-read-only nil))
    (mew-pop-to-buffer buf) ;; for the next forward-line
    (if (not (or (eq major-mode 'mew-summary-mode)
		 (eq major-mode 'mew-virtual-mode)))
	()
      (forward-line arg) ;; minus arg results in prev
      (mew-summary-display))
    (mew-pop-to-buffer obuf) ;; for window config
    ))
      
(defun mew-message-prev-msg (&optional arg)
  "Display a message or a part above."
  (interactive "p")
  (mew-message-next-msg (- arg)))

(provide 'mew-message)

;;; Copyright Notice:

;; Copyright (C) 1996, 1997, 1998 Mew developing team.
;; All rights reserved.

;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;; 
;; 1. Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;; 2. Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;; 3. All advertising materials mentioning features or use of this software
;;    must display the following acknowledgement:
;;       This product includes software developed by 
;;       Mew developing team and its contributors.
;; 4. Neither the name of the team nor the names of its contributors
;;    may be used to endorse or promote products derived from this software
;;    without specific prior written permission.
;; 
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

;;; mew-message.el ends here