+ ;; Sanity check to try and make sure tar-data-swapped tracks the swap
+ ;; state correctly: the raw data is expected to be always larger than
+ ;; the summary.
+ (progn
+ (assert (eq tar-data-swapped
+ (> (buffer-size tar-data-buffer) (buffer-size))))
+ tar-data-swapped)))
+
+(defun tar-swap-data ()
+ "Swap buffer contents between current buffer and `tar-data-buffer'.
+Preserve the modified states of the buffers and set `buffer-swapped-with'."
+ (let ((data-buffer-modified-p (buffer-modified-p tar-data-buffer))
+ (current-buffer-modified-p (buffer-modified-p)))
+ (buffer-swap-text tar-data-buffer)
+ (setq tar-data-swapped (not tar-data-swapped))
+ (restore-buffer-modified-p data-buffer-modified-p)
+ (with-current-buffer tar-data-buffer
+ (restore-buffer-modified-p current-buffer-modified-p))))