diff options
| author | Richard M. Stallman | 1993-05-28 21:29:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-05-28 21:29:37 +0000 |
| commit | cbfa19e9210ccba7d3ecf25456293611fec7c215 (patch) | |
| tree | d34cddcf22acfc9f386808333f725bb3fbe44f55 | |
| parent | c1380f31bfd2b5bf42f6ffce36cc871e8a01f827 (diff) | |
| download | emacs-cbfa19e9210ccba7d3ecf25456293611fec7c215.tar.gz emacs-cbfa19e9210ccba7d3ecf25456293611fec7c215.zip | |
Version 3.8.1 from Gildea.
| -rw-r--r-- | lisp/mh-e.el | 343 |
1 files changed, 191 insertions, 152 deletions
diff --git a/lisp/mh-e.el b/lisp/mh-e.el index 63cc9efe2d8..f4ef521a1b0 100644 --- a/lisp/mh-e.el +++ b/lisp/mh-e.el | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | ;;; mh-e.el --- GNU Emacs interface to the MH mailer | 1 | ;;; mh-e.el --- GNU Emacs interface to the MH mail system |
| 2 | 2 | ||
| 3 | ;;; Copyright (C) 1985, 86, 87, 88, 89, 92 Free Software Foundation | 3 | ;;; Copyright (C) 1985, 86, 87, 88, 90, 92, 93 Free Software Foundation |
| 4 | 4 | ||
| 5 | ;; Author: James Larus <larus@ginger.berkeley.edu> | 5 | (defconst mh-e-time-stamp "Time-stamp: <93/05/27 18:02:50 gildea>") |
| 6 | ;; Version: 3.7 | ||
| 7 | ;; Keywords: mail | ||
| 8 | 6 | ||
| 9 | (defvar mh-e-RCS-id) | 7 | ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu> |
| 8 | ;; Version: 3.8.1 | ||
| 9 | ;; Keywords: mail | ||
| 10 | 10 | ||
| 11 | ;; GNU Emacs is distributed in the hope that it will be useful, | 11 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 12 | ;; but without any warranty. No author or distributor | 12 | ;; but without any warranty. No author or distributor |
| @@ -24,17 +24,31 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;;; This file contains mh-e, a GNU Emacs front end to the MH mail system | 27 | ;;; mh-e works with Emacs 18 or 19, and MH 5 or 6. |
| 28 | ;;; (specifically, for use with MH.5 and MH.6). | 28 | |
| 29 | ;;; HOW TO USE: | ||
| 30 | ;;; M-x mh-rmail to read mail. Type C-h m there for a list of commands. | ||
| 31 | ;;; C-u M-x mh-rmail to visit any folder. | ||
| 32 | ;;; M-x mh-smail to send mail. From within the mail reader, "m" works, too. | ||
| 33 | ;;; Your .emacs might benefit from these bindings: | ||
| 34 | ;;; (global-set-key "\C-xm" 'mh-smail) | ||
| 35 | ;;; (global-set-key "\C-x4m" 'mh-smail-other-window) | ||
| 36 | ;;; (global-set-key "\C-cr" 'mh-rmail) | ||
| 37 | |||
| 38 | ;;; MH (Message Handler) is a powerful mail reader. The MH newsgroup | ||
| 39 | ;;; is comp.mail.mh; the mailing list is mh-users@ics.uci.edu (send to | ||
| 40 | ;;; mh-users-request to be added). See the monthly Frequently Asked | ||
| 41 | ;;; Questions posting there for information on getting MH. | ||
| 29 | 42 | ||
| 30 | ;;; Original version for Gosling emacs by Brian Reid, Stanford, 1982. | 43 | ;;; NB. MH must have been compiled with the MHE compiler flag or several |
| 31 | ;;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985. | 44 | ;;; features necessary mh-e will be missing from MH commands, specifically |
| 32 | ;;; Rewritten for GNU Emacs, James Larus 1985. larus@ginger.berkeley.edu | 45 | ;;; the -build switch to repl and forw. |
| 33 | ;;; Modified by Stephen Gildea 1988. gildea@bbn.com | ||
| 34 | 46 | ||
| 35 | ;;; NB. MH must have been compiled with the MHE compiler flag or several | 47 | ;;; Original version for Gosling emacs by Brian Reid, Stanford, 1982. |
| 36 | ;;; features necessary mh-e will be missing from MH commands, specifically | 48 | ;;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985. |
| 37 | ;;; the -build switch to repl and forw. | 49 | ;;; Rewritten for GNU Emacs, James Larus 1985. larus@ginger.berkeley.edu |
| 50 | ;;; Modified by Stephen Gildea 1988. gildea@bbn.com | ||
| 51 | (defconst mh-e-RCS-id "$Header: mh-e.el,v 3.9 93/01/11 11:49:18 gildea Exp $") | ||
| 38 | 52 | ||
| 39 | ;;; Code: | 53 | ;;; Code: |
| 40 | 54 | ||
| @@ -47,7 +61,7 @@ | |||
| 47 | ;;;(defvar mh-progs "/usr/new/mh/" "Directory containing MH commands.") | 61 | ;;;(defvar mh-progs "/usr/new/mh/" "Directory containing MH commands.") |
| 48 | ;;;(defvar mh-lib "/usr/new/lib/mh/" "Directory of MH library.") | 62 | ;;;(defvar mh-lib "/usr/new/lib/mh/" "Directory of MH library.") |
| 49 | 63 | ||
| 50 | (defvar mh-redist-full-contents t | 64 | (defvar mh-redist-full-contents nil |
| 51 | "Non-nil if the `dist' command needs whole letter for redistribution. | 65 | "Non-nil if the `dist' command needs whole letter for redistribution. |
| 52 | This is the case when `send' is compiled with the BERK option.") | 66 | This is the case when `send' is compiled with the BERK option.") |
| 53 | 67 | ||
| @@ -70,8 +84,11 @@ It is passed three arguments: TO recipients, SUBJECT, and CC recipients.") | |||
| 70 | (defvar mh-inc-folder-hook nil | 84 | (defvar mh-inc-folder-hook nil |
| 71 | "Invoked after incorporating mail into a folder with \\[mh-inc-folder].") | 85 | "Invoked after incorporating mail into a folder with \\[mh-inc-folder].") |
| 72 | 86 | ||
| 87 | (defvar mh-before-quit-hook nil | ||
| 88 | "Invoked by \\[mh-quit] before quitting mh-e. See also mh-quit-hook") | ||
| 89 | |||
| 73 | (defvar mh-quit-hook nil | 90 | (defvar mh-quit-hook nil |
| 74 | "Invoked after quitting mh-e with \\[mh-quit].") | 91 | "Invoked after quitting mh-e by \\[mh-quit]. See also mh-before-quit-hook") |
| 75 | 92 | ||
| 76 | 93 | ||
| 77 | (defvar mh-ins-string nil | 94 | (defvar mh-ins-string nil |
| @@ -118,12 +135,12 @@ WARNING: do not delete the messages until printing is finished; | |||
| 118 | otherwise, your output may be truncated.") | 135 | otherwise, your output may be truncated.") |
| 119 | 136 | ||
| 120 | (defvar mh-summary-height 4 | 137 | (defvar mh-summary-height 4 |
| 121 | "*Number of lines in summary window.") | 138 | "*Number of lines in summary window (including the mode line).") |
| 122 | 139 | ||
| 123 | (defvar mh-recenter-summary-p nil | 140 | (defvar mh-recenter-summary-p nil |
| 124 | "*Recenter summary window when the show window is toggled off if non-nil.") | 141 | "*Recenter summary window when the show window is toggled off if non-nil.") |
| 125 | 142 | ||
| 126 | (defvar mh-ins-buf-prefix ">> " | 143 | (defvar mh-ins-buf-prefix "> " |
| 127 | "*String to put before each non-blank line of a yanked or inserted message. | 144 | "*String to put before each non-blank line of a yanked or inserted message. |
| 128 | Used when the message is inserted in an outgoing letter.") | 145 | Used when the message is inserted in an outgoing letter.") |
| 129 | 146 | ||
| @@ -141,7 +158,7 @@ windows displaying the message.") | |||
| 141 | 158 | ||
| 142 | (defvar mh-yank-from-start-of-msg t | 159 | (defvar mh-yank-from-start-of-msg t |
| 143 | "*Controls which part of a message is yanked by \\[mh-yank-cur-msg]. | 160 | "*Controls which part of a message is yanked by \\[mh-yank-cur-msg]. |
| 144 | If non-nil, include the entire message. If the symbol `body, then yank the | 161 | If non-nil, include the entire message. If the symbol `body', then yank the |
| 145 | message minus the header. If nil, yank only the portion of the message | 162 | message minus the header. If nil, yank only the portion of the message |
| 146 | following the point. If the show buffer has a region, this variable is | 163 | following the point. If the show buffer has a region, this variable is |
| 147 | ignored.") | 164 | ignored.") |
| @@ -154,9 +171,12 @@ value and it should be one of \"from\", \"to\", or \"cc\".") | |||
| 154 | (defvar mh-recursive-folders nil | 171 | (defvar mh-recursive-folders nil |
| 155 | "*If non-nil, then commands which operate on folders do so recursively.") | 172 | "*If non-nil, then commands which operate on folders do so recursively.") |
| 156 | 173 | ||
| 174 | (defvar mh-unshar-default-directory "" | ||
| 175 | "*Default for directory name prompted for by mh-unshar-msg.") | ||
| 176 | |||
| 157 | 177 | ||
| 158 | ;;; Parameterize mh-e to work with different scan formats. The defaults work | 178 | ;;; Parameterize mh-e to work with different scan formats. The defaults work |
| 159 | ;;; the standard MH scan listings. | 179 | ;;; with the standard MH scan listings. |
| 160 | 180 | ||
| 161 | (defvar mh-cmd-note 4 | 181 | (defvar mh-cmd-note 4 |
| 162 | "Offset to insert notation.") | 182 | "Offset to insert notation.") |
| @@ -214,7 +234,10 @@ The string is displayed after the folder's name. NIL for no annotation.") | |||
| 214 | If `mh-visible-headers' is non-nil, it is used instead to specify what | 234 | If `mh-visible-headers' is non-nil, it is used instead to specify what |
| 215 | to keep.") | 235 | to keep.") |
| 216 | 236 | ||
| 217 | (defvar mh-rejected-letter-start "^ ----- Unsent message follows -----$" | 237 | (defvar mh-rejected-letter-start |
| 238 | (concat "^ ----- Unsent message follows -----$" ;from mail system | ||
| 239 | "\\|^------- Unsent Draft$" ;from MH itself | ||
| 240 | "\\|^ --- The unsent message follows ---$") ;from AIX mail system | ||
| 218 | "Regexp specifying the beginning of the wrapper around a returned letter. | 241 | "Regexp specifying the beginning of the wrapper around a returned letter. |
| 219 | This wrapper is generated by the mail system when rejecting a letter.") | 242 | This wrapper is generated by the mail system when rejecting a letter.") |
| 220 | 243 | ||
| @@ -240,6 +263,9 @@ This wrapper is generated by the mail system when rejecting a letter.") | |||
| 240 | (defvar mh-pick-mode-map (make-sparse-keymap) | 263 | (defvar mh-pick-mode-map (make-sparse-keymap) |
| 241 | "Keymap for searching folder.") | 264 | "Keymap for searching folder.") |
| 242 | 265 | ||
| 266 | (defvar mh-searching-folder nil | ||
| 267 | "Folder this pick is searching.") | ||
| 268 | |||
| 243 | (defvar mh-letter-mode-syntax-table nil | 269 | (defvar mh-letter-mode-syntax-table nil |
| 244 | "Syntax table used while in mh-e letter mode.") | 270 | "Syntax table used while in mh-e letter mode.") |
| 245 | 271 | ||
| @@ -266,9 +292,6 @@ NIL means do not use draft folder.") | |||
| 266 | (defvar mh-previous-seq nil | 292 | (defvar mh-previous-seq nil |
| 267 | "Name of the sequence to which a message was last added.") | 293 | "Name of the sequence to which a message was last added.") |
| 268 | 294 | ||
| 269 | (defvar mh-signature-file-name "~/.signature" | ||
| 270 | "Name of file containing the user's signature.") | ||
| 271 | |||
| 272 | 295 | ||
| 273 | ;;; Macros and generic functions: | 296 | ;;; Macros and generic functions: |
| 274 | 297 | ||
| @@ -413,13 +436,13 @@ from a sequence." | |||
| 413 | (config (current-window-configuration)) | 436 | (config (current-window-configuration)) |
| 414 | (draft | 437 | (draft |
| 415 | (cond ((and mh-draft-folder (equal from-folder mh-draft-folder)) | 438 | (cond ((and mh-draft-folder (equal from-folder mh-draft-folder)) |
| 416 | (find-file (mh-msg-filename msg)) | 439 | (pop-to-buffer (find-file-noselect (mh-msg-filename msg)) t) |
| 417 | (rename-buffer (format "draft-%d" msg)) | 440 | (rename-buffer (format "draft-%d" msg)) |
| 418 | (buffer-name)) | 441 | (buffer-name)) |
| 419 | (t | 442 | (t |
| 420 | (mh-read-draft "clean-up" (mh-msg-filename msg) nil))))) | 443 | (mh-read-draft "clean-up" (mh-msg-filename msg) nil))))) |
| 421 | (mh-clean-msg-header (point-min) | 444 | (mh-clean-msg-header (point-min) |
| 422 | "^Date:\\|^Received:\\|^Message-Id:\\|^From:" | 445 | "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Delivery-Date:" |
| 423 | nil) | 446 | nil) |
| 424 | (goto-char (point-min)) | 447 | (goto-char (point-min)) |
| 425 | (set-buffer-modified-p nil) | 448 | (set-buffer-modified-p nil) |
| @@ -450,7 +473,7 @@ Default is the displayed message." | |||
| 450 | (forward-char 1) | 473 | (forward-char 1) |
| 451 | (delete-region (point-min) (point)) | 474 | (delete-region (point-min) (point)) |
| 452 | (mh-clean-msg-header (point-min) | 475 | (mh-clean-msg-header (point-min) |
| 453 | "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:" | 476 | "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Return-Path:" |
| 454 | nil)) | 477 | nil)) |
| 455 | (t | 478 | (t |
| 456 | (message "Does not appear to be a rejected letter."))) | 479 | (message "Does not appear to be a rejected letter."))) |
| @@ -517,7 +540,7 @@ If optional prefix argument provided, then prompt for the message sequence." | |||
| 517 | Non-nil second argument means do not signal an error if message does not exist. | 540 | Non-nil second argument means do not signal an error if message does not exist. |
| 518 | Non-nil third argument means not to show the message. | 541 | Non-nil third argument means not to show the message. |
| 519 | Return non-nil if cursor is at message." | 542 | Return non-nil if cursor is at message." |
| 520 | (interactive "NMessage number? ") | 543 | (interactive "NGoto message: ") |
| 521 | (let ((cur-msg (mh-get-msg-num nil)) | 544 | (let ((cur-msg (mh-get-msg-num nil)) |
| 522 | (starting-place (point)) | 545 | (starting-place (point)) |
| 523 | (msg-pattern (mh-msg-search-pat number))) | 546 | (msg-pattern (mh-msg-search-pat number))) |
| @@ -544,7 +567,7 @@ Return non-nil if cursor is at message." | |||
| 544 | (defun mh-inc-folder (&optional maildrop-name) | 567 | (defun mh-inc-folder (&optional maildrop-name) |
| 545 | "Inc(orporate) new mail into +inbox. | 568 | "Inc(orporate) new mail into +inbox. |
| 546 | Optional prefix argument specifies an alternate maildrop from the default. | 569 | Optional prefix argument specifies an alternate maildrop from the default. |
| 547 | If this is given, mail is incorporated into the current folder, rather | 570 | If this is given, incorporate mail into the current folder, rather |
| 548 | than +inbox. Run `mh-inc-folder-hook' after incorporating new mail." | 571 | than +inbox. Run `mh-inc-folder-hook' after incorporating new mail." |
| 549 | (interactive (list (if current-prefix-arg | 572 | (interactive (list (if current-prefix-arg |
| 550 | (expand-file-name | 573 | (expand-file-name |
| @@ -573,7 +596,8 @@ than +inbox. Run `mh-inc-folder-hook' after incorporating new mail." | |||
| 573 | (mh-remove-folder-from-folder-list folder) | 596 | (mh-remove-folder-from-folder-list folder) |
| 574 | (message "Folder %s removed" folder) | 597 | (message "Folder %s removed" folder) |
| 575 | (mh-set-folder-modified-p nil) ; so kill-buffer doesn't complain | 598 | (mh-set-folder-modified-p nil) ; so kill-buffer doesn't complain |
| 576 | (kill-buffer mh-show-buffer) | 599 | (if (get-buffer mh-show-buffer) |
| 600 | (kill-buffer mh-show-buffer)) | ||
| 577 | (kill-buffer folder)) | 601 | (kill-buffer folder)) |
| 578 | (message "Folder not removed"))) | 602 | (message "Folder not removed"))) |
| 579 | 603 | ||
| @@ -594,7 +618,9 @@ than +inbox. Run `mh-inc-folder-hook' after incorporating new mail." | |||
| 594 | (switch-to-buffer " *mh-temp*") | 618 | (switch-to-buffer " *mh-temp*") |
| 595 | (erase-buffer) | 619 | (erase-buffer) |
| 596 | (message "Listing folders...") | 620 | (message "Listing folders...") |
| 597 | (mh-exec-cmd-output "folders" t) | 621 | (mh-exec-cmd-output "folders" t (if mh-recursive-folders |
| 622 | "-recurse" | ||
| 623 | "-norecurse")) | ||
| 598 | (goto-char (point-min)) | 624 | (goto-char (point-min)) |
| 599 | (message "Listing folders...done")))) | 625 | (message "Listing folders...done")))) |
| 600 | 626 | ||
| @@ -660,7 +686,7 @@ Otherwise just send the message's body." | |||
| 660 | (interactive | 686 | (interactive |
| 661 | (list current-prefix-arg (read-string "Shell command on message: "))) | 687 | (list current-prefix-arg (read-string "Shell command on message: "))) |
| 662 | (save-excursion | 688 | (save-excursion |
| 663 | (set-buffer mh-show-buffer) | 689 | (mh-display-msg (mh-get-msg-num t) mh-current-folder) ;update show buffer |
| 664 | (goto-char (point-min)) | 690 | (goto-char (point-min)) |
| 665 | (if (not prefix-provided) (search-forward "\n\n")) | 691 | (if (not prefix-provided) (search-forward "\n\n")) |
| 666 | (shell-command-on-region (point) (point-max) command nil))) | 692 | (shell-command-on-region (point) (point-max) command nil))) |
| @@ -721,7 +747,7 @@ using filter mhl.reply in your MH directory." | |||
| 721 | (message "Composing a reply...") | 747 | (message "Composing a reply...") |
| 722 | (cond ((or (equal reply-to "from") (equal reply-to "")) | 748 | (cond ((or (equal reply-to "from") (equal reply-to "")) |
| 723 | (apply 'mh-exec-cmd | 749 | (apply 'mh-exec-cmd |
| 724 | "repl" "-build" | 750 | "repl" "-build" "-noquery" |
| 725 | "-nodraftfolder" mh-current-folder | 751 | "-nodraftfolder" mh-current-folder |
| 726 | msg | 752 | msg |
| 727 | "-nocc" "all" | 753 | "-nocc" "all" |
| @@ -729,7 +755,7 @@ using filter mhl.reply in your MH directory." | |||
| 729 | (list "-filter" "mhl.reply")))) | 755 | (list "-filter" "mhl.reply")))) |
| 730 | ((equal reply-to "to") | 756 | ((equal reply-to "to") |
| 731 | (apply 'mh-exec-cmd | 757 | (apply 'mh-exec-cmd |
| 732 | "repl" "-build" | 758 | "repl" "-build" "-noquery" |
| 733 | "-nodraftfolder" mh-current-folder | 759 | "-nodraftfolder" mh-current-folder |
| 734 | msg | 760 | msg |
| 735 | "-cc" "to" | 761 | "-cc" "to" |
| @@ -737,7 +763,7 @@ using filter mhl.reply in your MH directory." | |||
| 737 | (list "-filter" "mhl.reply")))) | 763 | (list "-filter" "mhl.reply")))) |
| 738 | ((or (equal reply-to "cc") (equal reply-to "all")) | 764 | ((or (equal reply-to "cc") (equal reply-to "all")) |
| 739 | (apply 'mh-exec-cmd | 765 | (apply 'mh-exec-cmd |
| 740 | "repl" "-build" | 766 | "repl" "-build" "-noquery" |
| 741 | "-nodraftfolder" mh-current-folder | 767 | "-nodraftfolder" mh-current-folder |
| 742 | msg | 768 | msg |
| 743 | "-cc" "all" "-nocc" "me" | 769 | "-cc" "all" "-nocc" "me" |
| @@ -764,9 +790,11 @@ using filter mhl.reply in your MH directory." | |||
| 764 | 790 | ||
| 765 | 791 | ||
| 766 | (defun mh-quit () | 792 | (defun mh-quit () |
| 767 | "Restore the previous window configuration, if one exists. | 793 | "Quit mh-e. |
| 768 | Finish by running mh-quit-hook." | 794 | Start by running mh-before-quit-hook. Restore the previous window |
| 795 | configuration, if one exists. Finish by running mh-quit-hook." | ||
| 769 | (interactive) | 796 | (interactive) |
| 797 | (run-hooks 'mh-before-quit-hook) | ||
| 770 | (if mh-previous-window-config | 798 | (if mh-previous-window-config |
| 771 | (set-window-configuration mh-previous-window-config)) | 799 | (set-window-configuration mh-previous-window-config)) |
| 772 | (run-hooks 'mh-quit-hook)) | 800 | (run-hooks 'mh-quit-hook)) |
| @@ -903,7 +931,7 @@ If optional prefix argument provided, then prompt for the message sequence." | |||
| 903 | (mh-add-msgs-to-seq from to)) | 931 | (mh-add-msgs-to-seq from to)) |
| 904 | 932 | ||
| 905 | 933 | ||
| 906 | (defun mh-rescan-folder (range) | 934 | (defun mh-rescan-folder (&optional range) |
| 907 | "Rescan a folder after optionally processing the outstanding commands. | 935 | "Rescan a folder after optionally processing the outstanding commands. |
| 908 | If optional prefix argument is provided, prompt for the range of | 936 | If optional prefix argument is provided, prompt for the range of |
| 909 | messages to display. Otherwise show the entire folder." | 937 | messages to display. Otherwise show the entire folder." |
| @@ -987,7 +1015,10 @@ setting of the variable mh-redist-full-contents. See its documentation." | |||
| 987 | 1015 | ||
| 988 | 1016 | ||
| 989 | (defun mh-send (to cc subject) | 1017 | (defun mh-send (to cc subject) |
| 990 | "Compose and send a letter." | 1018 | "Compose and send a letter. |
| 1019 | The letter is composed in mh-letter-mode; see its documentation for more | ||
| 1020 | details. If `mh-compose-letter-function' is defined, it is called on the | ||
| 1021 | draft and passed three arguments: to, subject, and cc." | ||
| 991 | (interactive "sTo: \nsCc: \nsSubject: ") | 1022 | (interactive "sTo: \nsCc: \nsSubject: ") |
| 992 | (let ((config (current-window-configuration))) | 1023 | (let ((config (current-window-configuration))) |
| 993 | (delete-other-windows) | 1024 | (delete-other-windows) |
| @@ -1042,14 +1073,15 @@ mh-summary-height) and the show buffer below it." | |||
| 1042 | (mh-show-message-in-other-window) | 1073 | (mh-show-message-in-other-window) |
| 1043 | (mh-display-msg msg folder)) | 1074 | (mh-display-msg msg folder)) |
| 1044 | (other-window -1) | 1075 | (other-window -1) |
| 1045 | (shrink-window (- (window-height) mh-summary-height)) | 1076 | (if (not (= (1+ (window-height)) (screen-height))) ;not horizontally split |
| 1077 | (shrink-window (- (window-height) mh-summary-height))) | ||
| 1046 | (mh-recenter nil) | 1078 | (mh-recenter nil) |
| 1047 | (if (not (memq msg mh-seen-list)) (mh-push msg mh-seen-list))) | 1079 | (if (not (memq msg mh-seen-list)) (mh-push msg mh-seen-list))) |
| 1048 | 1080 | ||
| 1049 | 1081 | ||
| 1050 | (defun mh-sort-folder () | 1082 | (defun mh-sort-folder () |
| 1051 | "Sort the messages in the current folder by date." | 1083 | "Sort the messages in the current folder by date." |
| 1052 | (interactive "") | 1084 | (interactive) |
| 1053 | (mh-process-or-undo-commands mh-current-folder) | 1085 | (mh-process-or-undo-commands mh-current-folder) |
| 1054 | (setq mh-next-direction 'forward) | 1086 | (setq mh-next-direction 'forward) |
| 1055 | (mh-set-folder-modified-p t) ; lock folder while sorting | 1087 | (mh-set-folder-modified-p t) ; lock folder while sorting |
| @@ -1075,21 +1107,30 @@ provided, then prompt for the message sequence." | |||
| 1075 | (if current-prefix-arg | 1107 | (if current-prefix-arg |
| 1076 | (mh-read-seq-default "Undo" t) | 1108 | (mh-read-seq-default "Undo" t) |
| 1077 | (mh-get-msg-num t)))) | 1109 | (mh-get-msg-num t)))) |
| 1078 | |||
| 1079 | (cond (prefix-provided | 1110 | (cond (prefix-provided |
| 1080 | (mh-mapc (function mh-undo-msg) (mh-seq-to-msgs msg-or-seq))) | 1111 | (mh-mapc (function mh-undo-msg) (mh-seq-to-msgs msg-or-seq))) |
| 1081 | ((or (looking-at mh-deleted-msg-regexp) | ||
| 1082 | (looking-at mh-refiled-msg-regexp)) | ||
| 1083 | (mh-undo-msg (mh-get-msg-num t))) | ||
| 1084 | (t | 1112 | (t |
| 1085 | (error "Nothing to undo"))) | 1113 | (let ((original-position (point))) |
| 1114 | (beginning-of-line) | ||
| 1115 | (while (not (or (looking-at mh-deleted-msg-regexp) | ||
| 1116 | (looking-at mh-refiled-msg-regexp) | ||
| 1117 | (and (eq mh-next-direction 'forward) (bobp)) | ||
| 1118 | (and (eq mh-next-direction 'backward) | ||
| 1119 | (save-excursion (forward-line) (eobp))))) | ||
| 1120 | (forward-line (if (eq mh-next-direction 'forward) -1 1))) | ||
| 1121 | (if (or (looking-at mh-deleted-msg-regexp) | ||
| 1122 | (looking-at mh-refiled-msg-regexp)) | ||
| 1123 | (progn | ||
| 1124 | (mh-undo-msg (mh-get-msg-num t)) | ||
| 1125 | (mh-maybe-show)) | ||
| 1126 | (goto-char original-position) | ||
| 1127 | (error "Nothing to undo"))))) | ||
| 1086 | ;; update the mh-refile-list so mh-outstanding-commands-p will work | 1128 | ;; update the mh-refile-list so mh-outstanding-commands-p will work |
| 1087 | (mh-mapc (function | 1129 | (mh-mapc (function |
| 1088 | (lambda (elt) | 1130 | (lambda (elt) |
| 1089 | (if (not (mh-seq-to-msgs elt)) | 1131 | (if (not (mh-seq-to-msgs elt)) |
| 1090 | (setq mh-refile-list (delq elt mh-refile-list))))) | 1132 | (setq mh-refile-list (delq elt mh-refile-list))))) |
| 1091 | mh-refile-list) | 1133 | mh-refile-list) |
| 1092 | |||
| 1093 | (if (not (mh-outstanding-commands-p)) | 1134 | (if (not (mh-outstanding-commands-p)) |
| 1094 | (mh-set-folder-modified-p nil))) | 1135 | (mh-set-folder-modified-p nil))) |
| 1095 | 1136 | ||
| @@ -1098,18 +1139,17 @@ provided, then prompt for the message sequence." | |||
| 1098 | ;; Undo the deletion or refile of one MESSAGE. | 1139 | ;; Undo the deletion or refile of one MESSAGE. |
| 1099 | (cond ((memq msg mh-delete-list) | 1140 | (cond ((memq msg mh-delete-list) |
| 1100 | (setq mh-delete-list (delq msg mh-delete-list)) | 1141 | (setq mh-delete-list (delq msg mh-delete-list)) |
| 1101 | (mh-remove-msg-from-seq msg 'deleted t) | 1142 | (mh-remove-msg-from-seq msg 'deleted t)) |
| 1102 | (mh-notate msg ? mh-cmd-note)) | ||
| 1103 | (t | 1143 | (t |
| 1104 | (mh-mapc (function (lambda (dest) | 1144 | (mh-mapc (function (lambda (dest) |
| 1105 | (mh-remove-msg-from-seq msg dest t))) | 1145 | (mh-remove-msg-from-seq msg dest t))) |
| 1106 | mh-refile-list) | 1146 | mh-refile-list))) |
| 1107 | (mh-notate msg ? mh-cmd-note)))) | 1147 | (mh-notate msg ? mh-cmd-note)) |
| 1108 | 1148 | ||
| 1109 | 1149 | ||
| 1110 | (defun mh-undo-folder (&rest ignore) | 1150 | (defun mh-undo-folder (&rest ignore) |
| 1111 | "Undo all commands in current folder." | 1151 | "Undo all commands in current folder." |
| 1112 | (interactive "") | 1152 | (interactive) |
| 1113 | (cond ((or mh-do-not-confirm | 1153 | (cond ((or mh-do-not-confirm |
| 1114 | (yes-or-no-p "Undo all commands in folder? ")) | 1154 | (yes-or-no-p "Undo all commands in folder? ")) |
| 1115 | (setq mh-delete-list nil | 1155 | (setq mh-delete-list nil |
| @@ -1123,22 +1163,57 @@ provided, then prompt for the message sequence." | |||
| 1123 | (sit-for 2)))) | 1163 | (sit-for 2)))) |
| 1124 | 1164 | ||
| 1125 | 1165 | ||
| 1166 | (defun mh-unshar-msg (dir) | ||
| 1167 | "Unpack the shar file contained in the current message into directory DIR." | ||
| 1168 | (interactive (list (read-file-name "Unshar message in directory: " | ||
| 1169 | mh-unshar-default-directory | ||
| 1170 | mh-unshar-default-directory nil))) | ||
| 1171 | (mh-display-msg (mh-get-msg-num t) mh-current-folder) ;update show buffer | ||
| 1172 | (mh-unshar-buffer dir)) | ||
| 1173 | |||
| 1174 | (defun mh-unshar-buffer (dir) | ||
| 1175 | ;; Unpack the shar file contained in the current buffer into directory DIR. | ||
| 1176 | (goto-char (point-min)) | ||
| 1177 | (if (or (re-search-forward "^#![ \t]*/bin/sh" nil t) | ||
| 1178 | (and (re-search-forward "^[^a-z0-9\"]*cut here\b" nil t) | ||
| 1179 | (forward-line 1)) | ||
| 1180 | (re-search-forward "^#" nil t) | ||
| 1181 | (re-search-forward "^: " nil t)) | ||
| 1182 | (let ((default-directory (expand-file-name dir)) | ||
| 1183 | (start (progn (beginning-of-line) (point))) | ||
| 1184 | (log-buffer (get-buffer-create "*Unshar Output*"))) | ||
| 1185 | (save-excursion | ||
| 1186 | (set-buffer log-buffer) | ||
| 1187 | (setq default-directory (expand-file-name dir)) | ||
| 1188 | (erase-buffer) | ||
| 1189 | (if (file-directory-p default-directory) | ||
| 1190 | (insert "cd " dir "\n") | ||
| 1191 | (insert "mkdir " dir "\n") | ||
| 1192 | (call-process "mkdir" nil log-buffer t default-directory))) | ||
| 1193 | (set-window-start (display-buffer log-buffer) 0) ;so can watch progress | ||
| 1194 | (call-process-region start (point-max) "sh" nil log-buffer t)) | ||
| 1195 | (error "Cannot find start of shar."))) | ||
| 1196 | |||
| 1197 | |||
| 1126 | (defun mh-visit-folder (folder &optional range) | 1198 | (defun mh-visit-folder (folder &optional range) |
| 1127 | "Visit FOLDER and display RANGE of messages." | 1199 | "Visit FOLDER and display RANGE of messages. |
| 1200 | Assumes mh-e has already been initialized." | ||
| 1128 | (interactive (list (mh-prompt-for-folder "Visit" "+inbox" t) | 1201 | (interactive (list (mh-prompt-for-folder "Visit" "+inbox" t) |
| 1129 | (mh-read-msg-range "Range [all]? "))) | 1202 | (mh-read-msg-range "Range [all]? "))) |
| 1130 | (let ((config (current-window-configuration))) | 1203 | (let ((config (current-window-configuration))) |
| 1131 | (mh-scan-folder folder (or range "all")) | 1204 | (mh-scan-folder folder (or range "all")) |
| 1132 | (setq mh-previous-window-config config))) | 1205 | (setq mh-previous-window-config config)) |
| 1206 | nil) | ||
| 1133 | 1207 | ||
| 1134 | 1208 | ||
| 1135 | (defun mh-widen () | 1209 | (defun mh-widen () |
| 1136 | "Remove restrictions from the current folder, thereby showing all messages." | 1210 | "Remove restrictions from the current folder, thereby showing all messages." |
| 1137 | (interactive "") | 1211 | (interactive) |
| 1138 | (with-mh-folder-updating (t) | 1212 | (if mh-narrowed-to-seq |
| 1139 | (delete-region (point-min) (point-max)) | 1213 | (with-mh-folder-updating (t) |
| 1140 | (widen) | 1214 | (delete-region (point-min) (point-max)) |
| 1141 | (mh-make-folder-mode-line)) | 1215 | (widen) |
| 1216 | (mh-make-folder-mode-line))) | ||
| 1142 | (setq mh-narrowed-to-seq nil)) | 1217 | (setq mh-narrowed-to-seq nil)) |
| 1143 | 1218 | ||
| 1144 | 1219 | ||
| @@ -1160,7 +1235,7 @@ provided, then prompt for the message sequence." | |||
| 1160 | 1235 | ||
| 1161 | 1236 | ||
| 1162 | (defun mh-refile-a-msg (msg destination) | 1237 | (defun mh-refile-a-msg (msg destination) |
| 1163 | ;; Refile MESSAGE in FOLDER. | 1238 | ;; Refile MESSAGE in FOLDER. FOLDER is a symbol, not a string. |
| 1164 | (save-excursion | 1239 | (save-excursion |
| 1165 | (mh-goto-msg msg nil t) | 1240 | (mh-goto-msg msg nil t) |
| 1166 | (cond ((looking-at mh-deleted-msg-regexp) | 1241 | (cond ((looking-at mh-deleted-msg-regexp) |
| @@ -1184,6 +1259,7 @@ provided, then prompt for the message sequence." | |||
| 1184 | 1259 | ||
| 1185 | (defun mh-display-msg (msg-num folder) | 1260 | (defun mh-display-msg (msg-num folder) |
| 1186 | ;; Display message NUMBER of FOLDER. | 1261 | ;; Display message NUMBER of FOLDER. |
| 1262 | ;; Sets the current buffer to the show buffer. | ||
| 1187 | (set-buffer folder) | 1263 | (set-buffer folder) |
| 1188 | ;; Bind variables in folder buffer in case they are local | 1264 | ;; Bind variables in folder buffer in case they are local |
| 1189 | (let ((formfile mhl-formfile) | 1265 | (let ((formfile mhl-formfile) |
| @@ -1253,7 +1329,7 @@ provided, then prompt for the message sequence." | |||
| 1253 | (save-restriction | 1329 | (save-restriction |
| 1254 | (goto-char start) | 1330 | (goto-char start) |
| 1255 | (if (search-forward "\n\n" nil t) | 1331 | (if (search-forward "\n\n" nil t) |
| 1256 | (backward-char 2)) | 1332 | (backward-char 1)) |
| 1257 | (narrow-to-region start (point)) | 1333 | (narrow-to-region start (point)) |
| 1258 | (goto-char (point-min)) | 1334 | (goto-char (point-min)) |
| 1259 | (if visible-headers | 1335 | (if visible-headers |
| @@ -1293,7 +1369,7 @@ provided, then prompt for the message sequence." | |||
| 1293 | ;; reused. | 1369 | ;; reused. |
| 1294 | (cond (mh-draft-folder | 1370 | (cond (mh-draft-folder |
| 1295 | (let ((orig-default-dir default-directory)) | 1371 | (let ((orig-default-dir default-directory)) |
| 1296 | (pop-to-buffer (find-file-noselect (mh-new-draft-name) t)) | 1372 | (pop-to-buffer (find-file-noselect (mh-new-draft-name)) t) |
| 1297 | (rename-buffer (format "draft-%s" (buffer-name))) | 1373 | (rename-buffer (format "draft-%s" (buffer-name))) |
| 1298 | (setq default-directory orig-default-dir))) | 1374 | (setq default-directory orig-default-dir))) |
| 1299 | (t | 1375 | (t |
| @@ -1436,9 +1512,9 @@ Variables controlling mh-e operation are (defaults in parentheses): | |||
| 1436 | a messages is toggled off. | 1512 | a messages is toggled off. |
| 1437 | 1513 | ||
| 1438 | mh-summary-height (4) | 1514 | mh-summary-height (4) |
| 1439 | Number of lines in the summary window. | 1515 | Number of lines in the summary window including the mode line. |
| 1440 | 1516 | ||
| 1441 | mh-ins-buf-prefix (\">> \") | 1517 | mh-ins-buf-prefix (\"> \") |
| 1442 | String to insert before each non-blank line of a message as it is | 1518 | String to insert before each non-blank line of a message as it is |
| 1443 | inserted in a draft letter. | 1519 | inserted in a draft letter. |
| 1444 | 1520 | ||
| @@ -1464,6 +1540,7 @@ The value of mh-folder-mode-hook is called when a new folder is set up." | |||
| 1464 | 'mh-first-msg-num nil ; Number of first msg in buffer | 1540 | 'mh-first-msg-num nil ; Number of first msg in buffer |
| 1465 | 'mh-last-msg-num nil ; Number of last msg in buffer | 1541 | 'mh-last-msg-num nil ; Number of last msg in buffer |
| 1466 | 'mh-previous-window-config nil) ; Previous window configuration | 1542 | 'mh-previous-window-config nil) ; Previous window configuration |
| 1543 | (setq truncate-lines t) | ||
| 1467 | (auto-save-mode -1) | 1544 | (auto-save-mode -1) |
| 1468 | (setq buffer-offer-save t) | 1545 | (setq buffer-offer-save t) |
| 1469 | (make-local-variable 'write-file-hooks) | 1546 | (make-local-variable 'write-file-hooks) |
| @@ -1696,7 +1773,7 @@ The value of mh-folder-mode-hook is called when a new folder is set up." | |||
| 1696 | (save-excursion | 1773 | (save-excursion |
| 1697 | (mh-first-msg) | 1774 | (mh-first-msg) |
| 1698 | (while (and msgs (< (point) (point-max))) | 1775 | (while (and msgs (< (point) (point-max))) |
| 1699 | (cond ((= (mh-get-msg-num nil) (car msgs)) | 1776 | (cond ((equal (mh-get-msg-num nil) (car msgs)) |
| 1700 | (delete-region (point) (save-excursion (forward-line) (point))) | 1777 | (delete-region (point) (save-excursion (forward-line) (point))) |
| 1701 | (setq msgs (cdr msgs))) | 1778 | (setq msgs (cdr msgs))) |
| 1702 | (t | 1779 | (t |
| @@ -1769,7 +1846,10 @@ invoked with no args, if those values are non-nil. | |||
| 1769 | (mh-set-mode-name "mh-e letter") | 1846 | (mh-set-mode-name "mh-e letter") |
| 1770 | (set-syntax-table mh-letter-mode-syntax-table) | 1847 | (set-syntax-table mh-letter-mode-syntax-table) |
| 1771 | (run-hooks 'text-mode-hook 'mh-letter-mode-hook) | 1848 | (run-hooks 'text-mode-hook 'mh-letter-mode-hook) |
| 1772 | (mh-when auto-fill-function | 1849 | (mh-when (and (boundp 'auto-fill-hook) auto-fill-hook) ;emacs 18 |
| 1850 | (make-local-variable 'auto-fill-hook) | ||
| 1851 | (setq auto-fill-hook 'mh-auto-fill-for-letter)) | ||
| 1852 | (mh-when (and (boundp 'auto-fill-function) auto-fill-function) ;emacs 19 | ||
| 1773 | (make-local-variable 'auto-fill-function) | 1853 | (make-local-variable 'auto-fill-function) |
| 1774 | (setq auto-fill-function 'mh-auto-fill-for-letter))) | 1854 | (setq auto-fill-function 'mh-auto-fill-for-letter))) |
| 1775 | 1855 | ||
| @@ -1797,7 +1877,7 @@ invoked with no args, if those values are non-nil. | |||
| 1797 | "Move point to the end of a specified header field. | 1877 | "Move point to the end of a specified header field. |
| 1798 | The field is indicated by the previous keystroke. Create the field if | 1878 | The field is indicated by the previous keystroke. Create the field if |
| 1799 | it does not exist. Set the mark to point before moving." | 1879 | it does not exist. Set the mark to point before moving." |
| 1800 | (interactive "") | 1880 | (interactive) |
| 1801 | (expand-abbrev) | 1881 | (expand-abbrev) |
| 1802 | (let ((target (cdr (assoc (logior last-input-char ?`) mh-to-field-choices))) | 1882 | (let ((target (cdr (assoc (logior last-input-char ?`) mh-to-field-choices))) |
| 1803 | (case-fold-search t)) | 1883 | (case-fold-search t)) |
| @@ -1805,9 +1885,10 @@ it does not exist. Set the mark to point before moving." | |||
| 1805 | (let ((eol (point))) | 1885 | (let ((eol (point))) |
| 1806 | (skip-chars-backward " \t") | 1886 | (skip-chars-backward " \t") |
| 1807 | (delete-region (point) eol)) | 1887 | (delete-region (point) eol)) |
| 1808 | (if (save-excursion | 1888 | (if (and (not (eq (logior last-input-char ?`) ?s)) |
| 1809 | (backward-char 1) | 1889 | (save-excursion |
| 1810 | (not (looking-at "[:,]"))) | 1890 | (backward-char 1) |
| 1891 | (not (looking-at "[:,]")))) | ||
| 1811 | (insert ", ") | 1892 | (insert ", ") |
| 1812 | (insert " "))) | 1893 | (insert " "))) |
| 1813 | (t | 1894 | (t |
| @@ -1833,8 +1914,8 @@ Prompt for the field name with a completion list of the current folders." | |||
| 1833 | 1914 | ||
| 1834 | (defun mh-insert-signature () | 1915 | (defun mh-insert-signature () |
| 1835 | "Insert the file ~/.signature at the current point." | 1916 | "Insert the file ~/.signature at the current point." |
| 1836 | (interactive "") | 1917 | (interactive) |
| 1837 | (insert-file-contents mh-signature-file-name) | 1918 | (insert-file-contents "~/.signature") |
| 1838 | (set-buffer-modified-p (buffer-modified-p))) ; force mode line update | 1919 | (set-buffer-modified-p (buffer-modified-p))) ; force mode line update |
| 1839 | 1920 | ||
| 1840 | 1921 | ||
| @@ -1883,7 +1964,7 @@ Put messages found in a sequence named `search'." | |||
| 1883 | (interactive) | 1964 | (interactive) |
| 1884 | (let ((pattern-buffer (buffer-name)) | 1965 | (let ((pattern-buffer (buffer-name)) |
| 1885 | (searching-buffer mh-searching-folder) | 1966 | (searching-buffer mh-searching-folder) |
| 1886 | (range) | 1967 | range msgs |
| 1887 | (pattern nil) | 1968 | (pattern nil) |
| 1888 | (new-buffer nil)) | 1969 | (new-buffer nil)) |
| 1889 | (save-excursion | 1970 | (save-excursion |
| @@ -1997,7 +2078,7 @@ Run mh-before-send-letter-hook before doing anything." | |||
| 1997 | "-nodraftfolder" mh-send-args file-name) | 2078 | "-nodraftfolder" mh-send-args file-name) |
| 1998 | (mh-exec-cmd-output "send" t "-watch" "-nopush" | 2079 | (mh-exec-cmd-output "send" t "-watch" "-nopush" |
| 1999 | "-nodraftfolder" file-name)) | 2080 | "-nodraftfolder" file-name)) |
| 2000 | (goto-char (point-max)) | 2081 | (goto-char (point-max)) ; show the interesting part |
| 2001 | (recenter -1) | 2082 | (recenter -1) |
| 2002 | (set-buffer draft-buffer)) ; for annotation below | 2083 | (set-buffer draft-buffer)) ; for annotation below |
| 2003 | (mh-send-args | 2084 | (mh-send-args |
| @@ -2068,7 +2149,8 @@ yanked message will be deleted." | |||
| 2068 | (delete-windows-on mh-show-buffer)) | 2149 | (delete-windows-on mh-show-buffer)) |
| 2069 | (set-buffer mh-show-buffer) ; Find displayed message | 2150 | (set-buffer mh-show-buffer) ; Find displayed message |
| 2070 | (let ((mh-ins-str (cond ((mark) | 2151 | (let ((mh-ins-str (cond ((mark) |
| 2071 | (buffer-substring (point) (mark))) | 2152 | (buffer-substring (region-beginning) |
| 2153 | (region-end))) | ||
| 2072 | ((eq 'body mh-yank-from-start-of-msg) | 2154 | ((eq 'body mh-yank-from-start-of-msg) |
| 2073 | (buffer-substring | 2155 | (buffer-substring |
| 2074 | (save-excursion | 2156 | (save-excursion |
| @@ -2102,7 +2184,7 @@ yanked message will be deleted." | |||
| 2102 | (defun mh-fully-kill-draft () | 2184 | (defun mh-fully-kill-draft () |
| 2103 | "Kill the draft message file and the draft message buffer. | 2185 | "Kill the draft message file and the draft message buffer. |
| 2104 | Use \\[kill-buffer] if you don't want to delete the draft message file." | 2186 | Use \\[kill-buffer] if you don't want to delete the draft message file." |
| 2105 | (interactive "") | 2187 | (interactive) |
| 2106 | (if (y-or-n-p "Kill draft message? ") | 2188 | (if (y-or-n-p "Kill draft message? ") |
| 2107 | (let ((config mh-previous-window-config)) | 2189 | (let ((config mh-previous-window-config)) |
| 2108 | (if (file-exists-p (buffer-file-name)) | 2190 | (if (file-exists-p (buffer-file-name)) |
| @@ -2198,7 +2280,8 @@ Use \\[kill-buffer] if you don't want to delete the draft message file." | |||
| 2198 | (save-excursion | 2280 | (save-excursion |
| 2199 | (mh-exec-cmd-quiet " *mh-temp*" "mark" folder "-list") | 2281 | (mh-exec-cmd-quiet " *mh-temp*" "mark" folder "-list") |
| 2200 | (goto-char (point-min)) | 2282 | (goto-char (point-min)) |
| 2201 | (while (re-search-forward "^[^:]+" nil t) | 2283 | ;; look for name in line of form "cur: 4" or "myseq (private): 23" |
| 2284 | (while (re-search-forward "^[^: ]+" nil t) | ||
| 2202 | (mh-push (mh-make-seq (intern (buffer-substring (match-beginning 0) | 2285 | (mh-push (mh-make-seq (intern (buffer-substring (match-beginning 0) |
| 2203 | (match-end 0))) | 2286 | (match-end 0))) |
| 2204 | (mh-read-msg-list)) | 2287 | (mh-read-msg-list)) |
| @@ -2324,7 +2407,7 @@ Use \\[kill-buffer] if you don't want to delete the draft message file." | |||
| 2324 | 2407 | ||
| 2325 | (defun mh-folder-name-p (name) | 2408 | (defun mh-folder-name-p (name) |
| 2326 | ;; Return non-NIL if NAME is possibly the name of a folder. | 2409 | ;; Return non-NIL if NAME is possibly the name of a folder. |
| 2327 | ;; A name can be a folder name if it begins with "+". | 2410 | ;; A name (a string or symbol) can be a folder name if it begins with "+". |
| 2328 | (if (symbolp name) | 2411 | (if (symbolp name) |
| 2329 | (eql (aref (symbol-name name) 0) ?+) | 2412 | (eql (aref (symbol-name name) 0) ?+) |
| 2330 | (eql (aref name 0) ?+))) | 2413 | (eql (aref name 0) ?+))) |
| @@ -2458,10 +2541,11 @@ Use \\[kill-buffer] if you don't want to delete the draft message file." | |||
| 2458 | (save-excursion | 2541 | (save-excursion |
| 2459 | (set-buffer (get-buffer-create " *mh-temp*")) | 2542 | (set-buffer (get-buffer-create " *mh-temp*")) |
| 2460 | (erase-buffer)) | 2543 | (erase-buffer)) |
| 2461 | (let ((process (apply 'start-process | 2544 | (let* ((process-connection-type nil) |
| 2462 | command nil | 2545 | (process (apply 'start-process |
| 2463 | (expand-file-name command mh-progs) | 2546 | command nil |
| 2464 | (mh-list-to-string args)))) | 2547 | (expand-file-name command mh-progs) |
| 2548 | (mh-list-to-string args)))) | ||
| 2465 | (set-process-filter process 'mh-process-daemon))) | 2549 | (set-process-filter process 'mh-process-daemon))) |
| 2466 | 2550 | ||
| 2467 | 2551 | ||
| @@ -2531,16 +2615,16 @@ Use \\[kill-buffer] if you don't want to delete the draft message file." | |||
| 2531 | ;;; User prompting commands. | 2615 | ;;; User prompting commands. |
| 2532 | 2616 | ||
| 2533 | (defun mh-prompt-for-folder (prompt default can-create) | 2617 | (defun mh-prompt-for-folder (prompt default can-create) |
| 2534 | ;; Prompt for a folder name with PROMPT. Returns the folder's name. | 2618 | ;; Prompt for a folder name with PROMPT. Returns the folder's name as a |
| 2535 | ;; DEFAULT is used if the folder exists and the user types return. | 2619 | ;; string. DEFAULT is used if the folder exists and the user types return. |
| 2536 | ;; If the CAN-CREATE flag is t, then a non-existant folder is made. | 2620 | ;; If the CAN-CREATE flag is t, then a non-existent folder is made. |
| 2537 | (let* ((prompt (format "%s folder%s" prompt | 2621 | (let* ((prompt (format "%s folder%s" prompt |
| 2538 | (if (equal "" default) | 2622 | (if (equal "" default) |
| 2539 | "? " | 2623 | "? " |
| 2540 | (format " [%s]? " default)))) | 2624 | (format " [%s]? " default)))) |
| 2541 | name) | 2625 | name) |
| 2542 | (if (null mh-folder-list) | 2626 | (if (null mh-folder-list) |
| 2543 | (setq mh-folder-list (mh-make-folder-list))) | 2627 | (mh-set-folder-list)) |
| 2544 | (while (and (setq name (completing-read prompt mh-folder-list | 2628 | (while (and (setq name (completing-read prompt mh-folder-list |
| 2545 | nil nil "+")) | 2629 | nil nil "+")) |
| 2546 | (equal name "") | 2630 | (equal name "") |
| @@ -2556,17 +2640,21 @@ Use \\[kill-buffer] if you don't want to delete the draft message file." | |||
| 2556 | (message "Creating %s" name) | 2640 | (message "Creating %s" name) |
| 2557 | (call-process "mkdir" nil nil nil (mh-expand-file-name name)) | 2641 | (call-process "mkdir" nil nil nil (mh-expand-file-name name)) |
| 2558 | (message "Creating %s...done" name) | 2642 | (message "Creating %s...done" name) |
| 2559 | (mh-push (list name) mh-folder-list) | 2643 | (mh-push (list name) mh-folder-list)) |
| 2560 | (mh-push (list (substring name 1 nil)) mh-folder-list)) | ||
| 2561 | (new-file-p | 2644 | (new-file-p |
| 2562 | (error "Folder %s is not created" name)) | 2645 | (error "Folder %s is not created" name)) |
| 2563 | (t | 2646 | (t |
| 2564 | (mh-when (null (assoc name mh-folder-list)) | 2647 | (mh-when (null (assoc name mh-folder-list)) |
| 2565 | (mh-push (list name) mh-folder-list) | 2648 | (mh-push (list name) mh-folder-list))))) |
| 2566 | (mh-push (list (substring name 1 nil)) mh-folder-list))))) | ||
| 2567 | name)) | 2649 | name)) |
| 2568 | 2650 | ||
| 2569 | 2651 | ||
| 2652 | (defun mh-set-folder-list () | ||
| 2653 | "Sets mh-folder-list correctly. | ||
| 2654 | A useful function for the command line or for when you need to sync by hand." | ||
| 2655 | (setq mh-folder-list (mh-make-folder-list))) | ||
| 2656 | |||
| 2657 | |||
| 2570 | (defun mh-make-folder-list () | 2658 | (defun mh-make-folder-list () |
| 2571 | "Return a list of the user's folders. | 2659 | "Return a list of the user's folders. |
| 2572 | Result is in a form suitable for completing read." | 2660 | Result is in a form suitable for completing read." |
| @@ -2687,21 +2775,15 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2687 | ;; Returns the empty string if the field is not in the message. | 2775 | ;; Returns the empty string if the field is not in the message. |
| 2688 | (let ((case-fold-search t)) | 2776 | (let ((case-fold-search t)) |
| 2689 | (goto-char (point-min)) | 2777 | (goto-char (point-min)) |
| 2690 | (cond ((not (search-forward field nil t)) "") | 2778 | (cond ((not (re-search-forward (format "^%s" field) nil t)) "") |
| 2691 | ((looking-at "[\t ]*$") "") | 2779 | ((looking-at "[\t ]*$") "") |
| 2692 | (t | 2780 | (t |
| 2693 | (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t) | 2781 | (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t) |
| 2694 | (let ((field (buffer-substring (match-beginning 1) | 2782 | (let ((start (match-beginning 1))) |
| 2695 | (match-end 1))) | 2783 | (forward-line 1) |
| 2696 | (end-of-match (point))) | 2784 | (while (looking-at "[ \t]") |
| 2697 | (forward-line) | 2785 | (forward-line 1)) |
| 2698 | (while (looking-at "[ \t]") (forward-line 1)) | 2786 | (buffer-substring start (1- (point)))))))) |
| 2699 | (backward-char 1) | ||
| 2700 | (if (<= (point) end-of-match) | ||
| 2701 | field | ||
| 2702 | (format "%s%s" | ||
| 2703 | field | ||
| 2704 | (buffer-substring end-of-match (point))))))))) | ||
| 2705 | 2787 | ||
| 2706 | 2788 | ||
| 2707 | (defun mh-insert-fields (&rest name-values) | 2789 | (defun mh-insert-fields (&rest name-values) |
| @@ -2725,6 +2807,7 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2725 | (defun mh-position-on-field (field set-mark) | 2807 | (defun mh-position-on-field (field set-mark) |
| 2726 | ;; Set point to the end of the line beginning with FIELD. | 2808 | ;; Set point to the end of the line beginning with FIELD. |
| 2727 | ;; Set the mark to the old value of point, if SET-MARK is non-nil. | 2809 | ;; Set the mark to the old value of point, if SET-MARK is non-nil. |
| 2810 | ;; Returns non-nil iff the field was found. | ||
| 2728 | (let ((case-fold-search t)) | 2811 | (let ((case-fold-search t)) |
| 2729 | (if set-mark (push-mark)) | 2812 | (if set-mark (push-mark)) |
| 2730 | (goto-char (point-min)) | 2813 | (goto-char (point-min)) |
| @@ -2740,52 +2823,6 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2740 | (if (re-search-forward "^$\\|^-+$" nil nil) | 2823 | (if (re-search-forward "^$\\|^-+$" nil nil) |
| 2741 | (forward-line arg))) | 2824 | (forward-line arg))) |
| 2742 | 2825 | ||
| 2743 | |||
| 2744 | (defun mh-unshar (dir) | ||
| 2745 | "Unshar the current message in the directory given by DIR." | ||
| 2746 | (interactive "DUnshar in directory: ") | ||
| 2747 | (let ((default-directory default-directory) | ||
| 2748 | (errbuf " *Unshar Output*") | ||
| 2749 | (curbuf (current-buffer)) | ||
| 2750 | (show-buffer mh-show-buffer) | ||
| 2751 | start | ||
| 2752 | ) | ||
| 2753 | (setq dir (expand-file-name dir)) | ||
| 2754 | (if (not (eq system-type 'vax-vms)) | ||
| 2755 | (setq dir (file-name-as-directory dir))) | ||
| 2756 | (mh-show nil) ;;; force showing of current message | ||
| 2757 | (save-excursion | ||
| 2758 | (set-buffer show-buffer) | ||
| 2759 | (goto-char (point-min)) | ||
| 2760 | (message "Looking for start of shar package ...") | ||
| 2761 | (if (or (re-search-forward "^#![ \t]*/bin/sh" nil t) | ||
| 2762 | (and (re-search-forward "^[^a-z0-9\"]*cut here" nil t) | ||
| 2763 | (forward-line 1)) | ||
| 2764 | (re-search-forward "^#" nil t) | ||
| 2765 | (re-search-forward "^: " nil t) | ||
| 2766 | ) | ||
| 2767 | (progn | ||
| 2768 | (beginning-of-line) | ||
| 2769 | (setq start (point)) | ||
| 2770 | (set-buffer curbuf) | ||
| 2771 | (pop-to-buffer errbuf) | ||
| 2772 | (kill-region (point-max) (point-min)) | ||
| 2773 | (insert (format "Unsharing in directory \"%s\" ...\n\n" dir)) | ||
| 2774 | (message "Please wait ...") | ||
| 2775 | (sit-for 0) | ||
| 2776 | (set-buffer show-buffer) | ||
| 2777 | (setq default-directory dir) | ||
| 2778 | (call-process-region start (point-max) | ||
| 2779 | "/bin/sh" nil errbuf t) | ||
| 2780 | (pop-to-buffer curbuf) | ||
| 2781 | (message "Unshar done") | ||
| 2782 | ) | ||
| 2783 | (error "Can't find start of shar file") | ||
| 2784 | ) | ||
| 2785 | ) | ||
| 2786 | ) | ||
| 2787 | ) | ||
| 2788 | |||
| 2789 | 2826 | ||
| 2790 | 2827 | ||
| 2791 | ;;; Build the folder-mode keymap: | 2828 | ;;; Build the folder-mode keymap: |
| @@ -2808,7 +2845,7 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2808 | (define-key mh-folder-mode-map "\ef" 'mh-visit-folder) | 2845 | (define-key mh-folder-mode-map "\ef" 'mh-visit-folder) |
| 2809 | (define-key mh-folder-mode-map "\ek" 'mh-kill-folder) | 2846 | (define-key mh-folder-mode-map "\ek" 'mh-kill-folder) |
| 2810 | (define-key mh-folder-mode-map "\el" 'mh-list-folders) | 2847 | (define-key mh-folder-mode-map "\el" 'mh-list-folders) |
| 2811 | (define-key mh-folder-mode-map "\en" 'mh-unshar) | 2848 | (define-key mh-folder-mode-map "\en" 'mh-unshar-msg) |
| 2812 | (define-key mh-folder-mode-map "\eo" 'mh-write-msg-to-file) | 2849 | (define-key mh-folder-mode-map "\eo" 'mh-write-msg-to-file) |
| 2813 | (define-key mh-folder-mode-map "\ep" 'mh-pack-folder) | 2850 | (define-key mh-folder-mode-map "\ep" 'mh-pack-folder) |
| 2814 | (define-key mh-folder-mode-map "\es" 'mh-search-folder) | 2851 | (define-key mh-folder-mode-map "\es" 'mh-search-folder) |
| @@ -2826,6 +2863,7 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2826 | (define-key mh-folder-mode-map "m" 'mh-send) | 2863 | (define-key mh-folder-mode-map "m" 'mh-send) |
| 2827 | (define-key mh-folder-mode-map "a" 'mh-reply) | 2864 | (define-key mh-folder-mode-map "a" 'mh-reply) |
| 2828 | (define-key mh-folder-mode-map "j" 'mh-goto-msg) | 2865 | (define-key mh-folder-mode-map "j" 'mh-goto-msg) |
| 2866 | (define-key mh-folder-mode-map "<" 'mh-first-msg) | ||
| 2829 | (define-key mh-folder-mode-map "g" 'mh-goto-msg) | 2867 | (define-key mh-folder-mode-map "g" 'mh-goto-msg) |
| 2830 | (define-key mh-folder-mode-map "\177" 'mh-previous-page) | 2868 | (define-key mh-folder-mode-map "\177" 'mh-previous-page) |
| 2831 | (define-key mh-folder-mode-map " " 'mh-page-msg) | 2869 | (define-key mh-folder-mode-map " " 'mh-page-msg) |
| @@ -2879,10 +2917,11 @@ Assumes that any filename that starts with '+' is a folder name." | |||
| 2879 | 2917 | ||
| 2880 | ;;; For Gnu Emacs. | 2918 | ;;; For Gnu Emacs. |
| 2881 | ;;; Local Variables: *** | 2919 | ;;; Local Variables: *** |
| 2882 | ;;; eval: (put 'mh-when 'lisp-indent-function 1) *** | 2920 | ;;; eval: (put 'mh-when 'lisp-indent-hook 1) *** |
| 2883 | ;;; eval: (put 'with-mh-folder-updating 'lisp-indent-function 1) *** | 2921 | ;;; eval: (put 'with-mh-folder-updating 'lisp-indent-hook 1) *** |
| 2884 | ;;; End: *** | 2922 | ;;; End: *** |
| 2885 | 2923 | ||
| 2886 | (provide 'mh-e) | 2924 | (provide 'mh-e) |
| 2887 | 2925 | ||
| 2888 | ;;; mh-e.el ends here | 2926 | ;;; mh-e.el ends here |
| 2927 | |||