home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
mh-e.pat
/
mh-e
Wrap
Lisp/Scheme
|
1993-01-22
|
40KB
|
1,264 lines
*** /tmp/,RCSt1a23165 Wed Jan 20 11:15:09 1993
--- mh-e.el Wed Jan 20 11:13:30 1993
***************
*** 5,10
(setq mh-e-time-stamp "92/01/21 10:59:18 gildea")
(provide 'mh-e)
;;; Copyright (c) 1985,1986,1987,1988,1990,1992 Free Software Foundation
;;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
;;; Please send suggestions and corrections to the above address.
--- 5,12 -----
(setq mh-e-time-stamp "92/01/21 10:59:18 gildea")
(provide 'mh-e)
+ (require 'mh-db)
+
;;; Copyright (c) 1985,1986,1987,1988,1990,1992 Free Software Foundation
;;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
;;; Please send suggestions and corrections to the above address.
***************
*** 57,63
;;;(defvar mh-lib "/usr/new/lib/mh/" "Directory of MH library.")
(defvar mh-redist-full-contents nil
! "Non-nil if the `dist' command needs whole letter for redistribution.
This is the case when `send' is compiled with the BERK option.")
--- 59,65 -----
;;;(defvar mh-lib "/usr/new/lib/mh/" "Directory of MH library.")
(defvar mh-redist-full-contents nil
! "*Non-nil if the `dist' command needs whole letter for redistribution.
This is the case when `send' is compiled with the BERK option.")
***************
*** 85,90
(defvar mh-quit-hook nil
"Invoked after quitting mh-e by \\[mh-quit]. See also mh-before-quit-hook")
(defvar mh-ins-string nil
"Temporarily set by `mh-insert-prefix' prior to running `mh-yank-hooks'.")
--- 87,101 -----
(defvar mh-quit-hook nil
"Invoked after quitting mh-e by \\[mh-quit]. See also mh-before-quit-hook")
+ (defvar mh-signature-func nil
+ "Function to call to obtain a signature when `mh-insert-signature' is called.
+ If `mh-signature-func' is nil, the old-style behavior of inserting the
+ contents of ~/.signature occurs. If `mh-signature-func' is non-nil, it is the
+ function to invoke to obtain a signature. If the function returns a string,
+ the string is assumed to be the name of the file to insert. If the function
+ returns a list, the list must contain only a single string, which is inserted
+ verbatim into the buffer. If the function returns anything else (like `nil'),
+ the contents of ~/.signature are inserted.
When the function is called, the current buffer is the draft buffer, which can
be scanned by the function to determine an appropriate signature.
***************
*** 86,91
"Invoked after quitting mh-e by \\[mh-quit]. See also mh-before-quit-hook")
(defvar mh-ins-string nil
"Temporarily set by `mh-insert-prefix' prior to running `mh-yank-hooks'.")
--- 97,108 -----
verbatim into the buffer. If the function returns anything else (like `nil'),
the contents of ~/.signature are inserted.
+ When the function is called, the current buffer is the draft buffer, which can
+ be scanned by the function to determine an appropriate signature.
+
+ `mh-signature-func' is similar to a hook, except that hooks do not return
+ values.")
+
(defvar mh-ins-string nil
"Temporarily set by `mh-insert-prefix' prior to running `mh-yank-hooks'.")
***************
*** 118,124
A value of T means use the default format file.
Nil means don't use mhl to format messages.")
! (defvar mh-lpr-command-format "lpr -p -J '%s'"
"*Format for Unix command that prints a message.
The string should be a Unix command line, with the string '%s' where
the job's name (folder and message number) should appear. The message text
--- 135,144 -----
A value of T means use the default format file.
Nil means don't use mhl to format messages.")
! (defvar mh-lpr-command-format (cond ((eq system-type 'hpux)
! "fold -80 | pr -h '%s' | lp")
! (t "lpr -p -J '%s'")
! )
"*Format for Unix command that prints a message.
The string should be a Unix command line, with the string '%s' where
the job's name (folder and message number) should appear. The message text
***************
*** 247,253
"User's mail folder.")
(defvar mh-last-destination nil
! "Destination of last refile or write command.")
(defvar mh-folder-mode-map (make-keymap)
"Keymap for MH folders.")
--- 267,274 -----
"User's mail folder.")
(defvar mh-last-destination nil
! "Destination of last refile or write command.
! `(car mh-last-destination)' is one of 'refile, 'write, or 'other.")
(defvar mh-folder-mode-map (make-keymap)
"Keymap for MH folders.")
***************
*** 471,478
(message "Does not appear to be a rejected letter.")))
(goto-char (point-min))
(set-buffer-modified-p nil)
! (mh-compose-and-send-mail draft "" from-folder msg (mh-get-field "To")
! (mh-get-field "From") (mh-get-field "cc")
nil nil config)))
--- 492,499 -----
(message "Does not appear to be a rejected letter.")))
(goto-char (point-min))
(set-buffer-modified-p nil)
! (mh-compose-and-send-mail draft "" from-folder msg (mh-get-field "To:")
! (mh-get-field "From:") (mh-get-field "cc:")
nil nil config)))
***************
*** 489,496
(if current-prefix-arg
(mh-read-seq-default "Forward" t)
(mh-get-msg-num t))
! (read-string "To: ")
! (read-string "Cc: ")))
(let* ((folder mh-current-folder)
(config (current-window-configuration))
;; forw always leaves file in "draft" since it doesn't have -draft
--- 510,517 -----
(if current-prefix-arg
(mh-read-seq-default "Forward" t)
(mh-get-msg-num t))
! (mh-read-to-address)
! (mh-read-cc-address)))
(let* ((folder mh-current-folder)
(config (current-window-configuration))
;; forw always leaves file in "draft" since it doesn't have -draft
***************
*** 569,574
(if (not maildrop-name)
(cond ((not (get-buffer "+inbox"))
(mh-make-folder "+inbox")
(setq mh-previous-window-config config))
((not (eq (current-buffer) (get-buffer "+inbox")))
(switch-to-buffer "+inbox")
--- 590,596 -----
(if (not maildrop-name)
(cond ((not (get-buffer "+inbox"))
(mh-make-folder "+inbox")
+ (delete-other-windows)
(setq mh-previous-window-config config))
((not (eq (current-buffer) (get-buffer "+inbox")))
(switch-to-buffer "+inbox")
***************
*** 572,577
(setq mh-previous-window-config config))
((not (eq (current-buffer) (get-buffer "+inbox")))
(switch-to-buffer "+inbox")
(setq mh-previous-window-config config)))))
(mh-get-new-mail maildrop-name)
(run-hooks 'mh-inc-folder-hook))
--- 594,600 -----
(setq mh-previous-window-config config))
((not (eq (current-buffer) (get-buffer "+inbox")))
(switch-to-buffer "+inbox")
+ (delete-other-windows)
(setq mh-previous-window-config config)))))
(mh-get-new-mail maildrop-name)
(run-hooks 'mh-inc-folder-hook))
***************
*** 653,659
(mh-maybe-show))
(t
(forward-line -1)
! (if (get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer)))))
--- 676,682 -----
(mh-maybe-show))
(t
(forward-line -1)
! (if (mh-get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer)))))
***************
*** 684,690
(shell-command-on-region (point) (point-max) command nil)))
! (defun mh-refile-msg (prefix-provided msg-or-seq dest)
"Refile MESSAGE(s) (default: displayed message) in FOLDER.
If optional prefix argument provided, then prompt for message sequence."
(interactive
--- 707,713 -----
(shell-command-on-region (point) (point-max) command nil)))
! (defun mh-refile-msg (prefix-provided msg-or-seq folder)
"Refile MESSAGE(s) (default: displayed message) in FOLDER.
If optional prefix argument provided, then prompt for message sequence.
If mh-auto-folder-alist is non-nil, it will be used to determine the name
***************
*** 686,692
(defun mh-refile-msg (prefix-provided msg-or-seq dest)
"Refile MESSAGE(s) (default: displayed message) in FOLDER.
! If optional prefix argument provided, then prompt for message sequence."
(interactive
(list current-prefix-arg
(if current-prefix-arg
--- 709,718 -----
(defun mh-refile-msg (prefix-provided msg-or-seq folder)
"Refile MESSAGE(s) (default: displayed message) in FOLDER.
! If optional prefix argument provided, then prompt for message sequence.
! If mh-auto-folder-alist is non-nil, it will be used to determine the name
! of the default folder.
! "
(interactive
;; Here, we want to preserve the value of mh-showing, while preserving
;; the current value.
***************
*** 688,696
"Refile MESSAGE(s) (default: displayed message) in FOLDER.
If optional prefix argument provided, then prompt for message sequence."
(interactive
! (list current-prefix-arg
! (if current-prefix-arg
! (mh-read-seq-default "Refile" t)
(mh-get-msg-num t))
(intern
(mh-prompt-for-folder "Destination"
--- 714,725 -----
of the default folder.
"
(interactive
! ;; Here, we want to preserve the value of mh-showing, while preserving
! ;; the current value.
! (let ( (mh-showing (and (boundp 'mh-showing) mh-showing)) )
! (list current-prefix-arg
! (if current-prefix-arg
! (mh-read-seq-default "Refile" t)
(mh-get-msg-num t))
(intern
(mh-prompt-for-folder "Destination"
***************
*** 692,704
(if current-prefix-arg
(mh-read-seq-default "Refile" t)
(mh-get-msg-num t))
! (intern
! (mh-prompt-for-folder "Destination"
! (if (eq 'refile (car mh-last-destination))
! (symbol-name (cdr mh-last-destination))
! "")
! t))))
! (setq mh-last-destination (cons 'refile dest))
(if prefix-provided
(mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq dest)
(mh-refile-a-msg msg-or-seq dest))
--- 721,731 -----
(if current-prefix-arg
(mh-read-seq-default "Refile" t)
(mh-get-msg-num t))
! (intern
! (mh-prompt-for-folder "Destination"
! (mh-get-default-refile-folder)
! t)))))
! (setq mh-last-destination (cons 'refile folder))
(if prefix-provided
(mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq folder)
(mh-refile-a-msg msg-or-seq folder))
***************
*** 700,707
t))))
(setq mh-last-destination (cons 'refile dest))
(if prefix-provided
! (mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq dest)
! (mh-refile-a-msg msg-or-seq dest))
(mh-next-msg))
--- 727,734 -----
t)))))
(setq mh-last-destination (cons 'refile folder))
(if prefix-provided
! (mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq folder)
! (mh-refile-a-msg msg-or-seq folder))
(mh-next-msg))
***************
*** 787,792
configuration, if one exists. Finish by running mh-quit-hook."
(interactive)
(run-hooks 'mh-before-quit-hook)
(if mh-previous-window-config
(set-window-configuration mh-previous-window-config))
(run-hooks 'mh-quit-hook))
--- 814,823 -----
configuration, if one exists. Finish by running mh-quit-hook."
(interactive)
(run-hooks 'mh-before-quit-hook)
+ (if mh-current-folder
+ (bury-buffer mh-current-folder))
+ (if (and mh-show-buffer (get-buffer mh-show-buffer))
+ (bury-buffer mh-show-buffer))
(if mh-previous-window-config
(set-window-configuration mh-previous-window-config))
(mh-save-variables)
***************
*** 789,794
(run-hooks 'mh-before-quit-hook)
(if mh-previous-window-config
(set-window-configuration mh-previous-window-config))
(run-hooks 'mh-quit-hook))
--- 820,826 -----
(bury-buffer mh-show-buffer))
(if mh-previous-window-config
(set-window-configuration mh-previous-window-config))
+ (mh-save-variables)
(run-hooks 'mh-quit-hook))
***************
*** 858,864
(cond ((re-search-backward mh-good-msg-regexp nil 0 arg)
(mh-maybe-show))
(t
! (if (get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer)))))
--- 890,896 -----
(cond ((re-search-backward mh-good-msg-regexp nil 0 arg)
(mh-maybe-show))
(t
! (if (mh-get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer)))))
***************
*** 929,935
messages to display. Otherwise show the entire folder."
(interactive (list (if current-prefix-arg
(mh-read-msg-range "Range to scan [all]? ")
! nil)))
(setq mh-next-direction 'forward)
(mh-scan-folder mh-current-folder (or range "all")))
--- 961,967 -----
messages to display. Otherwise show the entire folder."
(interactive (list (if current-prefix-arg
(mh-read-msg-range "Range to scan [all]? ")
! "")))
(setq mh-next-direction 'forward)
(mh-scan-folder mh-current-folder (if (string= range "")
"all"
***************
*** 931,937
(mh-read-msg-range "Range to scan [all]? ")
nil)))
(setq mh-next-direction 'forward)
! (mh-scan-folder mh-current-folder (or range "all")))
(defun mh-redistribute (to cc msg)
--- 963,971 -----
(mh-read-msg-range "Range to scan [all]? ")
"")))
(setq mh-next-direction 'forward)
! (mh-scan-folder mh-current-folder (if (string= range "")
! "all"
! range)))
(defun mh-redistribute (to cc msg)
***************
*** 938,945
"Redistribute a letter.
Depending on how your copy of MH was compiled, you may need to change the
setting of the variable mh-redist-full-contents. See its documentation."
! (interactive (list (read-string "Redist-To: ")
! (read-string "Redist-Cc: ")
(mh-get-msg-num t)))
(save-window-excursion
(let ((folder mh-current-folder)
--- 972,979 -----
"Redistribute a letter.
Depending on how your copy of MH was compiled, you may need to change the
setting of the variable mh-redist-full-contents. See its documentation."
! (interactive (list (mh-read-to-address "Redist-To: ")
! (mh-read-cc-address "Redist-Cc: ")
(mh-get-msg-num t)))
(save-window-excursion
(let ((folder mh-current-folder)
***************
*** 1011,1017
The letter is composed in mh-letter-mode; see its documentation for more
details. If `mh-compose-letter-function' is defined, it is called on the
draft and passed three arguments: to, subject, and cc."
! (interactive "sTo: \nsCc: \nsSubject: ")
(let ((config (current-window-configuration)))
(delete-other-windows)
(mh-send-sub to cc subject config)))
--- 1045,1051 -----
The letter is composed in mh-letter-mode; see its documentation for more
details. If `mh-compose-letter-function' is defined, it is called on the
draft and passed three arguments: to, subject, and cc."
! (interactive (mh-read-to-cc-subject))
(let ((config (current-window-configuration)))
(delete-other-windows)
(mh-send-sub to cc subject config)))
***************
*** 1019,1025
(defun mh-send-other-window (to cc subject)
"Compose and send a letter in another window.."
! (interactive "sTo: \nsCc: \nsSubject: ")
(let ((pop-up-windows t))
(mh-send-sub to cc subject (current-window-configuration))))
--- 1053,1059 -----
(defun mh-send-other-window (to cc subject)
"Compose and send a letter in another window.."
! (interactive (mh-read-to-cc-subject))
(let ((pop-up-windows t))
(mh-send-sub to cc subject (current-window-configuration))))
***************
*** 1059,1065
(setq msg (mh-get-msg-num t)))
(setq mh-showing t)
(mh-set-mode-name "mh-e show")
! (if (not (eql (next-window (minibuffer-window)) (selected-window)))
(delete-other-windows)) ; force ourself to the top window
(let ((folder mh-current-folder))
(mh-show-message-in-other-window)
--- 1093,1099 -----
(setq msg (mh-get-msg-num t)))
(setq mh-showing t)
(mh-set-mode-name "mh-e show")
! (if (not (eql (minibuffer-window) (selected-window)))
(delete-other-windows)) ; force ourself to the top window
(let ((folder mh-current-folder))
(mh-show-message-in-other-window)
***************
*** 1193,1199
(interactive (list (mh-prompt-for-folder "Visit" "+inbox" t)
(mh-read-msg-range "Range [all]? ")))
(let ((config (current-window-configuration)))
! (mh-scan-folder folder (or range "all"))
(setq mh-previous-window-config config))
nil)
--- 1227,1235 -----
(interactive (list (mh-prompt-for-folder "Visit" "+inbox" t)
(mh-read-msg-range "Range [all]? ")))
(let ((config (current-window-configuration)))
! (mh-scan-folder folder (if (string= range "")
! "all"
! range))
(setq mh-previous-window-config config))
nil)
***************
*** 1300,1306
(defun mh-invalidate-show-buffer ()
;; Invalidate the show buffer so we must update it to use it.
! (if (get-buffer mh-show-buffer)
(save-excursion
(set-buffer mh-show-buffer)
(setq buffer-file-name nil))))
--- 1336,1342 -----
(defun mh-invalidate-show-buffer ()
;; Invalidate the show buffer so we must update it to use it.
! (if (mh-get-buffer mh-show-buffer)
(save-excursion
(set-buffer mh-show-buffer)
(setq buffer-file-name nil))))
***************
*** 1307,1313
(defun mh-show-message-in-other-window ()
! (switch-to-buffer-other-window mh-show-buffer)
(if mh-bury-show-buffer (bury-buffer (current-buffer))))
--- 1343,1349 -----
(defun mh-show-message-in-other-window ()
! (switch-to-buffer-other-window (mh-get-buffer mh-show-buffer))
(if mh-bury-show-buffer (bury-buffer (current-buffer))))
***************
*** 1404,1410
;; Move backward or forward to the next undeleted message in the buffer.
(if (eq mh-next-direction 'forward)
(mh-next-undeleted-msg 1)
! (mh-previous-undeleted-msg 1)))
(defun mh-set-scan-mode ()
--- 1440,1446 -----
;; Move backward or forward to the next undeleted message in the buffer.
(if (eq mh-next-direction 'forward)
(mh-next-undeleted-msg 1)
! (mh-previous-undeleted-msg 1)))
(defun mh-set-scan-mode ()
***************
*** 1409,1415
(defun mh-set-scan-mode ()
;; Display the scan listing buffer, but do not show a message.
! (if (get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer))
(mh-set-mode-name "mh-e scan")
(setq mh-showing nil)
--- 1445,1451 -----
(defun mh-set-scan-mode ()
;; Display the scan listing buffer, but do not show a message.
! (if (mh-get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer))
(mh-set-mode-name "mh-e scan")
(setq mh-showing nil)
***************
*** 1429,1434
(save-excursion (set-buffer (other-buffer)))
(set-buffer-modified-p (buffer-modified-p)))
;;; The folder data abstraction.
--- 1465,1479 -----
(save-excursion (set-buffer (other-buffer)))
(set-buffer-modified-p (buffer-modified-p)))
+
+ (defun mh-get-buffer (buf)
+ "Create buffer BUF and mark it as not keeping undo information."
+ (let ( (buffer (get-buffer-create buf)) )
+ (buffer-flush-undo buffer)
+ buffer
+ ))
+
+
;;; The folder data abstraction.
***************
*** 1539,1544
(setq write-file-hooks '(mh-execute-commands))
(make-local-variable 'revert-buffer-function)
(setq revert-buffer-function 'mh-undo-folder)
(run-hooks 'mh-folder-mode-hook))
--- 1584,1590 -----
(setq write-file-hooks '(mh-execute-commands))
(make-local-variable 'revert-buffer-function)
(setq revert-buffer-function 'mh-undo-folder)
+ (mh-load-variables-if-necessary)
(run-hooks 'mh-folder-mode-hook))
***************
*** 1569,1575
(defun mh-regenerate-headers (range)
;; Replace buffer with scan of its contents over range RANGE.
! (let ((folder mh-current-folder))
(message "Scanning %s..." folder)
(with-mh-folder-updating (nil)
(erase-buffer)
--- 1615,1626 -----
(defun mh-regenerate-headers (range)
;; Replace buffer with scan of its contents over range RANGE.
! (let ((folder mh-current-folder)
! real-folder
! index-cache-dir
! index-cache
! (downcase-range (downcase range))
! )
(message "Scanning %s..." folder)
(setq real-folder (substring folder 1))
(setq index-cache-dir (concat mh-user-path real-folder))
***************
*** 1571,1576
;; Replace buffer with scan of its contents over range RANGE.
(let ((folder mh-current-folder))
(message "Scanning %s..." folder)
(with-mh-folder-updating (nil)
(erase-buffer)
(mh-exec-cmd-output "scan" nil
--- 1622,1630 -----
(downcase-range (downcase range))
)
(message "Scanning %s..." folder)
+ (setq real-folder (substring folder 1))
+ (setq index-cache-dir (concat mh-user-path real-folder))
+ (setq index-cache (concat mh-user-path real-folder "/.mh-e-index"))
(with-mh-folder-updating (nil)
(erase-buffer)
(setq truncate-lines t)
***************
*** 1573,1582
(message "Scanning %s..." folder)
(with-mh-folder-updating (nil)
(erase-buffer)
! (mh-exec-cmd-output "scan" nil
! "-noclear" "-noheader"
! "-width" (window-width)
! folder range)
(goto-char (point-min))
(cond ((looking-at "scan: no messages in")
(keep-lines mh-valid-scan-line)) ; Flush random scan lines
--- 1627,1654 -----
(setq index-cache (concat mh-user-path real-folder "/.mh-e-index"))
(with-mh-folder-updating (nil)
(erase-buffer)
! (setq truncate-lines t)
! (if (or (not (string= downcase-range "all"))
! (not (file-exists-p index-cache))
! (file-newer-than-file-p index-cache-dir index-cache)
! )
! (progn
! (mh-exec-cmd-output "scan" nil
! "-noclear" "-noheader"
! "-width" (window-width)
! folder range)
! (if (and (file-writable-p index-cache)
! (string= downcase-range "all")
! )
! (progn
! (write-region (point-min) (point-max) index-cache)
! )
! )
! )
! (progn
! (insert-file index-cache)
! )
! )
(goto-char (point-min))
(cond ((looking-at "scan: no messages in")
(keep-lines mh-valid-scan-line)) ; Flush random scan lines
***************
*** 1837,1842
(setq major-mode 'mh-letter-mode)
(mh-set-mode-name "mh-e letter")
(set-syntax-table mh-letter-mode-syntax-table)
(run-hooks 'text-mode-hook 'mh-letter-mode-hook)
(mh-when auto-fill-hook
(make-local-variable 'auto-fill-hook)
--- 1909,1915 -----
(setq major-mode 'mh-letter-mode)
(mh-set-mode-name "mh-e letter")
(set-syntax-table mh-letter-mode-syntax-table)
+ (mh-load-variables-if-necessary)
(run-hooks 'text-mode-hook 'mh-letter-mode-hook)
(mh-when auto-fill-hook
(make-local-variable 'auto-fill-hook)
***************
*** 1862,1867
(< cur-point (point)))))
(defun mh-to-field ()
"Move point to the end of a specified header field.
The field is indicated by the previous keystroke. Create the field if
--- 1935,1951 -----
(< cur-point (point)))))
+ (defun mh-insert-header-line (line)
+ "Move to the header, and insert the text given by LINE.
+ This function assumes that a similar header line does not already exist."
+ (let ()
+ (goto-char (dot-min))
+ (re-search-forward "\\(^--------\\)\\|\\(^$\\)")
+ (beginning-of-line 1)
+ (insert line)
+ ))
+
+
(defun mh-to-field ()
"Move point to the end of a specified header field.
The field is indicated by the previous keystroke. Create the field if
***************
*** 1904,1911
(defun mh-insert-signature ()
"Insert the file ~/.signature at the current point."
(interactive)
! (insert-file-contents "~/.signature")
! (set-buffer-modified-p (buffer-modified-p))) ; force mode line update
(defun mh-check-whom ()
--- 1988,2019 -----
(defun mh-insert-signature ()
"Insert the file ~/.signature at the current point."
(interactive)
! (let ( (file "~/.signature") result)
! (save-window-excursion
! (if mh-signature-func
! (progn
! (save-window-excursion
! (save-excursion
! ;;
! ;; The environment is preserved during the function call
! ;;
! (setq result (funcall mh-signature-func))
! ))
! (cond
! ( (stringp result)
! (setq file result)
! )
! ( (and (listp result) (stringp (car result)))
! (insert (car result))
! (setq file nil)
! )
! )
! ))
! (if file
! (insert-file-contents file))
! )
! (set-buffer-modified-p (buffer-modified-p)) ; force mode line update
! ))
(defun mh-check-whom ()
***************
*** 2053,2058
Run mh-before-send-letter-hook before doing anything."
(interactive "P")
(run-hooks 'mh-before-send-letter-hook)
(set-buffer-modified-p t) ; Make sure buffer is written
(save-buffer)
(message "Sending...")
--- 2161,2168 -----
Run mh-before-send-letter-hook before doing anything."
(interactive "P")
(run-hooks 'mh-before-send-letter-hook)
+ (if (and (boundp 'mh-add-md4-signature) mh-add-md4-signature)
+ (mh-add-md4-header))
(set-buffer-modified-p t) ; Make sure buffer is written
(save-buffer)
(message "Sending...")
***************
*** 2136,2142
(set-buffer mh-sent-from-folder)
(if mh-delete-yanked-msg-window
(delete-windows-on mh-show-buffer))
! (set-buffer mh-show-buffer) ; Find displayed message
(let ((mh-ins-str (cond ((mark)
(buffer-substring (region-beginning)
(region-end)))
--- 2246,2252 -----
(set-buffer mh-sent-from-folder)
(if mh-delete-yanked-msg-window
(delete-windows-on mh-show-buffer))
! (set-buffer (mh-get-buffer mh-show-buffer)) ; Find displayed message
(let ((mh-ins-str (cond ((mark)
(buffer-substring (region-beginning)
(region-end)))
***************
*** 2484,2489
(yank)
(goto-char beginning-of-line)))
;;; Issue commands to MH.
--- 2594,2650 -----
(yank)
(goto-char beginning-of-line)))
+
+ (defun mh-insert-sequence-list (seq)
+ "Format and insert, into the current buf, a description of the sequence SEQ."
+ (let ( (name (car seq))
+ (s (sort (copy-sequence (cdr seq)) '<))
+ (last-col 76)
+ name-spec
+ )
+ (insert (setq name-spec (format "%20s:" name)))
+ (while s
+ (if (> (current-column) last-col)
+ (progn
+ (insert "\n")
+ (move-to-column (length name-spec))
+ )
+ )
+ (insert (format " %s" (car s)))
+ (setq s (cdr s))
+ )
+ (insert "\n")
+ )
+ )
+
+
+ (defun mh-list-sequences (folder)
+ "List the sequences defined in FOLDER."
+ (interactive (list (mh-prompt-for-folder "List sequences in"
+ mh-current-folder t)))
+ (let ( (temp-buffer " *mh-temp*")
+ (l mh-seq-list)
+ )
+ (with-output-to-temp-buffer temp-buffer
+ (save-excursion
+ (set-buffer temp-buffer)
+ (setq buffer-read-only nil)
+ (erase-buffer)
+ (message "Listing sequences ...")
+
+ (insert "Sequences in folder " folder ":\n\n")
+ (while l
+ (mh-insert-sequence-list (car l))
+ (setq l (cdr l))
+ )
+
+ (goto-char (point-min))
+ (message "Listing sequences...done")
+ )
+ )
+ )
+ )
+
;;; Issue commands to MH.
***************
*** 2492,2498
;; Execute MH command COMMAND with ARGS.
;; Any output is assumed to be an error and is shown to the user.
(save-excursion
! (set-buffer " *mh-temp*")
(erase-buffer)
(apply 'call-process
(expand-file-name command mh-progs) nil t nil
--- 2653,2659 -----
;; Execute MH command COMMAND with ARGS.
;; Any output is assumed to be an error and is shown to the user.
(save-excursion
! (buffer-flush-undo (set-buffer " *mh-temp*"))
(erase-buffer)
(apply 'call-process
(expand-file-name command mh-progs) nil t nil
***************
*** 2507,2513
;; In BUFFER, execute MH command COMMAND with ARGS.
;; ARGS is a list of strings. Return in BUFFER, if one exists.
(mh-when (stringp buffer)
! (set-buffer buffer)
(erase-buffer))
(apply 'call-process
(expand-file-name command mh-progs) nil buffer nil
--- 2668,2674 -----
;; In BUFFER, execute MH command COMMAND with ARGS.
;; ARGS is a list of strings. Return in BUFFER, if one exists.
(mh-when (stringp buffer)
! (buffer-flush-undo (set-buffer buffer))
(erase-buffer))
(apply 'call-process
(expand-file-name command mh-progs) nil buffer nil
***************
*** 2603,2611
;;; User prompting commands.
! (defun mh-prompt-for-folder (prompt default can-create)
! ;; Prompt for a folder name with PROMPT. Returns the folder's name as a
! ;; string. DEFAULT is used if the folder exists and the user types return.
;; If the CAN-CREATE flag is t, then a non-existent folder is made.
(let* ((prompt (format "%s folder%s" prompt
(if (equal "" default)
--- 2764,2772 -----
;;; User prompting commands.
! (defun mh-prompt-for-folder (prompt-string default can-create)
! ;; Prompt for a folder name with PROMPT-STRING. Returns the folder's name as
! ;; a string. DEFAULT is used if the folder exists and the user types return.
;; If the CAN-CREATE flag is t, then a non-existent folder is made.
(let (prompt name)
(if (null mh-folder-list)
***************
*** 2607,2617
;; Prompt for a folder name with PROMPT. Returns the folder's name as a
;; string. DEFAULT is used if the folder exists and the user types return.
;; If the CAN-CREATE flag is t, then a non-existent folder is made.
! (let* ((prompt (format "%s folder%s" prompt
! (if (equal "" default)
! "? "
! (format " [%s]? " default))))
! name)
(if (null mh-folder-list)
(mh-set-folder-list))
(while (and (setq name (completing-read prompt mh-folder-list
--- 2768,2774 -----
;; Prompt for a folder name with PROMPT-STRING. Returns the folder's name as
;; a string. DEFAULT is used if the folder exists and the user types return.
;; If the CAN-CREATE flag is t, then a non-existent folder is made.
! (let (prompt name)
(if (null mh-folder-list)
(mh-set-folder-list))
(setq prompt (format "%s folder%s" prompt-string
***************
*** 2614,2619
name)
(if (null mh-folder-list)
(mh-set-folder-list))
(while (and (setq name (completing-read prompt mh-folder-list
nil nil "+"))
(equal name "")
--- 2771,2791 -----
(let (prompt name)
(if (null mh-folder-list)
(mh-set-folder-list))
+ (setq prompt (format "%s folder%s" prompt-string
+ (if (equal "" default)
+ (let (folder)
+ (setq folder
+ (if mh-auto-folder-alist
+ (mh-auto-select-folder
+ mh-auto-folder-alist
+ 'other)))
+ (if (or (not folder) (string= folder ""))
+ "? "
+ (progn
+ (setq default folder)
+ (format " [%s]? " folder)
+ )))
+ (format " [%s]? " default))))
(while (and (setq name (completing-read prompt mh-folder-list
nil nil "+"))
(equal name "")
***************
*** 2625,2631
(let ((new-file-p (not (file-exists-p (mh-expand-file-name name)))))
(cond ((and new-file-p
(y-or-n-p
! (format "Folder %s does not exist. Create it? " name)))
(message "Creating %s" name)
(call-process "mkdir" nil nil nil (mh-expand-file-name name))
(message "Creating %s...done" name)
--- 2797,2803 -----
(let ((new-file-p (not (file-exists-p (mh-expand-file-name name)))))
(cond ((and new-file-p
(y-or-n-p
! (format "Folder %s does not exist. Create it? " name)))
(message "Creating %s" name)
(call-process "mkdir" nil nil nil (mh-expand-file-name name))
(message "Creating %s...done" name)
***************
*** 2672,2677
(delq (assoc folder mh-folder-list) mh-folder-list)))
(defun mh-read-msg-range (prompt)
;; Read a list of blank-separated items.
(let* ((buf (read-string prompt))
--- 2844,2868 -----
(delq (assoc folder mh-folder-list) mh-folder-list)))
+ (defun mh-drop-spaces (str)
+ "Return a copy of STR, with leading and trailing spaces removed."
+ (let (loc)
+ (if (string-match "^[ \t]+" str)
+ (setq str (substring str (match-end 0)))
+ )
+ (if (string-match "[ \t]+$" str)
+ (progn
+ (setq loc (match-beginning 0))
+ (if (> loc 0)
+ (setq loc (1- loc))
+ )
+ (setq str (substring str 0 loc))
+ )
+ )
+ str
+ )
+ )
+
(defun mh-read-msg-range (prompt)
;; Read a list of blank-separated items.
(let* ((buf (read-string prompt))
***************
*** 2677,2688
(let* ((buf (read-string prompt))
(buf-size (length buf))
(start 0)
! (input ()))
! (while (< start buf-size)
! (let ((next (read-from-string buf start buf-size)))
! (mh-push (car next) input)
! (setq start (cdr next))))
! (nreverse input)))
--- 2868,2895 -----
(let* ((buf (read-string prompt))
(buf-size (length buf))
(start 0)
! (input ""))
! (while (> (length buf) 0)
! (if (string-match "\\([^, \t]*\\)\\([, \t]*\\)" buf)
! (progn
! (if (/= (match-beginning 1) (match-end 1))
! (setq input (concat input " "
! (substring buf
! (match-beginning 1)
! (match-end 1))))
! )
! )
! (error "Error in mh-read-msg-range")
! )
! (setq buf (substring buf (match-end 2)))
! )
! (setq input (mh-drop-spaces input))
! (if (string= input "")
! (setq input "all")
! )
! input
! )
! )
***************
*** 2812,2817
(if (re-search-forward "^$\\|^-+$" nil nil)
(forward-line arg)))
;;; Build the folder-mode keymap:
--- 3019,3104 -----
(if (re-search-forward "^$\\|^-+$" nil nil)
(forward-line arg)))
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;;
+ ;; Autoloads for MH enhancements:
+ ;;
+
+ (autoload 'mh-expand-alias "mh-alias"
+ "Expand the alias before point.
+ In order for the alias to be expanded, point must be either in the minibuffer
+ or in the To: or Cc: mail headers. Otherwise, the keypress used to invoke
+ this function is instead inserted into the buffer.
+
+ If the alias is not unique, all matching possibilities are displayed in
+ a pop-up buffer. If there is no alias before point, all aliases are
+ displayed."
+ t nil)
+
+ (autoload 'mh-read-to-cc-subject "mh-alias"
+ "Read addresses for To: and Cc:, and read a subject line.
+ The result is returned in a form suitable for passing to the `interactive'
+ function."
+ nil nil)
+
+ (autoload 'mh-read-to-address "mh-alias"
+ "Ask the user for a To: address, only if mh-ask-to-address is non-nil."
+ nil nil)
+
+ (autoload 'mh-read-cc-address "mh-alias"
+ "Ask the user for a Cc: address, only if mh-ask-to-address is non-nil."
+ nil nil)
+
+ (autoload 'mh-read-subject "mh-alias"
+ "Ask the user for a Subject:, only if mh-ask-to-address is non-nil."
+ nil nil)
+
+
+ (autoload 'mh-auto-select-folder "mh-refile"
+ "Return the name of a folder to refile the current message in.
+ The current buffer is scanned for this information."
+ nil nil)
+
+ (autoload 'mh-get-default-refile-folder "mh-refile"
+ "Get a default name for refiling a message."
+ nil nil)
+
+ (autoload 'mh-set-default-refile-folder "mh-refile"
+ "Set the default folder for the MH message under the cursor in the current
+ folder buffer."
+ t nil)
+
+
+ (autoload 'mh-unshar "mh-shar"
+ "Unshar the current message in the directory given by DIR."
+ t nil)
+
+ (autoload 'mh-uudecode "mh-shar"
+ "Unshar the current message in the directory given by DIR."
+ t nil)
+
+
+ (autoload 'mh-add-md4-header "mh-shar"
+ "Insert an \"X-Md4-Signature:\" line into the header."
+ nil nil)
+
+ (autoload 'mh-check-md4-signature "mh-shar"
+ "If an MD4 signature is present in the header, check it and report the results."
+ t nil)
+
+ (autoload 'mh-shar-and-insert "mh-shar"
+ "Shar the file FILE, passing OTHER-ARGS (if any) to the shar program.
+ The shar contents in then inserted into the current buffer."
+ t nil)
+
+ (autoload 'mh-uuencode-and-insert "mh-shar"
+ "Uuencode and insert the file FILE into the current buffer.
+ Normally, the uuencoded filename does not contain a pathname.
+ If ABSOLUTE is non-nil, or if a prefix argument is given, the uuencoded
+ information will contain an absolute pathname."
+ t nil)
+
+
;;; Build the folder-mode keymap:
***************
*** 2822,2827
(define-key mh-folder-mode-map "?" 'mh-msg-is-in-seq)
(define-key mh-folder-mode-map "%" 'mh-put-msg-in-seq)
(define-key mh-folder-mode-map "|" 'mh-pipe-msg)
(define-key mh-folder-mode-map "\ea" 'mh-edit-again)
(define-key mh-folder-mode-map "\e%" 'mh-delete-msg-from-seq)
(define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
--- 3109,3115 -----
(define-key mh-folder-mode-map "?" 'mh-msg-is-in-seq)
(define-key mh-folder-mode-map "%" 'mh-put-msg-in-seq)
(define-key mh-folder-mode-map "|" 'mh-pipe-msg)
+ (define-key mh-folder-mode-map "=" 'mh-set-default-refile-folder)
(define-key mh-folder-mode-map "\ea" 'mh-edit-again)
(define-key mh-folder-mode-map "\e%" 'mh-delete-msg-from-seq)
(define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
***************
*** 2827,2832
(define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
(define-key mh-folder-mode-map "\C-xw" 'mh-widen)
(define-key mh-folder-mode-map "\eb" 'mh-burst-digest)
(define-key mh-folder-mode-map "\eu" 'mh-undo-folder)
(define-key mh-folder-mode-map "\e " 'mh-page-digest)
(define-key mh-folder-mode-map "\e\177" 'mh-page-digest-backwards)
--- 3115,3124 -----
(define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
(define-key mh-folder-mode-map "\C-xw" 'mh-widen)
(define-key mh-folder-mode-map "\eb" 'mh-burst-digest)
+ (define-key mh-folder-mode-map "\ec" 'mh-uudecode)
+ (define-key mh-folder-mode-map "\en" 'mh-unshar)
+ (define-key mh-folder-mode-map "\eq" 'mh-list-sequences)
+ (define-key mh-folder-mode-map "\eS" 'mh-sort-folder)
(define-key mh-folder-mode-map "\eu" 'mh-undo-folder)
(define-key mh-folder-mode-map "\e " 'mh-page-digest)
(define-key mh-folder-mode-map "\e\177" 'mh-page-digest-backwards)
***************
*** 2864,2869
(define-key mh-folder-mode-map "p" 'mh-previous-undeleted-msg)
(define-key mh-folder-mode-map "n" 'mh-next-undeleted-msg)
(define-key mh-folder-mode-map "o" 'mh-refile-msg)
;;; Build the letter-mode keymap:
--- 3156,3166 -----
(define-key mh-folder-mode-map "p" 'mh-previous-undeleted-msg)
(define-key mh-folder-mode-map "n" 'mh-next-undeleted-msg)
(define-key mh-folder-mode-map "o" 'mh-refile-msg)
+ (define-key mh-folder-mode-map "v" 'mh-check-md4-signature)
+ (define-key mh-letter-mode-map "\C-cs" 'mh-shar-and-insert)
+ (define-key mh-letter-mode-map "\C-cu" 'mh-uuencode-and-insert)
+ ;; Make TAB expand aliases
+ (define-key mh-letter-mode-map "\t" 'mh-expand-