Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / miscellany / mhe / mh-repl.ml
1 ;  This autoloaded file implements the "r" command of mhe
2 (defun     
3     (&mh-repl actn exfl sm fn annotate ft
4         (save-window-excursion 
5             (error-occured
6                 (&mh-save-killbuffer)
7                 (temp-use-buffer (concat "+" mh-folder))
8                 (setq fn (&mh-get-fname))
9                 (setq annotate mh-annotate)
10                 (setq ft mh-folder-title)
11                 (temp-use-buffer "message")
12                 (setq mode-string "mhe")
13                 (setq sm mode-line-format)
14                 (message  "Replying to message " (&mh-get-msgnum) "...")
15                 (sit-for 0)
16                 (pop-to-buffer "message")
17                 (if (error-occured (read-file fn))
18                     (error-message "Message " fn " does not exist!"))
19                 (pop-to-buffer "reply") (erase-buffer)
20                 (insert-string "One moment, please....")
21                 (unlink-file (concat mh-path "/reply"))
22                 (error-occured 
23                     (send-to-shell 
24                         (concat mh-progs "/repl -build +" ft " "
25                                 (&mh-get-msgnum))
26                     ))
27                 (show-shell-errors)
28             )
29             (if (file-exists (concat mh-path "/reply"))
30                 (read-file (concat mh-path "/reply"))
31                 (error-message "Reply failed: cannot construct header"
32                     " (file " mh-path "/reply)")
33             )
34             (pop-to-buffer "reply")
35             (local-bind-to-key "exit-emacs" "\\18\\ 3")
36             (mail-mode) (end-of-file)
37             (setq exfl 0)
38             (while (= exfl 0)
39                    (error-occured
40                            (pop-to-buffer "message")
41                            (setq mode-line-format
42                                  "{%b}          %[^X^C exits to top level%]          %M")
43                            (pop-to-buffer "reply")
44                            (setq mode-line-format
45                                  (concat "{%b}"
46                                          "%[%p of " mh-path "/reply"
47                                          "%]    (^X^C exits to top level)     %M"))
48                            (&mh-restore-killbuffer)
49                            (recursive-edit)
50                            (setq mode-line-format
51                                  (concat "%[%p of " mh-path "/reply%]           %M"))
52                            (pop-to-buffer "message")
53                            (setq mode-line-format sm)
54                            (sit-for 0)
55                    )
56                    (setq actn (get-response "Ready to send. Action? (m, q, e, or ?) " "mMqQeE\\ 3
57                                   "m: mail it, q: quit, e: resume editing, ?: this msg."))
58                    (if (= actn 'm')
59                        (progn (message "Sending...") (sit-for 0)
60                               (pop-to-buffer "reply")
61                               (write-current-file)
62                               (send-to-shell 
63                                   (concat mh-progs "/send -noverbose "
64                                           mh-path "/reply"
65                                   ))
66                               (pop-to-buffer "message")
67                               (if annotate
68                                   (annotate "Replied")
69                               )
70                               (setq exfl 1))
71                        (= actn 'q')
72                        (progn
73                              (&mh-restore-killbuffer)
74                              (pop-to-buffer (concat "+" mh-folder))
75                              (delete-other-windows)
76                              (setq mode-line-format sm)
77                              (error-message "Message not sent; its text remains in buffer 'reply'")
78                        )
79                    )
80             )
81         )
82         (pop-to-buffer (concat "+" mh-folder)) (delete-other-windows)
83         (pop-to-buffer "message")
84         (setq mode-line-format sm) (previous-window)
85     )
86 )