• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/mail/

Lines Matching +defs:rmail +defs:make +defs:summary +defs:line

0 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
32 ;; selection by dispatch table, summary by attributes and keywords,
36 ;; New features include: rmail and rmail-summary buffers remain
38 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
39 ;; variable, and a bury rmail buffer (wipe) command.
50 (defvar rmail-use-spam-filter)
57 ;(defvar rmail-spool-directory "/usr/spool/mail/"
60 ;(defvar rmail-file-name
64 (defgroup rmail nil
68 (defgroup rmail-retrieve nil
70 :prefix "rmail-"
71 :group 'rmail)
73 (defgroup rmail-files nil
75 :prefix "rmail-"
76 :group 'rmail)
78 (defgroup rmail-headers nil
80 :prefix "rmail-"
81 :group 'rmail)
83 (defgroup rmail-reply nil
85 :prefix "rmail-"
86 :group 'rmail)
88 (defgroup rmail-summary nil
89 "Rmail summary options."
90 :prefix "rmail-"
91 :prefix "rmail-summary-"
92 :group 'rmail)
94 (defgroup rmail-output nil
96 :prefix "rmail-output-"
97 :prefix "rmail-"
98 :group 'rmail)
100 (defgroup rmail-edit nil
102 :prefix "rmail-edit-"
103 :group 'rmail)
105 (defgroup rmail-obsolete nil
107 :group 'rmail)
109 (defcustom rmail-movemail-program nil
111 :group 'rmail-retrieve
114 (defcustom rmail-pop-password nil
116 Please use `rmail-remote-password' instead."
119 :group 'rmail-obsolete)
121 (defcustom rmail-pop-password-required nil
123 Please use rmail-remote-password-required instead."
125 :group 'rmail-obsolete)
127 (defcustom rmail-remote-password nil
132 :set-after '(rmail-pop-password)
136 (boundp 'rmail-pop-password)
137 rmail-pop-password)
138 rmail-pop-password
140 (setq rmail-pop-password nil))
141 :group 'rmail-retrieve
144 (defcustom rmail-remote-password-required nil
147 :set-after '(rmail-pop-password-required)
151 (boundp 'rmail-pop-password-required)
152 rmail-pop-password-required)
153 rmail-pop-password-required
155 (setq rmail-pop-password-required nil))
156 :group 'rmail-retrieve
159 (defcustom rmail-movemail-flags nil
164 :group 'rmail-retrieve
167 (defvar rmail-remote-password-error "invalid usercode or password\\|
174 (defvar rmail-encoded-remote-password nil)
176 (defcustom rmail-preserve-inbox nil
179 :group 'rmail-retrieve)
181 (defcustom rmail-movemail-search-path nil
183 :group 'rmail-retrieve
186 (defun rmail-probe (prog)
206 (defun rmail-autodetect ()
208 If `rmail-movemail-program' is non-nil, use it.
210 `rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
211 (if rmail-movemail-program
212 (rmail-probe rmail-movemail-program)
214 (dolist (dir (append rmail-movemail-search-path exec-path
220 (let ((x (rmail-probe progname)))
222 (setq rmail-movemail-program progname)
225 (defvar rmail-movemail-variant-in-use nil
234 (defun rmail-movemail-variant-p (&rest variants)
237 (when (not rmail-movemail-variant-in-use)
239 (setq rmail-movemail-variant-in-use (rmail-autodetect)))
240 (not (null (member rmail-movemail-variant-in-use variants))))
243 (defcustom rmail-dont-reply-to-names nil "\
246 plus whatever is specified by `rmail-default-dont-reply-to-names'."
248 :group 'rmail-reply)
251 (defvar rmail-default-dont-reply-to-names "\\`info-" "\
253 variable `rmail-dont-reply-to-names', for when the user does not set
254 `rmail-dont-reply-to-names' explicitly. (The other part of the default
259 (defcustom rmail-ignored-headers
263 "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
272 "\\|^mbox-line:\\|^cancel-lock:\\|^DomainKey-Signature:"
277 \(See also `rmail-nonignored-headers', which overrides this regexp.)
281 To make a change in this variable take effect
283 go to that message and type \\[rmail-toggle-header] twice."
285 :group 'rmail-headers)
287 (defcustom rmail-nonignored-headers "^x-spam-status:"
289 This regexp overrides `rmail-ignored-headers'; if both this regexp
295 To make a change in this variable take effect
297 go to that message and type \\[rmail-toggle-header] twice."
299 :group 'rmail-headers)
302 (defcustom rmail-displayed-headers nil
305 `rmail-ignored-headers'."
307 :group 'rmail-headers)
310 (defcustom rmail-retry-ignored-headers "^x-authentication-warning:" "\
313 :group 'rmail-headers)
316 (defcustom rmail-highlighted-headers "^From:\\|^Subject:" "\
319 See also `rmail-highlight-face'."
321 :group 'rmail-headers)
323 (defface rmail-highlight
326 :group 'rmail-headers
330 (defcustom rmail-highlight-face 'rmail-highlight "\
334 :group 'rmail-headers)
337 (defcustom rmail-delete-after-output nil "\
340 :group 'rmail-files)
343 (defcustom rmail-primary-inbox-list nil "\
355 :group 'rmail-retrieve
356 :group 'rmail-files)
359 (defcustom rmail-mail-new-frame nil
364 :group 'rmail-reply)
367 (defcustom rmail-secondary-file-directory "~/"
370 :group 'rmail-files)
372 (defcustom rmail-secondary-file-regexp "\\.xmail$"
375 :group 'rmail-files)
378 (defcustom rmail-confirm-expunge 'y-or-n-p
384 :group 'rmail-files)
387 (defvar rmail-mode-hook nil
391 (defvar rmail-get-new-mail-hook nil
395 (defcustom rmail-show-message-hook nil
399 :group 'rmail)
402 (defvar rmail-quit-hook nil
406 (defvar rmail-delete-message-hook nil
415 (defvar rmail-mmdf-delim1 "^\001\001\001\001\n"
417 (defvar rmail-mmdf-delim2 "^\001\001\001\001\n"
420 (defcustom rmail-message-filter nil
423 before obeying `rmail-ignored-headers'."
424 :group 'rmail-headers
427 (defcustom rmail-automatic-folder-directives nil
449 :group 'rmail
453 (defvar rmail-reply-prefix "Re: "
454 "String to prepend to Subject line when replying to a message.")
460 (defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
461 "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
463 (defcustom rmail-display-summary nil
464 "*If non-nil, Rmail always displays the summary buffer."
465 :group 'rmail-summary
469 (defvar rmail-inbox-list nil)
470 (put 'rmail-inbox-list 'permanent-local t)
472 (defvar rmail-keywords nil)
473 (put 'rmail-keywords 'permanent-local t)
475 (defvar rmail-buffer nil
478 In a summary buffer, this holds the RMAIL buffer it is a summary for.")
479 (put 'rmail-buffer 'permanent-local t)
483 (defvar rmail-current-message nil)
484 (put 'rmail-current-message 'permanent-local t)
486 (defvar rmail-total-messages nil)
487 (put 'rmail-total-messages 'permanent-local t)
489 (defvar rmail-message-vector nil)
490 (put 'rmail-message-vector 'permanent-local t)
492 (defvar rmail-deleted-vector nil)
493 (put 'rmail-deleted-vector 'permanent-local t)
495 (defvar rmail-msgref-vector nil
499 (put 'rmail-msgref-vector 'permanent-local t)
501 (defvar rmail-overlay-list nil)
502 (put 'rmail-overlay-list 'permanent-local t)
504 ;; These are used by autoloaded rmail-summary.
506 (defvar rmail-summary-buffer nil)
507 (put 'rmail-summary-buffer 'permanent-local t)
508 (defvar rmail-summary-vector nil)
509 (put 'rmail-summary-vector 'permanent-local t)
511 (defvar rmail-view-buffer nil
513 (put 'rmail-view-buffer 'permanent-local t)
519 (defvar rmail-last-label nil)
520 (put 'rmail-last-label 'permanent-local t)
523 (defvar rmail-last-multi-labels nil)
525 (defvar rmail-last-regexp nil)
526 (put 'rmail-last-regexp 'permanent-local t)
528 (defcustom rmail-default-file "~/xmail"
529 "*Default file name for \\[rmail-output]."
531 :group 'rmail-files)
532 (defcustom rmail-default-rmail-file "~/XMAIL"
533 "*Default file name for \\[rmail-output-to-rmail-file]."
535 :group 'rmail-files)
536 (defcustom rmail-default-body-file "~/mailout"
537 "*Default file name for \\[rmail-output-body-to-file]."
539 :group 'rmail-files
545 (defvar rmail-file-coding-system nil
551 (defcustom rmail-enable-mime nil
558 if the feature specified by `rmail-mime-feature' is not available
563 :group 'rmail)
565 (defvar rmail-enable-mime-composing nil
566 "*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
569 (defvar rmail-show-mime-function nil
571 This function is called when `rmail-enable-mime' is non-nil.
575 (defvar rmail-insert-mime-forwarded-message-function nil
577 This function is called if `rmail-enable-mime' or
578 `rmail-enable-mime-composing' is non-nil.
584 (defvar rmail-insert-mime-resent-message-function nil
586 This function is called if `rmail-enable-mime' is non-nil.
592 (defvar rmail-search-mime-message-function nil
594 This function is called if `rmail-enable-mime' is non-nil.
599 (defvar rmail-search-mime-header-function nil
601 This function is called if `rmail-enable-mime' is non-nil.
608 (defvar rmail-mime-feature 'rmail-mime
610 When starting Rmail, if `rmail-enable-mime' is non-nil,
613 The default value is `rmail-mime'. This feature is provided by
614 the rmail-mime package available at <http://www.m17n.org/rmail-mime/>.")
617 (defvar rmail-decode-mime-charset t
622 If the variable `rmail-enable-mime' is non-nil, this variables is
624 the variable `rmail-mime-feature'.")
627 (defvar rmail-mime-charset-pattern
638 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
640 (defvar rmail-unix-mail-delimiter
650 ;; a `From' line. The leading phrase can be stripped, e.g.
692 (defvar rmail-font-lock-keywords
711 (beginning-of-line) (end-of-line)
718 ;; Perform BODY in the summary buffer
720 (defmacro rmail-select-summary (&rest body)
721 `(let ((total rmail-total-messages))
722 (if (rmail-summary-displayed)
727 (pop-to-buffer rmail-summary-buffer)
728 ;; rmail-total-messages is a buffer-local var
729 ;; in the rmail buffer.
730 ;; This way we make it available for the body
731 ;; even tho the rmail buffer is not current.
732 (let ((rmail-total-messages total))
736 (set-buffer rmail-summary-buffer)
737 (let ((rmail-total-messages total))
739 (rmail-maybe-display-summary)))
747 (defvar rmail-enable-multibyte nil)
750 (defun rmail-require-mime-maybe ()
751 "Require `rmail-mime-feature' if that is non-nil.
752 Signal an error and set `rmail-mime-feature' to nil if the feature
754 (when rmail-enable-mime
756 (require rmail-mime-feature)
761 by setting `rmail-enable-mime' to non-nil, the required feature
762 `%s' (the value of `rmail-mime-feature')
765 rmail-mime-feature))
766 (setq rmail-enable-mime nil)))))
770 (defun rmail (&optional file-name-arg)
772 Moves messages into file named by `rmail-file-name' (a babyl format file)
776 May be called with file name as argument; then performs rmail editing on
781 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
783 (list (read-file-name "Run rmail on RMAIL file: "))))
784 (rmail-require-mime-maybe)
785 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
792 (rmail-enable-multibyte
800 ;; rmail-decode-babyl-format or
801 ;; rmail-convert-to-babyl-format.
802 (coding-system-for-read (and rmail-enable-multibyte 'raw-text))
807 ;; but that should not be needed now that rmail-mode
815 (eq major-mode 'rmail-mode))
816 (progn (rmail-forget-messages)
817 (rmail-set-message-counters))))
821 (if (eq major-mode 'rmail-edit-mode)
825 (or (eq major-mode 'rmail-mode)
826 (progn (rmail-mode-2)
829 (rmail-mode-2)
831 (rmail-convert-file)
834 ;; unibyte. We must make it multibyte if necessary.
835 (if (and rmail-enable-multibyte
839 (rmail-maybe-set-message-counters)
842 (rmail-get-new-mail))
843 (rmail-show-message (rmail-first-unseen-message)))
845 (if rmail-display-summary (rmail-summary))
846 (rmail-construct-io-menu)
848 (run-hooks 'rmail-mode-hook))))))
852 ;; all these inboxes to feed into the primary rmail file.
853 ; (defun rmail-convert-mailpath (string)
864 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
867 ;; This calls rmail-decode-babyl-format if the file is already Babyl.
869 (defun rmail-convert-file ()
878 ;; Just fix the babyl file header; don't make a new one,
881 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
884 (rmail-insert-rmail-file-header))
888 (rmail-insert-rmail-file-header)))
902 ;; (rmail-convert-to-babyl-format would delete the header.)
906 (rmail-convert-to-babyl-format)
908 (if (and (not rmail-enable-mime)
909 rmail-enable-multibyte)
911 (rmail-decode-babyl-format)))))
913 (defun rmail-insert-rmail-file-header ()
915 ;; -*-rmail-*- is here so that visiting the file normally
917 (insert "BABYL OPTIONS: -*- rmail -*-
920 Note: This is the header of an rmail file.
921 Note: If you are seeing it in rmail,
925 ;; rmail-file-coding-system, or if it is nil, do auto conversion.
927 (defun rmail-decode-babyl-format ()
930 (coding-system rmail-file-coding-system)
961 (defvar rmail-mode-map nil)
962 (if rmail-mode-map
964 (setq rmail-mode-map (make-keymap))
965 (suppress-keymap rmail-mode-map)
966 (define-key rmail-mode-map "a" 'rmail-add-label)
967 (define-key rmail-mode-map "b" 'rmail-bury)
968 (define-key rmail-mode-map "c" 'rmail-continue)
969 (define-key rmail-mode-map "d" 'rmail-delete-forward)
970 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward)
971 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
972 (define-key rmail-mode-map "f" 'rmail-forward)
973 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
974 (define-key rmail-mode-map "h" 'rmail-summary)
975 (define-key rmail-mode-map "i" 'rmail-input)
976 (define-key rmail-mode-map "j" 'rmail-show-message)
977 (define-key rmail-mode-map "k" 'rmail-kill-label)
978 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
979 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
980 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
981 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
982 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
983 (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
984 (define-key rmail-mode-map "m" 'rmail-mail)
985 (define-key rmail-mode-map "\em" 'rmail-retry-failure)
986 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
987 (define-key rmail-mode-map "\en" 'rmail-next-message)
988 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
989 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
990 (define-key rmail-mode-map "\C-o" 'rmail-output)
991 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
992 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
993 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
994 (define-key rmail-mode-map "q" 'rmail-quit)
995 (define-key rmail-mode-map "r" 'rmail-reply)
997 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
998 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
999 (define-key rmail-mode-map "\es" 'rmail-search)
1000 (define-key rmail-mode-map "t" 'rmail-toggle-header)
1001 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
1002 (define-key rmail-mode-map "w" 'rmail-output-body-to-file)
1003 (define-key rmail-mode-map "x" 'rmail-expunge)
1004 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
1005 (define-key rmail-mode-map "/" 'rmail-end-of-message)
1006 (define-key rmail-mode-map "<" 'rmail-first-message)
1007 (define-key rmail-mode-map ">" 'rmail-last-message)
1008 (define-key rmail-mode-map " " 'scroll-up)
1009 (define-key rmail-mode-map "\177" 'scroll-down)
1010 (define-key rmail-mode-map "?" 'describe-mode)
1011 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
1012 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
1013 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
1014 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
1015 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
1016 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
1017 (define-key rmail-mode-map "\C-c\C-s\C-k" 'rmail-sort-by-labels)
1018 (define-key rmail-mode-map "\C-c\C-n" 'rmail-next-same-subject)
1019 (define-key rmail-mode-map "\C-c\C-p" 'rmail-previous-same-subject)
1023 (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
1025 (define-key rmail-mode-map [menu-bar classify]
1026 (cons "Classify" (make-sparse-keymap "Classify")))
1028 (define-key rmail-mode-map [menu-bar classify input-menu]
1031 (define-key rmail-mode-map [menu-bar classify output-menu]
1034 (define-key rmail-mode-map [menu-bar classify output-body]
1035 '("Output body to file..." . rmail-output-body-to-file))
1037 (define-key rmail-mode-map [menu-bar classify output-inbox]
1038 '("Output (inbox)..." . rmail-output))
1040 (define-key rmail-mode-map [menu-bar classify output]
1041 '("Output (Rmail)..." . rmail-output-to-rmail-file))
1043 (define-key rmail-mode-map [menu-bar classify kill-label]
1044 '("Kill Label..." . rmail-kill-label))
1046 (define-key rmail-mode-map [menu-bar classify add-label]
1047 '("Add Label..." . rmail-add-label))
1049 (define-key rmail-mode-map [menu-bar summary]
1050 (cons "Summary" (make-sparse-keymap "Summary")))
1052 (define-key rmail-mode-map [menu-bar summary senders]
1053 '("By Senders..." . rmail-summary-by-senders))
1055 (define-key rmail-mode-map [menu-bar summary labels]
1056 '("By Labels..." . rmail-summary-by-labels))
1058 (define-key rmail-mode-map [menu-bar summary recipients]
1059 '("By Recipients..." . rmail-summary-by-recipients))
1061 (define-key rmail-mode-map [menu-bar summary topic]
1062 '("By Topic..." . rmail-summary-by-topic))
1064 (define-key rmail-mode-map [menu-bar summary regexp]
1065 '("By Regexp..." . rmail-summary-by-regexp))
1067 (define-key rmail-mode-map [menu-bar summary all]
1068 '("All" . rmail-summary))
1070 (define-key rmail-mode-map [menu-bar mail]
1071 (cons "Mail" (make-sparse-keymap "Mail")))
1073 (define-key rmail-mode-map [menu-bar mail rmail-get-new-mail]
1074 '("Get New Mail" . rmail-get-new-mail))
1076 (define-key rmail-mode-map [menu-bar mail lambda]
1079 (define-key rmail-mode-map [menu-bar mail continue]
1080 '("Continue" . rmail-continue))
1082 (define-key rmail-mode-map [menu-bar mail resend]
1083 '("Re-send..." . rmail-resend))
1085 (define-key rmail-mode-map [menu-bar mail forward]
1086 '("Forward" . rmail-forward))
1088 (define-key rmail-mode-map [menu-bar mail retry]
1089 '("Retry" . rmail-retry-failure))
1091 (define-key rmail-mode-map [menu-bar mail reply]
1092 '("Reply" . rmail-reply))
1094 (define-key rmail-mode-map [menu-bar mail mail]
1095 '("Mail" . rmail-mail))
1097 (define-key rmail-mode-map [menu-bar delete]
1098 (cons "Delete" (make-sparse-keymap "Delete")))
1100 (define-key rmail-mode-map [menu-bar delete expunge/save]
1101 '("Expunge/Save" . rmail-expunge-and-save))
1103 (define-key rmail-mode-map [menu-bar delete expunge]
1104 '("Expunge" . rmail-expunge))
1106 (define-key rmail-mode-map [menu-bar delete undelete]
1107 '("Undelete" . rmail-undelete-previous-message))
1109 (define-key rmail-mode-map [menu-bar delete delete]
1110 '("Delete" . rmail-delete-forward))
1112 (define-key rmail-mode-map [menu-bar move]
1113 (cons "Move" (make-sparse-keymap "Move")))
1115 (define-key rmail-mode-map [menu-bar move search-back]
1116 '("Search Back..." . rmail-search-backwards))
1118 (define-key rmail-mode-map [menu-bar move search]
1119 '("Search..." . rmail-search))
1121 (define-key rmail-mode-map [menu-bar move previous]
1122 '("Previous Nondeleted" . rmail-previous-undeleted-message))
1124 (define-key rmail-mode-map [menu-bar move next]
1125 '("Next Nondeleted" . rmail-next-undeleted-message))
1127 (define-key rmail-mode-map [menu-bar move last]
1128 '("Last" . rmail-last-message))
1130 (define-key rmail-mode-map [menu-bar move first]
1131 '("First" . rmail-first-message))
1133 (define-key rmail-mode-map [menu-bar move previous]
1134 '("Previous" . rmail-previous-message))
1136 (define-key rmail-mode-map [menu-bar move next]
1137 '("Next" . rmail-next-message))
1140 (defvar rmail-tool-bar-map
1142 (let ((map (make-sparse-keymap)))
1143 (tool-bar-local-item-from-menu 'rmail-get-new-mail "mail/inbox"
1144 map rmail-mode-map)
1145 (tool-bar-local-item-from-menu 'rmail-next-undeleted-message "right-arrow"
1146 map rmail-mode-map)
1147 (tool-bar-local-item-from-menu 'rmail-previous-undeleted-message "left-arrow"
1148 map rmail-mode-map)
1149 (tool-bar-local-item-from-menu 'rmail-search "search"
1150 map rmail-mode-map)
1151 (tool-bar-local-item-from-menu 'rmail-input "open"
1152 map rmail-mode-map)
1153 (tool-bar-local-item-from-menu 'rmail-mail "mail/compose"
1154 map rmail-mode-map)
1155 (tool-bar-local-item-from-menu 'rmail-reply "mail/reply-all"
1156 map rmail-mode-map)
1157 (tool-bar-local-item-from-menu 'rmail-forward "mail/forward"
1158 map rmail-mode-map)
1159 (tool-bar-local-item-from-menu 'rmail-delete-forward "close"
1160 map rmail-mode-map)
1161 (tool-bar-local-item-from-menu 'rmail-output "mail/move"
1162 map rmail-mode-map)
1163 (tool-bar-local-item-from-menu 'rmail-output-body-to-file "mail/save"
1164 map rmail-mode-map)
1165 (tool-bar-local-item-from-menu 'rmail-expunge "delete"
1166 map rmail-mode-map)
1173 (put 'rmail-mode 'mode-class 'special)
1175 (defun rmail-mode-kill-summary ()
1176 (if rmail-summary-buffer (kill-buffer rmail-summary-buffer)))
1179 (defun rmail-mode ()
1180 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
1184 \\[rmail-beginning-of-message] Move point to front of this message.
1185 \\[rmail-end-of-message] Move point to bottom of this message.
1188 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
1189 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
1190 \\[rmail-next-message] Move to Next message whether deleted or not.
1191 \\[rmail-previous-message] Move to Previous message whether deleted or not.
1192 \\[rmail-first-message] Move to the first message in Rmail file.
1193 \\[rmail-last-message] Move to the last message in Rmail file.
1194 \\[rmail-show-message] Jump to message specified by numeric position in file.
1195 \\[rmail-search] Search for string and show message it is found in.
1196 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
1197 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
1198 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
1200 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
1201 \\[rmail-expunge] Expunge deleted messages.
1202 \\[rmail-expunge-and-save] Expunge and save the file.
1203 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
1205 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
1206 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
1207 \\[rmail-continue] Continue composing outgoing message started before.
1208 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
1209 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
1210 \\[rmail-forward] Forward this message to another user.
1211 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
1212 \\[rmail-output] Output this message to a Unix-format mail file (append it).
1213 \\[rmail-output-body-to-file] Save message body to a file. Default filename comes from Subject line.
1214 \\[rmail-input] Input Rmail file. Run Rmail on that file.
1215 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
1216 \\[rmail-kill-label] Kill label. Remove a label from current message.
1217 \\[rmail-next-labeled-message] Move to Next message with specified label
1220 Any other label is present only if you add it with \\[rmail-add-label].
1221 \\[rmail-previous-labeled-message] Move to Previous message with specified label
1222 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
1223 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
1224 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
1225 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
1226 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
1227 \\[rmail-toggle-header] Toggle display of complete header."
1229 (let ((finding-rmail-file (not (eq major-mode 'rmail-mode))))
1230 (rmail-mode-2)
1231 (when (and finding-rmail-file
1234 (let ((rmail-enable-multibyte t))
1235 (rmail-require-mime-maybe)
1236 (rmail-convert-file)
1239 (rmail-set-message-counters)
1240 (rmail-show-message rmail-total-messages)
1241 (when finding-rmail-file
1242 (when rmail-display-summary
1243 (rmail-summary))
1244 (rmail-construct-io-menu))
1245 (run-mode-hooks 'rmail-mode-hook)))
1247 (defun rmail-mode-2 ()
1249 (rmail-mode-1)
1250 (rmail-perm-variables)
1251 (rmail-variables))
1253 (defun rmail-mode-1 ()
1254 (setq major-mode 'rmail-mode)
1261 ;; rmail-output-to-rmail-file enables auto save when you do that.
1263 (setq mode-line-modified "--")
1264 (use-local-map rmail-mode-map)
1269 (defun rmail-perm-variables ()
1270 (make-local-variable 'rmail-last-label)
1271 (make-local-variable 'rmail-last-regexp)
1272 (make-local-variable 'rmail-deleted-vector)
1273 (make-local-variable 'rmail-buffer)
1274 (setq rmail-buffer (current-buffer))
1275 (make-local-variable 'rmail-view-buffer)
1276 (setq rmail-view-buffer rmail-buffer)
1277 (make-local-variable 'rmail-summary-buffer)
1278 (make-local-variable 'rmail-summary-vector)
1279 (make-local-variable 'rmail-current-message)
1280 (make-local-variable 'rmail-total-messages)
1281 (make-local-variable 'rmail-overlay-list)
1282 (setq rmail-overlay-list nil)
1283 (make-local-variable 'rmail-message-vector)
1284 (make-local-variable 'rmail-msgref-vector)
1285 (make-local-variable 'rmail-inbox-list)
1286 (setq rmail-inbox-list (rmail-parse-file-inboxes))
1288 (and (null rmail-inbox-list)
1289 (or (equal buffer-file-name (expand-file-name rmail-file-name))
1291 (abbreviate-file-name (file-truename rmail-file-name))))
1292 (setq rmail-inbox-list
1293 (or rmail-primary-inbox-list
1295 (concat rmail-spool-directory
1297 (make-local-variable 'rmail-keywords)
1298 (set (make-local-variable 'tool-bar-map) rmail-tool-bar-map)
1300 (setq rmail-keywords nil))
1303 (defun rmail-variables ()
1304 (make-local-variable 'save-buffer-coding-system)
1307 ;; because it should be determined in rmail-show-message.
1312 (make-local-variable 'local-enable-local-variables)
1314 (make-local-variable 'revert-buffer-function)
1315 (setq revert-buffer-function 'rmail-revert)
1316 (make-local-variable 'font-lock-defaults)
1318 '(rmail-font-lock-keywords
1321 (font-lock-fontify-buffer-function . rmail-fontify-buffer-function)
1322 (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function)
1324 (make-local-variable 'require-final-newline)
1326 (make-local-variable 'version-control)
1328 (make-local-variable 'kill-buffer-hook)
1329 (add-hook 'kill-buffer-hook 'rmail-mode-kill-summary)
1330 (make-local-variable 'file-precious-flag)
1332 (make-local-variable 'desktop-save-buffer)
1335 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
1336 (defun rmail-revert (arg noconfirm)
1337 (set-buffer rmail-buffer)
1339 (rmail-enable-multibyte enable-multibyte-characters)
1340 ;; See similar code in `rmail'.
1341 (coding-system-for-read (and rmail-enable-multibyte 'raw-text)))
1347 (set-buffer rmail-buffer)
1348 (rmail-mode-2)
1350 (rmail-convert-file)
1353 (if (and rmail-enable-multibyte
1357 (rmail-set-message-counters)
1358 (rmail-show-message rmail-total-messages)
1359 (run-hooks 'rmail-mode-hook)))))
1364 (defun rmail-parse-file-inboxes ()
1375 (narrow-to-region (point) (progn (end-of-line) (point)))
1379 (defun rmail-expunge-and-save ()
1382 (rmail-expunge)
1383 (set-buffer rmail-buffer)
1385 (if (rmail-summary-exists)
1386 (rmail-select-summary (set-buffer-modified-p nil))))
1388 (defun rmail-quit ()
1390 Hook `rmail-quit-hook' is run after expunging."
1392 (rmail-expunge-and-save)
1393 (when (boundp 'rmail-quit-hook)
1394 (run-hooks 'rmail-quit-hook))
1395 ;; Don't switch to the summary buffer even if it was recently visible.
1396 (when rmail-summary-buffer
1397 (replace-buffer-in-windows rmail-summary-buffer)
1398 (bury-buffer rmail-summary-buffer))
1399 (if rmail-enable-mime
1400 (let ((obuf rmail-buffer)
1401 (ovbuf rmail-view-buffer))
1402 (set-buffer rmail-view-buffer)
1411 (defun rmail-bury ()
1412 "Bury current Rmail buffer and its summary buffer."
1414 ;; This let var was called rmail-buffer, but that interfered
1415 ;; with the buffer-local var used in summary buffers.
1417 (if (rmail-summary-exists)
1419 (while (setq window (get-buffer-window rmail-summary-buffer))
1421 (bury-buffer rmail-summary-buffer)))
1424 (defun rmail-duplicate-message ()
1431 (number rmail-current-message)
1432 (string (buffer-substring (rmail-msgbeg rmail-current-message)
1433 (rmail-msgend rmail-current-message))))
1434 (goto-char (rmail-msgend rmail-current-message))
1436 (rmail-forget-messages)
1437 (rmail-show-message number)
1441 (defun rmail-input (filename)
1443 (interactive "FRun rmail on RMAIL file: ")
1444 (rmail filename))
1451 (defun rmail-find-all-files (start)
1452 "Return list of file in dir START that match `rmail-secondary-file-regexp'."
1456 (files (directory-files start t rmail-secondary-file-regexp)))
1461 (defun rmail-list-to-menu (menu-name l action &optional full-name)
1462 (let ((menu (make-sparse-keymap menu-name)))
1469 (rmail-list-to-menu (car item) (cdr item)
1485 rmail-secondary-file-directory))))))
1492 (put 'rmail-disable-menu 'menu-enable ''nil)
1494 (defun rmail-construct-io-menu ()
1495 (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
1498 (define-key rmail-mode-map [menu-bar classify input-menu]
1500 (rmail-list-to-menu "Input Rmail File"
1502 'rmail-input)))
1503 (define-key rmail-mode-map [menu-bar classify output-menu]
1505 (rmail-list-to-menu "Output Rmail File"
1507 'rmail-output-to-rmail-file))))
1509 (define-key rmail-mode-map [menu-bar classify input-menu]
1510 '("Input Rmail File" . rmail-disable-menu))
1511 (define-key rmail-mode-map [menu-bar classify output-menu]
1512 '("Output Rmail File" . rmail-disable-menu)))))
1521 (defun rmail-get-new-mail (&optional file-name)
1524 variable `rmail-primary-inbox-list' specifies the inboxes for your
1533 If the variable `rmail-preserve-inbox' is non-nil, new mail will
1536 This function runs `rmail-get-new-mail-hook' before saving the updated file.
1541 (run-hooks 'rmail-before-get-new-mail-hook)
1546 (set-buffer rmail-buffer)
1547 (rmail-maybe-set-message-counters)
1553 rmail-inbox-list))
1554 (rmail-enable-multibyte (default-value 'enable-multibyte-characters))
1565 (make-backup-files (and make-backup-files (buffer-modified-p)))
1567 ;; Don't make undo records for what we do in getting mail.
1598 (rmail-insert-inbox-text files nil)
1599 (setq delete-files (rmail-insert-inbox-text files t)))
1604 (setq new-messages (rmail-convert-to-babyl-format)
1626 (rmail-count-new-messages)
1627 (run-hooks 'rmail-get-new-mail-hook)
1642 (if (or file-name rmail-inbox-list)
1645 (if (and (featurep 'rmail-spam-filter)
1646 rmail-use-spam-filter)
1648 ((old-messages (- rmail-total-messages new-messages))
1654 (substring rmail-deleted-vector 0 (1+
1657 (setq rmail-deleted-vector
1658 (make-string (1+ rmail-total-messages) ?\ ))
1660 rmail-total-messages)
1662 (if (not (rmail-spam-filter rsf-scanned-message-number))
1669 (when (rmail-expunge-confirmed)
1670 (rmail-only-expunge t))
1672 (setq rmail-deleted-vector
1675 (make-string (- rmail-total-messages old-messages)
1678 (if (rmail-summary-exists)
1679 (rmail-select-summary
1680 (rmail-update-summary)))
1684 (if (and (featurep 'rmail-spam-filter)
1685 rmail-use-spam-filter
1697 (if (and (featurep 'rmail-spam-filter)
1698 rmail-use-spam-filter
1705 (rmail-show-message (rmail-first-unseen-message))
1706 (run-hooks 'rmail-after-get-new-mail-hook)
1710 (or found (rmail-show-message)))))
1712 (defun rmail-parse-url (file)
1730 (when rmail-remote-password-required
1731 (setq got-password (not (rmail-have-password)))
1732 (setq supplied-password (rmail-get-remote-password
1735 (if (rmail-movemail-variant-p 'emacs)
1753 (when rmail-remote-password-required
1754 (setq got-password (not (rmail-have-password)))
1755 (setq supplied-password (rmail-get-remote-password nil)))
1762 (defun rmail-insert-inbox-text (files renamep)
1773 (let ((url-data (rmail-parse-url file)))
1792 ;; Use the directory of this rmail file
1794 ;; if that is on a full disk and this rmail
1828 (list (or rmail-movemail-program
1832 (if rmail-preserve-inbox
1835 (if (rmail-movemail-variant-p 'mailutils)
1836 (append (list "--emacs") rmail-movemail-flags)
1837 rmail-movemail-flags)
1858 (re-search-forward rmail-remote-password-error
1860 (rmail-set-remote-password nil))
1864 (when (rmail-movemail-variant-p 'mailutils)
1888 (if (not (and rmail-preserve-inbox (string= file tofile)))
1896 (defun rmail-decode-region (from to coding)
1909 ;; the rmail-break-forwarded-messages feature is not implemented
1910 (defun rmail-convert-to-babyl-format ()
1920 (concat rmail-mmdf-delim1 "\\|^From") nil t)
1921 (beginning-of-line)
1940 ;; Narrowing will make sure that whatever follows the junk
1951 (forward-line 1)
1953 (forward-line 1)
1954 (forward-line 2))
2002 (or rmail-enable-mime
2003 (not rmail-enable-multibyte)
2005 (if (and rmail-decode-mime-charset
2011 rmail-mime-charset-pattern
2014 (rmail-decode-region start (point) mime-charset)))))
2018 (forward-line 1)
2020 (forward-line 1)
2021 (forward-line 2))
2035 (looking-at rmail-mmdf-delim1))
2038 (re-search-forward rmail-mmdf-delim2 nil t)
2047 (or rmail-enable-mime
2048 (not rmail-enable-multibyte)
2052 (forward-line 3)
2063 (rmail-nuke-pinhead-header)
2089 ;; Back up to end of prev line,
2095 (eol (progn (end-of-line) (point))))
2111 (looking-at rmail-mmdf-delim1))
2119 rmail-unix-mail-delimiter
2121 rmail-mmdf-delim1 "\\|"
2169 (or rmail-enable-mime
2170 (not rmail-enable-multibyte)
2172 (if (and rmail-decode-mime-charset
2178 rmail-mime-charset-pattern
2181 (rmail-decode-region start (point) mime-charset)))
2184 (forward-line 3)
2201 ;; Delete the "From ..." line, creating various other headers with
2203 ;; original line into a mail-from: header line for debugging and for
2204 ;; use by the rmail-output function.
2205 (defun rmail-nuke-pinhead-header ()
2225 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
2257 (defun rmail-reformat-message (beg end)
2259 (forward-line 1)
2266 (forward-line 1)
2268 (while (looking-at "Summary-line:\\|Mail-From:")
2269 (forward-line 1)))
2272 (progn (forward-line 1) (point))))
2279 (if rmail-message-filter (funcall rmail-message-filter))
2280 (if (or rmail-displayed-headers rmail-ignored-headers)
2281 (rmail-clear-headers))))
2283 (defun rmail-clear-headers (&optional ignored-headers)
2287 Otherwise, if `rmail-displayed-headers' is non-nil,
2289 Otherwise, delete all header fields whose names match `rmail-ignored-headers'
2290 unless they also match `rmail-nonignored-headers'."
2295 (if (and rmail-displayed-headers (null ignored-headers))
2307 (re-search-forward rmail-displayed-headers lim t))
2311 (or ignored-headers (setq ignored-headers rmail-ignored-headers))
2317 (beginning-of-line)
2318 (if (looking-at rmail-nonignored-headers)
2319 (forward-line 1)
2326 (defun rmail-msg-is-pruned ()
2327 (rmail-maybe-set-message-counters)
2329 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
2332 (forward-line 1)
2335 (defun rmail-msg-restore-non-pruned-header ()
2341 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
2343 (forward-line 1)
2347 ;; Insert new EOOH line at the proper place.
2348 (forward-line 1)
2351 (forward-line 1)))
2357 (forward-line -1)
2364 ;; Narrow to after the new EOOH line.
2369 (defun rmail-msg-prune-header ()
2373 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
2374 (rmail-reformat-message (point-min) (point-max)))
2378 (defun rmail-toggle-header (&optional arg)
2383 (let* ((pruned (with-current-buffer rmail-buffer
2384 (rmail-msg-is-pruned)))
2390 (set-buffer rmail-buffer)
2391 (rmail-maybe-set-message-counters)
2392 (if rmail-enable-mime
2395 (rmail-msg-restore-non-pruned-header)
2396 (rmail-msg-prune-header))
2397 (funcall rmail-show-mime-function))
2406 (end-of-line)
2409 (old-screen-line
2410 (rmail-count-screen-lines (window-start window) (point))))
2412 (rmail-msg-restore-non-pruned-header)
2413 (rmail-msg-prune-header))
2425 (recenter old-screen-line)
2429 (rmail-highlight-headers))))
2431 (defun rmail-narrow-to-non-pruned-header ()
2434 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
2436 (forward-line 1)
2439 (forward-line 1)
2443 (forward-line 2)
2452 (defun rmail-count-screen-lines (start end)
2464 ;; so it will appear in the mode line.
2465 (defun rmail-display-labels ()
2471 (goto-char (rmail-msgbeg rmail-current-message))
2472 (forward-line 1)
2475 (narrow-to-region (point) (progn (end-of-line) (point)))
2506 (setq mode-line-process
2508 rmail-current-message rmail-total-messages blurb))
2509 ;; If rmail-enable-mime is non-nil, we may have to update
2510 ;; `mode-line-process' of rmail-view-buffer too.
2511 (if (and rmail-enable-mime
2512 (not (eq (current-buffer) rmail-view-buffer))
2513 (buffer-live-p rmail-view-buffer))
2514 (let ((mlp mode-line-process))
2515 (with-current-buffer rmail-view-buffer
2516 (setq mode-line-process mlp))))))
2521 (defun rmail-set-attribute (attr state &optional msgnum)
2522 (set-buffer rmail-buffer)
2526 (or msgnum (setq msgnum rmail-current-message))
2531 (goto-char (+ 3 (rmail-msgbeg msgnum)))
2535 (prog1 (point) (end-of-line)) t)))))
2539 (beginning-of-line)
2543 (rmail-set-message-deleted-p msgnum state)))
2550 (if (= msgnum rmail-current-message)
2551 (rmail-display-labels))))))
2553 ;; Return t if the attributes/keywords line of msg number MSG
2555 (defun rmail-message-labels-p (msg labels)
2559 (goto-char (rmail-msgbeg msg))
2561 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
2566 (defun rmail-msgend (n)
2567 (marker-position (aref rmail-message-vector (1+ n))))
2569 (defun rmail-msgbeg (n)
2570 (marker-position (aref rmail-message-vector n)))
2572 (defun rmail-widen-to-current-msgbeg (function)
2583 (narrow-to-region (rmail-msgbeg rmail-current-message)
2590 (narrow-to-region (rmail-msgbeg rmail-current-message)
2591 (rmail-msgend rmail-current-message)))))
2593 (defun rmail-forget-messages ()
2595 (if (vectorp rmail-message-vector)
2597 (v rmail-message-vector)
2602 (setq rmail-message-vector nil)
2603 (setq rmail-msgref-vector nil)
2604 (setq rmail-deleted-vector nil)))
2606 (defun rmail-maybe-set-message-counters ()
2607 (if (not (and rmail-deleted-vector
2608 rmail-message-vector
2609 rmail-current-message
2610 rmail-total-messages))
2611 (rmail-set-message-counters)))
2613 (defun rmail-count-new-messages (&optional nomsg)
2626 (rmail-set-message-counters-counter (point-min))
2627 (setq rmail-current-message (1+ rmail-total-messages))
2628 (setq rmail-total-messages
2629 (+ rmail-total-messages total-messages))
2630 (setq rmail-message-vector
2631 (vconcat rmail-message-vector (cdr messages-head)))
2632 (aset rmail-message-vector
2633 rmail-current-message (car messages-head))
2634 (setq rmail-deleted-vector
2635 (concat rmail-deleted-vector deleted-head))
2636 (setq rmail-summary-vector
2637 (vconcat rmail-summary-vector (make-vector total-messages nil)))
2638 (setq rmail-msgref-vector
2639 (vconcat rmail-msgref-vector (make-vector total-messages nil)))
2640 ;; Fill in the new elements of rmail-msgref-vector.
2641 (let ((i (1+ (- rmail-total-messages total-messages))))
2642 (while (<= i rmail-total-messages)
2643 (aset rmail-msgref-vector i (list i))
2648 (defun rmail-set-message-counters ()
2649 (rmail-forget-messages)
2667 (rmail-set-message-counters-counter (min (point) point-save))
2669 (rmail-set-message-counters-counter)
2670 (setq rmail-total-messages total-messages)
2671 (setq rmail-current-message
2674 (setq rmail-message-vector
2676 rmail-deleted-vector (concat "0" deleted-head)
2677 rmail-summary-vector (make-vector rmail-total-messages nil)
2678 rmail-msgref-vector (make-vector (1+ rmail-total-messages) nil))
2680 (while (<= i rmail-total-messages)
2681 (aset rmail-msgref-vector i (list i))
2685 (defun rmail-set-message-counters-counter (&optional stop)
2689 ;; Detect messages that have been added with DOS line endings and
2690 ;; convert the line endings for such messages.
2695 (message "Counting messages...(converting line endings)")
2707 (forward-line 2))
2714 (defun rmail-beginning-of-message ()
2717 (let ((rmail-show-message-hook
2720 (rmail-show-message rmail-current-message)))
2722 (defun rmail-end-of-message ()
2725 (let ((rmail-show-message-hook
2729 (rmail-show-message rmail-current-message)))
2731 (defun rmail-unknown-mail-followup-to ()
2735 (rmail-narrow-to-non-pruned-header)
2747 (or rmail-user-mail-address-regexp
2764 (defun rmail-show-message (&optional n no-summary)
2766 If summary buffer is currently displayed, update current message there also."
2768 (or (eq major-mode 'rmail-mode)
2769 (switch-to-buffer rmail-buffer))
2770 (rmail-maybe-set-message-counters)
2772 (if (zerop rmail-total-messages)
2775 (setq mode-line-process nil))
2778 (setq n rmail-current-message)
2781 rmail-current-message 1
2783 ((> n rmail-total-messages)
2784 (setq n rmail-total-messages
2785 rmail-current-message rmail-total-messages
2788 (setq rmail-current-message n))))
2789 (let ((beg (rmail-msgbeg n)))
2791 (forward-line 1)
2793 (let ((end (rmail-msgend n)))
2796 (forward-line 2)
2797 ;; If there's a Summary-line in the (otherwise empty)
2798 ;; header, we didn't yet get past the EOOH line.
2800 (forward-line 1))
2816 (rmail-set-attribute "unseen" nil)
2817 (let ((end (rmail-msgend n)))
2820 (rmail-reformat-message beg end)
2829 (rmail-display-labels)
2830 (if (eq rmail-enable-mime t)
2831 (funcall rmail-show-mime-function)
2832 (setq rmail-view-buffer rmail-buffer))
2834 (rmail-unknown-mail-followup-to))
2835 (rmail-highlight-headers)
2837 (run-hooks 'rmail-show-message-hook)
2838 ;; If there is a summary buffer, try to move to this message
2840 ;; is not mentioned in the summary.
2842 ;; of cursor motion in the summary buffer.
2843 (and (rmail-summary-exists) (not no-summary)
2844 (let ((curr-msg rmail-current-message))
2845 (rmail-select-summary
2846 (rmail-summary-goto-msg curr-msg t t))))
2847 (with-current-buffer rmail-buffer
2848 (rmail-auto-file))
2852 (defun rmail-redecode-body (coding &optional raw)
2879 (when (not rmail-enable-mime)
2880 (or (eq major-mode 'rmail-mode)
2881 (switch-to-buffer rmail-buffer))
2883 (let ((pruned (rmail-msg-is-pruned))
2886 (let ((msgbeg (rmail-msgbeg rmail-current-message))
2887 (msgend (rmail-msgend rmail-current-message))
2893 (rmail-toggle-header 1))
2920 ;; clearly doesn't make sense to encode.
2941 (beginning-of-line)
2946 (rmail-show-message))
2949 (rmail-toggle-header 0)))))))
2952 (defun rmail-highlight-headers ()
2955 rmail-highlighted-headers)
2964 (face (or rmail-highlight-face
2968 (overlays rmail-overlay-list))
2970 (while (re-search-forward rmail-highlighted-headers nil t)
2974 (while (progn (forward-line 1)
2988 ;; rmail-overlay-list.
2989 (setq overlay (make-overlay beg (point)))
2991 (setq rmail-overlay-list
2992 (cons overlay rmail-overlay-list))))))))))
2994 (defun rmail-auto-file ()
2997 (if (or (rmail-message-labels-p rmail-current-message "filed")
2999 (expand-file-name rmail-file-name))))
3006 (d rmail-automatic-folder-directives)
3023 (rmail-delete-forward)
3025 (rmail-delete-message)
3026 (rmail-output-to-rmail-file folder 1 t)
3030 (defun rmail-next-message (n)
3034 (set-buffer rmail-buffer)
3035 (rmail-maybe-set-message-counters)
3036 (rmail-show-message (+ rmail-current-message n)))
3038 (defun rmail-previous-message (n)
3042 (rmail-next-message (- n)))
3044 (defun rmail-next-undeleted-message (n)
3051 (set-buffer rmail-buffer)
3052 (rmail-maybe-set-message-counters)
3053 (let ((lastwin rmail-current-message)
3054 (current rmail-current-message))
3055 (while (and (> n 0) (< current rmail-total-messages))
3057 (if (not (rmail-message-deleted-p current))
3061 (if (not (rmail-message-deleted-p current))
3063 (if (/= lastwin rmail-current-message)
3064 (progn (rmail-show-message lastwin)
3072 (defun rmail-previous-undeleted-message (n)
3077 (rmail-next-undeleted-message (- n)))
3079 (defun rmail-first-message ()
3082 (rmail-maybe-set-message-counters)
3083 (rmail-show-message 1))
3085 (defun rmail-last-message ()
3088 (rmail-maybe-set-message-counters)
3089 (rmail-show-message rmail-total-messages))
3091 (defun rmail-what-message ()
3094 (high rmail-total-messages)
3095 (mid (/ rmail-total-messages 2)))
3097 (if (>= where (rmail-msgbeg mid))
3101 (if (>= where (rmail-msgbeg high)) high low)))
3103 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
3105 (goto-char (rmail-msgbeg msg))
3113 (defun rmail-message-regexp-p (n regexp)
3115 (let ((beg (rmail-msgbeg n))
3116 (end (rmail-msgend n)))
3118 (forward-line 1)
3122 (forward-line 2)
3123 ;; If there's a Summary-line in the (otherwise empty)
3124 ;; header, we didn't yet get past the EOOH line.
3126 (forward-line 1))
3136 (if rmail-enable-mime
3137 (funcall rmail-search-mime-header-function n regexp end)
3140 (defun rmail-search-message (msg regexp)
3142 (goto-char (rmail-msgbeg msg))
3143 (if rmail-enable-mime
3144 (funcall rmail-search-mime-message-function msg regexp)
3145 (re-search-forward regexp (rmail-msgend msg) t)))
3147 (defvar rmail-search-last-regexp nil)
3148 (defun rmail-search (regexp &optional n)
3160 (if rmail-search-last-regexp
3162 rmail-search-last-regexp "): ")
3166 (setq rmail-search-last-regexp regexp))
3167 ((not rmail-search-last-regexp)
3169 (list rmail-search-last-regexp
3175 (set-buffer rmail-buffer)
3176 (rmail-maybe-set-message-counters)
3182 (msg rmail-current-message))
3192 win (rmail-search-message msg regexp)))
3193 (while (and (null win) (< msg rmail-total-messages))
3195 win (rmail-search-message msg regexp))))
3199 (rmail-show-message msg)
3220 (defun rmail-search-backwards (regexp &optional n)
3232 (if rmail-search-last-regexp
3234 rmail-search-last-regexp "): ")
3238 (setq rmail-search-last-regexp regexp))
3239 ((not rmail-search-last-regexp)
3241 (list rmail-search-last-regexp
3243 (rmail-search regexp (- (or n 1))))
3246 (defun rmail-first-unseen-message ()
3247 (rmail-maybe-set-message-counters)
3252 (while (and (not found) (<= current rmail-total-messages))
3253 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
3258 ;; (rmail-show-message found))
3261 (defun rmail-current-subject ()
3268 (if (string-match rmail-reply-regexp subject)
3274 (defun rmail-current-subject-regexp ()
3276 The regular expression matches the subject header line of
3283 `rmail-reply-regexp' and ends with a newline."
3284 (let ((subject (rmail-current-subject)))
3292 (if (string= "\\`" (substring rmail-reply-regexp 0 2))
3293 (substring rmail-reply-regexp 2)
3294 rmail-reply-regexp)
3297 (defun rmail-next-same-subject (n)
3302 (let ((search-regexp (rmail-current-subject-regexp))
3304 (i rmail-current-message)
3312 (< i rmail-total-messages)
3317 (< i rmail-total-messages)
3320 (goto-char (rmail-msgbeg i))
3330 (rmail-show-message found)
3334 (defun rmail-previous-same-subject (n)
3339 (rmail-next-same-subject (- n)))
3344 (defun rmail-message-deleted-p (n)
3345 (= (aref rmail-deleted-vector n) ?D))
3347 (defun rmail-set-message-deleted-p (n state)
3348 (aset rmail-deleted-vector n (if state ?D ?\ )))
3350 (defun rmail-delete-message ()
3353 (rmail-set-attribute "deleted" t)
3354 (run-hooks 'rmail-delete-message-hook))
3356 (defun rmail-undelete-previous-message ()
3359 (set-buffer rmail-buffer)
3360 (let ((msg rmail-current-message))
3362 (not (rmail-message-deleted-p msg)))
3366 (if (/= msg rmail-current-message)
3367 (rmail-show-message msg))
3368 (rmail-set-attribute "deleted" nil)
3369 (if (rmail-summary-exists)
3371 (set-buffer rmail-summary-buffer)
3372 (rmail-summary-mark-undeleted msg)))
3373 (rmail-maybe-display-summary))))
3375 (defun rmail-delete-forward (&optional backward)
3377 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
3382 (rmail-set-attribute "deleted" t)
3383 (run-hooks 'rmail-delete-message-hook)
3384 (let ((del-msg rmail-current-message))
3385 (if (rmail-summary-exists)
3386 (rmail-select-summary
3387 (rmail-summary-mark-deleted del-msg)))
3388 (prog1 (rmail-next-undeleted-message (if backward -1 1))
3389 (rmail-maybe-display-summary))))
3391 (defun rmail-delete-backward ()
3393 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
3395 (rmail-delete-forward t))
3399 ;; DELETEDVEC should be rmail-deleted-vector.
3401 (defun rmail-msg-number-after-expunge (deletedvec oldnum)
3412 (defun rmail-expunge-confirmed ()
3414 See also user-option `rmail-confirm-expunge'."
3415 (set-buffer rmail-buffer)
3416 (or (not (stringp rmail-deleted-vector))
3417 (not (string-match "D" rmail-deleted-vector))
3418 (null rmail-confirm-expunge)
3419 (funcall rmail-confirm-expunge
3422 (defun rmail-only-expunge (&optional dont-show)
3425 (set-buffer rmail-buffer)
3430 (rmail-maybe-set-message-counters)
3433 (opoint (if (and (> rmail-current-message 0)
3434 (rmail-message-deleted-p rmail-current-message))
3436 (if rmail-enable-mime
3437 (with-current-buffer rmail-view-buffer
3440 (messages-head (cons (aref rmail-message-vector 0) nil))
3442 ;; Don't make any undo records for the expunging.
3451 (total rmail-total-messages)
3452 (new-message-number rmail-current-message)
3453 (new-summary nil)
3457 (messages rmail-message-vector)
3458 (deleted rmail-deleted-vector)
3459 (summary rmail-summary-vector))
3460 (setq rmail-total-messages nil
3461 rmail-current-message nil
3462 rmail-message-vector nil
3463 rmail-deleted-vector nil
3464 rmail-summary-vector nil)
3479 (setq new-summary
3480 (cons (if (= counter number) (aref summary (1- number)))
3481 new-summary))
3483 (cons (aref rmail-msgref-vector number)
3491 (setq rmail-current-message new-message-number
3492 rmail-total-messages counter
3493 rmail-message-vector (apply 'vector messages-head)
3494 rmail-deleted-vector (make-string (1+ counter) ?\ )
3495 rmail-summary-vector (vconcat (nreverse new-summary))
3496 rmail-msgref-vector (apply 'vector (nreverse new-msgref))
3502 (rmail-show-message
3503 (if (zerop rmail-current-message) 1 nil)))
3504 (if rmail-enable-mime
3508 (defun rmail-expunge ()
3509 "Erase deleted messages from Rmail file and summary buffer."
3511 (when (rmail-expunge-confirmed)
3512 (rmail-only-expunge)
3513 (if (rmail-summary-exists)
3514 (rmail-select-summary (rmail-update-summary)))))
3519 (defun rmail-start-mail (&optional noerase to subject in-reply-to cc
3530 (if rmail-mail-new-frame
3543 (defun rmail-mail ()
3548 (rmail-start-mail nil nil nil nil nil rmail-view-buffer))
3550 (defun rmail-continue ()
3553 (rmail-start-mail t))
3555 (defun rmail-reply (just-sender)
3563 (msgnum rmail-current-message))
3566 (if rmail-enable-mime
3573 (goto-char (rmail-msgbeg rmail-current-message))
3574 (forward-line 1)
3577 (progn (forward-line 2)
3579 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
3584 (beginning-of-line) (point)))))
3622 (concat rmail-reply-prefix
3624 (string-match rmail-reply-regexp subject))
3627 (rmail-start-mail
3637 (let* ((reply-to-list (rmail-dont-reply-to reply-to)))
3640 (rmail-make-in-reply-to-field from date message-id)
3643 ;; mail-strip-quoted-names is NOT necessary for rmail-dont-reply-to
3645 (let* ((cc-list (rmail-dont-reply-to
3649 rmail-view-buffer
3650 (list (list 'rmail-mark-message
3651 rmail-buffer
3652 (with-current-buffer rmail-buffer
3653 (aref rmail-msgref-vector msgnum))
3659 (defun rmail-mark-message (buffer msgnum-list attribute)
3663 which is an element of rmail-msgref-vector."
3667 (rmail-set-attribute attribute t (car msgnum-list)))))
3669 (defun rmail-make-in-reply-to-field (from date message-id)
3726 (rmail-make-in-reply-to-field from date message-id)))))
3729 (defun rmail-forward (resend)
3732 see the documentation of `rmail-resend'."
3735 (call-interactively 'rmail-resend)
3736 (let ((forward-buffer rmail-buffer)
3737 (msgnum rmail-current-message)
3746 (if (rmail-start-mail
3748 (list (list 'rmail-mark-message
3750 (with-current-buffer rmail-buffer
3751 (aref rmail-msgref-vector msgnum))
3757 (and (not rmail-mail-new-frame) (one-window-p t)))
3762 (if (or rmail-enable-mime rmail-enable-mime-composing)
3763 (funcall rmail-insert-mime-forwarded-message-function
3773 (beginning-of-line)
3775 (forward-line 1))
3786 (defun rmail-resend (address &optional from comment mail-alias-file)
3799 (unless (or (eq rmail-view-buffer (current-buffer))
3800 (eq rmail-buffer (current-buffer)))
3807 (mailbuf rmail-buffer))
3811 (if rmail-enable-mime
3812 (funcall rmail-insert-mime-resent-message-function mailbuf)
3823 (forward-line 1)
3825 (forward-line 1))
3851 (mail-abbrev-make-syntax-table))
3870 (forward-line 1))))
3876 (with-current-buffer rmail-buffer
3877 (rmail-set-attribute "resent" t rmail-current-message))))
3885 "^---+ Below this line is a copy of the message.$\\|"
3897 (defun rmail-retry-failure ()
3905 The variable `rmail-retry-ignored-headers' is a regular expression
3909 (let ((rmail-this-buffer (current-buffer))
3910 (msgnum rmail-current-message)
3917 (rmail-narrow-to-non-pruned-header)
3955 ;; the old message header. The first line of the
3956 ;; message started with two hyphens. A blank line
3957 ;; followed these random lines. The same line
3963 (progn (end-of-line) (point)))))
3979 (if (rmail-start-mail nil nil nil nil nil rmail-this-buffer
3980 (list (list 'rmail-mark-message
3981 rmail-this-buffer
3982 (aref rmail-msgref-vector msgnum)
3988 rmail-displayed-headers
3989 rmail-ignored-headers)
3991 (insert-buffer-substring rmail-this-buffer
3996 (rmail-clear-headers rmail-retry-ignored-headers)
3997 (rmail-clear-headers "^sender:\\|^return-path:\\|^received:")
4010 (defun rmail-summary-exists ()
4011 "Non-nil iff in an RMAIL buffer and an associated summary buffer exists.
4012 In fact, the non-nil value returned is the summary buffer itself."
4013 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
4014 rmail-summary-buffer))
4016 (defun rmail-summary-displayed ()
4017 "t iff in RMAIL buffer and an associated summary buffer is displayed."
4018 (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
4020 (defcustom rmail-redisplay-summary nil
4021 "*Non-nil means Rmail should show the summary when it changes.
4022 This has an effect only if a summary buffer exists."
4024 :group 'rmail-summary)
4026 (defcustom rmail-summary-window-size nil
4027 "*Non-nil means specify the height for an Rmail summary window."
4029 :group 'rmail-summary)
4031 ;; Put the summary buffer back on the screen, if user wants that.
4032 (defun rmail-maybe-display-summary ()
4035 ;; If requested, make sure the summary is displayed.
4036 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
4037 rmail-redisplay-summary
4038 (if (get-buffer-window rmail-summary-buffer 0)
4041 (get-buffer-window rmail-summary-buffer 0))))
4042 (make-frame-visible frame)
4044 (display-buffer rmail-summary-buffer)))
4045 ;; If requested, set the height of the summary window.
4046 (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
4047 rmail-summary-window-size
4048 (setq window (get-buffer-window rmail-summary-buffer))
4054 (enlarge-window (- rmail-summary-window-size (window-height))))
4060 (defun rmail-fontify-buffer-function ()
4062 (add-hook 'rmail-show-message-hook 'rmail-fontify-message nil t)
4064 (if rmail-current-message (rmail-fontify-message))
4068 (defun rmail-unfontify-buffer-function ()
4076 (remove-hook 'rmail-show-message-hook 'rmail-fontify-message t)
4077 (remove-text-properties (point-min) (point-max) '(rmail-fontified nil))
4081 (defun rmail-fontify-message ()
4083 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil)
4090 (add-text-properties (point-min) (point-max) '(rmail-fontified t))
4098 (defvar rmail-speedbar-match-folder-regexp "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"
4103 (defvar rmail-speedbar-last-user nil
4106 (defvar rmail-speedbar-key-map nil
4107 "Keymap used when in rmail display mode.")
4109 (defun rmail-install-speedbar-variables ()
4110 "Install those variables used by speedbar to enhance rmail."
4111 (if rmail-speedbar-key-map
4113 (setq rmail-speedbar-key-map (speedbar-make-specialized-keymap))
4115 (define-key rmail-speedbar-key-map "e" 'speedbar-edit-line)
4116 (define-key rmail-speedbar-key-map "r" 'speedbar-edit-line)
4117 (define-key rmail-speedbar-key-map "\C-m" 'speedbar-edit-line)
4118 (define-key rmail-speedbar-key-map "M"
4119 'rmail-speedbar-move-message-to-folder-on-line)))
4121 (defvar rmail-speedbar-menu-items
4122 '(["Read Folder" speedbar-edit-line t]
4123 ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line
4124 (save-excursion (beginning-of-line)
4130 (rmail-install-speedbar-variables)
4131 (add-hook 'speedbar-load-hook 'rmail-install-speedbar-variables))
4133 (defun rmail-speedbar-buttons (buffer)
4134 "Create buttons for BUFFER containing rmail messages.
4148 (end-of-line)
4152 (equal from rmail-speedbar-last-user))
4154 (setq rmail-speedbar-last-user from)
4159 'rmail-speedbar-button 'rmail-reply))
4164 nil rmail-speedbar-match-folder-regexp)))
4167 'rmail-speedbar-move-message (car df))
4169 'rmail-speedbar-find-file nil t)
4172 (defun rmail-speedbar-button (text token indent)
4173 "Execute an rmail command specified by TEXT.
4178 (defun rmail-speedbar-find-file (text token indent)
4179 "Load in the rmail file TEXT.
4185 (defun rmail-speedbar-move-message-to-folder-on-line ()
4186 "If the current line is a folder, move current message to it."
4189 (beginning-of-line)
4190 (if (re-search-forward "<M> " (save-excursion (end-of-line) (point)) t)
4195 (defun rmail-speedbar-move-message (text token indent)
4196 "From button TEXT, copy current message to the rmail file specified by TOKEN.
4200 (rmail-output-to-rmail-file token)))
4208 (defun rmail-set-remote-password (password)
4212 (setq rmail-encoded-remote-password
4213 (rmail-encode-string password (emacs-pid)))
4214 (setq rmail-remote-password nil)
4215 (setq rmail-encoded-remote-password nil)))
4217 (defun rmail-get-remote-password (imap)
4220 (when (not rmail-encoded-remote-password)
4221 (if (not rmail-remote-password)
4222 (setq rmail-remote-password
4226 (rmail-set-remote-password rmail-remote-password)
4227 (setq rmail-remote-password nil))
4228 (rmail-encode-string rmail-encoded-remote-password (emacs-pid)))
4230 (defun rmail-have-password ()
4231 (or rmail-remote-password rmail-encoded-remote-password))
4233 (defun rmail-encode-string (string mask)
4254 (defun rmail-restore-desktop-buffer (desktop-buffer-file-name
4257 "Restore an rmail buffer specified in a desktop file."
4260 (rmail-input desktop-buffer-file-name)
4261 (if (eq major-mode 'rmail-mode)
4263 rmail-buffer))
4269 '(rmail-mode . rmail-restore-desktop-buffer))
4271 (provide 'rmail)
4274 ;;; rmail.el ends here