Added -clobber switch to mhstore(1) [Bug #11160].
[mmh] / docs / historical / mh-6.8.5 / miscellany / mhe / mh-exit.ml
1 ; This file implements the autoloaded "exit" function (not a command) of mhe.
2 (defun 
3     (&mh-exit ans retval
4         (temp-use-buffer "cmd-buffer")
5         (setq retval 0)
6         (setq ans (get-response "Preparing to exit. Action? [q, e, u, ?] "
7                       "qQeEuU\\ 3
8                       "q: quit (don't process) e: exit (after processing) u: undo (don't exit)"))
9         (if (| (= ans 'q') (= ans '\\ 3'))
10             (progn
11                   (temp-use-buffer "cmd-buffer") (setq ans 'y')
12                   (if (> (buffer-size) 0)
13                       (setq ans
14                             (get-response "Really exit without processing? "
15                                 "yYnN\\ 3" "y for Yes or n for No")))
16                   (if (| (= ans 'y') (= ans '\\ 3'))
17                       (progn
18                             (pop-to-buffer (concat "+" mh-folder))
19                             (erase-buffer)
20                             (setq retval 1)
21                       )
22                   )
23             )
24             (= ans 'e')
25             (progn
26                   (temp-use-buffer "cmd-buffer")
27                   (if (!= 0 (buffer-size))
28                       (progn
29                             (temp-use-buffer "cmd-buffer")
30                             (message "Processing deletes and moves...")
31                             (beginning-of-file)
32                             (split-long-lines)
33                             (beginning-of-file) (set-mark) (end-of-file)
34                             (progn s
35                                   (setq s (region-to-string))
36                                   (send-to-shell s)
37                                   (setq buffer-is-modified 0)
38                                   (temp-use-buffer (concat "+" mh-folder))
39                                   (&mh-make-headers-current)
40                                   (setq buffer-is-modified 0)
41                                   (setq retval 1)
42                             )
43                       )
44                       (setq retval 1)
45                   )
46             )
47         )
48         (sit-for 10)
49         retval
50     )
51     
52     (split-long-lines t s       ; make sure no overlong lines in cmd-buffer
53         (beginning-of-file)
54         (while (! (eobp))
55                (next-line)
56                (while
57                      (progn (beginning-of-line)
58                             (setq t (dot)) (end-of-line) (> (dot) (+ t 200)))
59                      (beginning-of-line) (set-mark)
60                      (if (looking-at "rmm")
61                          (progn (forward-word) (forward-word) (forward-word)
62                                 (backward-word))
63                          (looking-at "filem")
64                          (progn (forward-word) (forward-word)
65                                 (forward-word) (forward-word)
66                                 (forward-word) (backward-word))
67                      )
68                      (setq s (region-to-string)) (beginning-of-line)
69                      (goto-character (+ (dot) 200)) (backward-word)
70                      (delete-previous-character) (newline)
71                      (insert-string s)
72                )
73         )
74         (setq buffer-is-modified 0)
75     )
76 )