summaryrefslogtreecommitdiff
path: root/lisp/mail
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2008-12-31 02:44:00 +0000
committerChong Yidong <cyd@stupidchicken.com>2008-12-31 02:44:00 +0000
commitaae1ecbbc8f532609e8cd334b234bc81dba5e6d8 (patch)
treeedfc0bd042138ca26d69ae165385d8fdef3a6fd7 /lisp/mail
parent9b854b5c5ee247a4d37d4aa544310de0388785b5 (diff)
downloademacs-aae1ecbbc8f532609e8cd334b234bc81dba5e6d8.tar.gz
(buffer-swapped-with): New var, moved from files.el. Add advice to
basic-save-buffer to use it.
Diffstat (limited to 'lisp/mail')
-rw-r--r--lisp/mail/pmail.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el
index 3a43cc0ce90..428102bdfc3 100644
--- a/lisp/mail/pmail.el
+++ b/lisp/mail/pmail.el
@@ -41,6 +41,34 @@
(require 'mail-utils)
(eval-when-compile (require 'mule-util)) ; for detect-coding-with-priority
+
+;; The buffer-swapped-with feature has been moved here temporarily.
+;; When pmail is merged, this advice must be eliminated and the
+;; functionality somehow reimplemented.
+
+(defvar buffer-swapped-with nil
+ "Buffer that this buffer's contents are temporarily swapped with.
+You should only set this variable in file-visiting buffers,
+because it only affects how to save the buffer in its file.")
+
+(make-variable-buffer-local 'buffer-swapped-with)
+
+(defadvice basic-save-buffer
+ (around check-swap activate)
+ "If this buffer's real contents are swapped with some other buffer,
+temporarily unswap in order to save the real contents. This
+advice is temporarily used by pmail until a satisfactory solution
+can be written."
+ (if (not buffer-swapped-with)
+ ad-do-it
+ (unwind-protect
+ (let ((modp (buffer-modified-p)))
+ (buffer-swap-text buffer-swapped-with)
+ (set-buffer-modified-p modp)
+ ad-do-it)
+ (buffer-swap-text buffer-swapped-with)
+ (set-buffer-modified-p nil))))
+
(defconst pmail-attribute-header "X-RMAIL-ATTRIBUTES"
"The header that stores the Pmail attribute data.")