aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-05-28 17:43:58 +0000
committerStefan Monnier2008-05-28 17:43:58 +0000
commitdd798c64f3b27b657d04bba804bf0a63759609ca (patch)
treea0f717ffe1f7ee6d52a949db8b5dcaca82661182
parent792414668fce5c1fa0fd933f1ebeea99317b6ecc (diff)
downloademacs-dd798c64f3b27b657d04bba804bf0a63759609ca.tar.gz
emacs-dd798c64f3b27b657d04bba804bf0a63759609ca.zip
(tar-summarize-buffer): Fix reporter initialization.
(tar-mode): Use write-region-annotate-functions rather than write-contents-functions. (tar-extract): Remove unused var `pos'. (tar-subfile-save-buffer): Remove unused var `following-descs'. (tar-mode-write-file): Remove. (tar-write-region-annotate): New function.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/tar-mode.el37
2 files changed, 23 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b3e2660c5e4..1f6901920c4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12008-05-28 Stefan Monnier <monnier@iro.umontreal.ca> 12008-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * tar-mode.el (tar-summarize-buffer): Fix reporter initialization.
4 (tar-mode): Use write-region-annotate-functions rather than
5 write-contents-functions.
6 (tar-extract): Remove unused var `pos'.
7 (tar-subfile-save-buffer): Remove unused var `following-descs'.
8 (tar-mode-write-file): Remove.
9 (tar-write-region-annotate): New function.
10
3 * progmodes/flymake.el (flymake-save-buffer-in-file): 11 * progmodes/flymake.el (flymake-save-buffer-in-file):
4 * shadowfile.el (shadow-copy-file): 12 * shadowfile.el (shadow-copy-file):
5 * arc-mode.el (archive-*-write-file-member): 13 * arc-mode.el (archive-*-write-file-member):
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index 3a1a0144fbd..e3ca528ad8e 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -442,8 +442,9 @@ MODE should be an integer which is a file mode value."
442 (result '()) 442 (result '())
443 (pos (point-min)) 443 (pos (point-min))
444 (progress-reporter 444 (progress-reporter
445 (make-progress-reporter "Parsing tar file..." 445 (with-current-buffer tar-data-buffer
446 (point-min) (max 1 (- (buffer-size) 1024)))) 446 (make-progress-reporter "Parsing tar file..."
447 (point-min) (point-max))))
447 descriptor) 448 descriptor)
448 (with-current-buffer tar-data-buffer 449 (with-current-buffer tar-data-buffer
449 (while (and (<= (+ pos 512) (point-max)) 450 (while (and (<= (+ pos 512) (point-max))
@@ -467,7 +468,6 @@ MODE should be an integer which is a file mode value."
467 468
468 (and (null (tar-header-link-type descriptor)) 469 (and (null (tar-header-link-type descriptor))
469 (> size 0) 470 (> size 0)
470 ;; Round up to a multiple of 512.
471 (setq pos (+ pos (tar-roundup-512 size))))))) 471 (setq pos (+ pos (tar-roundup-512 size)))))))
472 472
473 (set (make-local-variable 'tar-parse-info) (nreverse result)) 473 (set (make-local-variable 'tar-parse-info) (nreverse result))
@@ -607,14 +607,13 @@ See also: variables `tar-update-datestamp' and `tar-anal-blocksize'.
607 locale-coding-system)) 607 locale-coding-system))
608 ;; Prevent loss of data when saving the file. 608 ;; Prevent loss of data when saving the file.
609 (set (make-local-variable 'file-precious-flag) t) 609 (set (make-local-variable 'file-precious-flag) t)
610 (auto-save-mode 0)
611 (buffer-disable-undo) 610 (buffer-disable-undo)
612 (widen) 611 (widen)
613 ;; Now move the Tar data into an auxiliary buffer, so we can use the main 612 ;; Now move the Tar data into an auxiliary buffer, so we can use the main
614 ;; buffer for the summary. 613 ;; buffer for the summary.
615 (assert (not (tar-data-swapped-p))) 614 (assert (not (tar-data-swapped-p)))
616 (set (make-local-variable 'revert-buffer-function) 'tar-mode-revert) 615 (set (make-local-variable 'revert-buffer-function) 'tar-mode-revert)
617 (set (make-local-variable 'write-contents-functions) '(tar-mode-write-file)) 616 (add-hook 'write-region-annotate-functions 'tar-write-region-annotate nil t)
618 (add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t) 617 (add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t)
619 (add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t) 618 (add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t)
620 ;; Tar data is made of bytes, not chars. 619 ;; Tar data is made of bytes, not chars.
@@ -747,7 +746,6 @@ appear on disk when you save the tar-file's buffer."
747 (concat tarname "!" name))) 746 (concat tarname "!" name)))
748 (buffer (get-file-buffer new-buffer-file-name)) 747 (buffer (get-file-buffer new-buffer-file-name))
749 (just-created nil) 748 (just-created nil)
750 (pos (point))
751 undo-list) 749 undo-list)
752 (unless buffer 750 (unless buffer
753 (setq buffer (generate-new-buffer bufname)) 751 (setq buffer (generate-new-buffer bufname))
@@ -1024,6 +1022,7 @@ for this to be permanent."
1024 tar-file-name-coding-system))) 1022 tar-file-name-coding-system)))
1025 (if (> (length encoded-new-name) 98) (error "name too long")) 1023 (if (> (length encoded-new-name) 98) (error "name too long"))
1026 (setf (tar-header-name (tar-current-descriptor)) new-name) 1024 (setf (tar-header-name (tar-current-descriptor)) new-name)
1025 ;; FIXME: Make it work for ././@LongLink.
1027 (tar-alter-one-field 0 1026 (tar-alter-one-field 0
1028 (substring (concat encoded-new-name (make-string 99 0)) 0 99)))) 1027 (substring (concat encoded-new-name (make-string 99 0)) 0 99))))
1029 1028
@@ -1103,8 +1102,7 @@ to make your changes permanent."
1103 (let* ((start (tar-header-data-start descriptor)) 1102 (let* ((start (tar-header-data-start descriptor))
1104 (name (tar-header-name descriptor)) 1103 (name (tar-header-name descriptor))
1105 (size (tar-header-size descriptor)) 1104 (size (tar-header-size descriptor))
1106 (head (memq descriptor tar-parse-info)) 1105 (head (memq descriptor tar-parse-info)))
1107 (following-descs (cdr head)))
1108 (if (not head) 1106 (if (not head)
1109 (error "Can't find this tar file entry in its parent tar file!")) 1107 (error "Can't find this tar file entry in its parent tar file!"))
1110 (with-current-buffer tar-data-buffer 1108 (with-current-buffer tar-data-buffer
@@ -1203,20 +1201,15 @@ Leaves the region wide."
1203 (insert (make-string (- goal-end (point-max)) ?\0)))))))) 1201 (insert (make-string (- goal-end (point-max)) ?\0))))))))
1204 1202
1205 1203
1206;; Used in write-file-hook to write tar-files out correctly. 1204;; Used in write-region-annotate-functions to write tar-files out correctly.
1207(defun tar-mode-write-file () 1205(defun tar-write-region-annotate (start end)
1208 (unwind-protect 1206 ;; When called from write-file (and auto-save), `start' is nil.
1209 (progn 1207 ;; When called from M-x write-region, we assume the user wants to save
1210 (if (tar-data-swapped-p) (buffer-swap-text tar-data-buffer)) 1208 ;; (part of) the summary, not the tar data.
1211 ;; Yuck: This is an internal function. We should improve the 1209 (unless (or start (not (tar-data-swapped-p)))
1212 ;; write-content-functions hook to make it easier to DTRT. 1210 (tar-clear-modification-flags)
1213 (prog1 (basic-save-buffer-1) 1211 (set-buffer tar-data-buffer)
1214 (unless (tar-data-swapped-p) (buffer-swap-text tar-data-buffer)) 1212 nil))
1215 (tar-clear-modification-flags)
1216 (set-buffer-modified-p nil)))
1217 (unless (tar-data-swapped-p) (buffer-swap-text tar-data-buffer)))
1218 ;; Return t because we've written the file.
1219 t)
1220 1213
1221(provide 'tar-mode) 1214(provide 'tar-mode)
1222 1215