1 ; This file implements "mhe", the display-oriented front end to the MH mail
2 ; system. Documentation is in file mh-doc.ml.
3 ; To install this at your site you must edit the variables flagged with
6 ; Brian K. Reid, Stanford, April 1982
8 ; This is version 4 (September 1982); it uses fast-filter-region.
10 ; UCI modification: we don't need fast-filter-region since we have
12 (setq stack-trace-on-error 1)
13 (declare-global ;*marks installation constants
14 mh-keymap-defined ; T iff keymap exists.
15 mh-folder ; string name, e.g. "inbox"
16 mh-path ; "/mnt/reid/Mail", or whatever
17 mh-progs ;*"/usr/local/lib/mh", or whatever
18 bboard-path ;*"/usr/spool/netnews", or whatever
19 mh-buffer-filename ; "/mnt/reid/Mail/inbox", or whatever
20 t-buffer-filename ; scratch for side effect from mh-folder
21 mh-flist ; "inbox,carbons,news", or whatever
22 mh-direction ; 1 is up, -1 is down.
23 mh-annotate ; are we annotating processed msgs?
24 mh-writeable ; is this folder write-enabled?
25 mh-last-destination ; destination of last "move" command
26 mhe-debug ; are we debugging macro package?
29 (argc) ; is this early enough, James?
30 (setq mh-keymap-defined 0)
32 (setq-default mh-annotate 1)
33 (setq-default mh-writeable 1)
34 (setq bboard-path "/dev/null"); UCI
36 (setq mh-progs "/usr/uci") ; UCI
38 (setq-default right-margin 77)
39 (setq-default mh-direction 1)
40 (setq pop-up-windows 1) ; mhe requires popup windows!
42 (declare-buffer-specific
52 (defun ; (mh "folder" "range")
54 (temp-use-buffer "cmd-buffer") (erase-buffer)
55 (setq backup-before-writing 0)
57 (setq folder (arg 1 (concat ": mh on folder? [" mh-folder "] ")))
59 (setq folder mh-folder))
60 (if (= '+' (string-to-char (substr folder 1 1)))
61 (setq folder (substr folder 2 -1)))
63 (setq mh-folder (get-folder-name "??" folder 1))
64 (&mh-read-folder mh-folder range t-buffer-filename mh-folder)
68 (pop-to-buffer (concat "+" mh-folder))
69 (use-local-map "&mh-keymap")
70 (error-occured (recursive-edit))
71 (setq stop-loop (&mh-exit))
76 ; This function marks a message as being deleted. This mark has two parts.
77 ; The letter "D" is placed in column 4 of the header line, and the message
78 ; number is added to the text of an "rmm" command that is being assembled
79 ; in the command buffer.
81 (&mh-Mark-file-deleted
82 (pop-to-buffer (concat "+" mh-folder))
84 (error-message "Sorry; this folder is read-only."))
86 (goto-character (+ (dot) 3))
87 (if (| (= (following-char) ' ') (= (following-char) '+'))
89 (delete-next-character)
91 (setq buffer-is-modified 0)
92 (temp-use-buffer "cmd-buffer")
96 (concat "^rmm +" mh-folder)))
99 (insert-string (concat "rmm +" mh-folder "\n"))
104 (insert-string (concat " " (&mh-get-msgnum)))
105 (setq buffer-is-modified 0)
106 (pop-to-buffer (concat "+" mh-folder))
112 ; These functions create (and make current) a header buffer on a new message
113 ; or bboard directory.
115 (&mh-new-folder which
116 (setq which (get-folder-name "New" "" 1))
117 (&mh-read-folder which "" t-buffer-filename which)
121 (error-message "B: command not implemented at UCI."); UCI
122 ;UCI (setq which (get-bboard-name))
123 ;UCI (&mh-read-folder which "" t-buffer-filename t-buffer-filename)
124 ;UCI (setq mh-annotate 0)
125 ;UCI (setq mh-writeable 0)
131 (if (= "+" (substr (current-buffer-name) 1 1))
135 (kill-to-end-of-line) (kill-to-end-of-line)
136 (setq buffer-is-modified 0)
138 (error-message "The " (char-to-string (last-key-struck)) " command works only in header windows.")
142 ; This function gets redefined when &mh-move is autoloaded. Shame on me for
143 ; giving it a name so similar to the function above.
145 (error-message "I can't repeat the last ^ command because you haven't typed one yet")
150 "nxt prev del ^put !rpt unmrk typ edit mail forw inc repl get bboard ^X^C ?")
153 ; This function is redefined when file mh-extras.ml is autoloaded
154 (&mh-beep (send-string-to-terminal "
\a"))
156 ; These functions are used to preserve the contents of the kill buffer
157 ; across things that we want to be invisible, so that the keyboard-level
158 ; user does not have to worry about system functions clobbering the kill
163 (temp-use-buffer "Kill buffer")
164 (temp-use-buffer "Kill save")
165 (setq backup-before-writing 0)
167 (yank-buffer "Kill buffer")
168 (setq buffer-is-modified 0)
172 (&mh-restore-killbuffer
174 (temp-use-buffer "Kill buffer")
176 (yank-buffer "Kill save")
180 ; These functions move the cursor around in a header buffer, and possibly
181 ; also display the message that the cursor now points to.
184 (pop-to-buffer (concat "+" mh-folder))
185 (setq mh-direction 1)
186 (next-line) (beginning-of-line)
188 (progn (previous-line)
189 (setq mh-direction -1)))
192 (pop-to-buffer (concat "+" mh-folder))
193 (setq mh-direction -1)
194 (previous-line) (beginning-of-line)
196 (setq mh-direction 1))
199 (another-line old-direction
200 (setq old-direction mh-direction)
201 (if (> mh-direction 0)
205 (if (!= old-direction mh-direction)
206 (if (> mh-direction 0)
214 ; These functions query the user for various things, and error-check the
215 ; responses. "get-response" reads a 1-letter response code in the minibuffer.
216 ; "get-folder-name" extracts the string name of an MH folder or file.
217 ; "get-bboard-name" gets the string name of a bboard file.
219 (get-response chr ok s c pr
220 (setq ok 0) (setq pr (arg 1))
231 (while (> (length s) 0)
232 (if (= chr (string-to-char (substr s 1 1)))
233 (progn (setq ok 1) (setq s ""))
234 (setq s (substr s 2 -1))
238 (progn (if (!= chr '?')
239 (setq pr (concat "Illegal response '"
247 (if (& (>= chr 'A') (<= chr 'Z'))
253 (get-folder-name ; (g-f-n "prompt" "default" can-create)
254 exists msgg name defarg
256 (if (> (nargs) 1) (setq defarg (arg 2)) (setq defarg ""))
257 (setq msgg (concat (arg 1) " folder name? "))
259 (if (= 0 (length defarg))
260 (setq name (get-tty-string msgg))
264 (if (= 0 (length name))
265 (error-message "Aborted."))
266 (if (!= (string-to-char (substr name 1 1)) '/')
267 (setq t-buffer-filename (concat mh-path "/" name))
268 (setq t-buffer-filename name)
270 (setq exists (file-exists t-buffer-filename))
271 (if (& (!= exists 1) (!= (arg 3) 0))
273 (setq ans (get-response
274 (concat "Folder +" name " does not exist. May I create it for you? ")
276 "Please answer y or n"))
279 (message "OK, I will create one for you.")
281 (concat "mkdir " t-buffer-filename))
288 (setq msgg (concat "Sorry, no such folder as `" name
295 (get-bboard-name exists msgg name
297 (setq msgg "BBoard name? ")
299 (setq name (get-tty-string msgg))
300 (if (= 0 (length name))
301 (error-message "Aborted."))
302 (if (!= (string-to-char (substr name 1 1)) '/')
303 (setq t-buffer-filename (concat bboard-path "/" name))
304 (setq t-buffer-filename name)
306 (setq exists (file-exists t-buffer-filename))
308 (setq msgg (concat "Sorry, no such BBoard as `" name
315 ; UCI hack for fast-filter-region
316 (defun (fast-filter-region UseUsersShell
317 (setq UseUsersShell use-users-shell)
318 (setq use-users-shell 0)
320 (arg 1 ": fast-filter-region (through command) "))
321 (setq use-users-shell UseUsersShell)
324 ; These functions are the initial entry points to mhe. "startup" is
325 ; expecting an argv like "emacs -lmh-e.ml -estartup +inbox 100-last
328 (setq stack-trace-on-error 0)
336 (error-occured (kill-process "newtime"))
341 (setq mh-progs "/usr/local/src/cmd/mh/progs")
342 (setq stack-trace-on-error 0)
349 (autoload "&mh-send" "mh-send.ml")
350 (autoload "&mh-show" "mh-show.ml")
351 (autoload "&mh-edit" "mh-edit.ml")
352 (autoload "&mh-repl" "mh-repl.ml")
353 (autoload "&mh-inc" "mh-inc.ml")
354 (autoload "&mh-help" "mh-help.ml")
355 (autoload "&mh-move" "mh-move.ml")
356 (autoload "&mh-unmark" "mh-unmark.ml")
357 (autoload "&mh-forw" "mh-forw.ml")
358 (autoload "&mh-exit" "mh-exit.ml")
359 (autoload "annotate" "mh-annot.ml")
360 (autoload "mail-mode" "mh-mode.ml")
361 (autoload "&mh-extras" "mh-extras.ml")
362 (autoload "&mh-xpack" "mh-extras.ml")
363 (if (! (is-bound time))
367 (load "mh-keymap.ml")