]> code.delx.au - gnu-emacs/blobdiff - lisp/tar-mode.el
Add defgroups, and use defcustom.
[gnu-emacs] / lisp / tar-mode.el
index 1bc65f094cafd332ece72a2e4fe8e2ff72aa04d2..5776680d6cbf62344551436b5be46b7e92ff3479 100644 (file)
@@ -494,9 +494,11 @@ is visible (and the real data of the buffer is hidden)."
   (define-key tar-mode-map "h" 'describe-mode)
   (define-key tar-mode-map "n" 'tar-next-line)
   (define-key tar-mode-map "\^N" 'tar-next-line)
+  (define-key tar-mode-map [down] 'tar-next-line)
   (define-key tar-mode-map "o" 'tar-extract-other-window)
   (define-key tar-mode-map "p" 'tar-previous-line)
   (define-key tar-mode-map "\^P" 'tar-previous-line)
+  (define-key tar-mode-map [up] 'tar-previous-line)
   (define-key tar-mode-map "r" 'tar-rename-entry)
   (define-key tar-mode-map "u" 'tar-unflag)
   (define-key tar-mode-map "v" 'tar-view)
@@ -602,9 +604,9 @@ See also: variables `tar-update-datestamp' and `tar-anal-blocksize'.
 
 (defun tar-subfile-mode (p)
   "Minor mode for editing an element of a tar-file.
-This mode redefines the save-buffer command to save the current buffer back
-into its associated tar-file buffer.  You must save that buffer to actually
-save your changes to disk."
+This mode arranges for \"saving\" this buffer to write the data
+into the tar-file buffer that it came from.  The changes will actually
+appear on disk when you save the tar-file's buffer."
   (interactive "P")
   (or (and (boundp 'tar-superior-buffer) tar-superior-buffer)
       (error "This buffer is not an element of a tar file"))
@@ -630,11 +632,19 @@ save your changes to disk."
 
 ;; Revert the buffer and recompute the dired-like listing.
 (defun tar-mode-revert (&optional no-autosave no-confirm)
-  (setq tar-header-offset nil)
-  (let ((revert-buffer-function nil))
-    (revert-buffer t no-confirm)
-    (widen))
-  (tar-mode))
+  (let ((revert-buffer-function nil)
+       (old-offset tar-header-offset)
+       success)
+    (setq tar-header-offset nil)
+    (unwind-protect
+       (and (revert-buffer t no-confirm)
+            (progn (widen)
+                   (setq success t)
+                   (tar-mode)))
+      ;; If the revert was canceled,
+      ;; put back the old value of tar-header-offset.
+      (or success
+         (setq tar-header-offset old-offset)))))
 
 
 (defun tar-next-line (p)
@@ -731,9 +741,9 @@ save your changes to disk."
                (make-local-variable 'tar-superior-descriptor)
                (setq tar-superior-buffer tar-buffer)
                (setq tar-superior-descriptor descriptor)
-               (tar-subfile-mode 1)            
-               (setq buffer-read-only read-only-p)
-               (set-buffer-modified-p nil))
+               (setq buffer-read-only read-only-p)             
+               (set-buffer-modified-p nil)
+               (tar-subfile-mode 1))
              (set-buffer tar-buffer))
          (narrow-to-region 1 tar-header-offset)))
       (if view-p
@@ -1186,7 +1196,8 @@ Leaves the region wide."
        ;; I suppose this is run in a context where changing the buffer is bad.
        ;; (tar-pad-to-blocksize)
        (write-region tar-header-offset (point-max) buffer-file-name nil t)
-       (tar-clear-modification-flags))
+       (tar-clear-modification-flags)
+       (set-buffer-modified-p nil))
     (narrow-to-region 1 tar-header-offset))
   ;; return T because we've written the file.
   t)