comparison lisp/mail/rmail.el @ 101595:93295628737c

(rmail-expunge-and-save): Always show a message, even when called from the summary. (Bug#2075) (rmail-no-mail-p): New func, extracted from rmail-show-message-maybe. (rmail-show-message-maybe): Use rmail-no-mail-p. (rmail-show-message): If empty folder, do nothing. (Bug#2076)
author Glenn Morris <rgm@gnu.org>
date Wed, 28 Jan 2009 02:50:41 +0000
parents 5d6ccf83e955
children 3fd27701bdb1
comparison
equal deleted inserted replaced
101594:76012a3bc99d 101595:93295628737c
1390 (set-buffer rmail-buffer) 1390 (set-buffer rmail-buffer)
1391 (rmail-expunge t) 1391 (rmail-expunge t)
1392 (rmail-swap-buffers-maybe) 1392 (rmail-swap-buffers-maybe)
1393 (save-buffer) 1393 (save-buffer)
1394 (if (rmail-summary-exists) 1394 (if (rmail-summary-exists)
1395 (rmail-select-summary (set-buffer-modified-p nil)) 1395 (rmail-select-summary (set-buffer-modified-p nil)))
1396 (rmail-show-message))) 1396 (rmail-show-message))
1397 1397
1398 (defun rmail-quit () 1398 (defun rmail-quit ()
1399 "Quit out of RMAIL. 1399 "Quit out of RMAIL.
1400 Hook `rmail-quit-hook' is run after expunging." 1400 Hook `rmail-quit-hook' is run after expunging."
1401 (interactive) 1401 (interactive)
2049 (setq attr-names (rmail-get-attr-names msg) 2049 (setq attr-names (rmail-get-attr-names msg)
2050 keywords (rmail-get-keywords msg)) 2050 keywords (rmail-get-keywords msg))
2051 (if (string= keywords "") 2051 (if (string= keywords "")
2052 (setq keywords nil)) 2052 (setq keywords nil))
2053 (cond 2053 (cond
2054 ((and attr-names keywords) (concat " " attr-names ", " keywords)) 2054 ;; FIXME ? old rmail did not have spaces in the comma-separated lists.
2055 ((and attr-names keywords) (concat " " attr-names "; " keywords))
2055 (attr-names (concat " " attr-names)) 2056 (attr-names (concat " " attr-names))
2056 (keywords (concat " " keywords)) 2057 (keywords (concat " " keywords))
2057 (t "")))) 2058 (t ""))))
2058 2059
2059 (defun rmail-display-labels () 2060 (defun rmail-display-labels ()
2148 "Return t if the attributes header for message MSG matches regexp ATTRS. 2149 "Return t if the attributes header for message MSG matches regexp ATTRS.
2149 This function assumes the Rmail buffer is unswapped." 2150 This function assumes the Rmail buffer is unswapped."
2150 (save-excursion 2151 (save-excursion
2151 (save-restriction 2152 (save-restriction
2152 (let ((start (rmail-msgbeg msg)) 2153 (let ((start (rmail-msgbeg msg))
2153 limit) 2154 limit)
2154 (widen) 2155 (widen)
2155 (goto-char start) 2156 (goto-char start)
2156 (setq limit (search-forward "\n\n" (rmail-msgend msg) t)) 2157 (setq limit (search-forward "\n\n" (rmail-msgend msg) t))
2157 (goto-char start) 2158 (goto-char start)
2158 (and limit 2159 (and limit
2159 (search-forward (concat rmail-attribute-header ": ") limit t) 2160 (search-forward (concat rmail-attribute-header ": ") limit t)
2160 (looking-at attrs)))))) 2161 (looking-at attrs))))))
2161 2162
2162 (defun rmail-message-unseen-p (msgnum) 2163 (defun rmail-message-unseen-p (msgnum)
2163 "Test the unseen attribute for message MSGNUM. 2164 "Test the unseen attribute for message MSGNUM.
2164 Return non-nil if the unseen attribute is set, nil otherwise." 2165 Return non-nil if the unseen attribute is set, nil otherwise."
2165 (rmail-message-attr-p msgnum "......U")) 2166 (rmail-message-attr-p msgnum "......U"))
2427 "Display the entire mailbox file." 2428 "Display the entire mailbox file."
2428 (interactive) 2429 (interactive)
2429 (rmail-swap-buffers-maybe) 2430 (rmail-swap-buffers-maybe)
2430 (widen)) 2431 (widen))
2431 2432
2433 (defun rmail-no-mail-p ()
2434 "Return nil if there is mail, else \"No mail.\"."
2435 (if (zerop rmail-total-messages)
2436 (save-excursion
2437 (with-current-buffer rmail-view-buffer
2438 (erase-buffer)
2439 "No mail."))))
2440
2432 (defun rmail-show-message-maybe (&optional n no-summary) 2441 (defun rmail-show-message-maybe (&optional n no-summary)
2433 "Show message number N (prefix argument), counting from start of file. 2442 "Show message number N (prefix argument), counting from start of file.
2434 If summary buffer is currently displayed, update current message there also." 2443 If summary buffer is currently displayed, update current message there also."
2435 (interactive "p") 2444 (interactive "p")
2436 (or (eq major-mode 'rmail-mode) 2445 (or (eq major-mode 'rmail-mode)
2437 (switch-to-buffer rmail-buffer)) 2446 (switch-to-buffer rmail-buffer))
2438 (rmail-swap-buffers-maybe) 2447 (rmail-swap-buffers-maybe)
2439 (rmail-maybe-set-message-counters) 2448 (rmail-maybe-set-message-counters)
2440 (widen) 2449 (widen)
2441 (let ((msgnum (or n rmail-current-message)) 2450 (let ((msgnum (or n rmail-current-message))
2442 blurb) 2451 (blurb (rmail-no-mail-p)))
2443 (if (zerop rmail-total-messages) 2452 (unless blurb
2444 (save-excursion
2445 (with-current-buffer rmail-view-buffer
2446 (erase-buffer)
2447 (setq blurb "No mail.")))
2448 (setq blurb (rmail-show-message msgnum)) 2453 (setq blurb (rmail-show-message msgnum))
2449 (when mail-mailing-lists 2454 (when mail-mailing-lists
2450 (rmail-unknown-mail-followup-to)) 2455 (rmail-unknown-mail-followup-to))
2451 (if transient-mark-mode (deactivate-mark)) 2456 (if transient-mark-mode (deactivate-mark))
2452 ;; If there is a summary buffer, try to move to this message 2457 ;; If there is a summary buffer, try to move to this message
2482 (let ((mbox-buf rmail-buffer) 2487 (let ((mbox-buf rmail-buffer)
2483 (view-buf rmail-view-buffer) 2488 (view-buf rmail-view-buffer)
2484 blurb beg end body-start coding-system character-coding is-text-message) 2489 blurb beg end body-start coding-system character-coding is-text-message)
2485 (if (not msg) 2490 (if (not msg)
2486 (setq msg rmail-current-message)) 2491 (setq msg rmail-current-message))
2487 (cond ((<= msg 0) 2492 (unless (setq blurb (rmail-no-mail-p))
2488 (setq msg 1 2493 (cond ((<= msg 0)
2489 rmail-current-message 1 2494 (setq msg 1
2490 blurb "No previous message")) 2495 rmail-current-message 1
2491 ((> msg rmail-total-messages) 2496 blurb "No previous message"))
2492 (setq msg rmail-total-messages 2497 ((> msg rmail-total-messages)
2493 rmail-current-message rmail-total-messages 2498 (setq msg rmail-total-messages
2494 blurb "No following message")) 2499 rmail-current-message rmail-total-messages
2495 (t (setq rmail-current-message msg))) 2500 blurb "No following message"))
2496 (with-current-buffer rmail-buffer 2501 (t (setq rmail-current-message msg)))
2497 ;; Mark the message as seen, bracket the message in the mail 2502 (with-current-buffer rmail-buffer
2498 ;; buffer and determine the coding system the transfer encoding. 2503 ;; Mark the message as seen, bracket the message in the mail
2499 (rmail-set-attribute rmail-unseen-attr-index nil) 2504 ;; buffer and determine the coding system the transfer encoding.
2500 (rmail-swap-buffers-maybe) 2505 (rmail-set-attribute rmail-unseen-attr-index nil)
2501 (setq beg (rmail-msgbeg msg) 2506 (rmail-swap-buffers-maybe)
2502 end (rmail-msgend msg)) 2507 (setq beg (rmail-msgbeg msg)
2503 (narrow-to-region beg end) 2508 end (rmail-msgend msg))
2504 (goto-char beg) 2509 (narrow-to-region beg end)
2505 (setq body-start (search-forward "\n\n" nil t)) 2510 (goto-char beg)
2506 (narrow-to-region beg (point)) 2511 (setq body-start (search-forward "\n\n" nil t))
2507 (goto-char beg) 2512 (narrow-to-region beg (point))
2508 (setq character-coding (mail-fetch-field "content-transfer-encoding") 2513 (goto-char beg)
2509 is-text-message (rmail-is-text-p) 2514 (setq character-coding (mail-fetch-field "content-transfer-encoding")
2510 coding-system (rmail-get-coding-system)) 2515 is-text-message (rmail-is-text-p)
2511 (if character-coding 2516 coding-system (rmail-get-coding-system))
2512 (setq character-coding (downcase character-coding))) 2517 (if character-coding
2513 (narrow-to-region beg end) 2518 (setq character-coding (downcase character-coding)))
2514 ;; Decode the message body into an empty view buffer using a 2519 (narrow-to-region beg end)
2515 ;; unibyte temporary buffer where the character decoding takes 2520 ;; Decode the message body into an empty view buffer using a
2516 ;; place. 2521 ;; unibyte temporary buffer where the character decoding takes
2517 (with-current-buffer rmail-view-buffer 2522 ;; place.
2518 (erase-buffer)) 2523 (with-current-buffer rmail-view-buffer
2519 (if (null character-coding) 2524 (erase-buffer))
2520 ;; Do it directly since that is fast. 2525 (if (null character-coding)
2521 (rmail-decode-region body-start end coding-system view-buf) 2526 ;; Do it directly since that is fast.
2522 ;; Can this be done directly, skipping the temp buffer? 2527 (rmail-decode-region body-start end coding-system view-buf)
2523 (with-temp-buffer 2528 ;; Can this be done directly, skipping the temp buffer?
2524 (set-buffer-multibyte nil) 2529 (with-temp-buffer
2525 (insert-buffer-substring mbox-buf body-start end) 2530 (set-buffer-multibyte nil)
2526 (cond 2531 (insert-buffer-substring mbox-buf body-start end)
2527 ((string= character-coding "quoted-printable") 2532 (cond
2528 (mail-unquote-printable-region (point-min) (point-max))) 2533 ((string= character-coding "quoted-printable")
2529 ((and (string= character-coding "base64") is-text-message) 2534 (mail-unquote-printable-region (point-min) (point-max)))
2530 (base64-decode-region (point-min) (point-max))) 2535 ((and (string= character-coding "base64") is-text-message)
2531 ((eq character-coding 'uuencode) 2536 (base64-decode-region (point-min) (point-max)))
2532 (error "Not supported yet")) 2537 ((eq character-coding 'uuencode)
2533 (t)) 2538 (error "Not supported yet"))
2534 (rmail-decode-region (point-min) (point-max) 2539 (t))
2535 coding-system view-buf))) 2540 (rmail-decode-region (point-min) (point-max)
2536 ;; Copy the headers to the front of the message view buffer. 2541 coding-system view-buf)))
2537 (with-current-buffer rmail-view-buffer 2542 ;; Copy the headers to the front of the message view buffer.
2538 (goto-char (point-min))) 2543 (with-current-buffer rmail-view-buffer
2539 (rmail-copy-headers beg end) 2544 (goto-char (point-min)))
2540 ;; Add the separator (blank line) between headers and body; 2545 (rmail-copy-headers beg end)
2541 ;; highlight the message, activate any URL like text and add 2546 ;; Add the separator (blank line) between headers and body;
2542 ;; special highlighting for and quoted material. 2547 ;; highlight the message, activate any URL like text and add
2543 (with-current-buffer rmail-view-buffer 2548 ;; special highlighting for and quoted material.
2544 (insert "\n") 2549 (with-current-buffer rmail-view-buffer
2545 (goto-char (point-min)) 2550 (insert "\n")
2546 (rmail-highlight-headers) 2551 (goto-char (point-min))
2547 ;(rmail-activate-urls) 2552 (rmail-highlight-headers)
2548 ;(rmail-process-quoted-material) 2553 ;(rmail-activate-urls)
2549 ) 2554 ;(rmail-process-quoted-material)
2550 ;; Update the mode-line with message status information and swap 2555 )
2551 ;; the view buffer/mail buffer contents. 2556 ;; Update the mode-line with message status information and swap
2552 (rmail-display-labels) 2557 ;; the view buffer/mail buffer contents.
2553 (let ((modp (buffer-modified-p))) 2558 (rmail-display-labels)
2554 (buffer-swap-text rmail-view-buffer) 2559 (let ((modp (buffer-modified-p)))
2555 (set-buffer-modified-p modp)) 2560 (buffer-swap-text rmail-view-buffer)
2556 (setq rmail-buffer-swapped t) 2561 (set-buffer-modified-p modp))
2557 (run-hooks 'rmail-show-message-hook)) 2562 (setq rmail-buffer-swapped t)
2563 (run-hooks 'rmail-show-message-hook)))
2558 blurb)) 2564 blurb))
2559 2565
2560 (defun rmail-copy-headers (beg end &optional ignored-headers) 2566 (defun rmail-copy-headers (beg end &optional ignored-headers)
2561 "Copy displayed header fields to the message viewer buffer. 2567 "Copy displayed header fields to the message viewer buffer.
2562 BEG and END marks the start and end positions of the message in 2568 BEG and END marks the start and end positions of the message in