aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-02-15 00:31:07 +0000
committerGlenn Morris2009-02-15 00:31:07 +0000
commite38658c49ba7d8c24db0fa044e5cab2760c724e3 (patch)
treec0211c367f0b84cba62450ce8caa071259cafd3f
parent002645bd38add90d74507ef0e50d44b3ec641952 (diff)
downloademacs-e38658c49ba7d8c24db0fa044e5cab2760c724e3.tar.gz
emacs-e38658c49ba7d8c24db0fa044e5cab2760c724e3.zip
(rmail-insert-rmail-file-header, rmail-count-new-messages)
(rmail-show-message): Remove unnecessary autoloads. (rmail-default-rmail-file): Remove unnecessary declaration. (gnus-output-to-rmail): Handle mbox Rmail as well as Babyl Rmail.
-rw-r--r--lisp/gnus/ChangeLog8
-rw-r--r--lisp/gnus/gnus-util.el77
2 files changed, 64 insertions, 21 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index b23626eb39f..61f1c16f364 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
12009-02-15 Glenn Morris <rgm@gnu.org>
2
3 * gnus-util.el (rmail-insert-rmail-file-header)
4 (rmail-count-new-messages, rmail-show-message): Remove unnecessary
5 autoloads.
6 (rmail-default-rmail-file): Remove unnecessary declaration.
7 (gnus-output-to-rmail): Handle mbox Rmail as well as Babyl Rmail.
8
12009-02-14 Glenn Morris <rgm@gnu.org> 92009-02-14 Glenn Morris <rgm@gnu.org>
2 10
3 * gnus.el (rmail-default-rmail-file): Remove declaration of deleted 11 * gnus.el (rmail-default-rmail-file): Remove declaration of deleted
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index d37bdf35128..3827bc17c5d 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -52,9 +52,6 @@
52 52
53(autoload 'message-fetch-field "message") 53(autoload 'message-fetch-field "message")
54(autoload 'gnus-get-buffer-window "gnus-win") 54(autoload 'gnus-get-buffer-window "gnus-win")
55(autoload 'rmail-insert-rmail-file-header "rmail")
56(autoload 'rmail-count-new-messages "rmail")
57(autoload 'rmail-show-message "rmail")
58(autoload 'nnheader-narrow-to-headers "nnheader") 55(autoload 'nnheader-narrow-to-headers "nnheader")
59(autoload 'nnheader-replace-chars-in-string "nnheader") 56(autoload 'nnheader-replace-chars-in-string "nnheader")
60(autoload 'mail-header-remove-comments "mail-parse") 57(autoload 'mail-header-remove-comments "mail-parse")
@@ -1053,31 +1050,45 @@ with potentially long computations."
1053 (autoload 'rmail-summary-displayed "rmail") 1050 (autoload 'rmail-summary-displayed "rmail")
1054 (autoload 'rmail-maybe-display-summary "rmail")))) 1051 (autoload 'rmail-maybe-display-summary "rmail"))))
1055 1052
1056(defvar rmail-default-rmail-file)
1057(defvar mm-text-coding-system) 1053(defvar mm-text-coding-system)
1058 1054
1059(declare-function mm-append-to-file "mm-util" 1055(declare-function mm-append-to-file "mm-util"
1060 (start end filename &optional codesys inhibit)) 1056 (start end filename &optional codesys inhibit))
1061 1057
1062(defun gnus-output-to-rmail (filename &optional ask) 1058(defun gnus-output-to-rmail (filename &optional ask)
1063 "Append the current article to an Rmail file named FILENAME." 1059 "Append the current article to an Rmail file named FILENAME.
1060In Emacs 22 this writes Babyl format; in Emacs 23 it writes mbox unless
1061FILENAME exists and is Babyl format."
1064 (require 'rmail) 1062 (require 'rmail)
1065 (require 'mm-util) 1063 (require 'mm-util)
1066 ;; Most of these codes are borrowed from rmailout.el. 1064 ;; Some of this codes is borrowed from rmailout.el.
1067 (setq filename (expand-file-name filename)) 1065 (setq filename (expand-file-name filename))
1068 (setq rmail-default-rmail-file filename) 1066 ;; FIXME should we really be messing with this defcustom?
1067 ;; It is not needed for the operation of this function.
1068 (if (boundp 'rmail-default-rmail-file)
1069 (setq rmail-default-rmail-file filename) ; 22
1070 (setq rmail-default-file filename)) ; 23
1069 (let ((artbuf (current-buffer)) 1071 (let ((artbuf (current-buffer))
1070 (tmpbuf (get-buffer-create " *Gnus-output*"))) 1072 (tmpbuf (get-buffer-create " *Gnus-output*"))
1073 ;; Babyl rmail.el defines this, mbox does not.
1074 (babyl (fboundp 'rmail-insert-rmail-file-header)))
1071 (save-excursion 1075 (save-excursion
1072 (or (get-file-buffer filename) 1076 ;; Note that we ignore the possibility of visiting a Babyl
1073 (file-exists-p filename) 1077 ;; format buffer in Emacs 23, since Rmail no longer supports that.
1078 (or (get-file-buffer filename)
1079 (progn
1080 ;; In case someone wants to write to a Babyl file from Emacs 23.
1081 (when (file-exists-p filename)
1082 (setq babyl (mail-file-babyl-p filename))
1083 t))
1074 (if (or (not ask) 1084 (if (or (not ask)
1075 (gnus-yes-or-no-p 1085 (gnus-yes-or-no-p
1076 (concat "\"" filename "\" does not exist, create it? "))) 1086 (concat "\"" filename "\" does not exist, create it? ")))
1077 (let ((file-buffer (create-file-buffer filename))) 1087 (let ((file-buffer (create-file-buffer filename)))
1078 (save-excursion 1088 (save-excursion
1079 (set-buffer file-buffer) 1089 (set-buffer file-buffer)
1080 (rmail-insert-rmail-file-header) 1090 (if (fboundp 'rmail-insert-rmail-file-header)
1091 (rmail-insert-rmail-file-header))
1081 (let ((require-final-newline nil) 1092 (let ((require-final-newline nil)
1082 (coding-system-for-write mm-text-coding-system)) 1093 (coding-system-for-write mm-text-coding-system))
1083 (gnus-write-buffer filename))) 1094 (gnus-write-buffer filename)))
@@ -1086,32 +1097,56 @@ with potentially long computations."
1086 (set-buffer tmpbuf) 1097 (set-buffer tmpbuf)
1087 (erase-buffer) 1098 (erase-buffer)
1088 (insert-buffer-substring artbuf) 1099 (insert-buffer-substring artbuf)
1089 (gnus-convert-article-to-rmail) 1100 (if babyl
1101 (gnus-convert-article-to-rmail)
1102 ;; Non-Babyl case copied from gnus-output-to-mail.
1103 (goto-char (point-min))
1104 (if (looking-at "From ")
1105 (forward-line 1)
1106 (insert "From nobody " (current-time-string) "\n"))
1107 (let (case-fold-search)
1108 (while (re-search-forward "^From " nil t)
1109 (beginning-of-line)
1110 (insert ">"))))
1090 ;; Decide whether to append to a file or to an Emacs buffer. 1111 ;; Decide whether to append to a file or to an Emacs buffer.
1091 (let ((outbuf (get-file-buffer filename))) 1112 (let ((outbuf (get-file-buffer filename)))
1092 (if (not outbuf) 1113 (if (not outbuf)
1093 (let ((file-name-coding-system nnmail-pathname-coding-system)) 1114 (progn
1094 (mm-append-to-file (point-min) (point-max) filename)) 1115 (unless babyl ; from gnus-output-to-mail
1116 (let ((buffer-read-only nil))
1117 (goto-char (point-max))
1118 (forward-char -2)
1119 (unless (looking-at "\n\n")
1120 (goto-char (point-max))
1121 (unless (bolp)
1122 (insert "\n"))
1123 (insert "\n"))))
1124 (let ((file-name-coding-system nnmail-pathname-coding-system))
1125 (mm-append-to-file (point-min) (point-max) filename)))
1095 ;; File has been visited, in buffer OUTBUF. 1126 ;; File has been visited, in buffer OUTBUF.
1096 (set-buffer outbuf) 1127 (set-buffer outbuf)
1097 (let ((buffer-read-only nil) 1128 (let ((buffer-read-only nil)
1098 (msg (and (boundp 'rmail-current-message) 1129 (msg (and (boundp 'rmail-current-message)
1099 (symbol-value 'rmail-current-message)))) 1130 (symbol-value 'rmail-current-message))))
1100 ;; If MSG is non-nil, buffer is in RMAIL mode. 1131 ;; If MSG is non-nil, buffer is in RMAIL mode.
1132 ;; Compare this with rmail-output-to-rmail-buffer in Emacs 23.
1101 (when msg 1133 (when msg
1102 (widen) 1134 (unless babyl
1103 (narrow-to-region (point-max) (point-max))) 1135 (rmail-swap-buffers-maybe)
1136 (rmail-maybe-set-message-counters))
1137 (widen)
1138 (narrow-to-region (point-max) (point-max)))
1104 (insert-buffer-substring tmpbuf) 1139 (insert-buffer-substring tmpbuf)
1105 (when msg 1140 (when msg
1106 (goto-char (point-min)) 1141 (when babyl
1107 (widen) 1142 (goto-char (point-min))
1108 (search-backward "\n\^_") 1143 (widen)
1109 (narrow-to-region (point) (point-max)) 1144 (search-backward "\n\^_")
1145 (narrow-to-region (point) (point-max)))
1110 (rmail-count-new-messages t) 1146 (rmail-count-new-messages t)
1111 (when (rmail-summary-exists) 1147 (when (rmail-summary-exists)
1112 (rmail-select-summary 1148 (rmail-select-summary
1113 (rmail-update-summary))) 1149 (rmail-update-summary)))
1114 (rmail-count-new-messages t)
1115 (rmail-show-message msg)) 1150 (rmail-show-message msg))
1116 (save-buffer))))) 1151 (save-buffer)))))
1117 (kill-buffer tmpbuf))) 1152 (kill-buffer tmpbuf)))