[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master f521225 2/2: Add a new tar-copy-preserve-time varia
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master f521225 2/2: Add a new tar-copy-preserve-time variable |
Date: |
Sun, 13 Oct 2019 23:41:52 -0400 (EDT) |
branch: master
commit f521225736b2a6ab38bb94298fb4d3ace3d9a9ec
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Add a new tar-copy-preserve-time variable
* lisp/tar-mode.el (tar-copy-preserve-time): New variable (bug#11882).
(tar-copy): Use it.
---
etc/NEWS | 5 +++++
lisp/tar-mode.el | 17 +++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 8f95496..63ab33b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -554,6 +554,11 @@ current and the previous or the next line, as before.
* Changes in Specialized Modes and Packages in Emacs 27.1
---
+** The 'C' command in 'tar-mode' will now preserve the timestamp of
+the extracted file if the new variable 'tar-copy-preserve-time' is
+non-nil.
+
+---
** 'autoconf-mode' is now used instead of 'm4-mode' for the
acinclude.m4/aclocal.m4/acsite.m4 files.
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index 8e7e194..569b01f 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -127,6 +127,11 @@ the file never exists on disk."
This information is useful, but it takes screen space away from file names."
:type 'boolean)
+(defcustom tar-copy-preserve-time nil
+ "Non-nil means that Tar mode preserves the timestamp when copying files."
+ :type 'boolean
+ :version "27.1")
+
(defvar tar-parse-info nil)
(defvar tar-superior-buffer nil
"Buffer containing the tar archive from which a member was extracted.")
@@ -1001,11 +1006,16 @@ actually appear on disk when you save the tar-file's
buffer."
(defun tar-copy (&optional to-file)
"In Tar mode, extract this entry of the tar file into a file on disk.
If TO-FILE is not supplied, it is prompted for, defaulting to the name of
-the current tar-entry."
+the current tar-entry.
+
+If `tar-copy-preserve-time' is non-nil, the original
+timestamp (if present in the tar file) will be used on the
+extracted file."
(interactive (list (tar-read-file-name)))
(let* ((descriptor (tar-get-descriptor))
(name (tar-header-name descriptor))
(size (tar-header-size descriptor))
+ (date (tar-header-date descriptor))
(start (tar-header-data-start descriptor))
(end (+ start size))
(inhibit-file-name-handlers inhibit-file-name-handlers)
@@ -1024,7 +1034,10 @@ the current tar-entry."
inhibit-file-name-handlers))
inhibit-file-name-operation 'write-region))
(let ((coding-system-for-write 'no-conversion))
- (write-region start end to-file nil nil nil t)))
+ (write-region start end to-file nil nil nil t))
+ (when (and tar-copy-preserve-time
+ date)
+ (set-file-times to-file date)))
(message "Copied tar entry %s to %s" name to-file)))
(defun tar-new-entry (filename &optional index)