From 76bf6666897923af632a6a2c8f1de051a6a7bb45 Mon Sep 17 00:00:00 2001
From: "Richard M. Stallman" <rms@gnu.org>
Date: Sat, 17 Aug 2002 05:00:30 +0000
Subject: [PATCH] (tar-subfile-mode): Use add-hook and remove-hook, and use
 write-file-functions instead of local-write-file-hooks. (tar-untar-buffer):
 Don't try to extract directories.

---
 lisp/tar-mode.el | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index 400dbdad134..9f34858cab2 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -388,11 +388,12 @@ MODE should be an integer which is a file mode value."
 		   (dir (file-name-directory name))
 		   (start (+ (tar-desc-data-start descriptor) tar-header-offset -1))
 		   (end (+ start (tar-header-size tokens))))
-	      (message "Extracting %s" name)
-	      (if (and dir (not (file-exists-p dir)))
-		  (make-directory dir t))
-	      (write-region start end name)
-	      (set-file-modes name (tar-header-mode tokens)))))
+	      (unless (file-directory-p name)
+		(message "Extracting %s" name)
+		(if (and dir (not (file-exists-p dir)))
+		    (make-directory dir t))
+		(write-region start end name)
+		(set-file-modes name (tar-header-mode tokens))))))
       (set-buffer-multibyte multibyte))))
 
 (defun tar-summarize-buffer ()
@@ -604,14 +605,13 @@ appear on disk when you save the tar-file's buffer."
 	    (not tar-subfile-mode)
 	    (> (prefix-numeric-value p) 0)))
   (cond (tar-subfile-mode
-	 (make-local-variable 'local-write-file-hooks)
-	 (setq local-write-file-hooks '(tar-subfile-save-buffer))
+	 (add-hook 'write-file-functions 'tar-subfile-save-buffer nil t)
 	 ;; turn off auto-save.
 	 (auto-save-mode -1)
 	 (setq buffer-auto-save-file-name nil)
 	 (run-hooks 'tar-subfile-mode-hook))
 	(t
-	 (kill-local-variable 'local-write-file-hooks))))
+	 (remove-hook 'write-file-functions 'tar-subfile-save-buffer t))))
 
 
 ;; Revert the buffer and recompute the dired-like listing.
-- 
2.39.5