aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/mail/pmail.el55
1 files changed, 13 insertions, 42 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el
index 733ce8c2cb5..c8ecb6d02f7 100644
--- a/lisp/mail/pmail.el
+++ b/lisp/mail/pmail.el
@@ -92,11 +92,6 @@ its character representation and its display representation.")
92(defvar total-messages) 92(defvar total-messages)
93(defvar tool-bar-map) 93(defvar tool-bar-map)
94 94
95(defvar pmail-buffers-swapped-p nil
96 "A flag that is non-nil when the message view buffer and the
97 message collection buffer are swapped, i.e. the Pmail buffer
98 contains a single decoded message.")
99
100(defvar pmail-header-style 'normal 95(defvar pmail-header-style 'normal
101 "The current header display style choice, one of 96 "The current header display style choice, one of
102'normal (selected headers) or 'full (all headers).") 97'normal (selected headers) or 'full (all headers).")
@@ -872,7 +867,8 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file."
872 (find-file-noselect file-name)))) 867 (find-file-noselect file-name))))
873 ;; Insure that the collection and view buffers are in sync and 868 ;; Insure that the collection and view buffers are in sync and
874 ;; insure that a message is not being edited. 869 ;; insure that a message is not being edited.
875 (pmail-swap-buffers-maybe) 870 (if (eq major-mode 'pmail-mode)
871 (pmail-swap-buffers-maybe))
876 (if (eq major-mode 'pmail-edit-mode) 872 (if (eq major-mode 'pmail-edit-mode)
877 (error "Exit Pmail Edit mode before getting new mail")) 873 (error "Exit Pmail Edit mode before getting new mail"))
878 (or (and existed (> (buffer-size) 0)) 874 (or (and existed (> (buffer-size) 0))
@@ -1000,7 +996,6 @@ The buffer is expected to be narrowed to just the header of the message."
1000;; I find I can't live without the default M-r command -- rms. 996;; I find I can't live without the default M-r command -- rms.
1001;; (define-key pmail-mode-map "\er" 'pmail-search-backwards) 997;; (define-key pmail-mode-map "\er" 'pmail-search-backwards)
1002 (define-key pmail-mode-map "s" 'pmail-expunge-and-save) 998 (define-key pmail-mode-map "s" 'pmail-expunge-and-save)
1003 (define-key pmail-mode-map "\C-x\C-s" 'pmail-save)
1004 (define-key pmail-mode-map "\es" 'pmail-search) 999 (define-key pmail-mode-map "\es" 'pmail-search)
1005 (define-key pmail-mode-map "t" 'pmail-toggle-header) 1000 (define-key pmail-mode-map "t" 'pmail-toggle-header)
1006 (define-key pmail-mode-map "u" 'pmail-undelete-previous-message) 1001 (define-key pmail-mode-map "u" 'pmail-undelete-previous-message)
@@ -1267,7 +1262,6 @@ Instead, these commands are available:
1267 (set-syntax-table text-mode-syntax-table) 1262 (set-syntax-table text-mode-syntax-table)
1268 (setq local-abbrev-table text-mode-abbrev-table) 1263 (setq local-abbrev-table text-mode-abbrev-table)
1269 ;; First attempt at adding hook functions to support buffer swapping... 1264 ;; First attempt at adding hook functions to support buffer swapping...
1270 (add-hook 'write-region-annotate-functions 'pmail-write-region-annotate nil t)
1271 (add-hook 'kill-buffer-hook 'pmail-mode-kill-buffer-hook nil t) 1265 (add-hook 'kill-buffer-hook 'pmail-mode-kill-buffer-hook nil t)
1272 (add-hook 'change-major-mode-hook 'pmail-change-major-mode-hook nil t)) 1266 (add-hook 'change-major-mode-hook 'pmail-change-major-mode-hook nil t))
1273 1267
@@ -1280,22 +1274,10 @@ Create the buffer if necessary."
1280 (unless buf 1274 (unless buf
1281 (generate-new-buffer name)))) 1275 (generate-new-buffer name))))
1282 1276
1283;; Used in write-region-annotate-functions to write Pmail files out
1284;; correctly.
1285(defun pmail-write-region-annotate (start end)
1286 ;; When called from write-file (and auto-save), `start' is nil.
1287 ;; When called from M-x write-region, we assume the user wants to save
1288 ;; (part of) the inbox, not the message display data.
1289 (unless (or start (not pmail-buffers-swapped-p))
1290 ;;(tar-clear-modification-flags)
1291 (set-buffer pmail-view-buffer)
1292 (widen)
1293 nil))
1294
1295(defun pmail-change-major-mode-hook () 1277(defun pmail-change-major-mode-hook ()
1296 ;; Bring the actual Pmail messages back into the main buffer. 1278 ;; Bring the actual Pmail messages back into the main buffer.
1297 (when (pmail-buffers-swapped-p) 1279 (when (pmail-buffers-swapped-p)
1298 (current-buffer) 1280 (setq buffer-swapped-with nil)
1299 (buffer-swap-text pmail-view-buffer))) 1281 (buffer-swap-text pmail-view-buffer)))
1300 ;; Throw away the summary. 1282 ;; Throw away the summary.
1301 ;;(when (buffer-live-p pmail-view-buffer) (kill-buffer pmail-view-buffer))) 1283 ;;(when (buffer-live-p pmail-view-buffer) (kill-buffer pmail-view-buffer)))
@@ -1347,7 +1329,6 @@ Create the buffer if necessary."
1347 (user-login-name))))))) 1329 (user-login-name)))))))
1348 (make-local-variable 'pmail-keywords) 1330 (make-local-variable 'pmail-keywords)
1349 (set (make-local-variable 'tool-bar-map) pmail-tool-bar-map) 1331 (set (make-local-variable 'tool-bar-map) pmail-tool-bar-map)
1350 (make-local-variable 'pmail-buffers-swapped-p)
1351 ;; this gets generated as needed 1332 ;; this gets generated as needed
1352 (setq pmail-keywords nil)) 1333 (setq pmail-keywords nil))
1353 1334
@@ -1420,16 +1401,6 @@ Create the buffer if necessary."
1420 (pmail-select-summary (set-buffer-modified-p nil)) 1401 (pmail-select-summary (set-buffer-modified-p nil))
1421 (pmail-show-message))) 1402 (pmail-show-message)))
1422 1403
1423(defun pmail-save ()
1424 "Save the PMAIL file."
1425 (interactive)
1426 (set-buffer pmail-buffer)
1427 (pmail-swap-buffers-maybe)
1428 (save-buffer)
1429 (if (pmail-summary-exists)
1430 (pmail-select-summary (set-buffer-modified-p nil))
1431 (pmail-show-message)))
1432
1433(defun pmail-quit () 1404(defun pmail-quit ()
1434 "Quit out of PMAIL. 1405 "Quit out of PMAIL.
1435Hook `pmail-quit-hook' is run after expunging." 1406Hook `pmail-quit-hook' is run after expunging."
@@ -2231,9 +2202,9 @@ Return the current message number if the Pmail buffer is in a
2231swapped state, i.e. it currently contains a single decoded 2202swapped state, i.e. it currently contains a single decoded
2232message rather than an entire message collection, nil otherwise." 2203message rather than an entire message collection, nil otherwise."
2233 (let (result) 2204 (let (result)
2234 (when pmail-buffers-swapped-p 2205 (when (pmail-buffers-swapped-p)
2235 (buffer-swap-text pmail-view-buffer) 2206 (buffer-swap-text pmail-view-buffer)
2236 (setq pmail-buffers-swapped-p nil 2207 (setq buffer-swapped-with nil
2237 result pmail-current-message)) 2208 result pmail-current-message))
2238 result)) 2209 result))
2239 2210
@@ -2243,7 +2214,7 @@ If message MSGNUM is non-nil make it the current message and
2243display it. Return nil." 2214display it. Return nil."
2244 (let (result) 2215 (let (result)
2245 (cond 2216 (cond
2246 ((not pmail-buffers-swapped-p) 2217 ((not (pmail-buffers-swapped-p))
2247 (let ((message (or msgnum pmail-current-message))) 2218 (let ((message (or msgnum pmail-current-message)))
2248 (pmail-show-message message))) 2219 (pmail-show-message message)))
2249 ((and msgnum (/= msgnum pmail-current-message)) 2220 ((and msgnum (/= msgnum pmail-current-message))
@@ -2461,10 +2432,10 @@ Ask the user whether to add that list name to `mail-mailing-lists'."
2461(defun pmail-swap-buffers-maybe () 2432(defun pmail-swap-buffers-maybe ()
2462 "Determine if the Pmail buffer is showing a message. 2433 "Determine if the Pmail buffer is showing a message.
2463If so restore the actual mbox message collection." 2434If so restore the actual mbox message collection."
2464 (when pmail-buffers-swapped-p 2435 (with-current-buffer pmail-buffer
2465 (with-current-buffer pmail-buffer 2436 (when (pmail-buffers-swapped-p)
2466 (buffer-swap-text pmail-view-buffer) 2437 (buffer-swap-text pmail-view-buffer)
2467 (setq pmail-buffers-swapped-p nil)))) 2438 (setq buffer-swapped-with nil))))
2468 2439
2469(defun pmail-show-message-maybe (&optional n no-summary) 2440(defun pmail-show-message-maybe (&optional n no-summary)
2470 "Show message number N (prefix argument), counting from start of file. 2441 "Show message number N (prefix argument), counting from start of file.
@@ -2583,7 +2554,7 @@ The current mail message becomes the message displayed."
2583 ;; the view buffer/mail buffer contents. 2554 ;; the view buffer/mail buffer contents.
2584 (pmail-display-labels) 2555 (pmail-display-labels)
2585 (buffer-swap-text pmail-view-buffer) 2556 (buffer-swap-text pmail-view-buffer)
2586 (setq pmail-buffers-swapped-p t) 2557 (setq buffer-swapped-with pmail-view-buffer)
2587 (run-hooks 'pmail-show-message-hook)) 2558 (run-hooks 'pmail-show-message-hook))
2588 blurb)) 2559 blurb))
2589 2560
@@ -2818,7 +2789,7 @@ Interactively, empty argument means use same regexp used last time."
2818 (let ((orig-message pmail-current-message) 2789 (let ((orig-message pmail-current-message)
2819 (msg pmail-current-message) 2790 (msg pmail-current-message)
2820 (reversep (< n 0)) 2791 (reversep (< n 0))
2821 (opoint (if pmail-buffers-swapped-p (point))) 2792 (opoint (if (pmail-buffers-swapped-p) (point)))
2822 found) 2793 found)
2823 (pmail-swap-buffers-maybe) 2794 (pmail-swap-buffers-maybe)
2824 (pmail-maybe-set-message-counters) 2795 (pmail-maybe-set-message-counters)
@@ -3150,7 +3121,7 @@ See also user-option `pmail-confirm-expunge'."
3150 (when (pmail-expunge-confirmed) 3121 (when (pmail-expunge-confirmed)
3151 (let ((old-total pmail-total-messages) 3122 (let ((old-total pmail-total-messages)
3152 (opoint (with-current-buffer pmail-buffer 3123 (opoint (with-current-buffer pmail-buffer
3153 (when pmail-buffers-swapped-p 3124 (when (pmail-buffers-swapped-p)
3154 (point))))) 3125 (point)))))
3155 (pmail-only-expunge dont-show) 3126 (pmail-only-expunge dont-show)
3156 (if (pmail-summary-exists) 3127 (if (pmail-summary-exists)
@@ -3209,7 +3180,7 @@ use \\[mail-yank-original] to yank the original message into it."
3209 (save-excursion 3180 (save-excursion
3210 (save-restriction 3181 (save-restriction
3211 (widen) 3182 (widen)
3212 (if pmail-buffers-swapped-p 3183 (if (pmail-buffers-swapped-p)
3213 (narrow-to-region 3184 (narrow-to-region
3214 (goto-char (point-min)) 3185 (goto-char (point-min))
3215 (search-forward "\n\n" nil 'move)) 3186 (search-forward "\n\n" nil 'move))