comparison lisp/mail/rmail.el @ 105396:7f82f9367cd1

(rmail-generate-viewer-buffer): Be more careful about reusing existing buffers, in case we happen to visit two files with the same basename. (Bug#4593)
author Glenn Morris <rgm@gnu.org>
date Sat, 03 Oct 2009 02:07:28 +0000
parents f4199c624c3c
children efd1475ab299
comparison
equal deleted inserted replaced
105395:175a7f7ac069 105396:7f82f9367cd1
1292 (add-hook 'change-major-mode-hook 'rmail-change-major-mode-hook nil t)) 1292 (add-hook 'change-major-mode-hook 'rmail-change-major-mode-hook nil t))
1293 1293
1294 (defun rmail-generate-viewer-buffer () 1294 (defun rmail-generate-viewer-buffer ()
1295 "Return a reusable buffer suitable for viewing messages. 1295 "Return a reusable buffer suitable for viewing messages.
1296 Create the buffer if necessary." 1296 Create the buffer if necessary."
1297 (let* ((suffix (file-name-nondirectory (or buffer-file-name (buffer-name)))) 1297 ;; We want to reuse any existing view buffer, so as not to create an
1298 (name (format " *message-viewer %s*" suffix)) 1298 ;; endless number of them. But we must avoid clashes if we visit
1299 (buf (get-buffer name))) 1299 ;; two different rmail files with the same basename (Bug#4593).
1300 (or buf 1300 (if (and (local-variable-p 'rmail-view-buffer)
1301 (generate-new-buffer name)))) 1301 (buffer-live-p rmail-view-buffer))
1302 rmail-view-buffer
1303 (generate-new-buffer
1304 (format " *message-viewer %s*"
1305 (file-name-nondirectory (or buffer-file-name (buffer-name)))))))
1302 1306
1303 (defun rmail-swap-buffers () 1307 (defun rmail-swap-buffers ()
1304 "Swap text between current buffer and `rmail-view-buffer'. 1308 "Swap text between current buffer and `rmail-view-buffer'.
1305 This function preserves the current buffer's modified flag, and also 1309 This function preserves the current buffer's modified flag, and also
1306 sets the current buffer's `buffer-file-coding-system' to that of 1310 sets the current buffer's `buffer-file-coding-system' to that of
1365 (setq rmail-seriously-modified nil) 1369 (setq rmail-seriously-modified nil)
1366 (setq rmail-buffer (current-buffer)) 1370 (setq rmail-buffer (current-buffer))
1367 (set-buffer-multibyte nil) 1371 (set-buffer-multibyte nil)
1368 (with-current-buffer (setq rmail-view-buffer (rmail-generate-viewer-buffer)) 1372 (with-current-buffer (setq rmail-view-buffer (rmail-generate-viewer-buffer))
1369 (setq buffer-undo-list t) 1373 (setq buffer-undo-list t)
1374 ;; Note that this does not erase the buffer. Should it?
1375 ;; It depends on how this is called. If somehow called with the
1376 ;; rmail buffers swapped, it would erase the message collection.
1370 (set (make-local-variable 'rmail-overlay-list) nil) 1377 (set (make-local-variable 'rmail-overlay-list) nil)
1371 (set-buffer-multibyte t) 1378 (set-buffer-multibyte t)
1372 ;; Force C-x C-s write Unix EOLs. 1379 ;; Force C-x C-s write Unix EOLs.
1373 (set-buffer-file-coding-system 'undecided-unix)) 1380 (set-buffer-file-coding-system 'undecided-unix))
1374 (make-local-variable 'rmail-summary-buffer) 1381 (make-local-variable 'rmail-summary-buffer)