diff options
| author | Lars Ingebrigtsen | 2019-10-14 05:41:45 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-14 05:41:45 +0200 |
| commit | f521225736b2a6ab38bb94298fb4d3ace3d9a9ec (patch) | |
| tree | 8f7f62005d919fe1991d90e6c640e31f00914bd5 | |
| parent | eac531b760aa805c293339eba78e58b5b89fa211 (diff) | |
| download | emacs-f521225736b2a6ab38bb94298fb4d3ace3d9a9ec.tar.gz emacs-f521225736b2a6ab38bb94298fb4d3ace3d9a9ec.zip | |
Add a new tar-copy-preserve-time variable
* lisp/tar-mode.el (tar-copy-preserve-time): New variable (bug#11882).
(tar-copy): Use it.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/tar-mode.el | 17 |
2 files changed, 20 insertions, 2 deletions
| @@ -554,6 +554,11 @@ current and the previous or the next line, as before. | |||
| 554 | * Changes in Specialized Modes and Packages in Emacs 27.1 | 554 | * Changes in Specialized Modes and Packages in Emacs 27.1 |
| 555 | 555 | ||
| 556 | --- | 556 | --- |
| 557 | ** The 'C' command in 'tar-mode' will now preserve the timestamp of | ||
| 558 | the extracted file if the new variable 'tar-copy-preserve-time' is | ||
| 559 | non-nil. | ||
| 560 | |||
| 561 | --- | ||
| 557 | ** 'autoconf-mode' is now used instead of 'm4-mode' for the | 562 | ** 'autoconf-mode' is now used instead of 'm4-mode' for the |
| 558 | acinclude.m4/aclocal.m4/acsite.m4 files. | 563 | acinclude.m4/aclocal.m4/acsite.m4 files. |
| 559 | 564 | ||
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index 8e7e1945cbc..569b01f978b 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el | |||
| @@ -127,6 +127,11 @@ the file never exists on disk." | |||
| 127 | This information is useful, but it takes screen space away from file names." | 127 | This information is useful, but it takes screen space away from file names." |
| 128 | :type 'boolean) | 128 | :type 'boolean) |
| 129 | 129 | ||
| 130 | (defcustom tar-copy-preserve-time nil | ||
| 131 | "Non-nil means that Tar mode preserves the timestamp when copying files." | ||
| 132 | :type 'boolean | ||
| 133 | :version "27.1") | ||
| 134 | |||
| 130 | (defvar tar-parse-info nil) | 135 | (defvar tar-parse-info nil) |
| 131 | (defvar tar-superior-buffer nil | 136 | (defvar tar-superior-buffer nil |
| 132 | "Buffer containing the tar archive from which a member was extracted.") | 137 | "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." | |||
| 1001 | (defun tar-copy (&optional to-file) | 1006 | (defun tar-copy (&optional to-file) |
| 1002 | "In Tar mode, extract this entry of the tar file into a file on disk. | 1007 | "In Tar mode, extract this entry of the tar file into a file on disk. |
| 1003 | If TO-FILE is not supplied, it is prompted for, defaulting to the name of | 1008 | If TO-FILE is not supplied, it is prompted for, defaulting to the name of |
| 1004 | the current tar-entry." | 1009 | the current tar-entry. |
| 1010 | |||
| 1011 | If `tar-copy-preserve-time' is non-nil, the original | ||
| 1012 | timestamp (if present in the tar file) will be used on the | ||
| 1013 | extracted file." | ||
| 1005 | (interactive (list (tar-read-file-name))) | 1014 | (interactive (list (tar-read-file-name))) |
| 1006 | (let* ((descriptor (tar-get-descriptor)) | 1015 | (let* ((descriptor (tar-get-descriptor)) |
| 1007 | (name (tar-header-name descriptor)) | 1016 | (name (tar-header-name descriptor)) |
| 1008 | (size (tar-header-size descriptor)) | 1017 | (size (tar-header-size descriptor)) |
| 1018 | (date (tar-header-date descriptor)) | ||
| 1009 | (start (tar-header-data-start descriptor)) | 1019 | (start (tar-header-data-start descriptor)) |
| 1010 | (end (+ start size)) | 1020 | (end (+ start size)) |
| 1011 | (inhibit-file-name-handlers inhibit-file-name-handlers) | 1021 | (inhibit-file-name-handlers inhibit-file-name-handlers) |
| @@ -1024,7 +1034,10 @@ the current tar-entry." | |||
| 1024 | inhibit-file-name-handlers)) | 1034 | inhibit-file-name-handlers)) |
| 1025 | inhibit-file-name-operation 'write-region)) | 1035 | inhibit-file-name-operation 'write-region)) |
| 1026 | (let ((coding-system-for-write 'no-conversion)) | 1036 | (let ((coding-system-for-write 'no-conversion)) |
| 1027 | (write-region start end to-file nil nil nil t))) | 1037 | (write-region start end to-file nil nil nil t)) |
| 1038 | (when (and tar-copy-preserve-time | ||
| 1039 | date) | ||
| 1040 | (set-file-times to-file date))) | ||
| 1028 | (message "Copied tar entry %s to %s" name to-file))) | 1041 | (message "Copied tar entry %s to %s" name to-file))) |
| 1029 | 1042 | ||
| 1030 | (defun tar-new-entry (filename &optional index) | 1043 | (defun tar-new-entry (filename &optional index) |