# HG changeset patch # User Andreas Schwab # Date 1230717529 0 # Node ID da95fec1ae70888e9abe04b0119f6ca3ab1a4d7b # Parent e680c5af27d36f99f1f32fc6fc222ea536f62283 (tar-mode): Set write-contents-functions instead of write-region-annotate-functions. (tar-mode-write-contents): New function. (tar-write-region-annotate): Remove. diff -r e680c5af27d3 -r da95fec1ae70 lisp/ChangeLog --- a/lisp/ChangeLog Wed Dec 31 02:44:00 2008 +0000 +++ b/lisp/ChangeLog Wed Dec 31 09:58:49 2008 +0000 @@ -1,3 +1,10 @@ +2008-12-31 Andreas Schwab + + * tar-mode.el (tar-mode): Set write-contents-functions instead of + write-region-annotate-functions. + (tar-mode-write-contents): New function. + (tar-write-region-annotate): Remove. + 2008-12-31 Chong Yidong * files.el (basic-save-buffer): Revert 2008-12-22 change. diff -r e680c5af27d3 -r da95fec1ae70 lisp/tar-mode.el --- a/lisp/tar-mode.el Wed Dec 31 02:44:00 2008 +0000 +++ b/lisp/tar-mode.el Wed Dec 31 09:58:49 2008 +0000 @@ -637,7 +637,7 @@ ;; buffer for the summary. (assert (not (tar-data-swapped-p))) (set (make-local-variable 'revert-buffer-function) 'tar-mode-revert) - (add-hook 'write-region-annotate-functions 'tar-write-region-annotate nil t) + (add-hook 'write-contents-functions 'tar-mode-write-contents nil t) (add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t) (add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t) ;; Tar data is made of bytes, not chars. @@ -1213,15 +1213,18 @@ (insert (make-string (- goal-end (point-max)) ?\0)))))))) -;; Used in write-region-annotate-functions to write tar-files out correctly. -(defun tar-write-region-annotate (start end) - ;; When called from write-file (and auto-save), `start' is nil. - ;; When called from M-x write-region, we assume the user wants to save - ;; (part of) the summary, not the tar data. - (unless (or start (not (tar-data-swapped-p))) - (tar-clear-modification-flags) - (set-buffer tar-data-buffer) - nil)) +;; Used in write-contents-functions to write tar-files out correctly. +(defun tar-mode-write-contents () + (save-excursion + (unwind-protect + (progn + (when (tar-data-swapped-p) (tar-swap-data)) + (write-region nil nil buffer-file-name nil t)) + (unless (tar-data-swapped-p) (tar-swap-data)))) + (tar-clear-modification-flags) + (set-buffer-modified-p nil) + ;; Return t because we've written the file. + t) (provide 'tar-mode)