diff options
| author | Eli Zaretskii | 1998-05-14 15:08:55 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1998-05-14 15:08:55 +0000 |
| commit | 380683ed5a4ea4825dbe99580b3c30749362c51d (patch) | |
| tree | c3040d36c6be08bbf45b1c27d8bf2e3318b2ed79 | |
| parent | 2036d16f5156093a02c384dffeec1bd766d0fee2 (diff) | |
| download | emacs-380683ed5a4ea4825dbe99580b3c30749362c51d.tar.gz emacs-380683ed5a4ea4825dbe99580b3c30749362c51d.zip | |
(archive-tmpdir): Make the prefix of the temporary
directory absolute.
(file-name-invalid-regexp): New variable.
(archive-zip-case-fiddle): Doc fix.
(archive-remote): Make it permanent-local.
(archive-member-coding-system): New variable.
(archive-mode): Don't use write-contents-hooks for remote
archives. Archives whose names are illegal for the current
filesystem are marked read-only.
(archive-summarize): Optional argument SHUT-UP makes it silent.
All callers changed.
(archive-unique-fname): New function.
(archive-maybe-copy): Use it.
(archive-maybe-copy, archive-write-file): Bind
coding-system-for-write to no-conversion.
(archive-maybe-update, archive-mode-revert): Bind
coding-system-for-read to no-conversion.
(archive-maybe-update): Remain at the same line in the archive
listing, after updating the archive. Print the buffer name of the
archive to be saved.
(archive-extract): Mark archive members whose names are invalid as
read-only. Don't set buffer-file-type. Remove the write-contents
hook for remote archives. Warn about read-only archives inside
other archives.
(archive-write-file-member): Handle remote archives. Restore
value of last-coding-system-used.
(archive-*-write-file-member): Handle archives inside other
archives. Save the value of last-coding-system-used.
(archive-write-file): New optional variable FILE: where to write
the archive; defaults to buffer-file-name, for remote archives.
(archive-zip-summarize, archive-zip-chmod-entry): Support VFAT
type of host filesystem.
(archive-zip-summarize): Don't fiddle letter case of mixed-case
file names.
| -rw-r--r-- | lisp/arc-mode.el | 204 |
1 files changed, 149 insertions, 55 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 1207a577910..a20770c9f53 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; arc-mode.el --- simple editing of archives | 1 | ;;; arc-mode.el --- simple editing of archives |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1995, 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Morten Welinder <terra@diku.dk> | 5 | ;; Author: Morten Welinder <terra@diku.dk> |
| 6 | ;; Keywords: archives msdog editing major-mode | 6 | ;; Keywords: archives msdog editing major-mode |
| @@ -120,13 +120,25 @@ | |||
| 120 | :group 'archive) | 120 | :group 'archive) |
| 121 | 121 | ||
| 122 | (defcustom archive-tmpdir | 122 | (defcustom archive-tmpdir |
| 123 | (expand-file-name | 123 | (make-temp-name |
| 124 | (make-temp-name (if (eq system-type 'ms-dos) "ar" "archive.tmp")) | 124 | (expand-file-name (if (eq system-type 'ms-dos) "ar" "archive.tmp") |
| 125 | (or (getenv "TMPDIR") (getenv "TMP") "/tmp")) | 125 | (or (getenv "TMPDIR") (getenv "TMP") "/tmp"))) |
| 126 | "*Directory for temporary files made by arc-mode.el" | 126 | "*Directory for temporary files made by arc-mode.el" |
| 127 | :type 'directory | 127 | :type 'directory |
| 128 | :group 'archive) | 128 | :group 'archive) |
| 129 | 129 | ||
| 130 | (defvar archive-file-name-invalid-regexp | ||
| 131 | (cond ((and (eq system-type 'ms-dos) (not (msdos-long-file-names))) | ||
| 132 | (concat "\\(^\\([A-z]:\\)?/?.*:\\)\\|" ; colon except after drive | ||
| 133 | "[+, ;=|<>\"?*]\\|\\[\\|\\]\\|" ; invalid characters | ||
| 134 | "\\(/\\.\\.?[^/]\\)\\|" ; leading dots | ||
| 135 | "\\(/[^/.]+\\.[^/.]*\\.\\)")) ; more than a single dot | ||
| 136 | ((memq system-type '(ms-dos windows-nt)) | ||
| 137 | (concat "\\(^\\([A-z]:\\)?/?.*:\\)\\|" ; colon except after drive | ||
| 138 | "[|<>\"?*]")) ; invalid characters | ||
| 139 | (t "[\000]")) | ||
| 140 | "Regexp recognizing file names which aren't allowed by the filesystem.") | ||
| 141 | |||
| 130 | (defcustom archive-remote-regexp "^/[^/:]*[^/:.]:" | 142 | (defcustom archive-remote-regexp "^/[^/:]*[^/:.]:" |
| 131 | "*Regexp recognizing archive files names that are not local. | 143 | "*Regexp recognizing archive files names that are not local. |
| 132 | A non-local file is one whose file name is not proper outside Emacs. | 144 | A non-local file is one whose file name is not proper outside Emacs. |
| @@ -265,9 +277,9 @@ Archive and member name will be added." | |||
| 265 | :group 'archive-zip) | 277 | :group 'archive-zip) |
| 266 | 278 | ||
| 267 | (defcustom archive-zip-case-fiddle t | 279 | (defcustom archive-zip-case-fiddle t |
| 268 | "*If non-nil then zip file members are case fiddled. | 280 | "*If non-nil then zip file members may be down-cased. |
| 269 | Case fiddling will only happen for members created by a system that | 281 | This case fiddling will only happen for members created by a system |
| 270 | uses caseless file names." | 282 | that uses caseless file names." |
| 271 | :type 'boolean | 283 | :type 'boolean |
| 272 | :group 'archive-zip) | 284 | :group 'archive-zip) |
| 273 | ;; ------------------------------ | 285 | ;; ------------------------------ |
| @@ -311,11 +323,17 @@ Archive and member name will be added." | |||
| 311 | (defvar archive-file-list-end nil "*Position just after last contents line.") | 323 | (defvar archive-file-list-end nil "*Position just after last contents line.") |
| 312 | (defvar archive-proper-file-start nil "*Position of real archive's start.") | 324 | (defvar archive-proper-file-start nil "*Position of real archive's start.") |
| 313 | (defvar archive-read-only nil "*Non-nil if the archive is read-only on disk.") | 325 | (defvar archive-read-only nil "*Non-nil if the archive is read-only on disk.") |
| 314 | (defvar archive-remote nil "*Non-nil if the archive is outside file system.") | ||
| 315 | (defvar archive-local-name nil "*Name of local copy of remote archive.") | 326 | (defvar archive-local-name nil "*Name of local copy of remote archive.") |
| 316 | (defvar archive-mode-map nil "*Local keymap for archive mode listings.") | 327 | (defvar archive-mode-map nil "*Local keymap for archive mode listings.") |
| 317 | (defvar archive-file-name-indent nil "*Column where file names start.") | 328 | (defvar archive-file-name-indent nil "*Column where file names start.") |
| 318 | 329 | ||
| 330 | (defvar archive-remote nil "*Non-nil if the archive is outside file system.") | ||
| 331 | (make-variable-buffer-local 'archive-remote) | ||
| 332 | (put 'archive-remote 'permanent-local t) | ||
| 333 | |||
| 334 | (defvar archive-member-coding-system nil "Coding-system of archive member.") | ||
| 335 | (make-variable-buffer-local 'archive-member-coding-system) | ||
| 336 | |||
| 319 | (defvar archive-alternate-display nil | 337 | (defvar archive-alternate-display nil |
| 320 | "*Non-nil when alternate information is shown.") | 338 | "*Non-nil when alternate information is shown.") |
| 321 | (make-variable-buffer-local 'archive-alternate-display) | 339 | (make-variable-buffer-local 'archive-alternate-display) |
| @@ -509,23 +527,36 @@ archive. | |||
| 509 | (make-local-variable 'revert-buffer-function) | 527 | (make-local-variable 'revert-buffer-function) |
| 510 | (setq revert-buffer-function 'archive-mode-revert) | 528 | (setq revert-buffer-function 'archive-mode-revert) |
| 511 | (auto-save-mode 0) | 529 | (auto-save-mode 0) |
| 512 | (make-local-variable 'write-contents-hooks) | ||
| 513 | (add-hook 'write-contents-hooks 'archive-write-file) | ||
| 514 | 530 | ||
| 515 | ;; Real file contents is binary | 531 | ;; Remote archives are not written by a hook. |
| 532 | (if archive-remote nil | ||
| 533 | (make-local-variable 'write-contents-hooks) | ||
| 534 | (add-hook 'write-contents-hooks 'archive-write-file)) | ||
| 535 | |||
| 516 | (make-local-variable 'require-final-newline) | 536 | (make-local-variable 'require-final-newline) |
| 517 | (setq require-final-newline nil) | 537 | (setq require-final-newline nil) |
| 518 | (make-local-variable 'enable-local-variables) | 538 | (make-local-variable 'enable-local-variables) |
| 519 | (setq enable-local-variables nil) | 539 | (setq enable-local-variables nil) |
| 520 | 540 | ||
| 521 | (make-local-variable 'archive-read-only) | 541 | (make-local-variable 'archive-read-only) |
| 522 | (setq archive-read-only (not (file-writable-p (buffer-file-name)))) | 542 | ;; Archives which are inside other archives and whose |
| 543 | ;; names are invalid for this OS, can't be written. | ||
| 544 | (setq archive-read-only | ||
| 545 | (or (not (file-writable-p (buffer-file-name))) | ||
| 546 | (and archive-subfile-mode | ||
| 547 | (string-match archive-file-name-invalid-regexp | ||
| 548 | (aref archive-subfile-mode 0))))) | ||
| 523 | 549 | ||
| 524 | ;; Should we use a local copy when accessing from outside Emacs? | 550 | ;; Should we use a local copy when accessing from outside Emacs? |
| 525 | (make-local-variable 'archive-local-name) | 551 | (make-local-variable 'archive-local-name) |
| 526 | (make-local-variable 'archive-remote) | 552 | |
| 527 | (setq archive-remote (string-match archive-remote-regexp | 553 | ;; An archive can contain another archive whose name is invalid |
| 528 | (buffer-file-name))) | 554 | ;; on local filesystem. Treat such archives as remote. |
| 555 | (or archive-remote | ||
| 556 | (setq archive-remote | ||
| 557 | (or (string-match archive-remote-regexp (buffer-file-name)) | ||
| 558 | (string-match archive-file-name-invalid-regexp | ||
| 559 | (buffer-file-name))))) | ||
| 529 | 560 | ||
| 530 | (setq major-mode 'archive-mode) | 561 | (setq major-mode 'archive-mode) |
| 531 | (setq mode-name (concat typename "-Archive")) | 562 | (setq mode-name (concat typename "-Archive")) |
| @@ -537,7 +568,7 @@ archive. | |||
| 537 | (make-local-variable 'archive-file-list-start) | 568 | (make-local-variable 'archive-file-list-start) |
| 538 | (make-local-variable 'archive-file-list-end) | 569 | (make-local-variable 'archive-file-list-end) |
| 539 | (make-local-variable 'archive-file-name-indent) | 570 | (make-local-variable 'archive-file-name-indent) |
| 540 | (archive-summarize) | 571 | (archive-summarize nil) |
| 541 | (setq buffer-read-only t)))) | 572 | (setq buffer-read-only t)))) |
| 542 | 573 | ||
| 543 | ;; Archive mode is suitable only for specially formatted data. | 574 | ;; Archive mode is suitable only for specially formatted data. |
| @@ -663,17 +694,21 @@ archive. | |||
| 663 | 'arc) | 694 | 'arc) |
| 664 | (t (error "Buffer format not recognized."))))) | 695 | (t (error "Buffer format not recognized."))))) |
| 665 | ;; ------------------------------------------------------------------------- | 696 | ;; ------------------------------------------------------------------------- |
| 666 | (defun archive-summarize () | 697 | (defun archive-summarize (&optional shut-up) |
| 667 | "Parse the contents of the archive file in the current buffer. | 698 | "Parse the contents of the archive file in the current buffer. |
| 668 | Place a dired-like listing on the front; | 699 | Place a dired-like listing on the front; |
| 669 | then narrow to it, so that only that listing | 700 | then narrow to it, so that only that listing |
| 670 | is visible (and the real data of the buffer is hidden)." | 701 | is visible (and the real data of the buffer is hidden). |
| 702 | Optional argument SHUT-UP, if non-nil, means don't print messages | ||
| 703 | when parsing the archive." | ||
| 671 | (widen) | 704 | (widen) |
| 672 | (let (buffer-read-only) | 705 | (let (buffer-read-only) |
| 673 | (message "Parsing archive file...") | 706 | (or shut-up |
| 707 | (message "Parsing archive file...")) | ||
| 674 | (buffer-disable-undo (current-buffer)) | 708 | (buffer-disable-undo (current-buffer)) |
| 675 | (setq archive-files (funcall (archive-name "summarize"))) | 709 | (setq archive-files (funcall (archive-name "summarize"))) |
| 676 | (message "Parsing archive file...done.") | 710 | (or shut-up |
| 711 | (message "Parsing archive file...done.")) | ||
| 677 | (setq archive-proper-file-start (point-marker)) | 712 | (setq archive-proper-file-start (point-marker)) |
| 678 | (narrow-to-region (point-min) (point)) | 713 | (narrow-to-region (point-min) (point)) |
| 679 | (set-buffer-modified-p nil) | 714 | (set-buffer-modified-p nil) |
| @@ -688,7 +723,7 @@ is visible (and the real data of the buffer is hidden)." | |||
| 688 | buffer-read-only) | 723 | buffer-read-only) |
| 689 | (widen) | 724 | (widen) |
| 690 | (delete-region (point-min) archive-proper-file-start) | 725 | (delete-region (point-min) archive-proper-file-start) |
| 691 | (archive-summarize) | 726 | (archive-summarize t) |
| 692 | (set-buffer-modified-p modified) | 727 | (set-buffer-modified-p modified) |
| 693 | (goto-char archive-file-list-start) | 728 | (goto-char archive-file-list-start) |
| 694 | (archive-next-line no))) | 729 | (archive-next-line no))) |
| @@ -727,32 +762,65 @@ This function changes the set of information shown for each files." | |||
| 727 | ;; ------------------------------------------------------------------------- | 762 | ;; ------------------------------------------------------------------------- |
| 728 | ;; Section: Local archive copy handling | 763 | ;; Section: Local archive copy handling |
| 729 | 764 | ||
| 765 | (defun archive-unique-fname (fname dir) | ||
| 766 | "Make sure a file FNAME can be created uniquely in directory DIR. | ||
| 767 | |||
| 768 | If FNAME can be uniquely created in DIR, it is returned unaltered. | ||
| 769 | If FNAME is something our underlying filesystem can't grok, or if another | ||
| 770 | file by that name already exists in DIR, a unique new name is generated | ||
| 771 | using `make-temp-name', and the generated name is returned." | ||
| 772 | (let ((fullname (expand-file-name fname dir)) | ||
| 773 | (alien (string-match archive-file-name-invalid-regexp fname))) | ||
| 774 | (if (or alien (file-exists-p fullname)) | ||
| 775 | (make-temp-name | ||
| 776 | (expand-file-name | ||
| 777 | (if (and (eq system-type 'ms-dos) (not (msdos-long-file-names))) | ||
| 778 | "am" | ||
| 779 | "arc-mode.") | ||
| 780 | dir)) | ||
| 781 | fullname))) | ||
| 782 | |||
| 730 | (defun archive-maybe-copy (archive) | 783 | (defun archive-maybe-copy (archive) |
| 731 | (if archive-remote | 784 | (let ((coding-system-for-write 'no-conversion)) |
| 732 | (let ((start (point-max))) | 785 | (if archive-remote |
| 733 | (setq archive-local-name (expand-file-name | 786 | (let ((start (point-max)) |
| 734 | (file-name-nondirectory archive) | 787 | ;; Sometimes ARCHIVE is invalid while its actual name, as |
| 735 | archive-tmpdir)) | 788 | ;; recorded in its parent archive, is not. For example, an |
| 736 | (make-directory archive-tmpdir t) | 789 | ;; archive bar.zip inside another archive foo.zip gets a name |
| 737 | (save-restriction | 790 | ;; "foo.zip:bar.zip", which is invalid on DOS/Windows. |
| 738 | (widen) | 791 | ;; So use the actual name if available. |
| 739 | (write-region start (point-max) archive-local-name nil 'nomessage)) | 792 | (archive-name |
| 740 | archive-local-name) | 793 | (or (and archive-subfile-mode (aref archive-subfile-mode 0)) |
| 741 | (if (buffer-modified-p) (save-buffer)) | 794 | archive))) |
| 742 | archive)) | 795 | (make-directory archive-tmpdir t) |
| 796 | (setq archive-local-name | ||
| 797 | (archive-unique-fname archive-name archive-tmpdir)) | ||
| 798 | (save-restriction | ||
| 799 | (widen) | ||
| 800 | (write-region start (point-max) archive-local-name nil 'nomessage)) | ||
| 801 | archive-local-name) | ||
| 802 | (if (buffer-modified-p) (save-buffer)) | ||
| 803 | archive))) | ||
| 743 | 804 | ||
| 744 | (defun archive-maybe-update (unchanged) | 805 | (defun archive-maybe-update (unchanged) |
| 745 | (if archive-remote | 806 | (if archive-remote |
| 746 | (let ((name archive-local-name) | 807 | (let ((name archive-local-name) |
| 747 | (modified (buffer-modified-p)) | 808 | (modified (buffer-modified-p)) |
| 809 | (coding-system-for-read 'no-conversion) | ||
| 810 | (lno (archive-get-lineno)) | ||
| 748 | buffer-read-only) | 811 | buffer-read-only) |
| 749 | (if unchanged nil | 812 | (if unchanged nil |
| 813 | (setq archive-files nil) | ||
| 750 | (erase-buffer) | 814 | (erase-buffer) |
| 751 | (insert-file-contents name) | 815 | (insert-file-contents name) |
| 752 | (archive-mode t)) | 816 | (archive-mode t) |
| 817 | (goto-char archive-file-list-start) | ||
| 818 | (archive-next-line lno)) | ||
| 753 | (archive-delete-local name) | 819 | (archive-delete-local name) |
| 754 | (if (not unchanged) | 820 | (if (not unchanged) |
| 755 | (message "Archive file must be saved for changes to take effect")) | 821 | (message |
| 822 | "Buffer `%s' must be saved for changes to take effect" | ||
| 823 | (buffer-name (current-buffer)))) | ||
| 756 | (set-buffer-modified-p (or modified (not unchanged)))))) | 824 | (set-buffer-modified-p (or modified (not unchanged)))))) |
| 757 | 825 | ||
| 758 | (defun archive-delete-local (name) | 826 | (defun archive-delete-local (name) |
| @@ -793,7 +861,11 @@ This function changes the set of information shown for each files." | |||
| 793 | (arcname (file-name-nondirectory archive)) | 861 | (arcname (file-name-nondirectory archive)) |
| 794 | (bufname (concat (file-name-nondirectory iname) " (" arcname ")")) | 862 | (bufname (concat (file-name-nondirectory iname) " (" arcname ")")) |
| 795 | (extractor (archive-name "extract")) | 863 | (extractor (archive-name "extract")) |
| 796 | (read-only-p (or archive-read-only view-p)) | 864 | ;; Members with file names which aren't valid for the |
| 865 | ;; underlying filesystem, are treated as read-only. | ||
| 866 | (read-only-p (or archive-read-only | ||
| 867 | view-p | ||
| 868 | (string-match archive-file-name-invalid-regexp ename))) | ||
| 797 | (buffer (get-buffer bufname)) | 869 | (buffer (get-buffer bufname)) |
| 798 | (just-created nil)) | 870 | (just-created nil)) |
| 799 | (if buffer | 871 | (if buffer |
| @@ -814,8 +886,6 @@ This function changes the set of information shown for each files." | |||
| 814 | (make-local-variable 'local-write-file-hooks) | 886 | (make-local-variable 'local-write-file-hooks) |
| 815 | (add-hook 'local-write-file-hooks 'archive-write-file-member) | 887 | (add-hook 'local-write-file-hooks 'archive-write-file-member) |
| 816 | (setq archive-subfile-mode descr) | 888 | (setq archive-subfile-mode descr) |
| 817 | ; (if (boundp 'default-buffer-file-type) | ||
| 818 | ; (setq buffer-file-type t)) | ||
| 819 | (if (and | 889 | (if (and |
| 820 | (null | 890 | (null |
| 821 | (if (fboundp extractor) | 891 | (if (fboundp extractor) |
| @@ -834,9 +904,16 @@ This function changes the set of information shown for each files." | |||
| 834 | (normal-mode) | 904 | (normal-mode) |
| 835 | ;; Just in case an archive occurs inside another archive. | 905 | ;; Just in case an archive occurs inside another archive. |
| 836 | (if (eq major-mode 'archive-mode) | 906 | (if (eq major-mode 'archive-mode) |
| 837 | (setq archive-remote t)) | 907 | (progn |
| 838 | (run-hooks 'archive-extract-hooks)) | 908 | (setq archive-remote t) |
| 839 | (archive-maybe-update t))) | 909 | (if read-only-p (setq archive-read-only t)) |
| 910 | ;; We will write out the archive ourselves if it is | ||
| 911 | ;; part of another archive. | ||
| 912 | (remove-hook 'write-contents-hooks 'archive-write-file t))) | ||
| 913 | (run-hooks 'archive-extract-hooks) | ||
| 914 | (if archive-read-only | ||
| 915 | (message "Note: altering this archive is not implemented.")))) | ||
| 916 | (archive-maybe-update t)) | ||
| 840 | (or (not (buffer-name buffer)) | 917 | (or (not (buffer-name buffer)) |
| 841 | (progn | 918 | (progn |
| 842 | (if view-p | 919 | (if view-p |
| @@ -952,17 +1029,21 @@ This function changes the set of information shown for each files." | |||
| 952 | (let ((writer (save-excursion (set-buffer archive-superior-buffer) | 1029 | (let ((writer (save-excursion (set-buffer archive-superior-buffer) |
| 953 | (archive-name "write-file-member"))) | 1030 | (archive-name "write-file-member"))) |
| 954 | (archive (save-excursion (set-buffer archive-superior-buffer) | 1031 | (archive (save-excursion (set-buffer archive-superior-buffer) |
| 955 | (buffer-file-name)))) | 1032 | (archive-maybe-copy (buffer-file-name))))) |
| 956 | (if (fboundp writer) | 1033 | (if (fboundp writer) |
| 957 | (funcall writer archive archive-subfile-mode) | 1034 | (funcall writer archive archive-subfile-mode) |
| 958 | (archive-*-write-file-member archive | 1035 | (archive-*-write-file-member archive |
| 959 | archive-subfile-mode | 1036 | archive-subfile-mode |
| 960 | (symbol-value writer)))) | 1037 | (symbol-value writer))) |
| 961 | (set-buffer-modified-p nil) | 1038 | (set-buffer-modified-p nil) |
| 962 | (message "Updating archive...done") | 1039 | (message "Updating archive...done")) |
| 963 | (set-buffer archive-superior-buffer) | 1040 | (set-buffer archive-superior-buffer) |
| 964 | (revert-buffer) | 1041 | (if (not archive-remote) (revert-buffer) (archive-maybe-update nil)))) |
| 965 | t))) | 1042 | ;; Restore the value of last-coding-system-used, so that basic-save-buffer |
| 1043 | ;; won't reset the coding-system of this archive member. | ||
| 1044 | (if (local-variable-p 'archive-member-coding-system) | ||
| 1045 | (setq last-coding-system-used archive-member-coding-system)) | ||
| 1046 | t) | ||
| 966 | 1047 | ||
| 967 | (defun archive-*-write-file-member (archive descr command) | 1048 | (defun archive-*-write-file-member (archive descr command) |
| 968 | (let* ((ename (aref descr 0)) | 1049 | (let* ((ename (aref descr 0)) |
| @@ -972,7 +1053,16 @@ This function changes the set of information shown for each files." | |||
| 972 | (unwind-protect | 1053 | (unwind-protect |
| 973 | (progn | 1054 | (progn |
| 974 | (make-directory (file-name-directory tmpfile) t) | 1055 | (make-directory (file-name-directory tmpfile) t) |
| 975 | (write-region (point-min) (point-max) tmpfile nil 'nomessage) | 1056 | ;; If the member is itself an archive, write it without |
| 1057 | ;; the dired-like listing we created. | ||
| 1058 | (if (eq major-mode 'archive-mode) | ||
| 1059 | (archive-write-file tmpfile) | ||
| 1060 | (write-region (point-min) (point-max) tmpfile nil 'nomessage)) | ||
| 1061 | ;; basic-save-buffer needs last-coding-system-used to have | ||
| 1062 | ;; the value used to write the file, so save it before any | ||
| 1063 | ;; further processing clobbers it (we restore it in | ||
| 1064 | ;; archive-write-file-member, above). | ||
| 1065 | (setq archive-member-coding-system last-coding-system-used) | ||
| 976 | (if (aref descr 3) | 1066 | (if (aref descr 3) |
| 977 | ;; Set the file modes, but make sure we can read it. | 1067 | ;; Set the file modes, but make sure we can read it. |
| 978 | (set-file-modes tmpfile (logior ?\400 (aref descr 3)))) | 1068 | (set-file-modes tmpfile (logior ?\400 (aref descr 3)))) |
| @@ -987,10 +1077,12 @@ This function changes the set of information shown for each files." | |||
| 987 | (error "Updating was unsuccessful (%S)" exitcode)))) | 1077 | (error "Updating was unsuccessful (%S)" exitcode)))) |
| 988 | (archive-delete-local tmpfile)))) | 1078 | (archive-delete-local tmpfile)))) |
| 989 | 1079 | ||
| 990 | (defun archive-write-file () | 1080 | (defun archive-write-file (&optional file) |
| 991 | (save-excursion | 1081 | (save-excursion |
| 992 | (write-region archive-proper-file-start (point-max) buffer-file-name nil t) | 1082 | (let ((coding-system-for-write 'no-conversion)) |
| 993 | (set-buffer-modified-p nil) | 1083 | (write-region archive-proper-file-start (point-max) |
| 1084 | (or file buffer-file-name) nil t) | ||
| 1085 | (set-buffer-modified-p nil)) | ||
| 994 | t)) | 1086 | t)) |
| 995 | ;; ------------------------------------------------------------------------- | 1087 | ;; ------------------------------------------------------------------------- |
| 996 | ;; Section: Marking and unmarking. | 1088 | ;; Section: Marking and unmarking. |
| @@ -1159,7 +1251,8 @@ as a relative change like \"g+rw\" as for chmod(2)" | |||
| 1159 | (defun archive-mode-revert (&optional no-autosave no-confirm) | 1251 | (defun archive-mode-revert (&optional no-autosave no-confirm) |
| 1160 | (let ((no (archive-get-lineno))) | 1252 | (let ((no (archive-get-lineno))) |
| 1161 | (setq archive-files nil) | 1253 | (setq archive-files nil) |
| 1162 | (let ((revert-buffer-function nil)) | 1254 | (let ((revert-buffer-function nil) |
| 1255 | (coding-system-for-read 'no-conversion)) | ||
| 1163 | (revert-buffer t t)) | 1256 | (revert-buffer t t)) |
| 1164 | (archive-mode) | 1257 | (archive-mode) |
| 1165 | (goto-char archive-file-list-start) | 1258 | (goto-char archive-file-list-start) |
| @@ -1426,7 +1519,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1426 | (string= (file-name-nondirectory efnname) ""))) | 1519 | (string= (file-name-nondirectory efnname) ""))) |
| 1427 | (mode (cond ((memq creator '(2 3)) ; Unix + VMS | 1520 | (mode (cond ((memq creator '(2 3)) ; Unix + VMS |
| 1428 | (archive-l-e (+ p 40) 2)) | 1521 | (archive-l-e (+ p 40) 2)) |
| 1429 | ((memq creator '(0 5 6 7 10 11)) ; Dos etc. | 1522 | ((memq creator '(0 5 6 7 10 11 15)) ; Dos etc. |
| 1430 | (logior ?\444 | 1523 | (logior ?\444 |
| 1431 | (if isdir (logior 16384 ?\111) 0) | 1524 | (if isdir (logior 16384 ?\111) 0) |
| 1432 | (if (zerop | 1525 | (if (zerop |
| @@ -1435,7 +1528,8 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1435 | (t nil))) | 1528 | (t nil))) |
| 1436 | (modestr (if mode (archive-int-to-mode mode) "??????????")) | 1529 | (modestr (if mode (archive-int-to-mode mode) "??????????")) |
| 1437 | (fiddle (and archive-zip-case-fiddle | 1530 | (fiddle (and archive-zip-case-fiddle |
| 1438 | (not (not (memq creator '(0 2 4 5 9)))))) | 1531 | (not (not (memq creator '(0 2 4 5 9)))) |
| 1532 | (string= (upcase efnname) efnname))) | ||
| 1439 | (ifnname (if fiddle (downcase efnname) efnname)) | 1533 | (ifnname (if fiddle (downcase efnname) efnname)) |
| 1440 | (text (format " %10s %8d %-11s %-8s %s" | 1534 | (text (format " %10s %8d %-11s %-8s %s" |
| 1441 | modestr | 1535 | modestr |
| @@ -1496,7 +1590,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1496 | (goto-char (+ p 40)) | 1590 | (goto-char (+ p 40)) |
| 1497 | (delete-char 2) | 1591 | (delete-char 2) |
| 1498 | (insert (logand newval 255) (lsh newval -8))) | 1592 | (insert (logand newval 255) (lsh newval -8))) |
| 1499 | ((memq creator '(0 5 6 7 10 11)) ; Dos etc. | 1593 | ((memq creator '(0 5 6 7 10 11 15)) ; Dos etc. |
| 1500 | (goto-char (+ p 38)) | 1594 | (goto-char (+ p 38)) |
| 1501 | (insert (logior (logand (char-after (point)) 254) | 1595 | (insert (logior (logand (char-after (point)) 254) |
| 1502 | (logand (logxor 1 (lsh newval -7)) 1))) | 1596 | (logand (logxor 1 (lsh newval -7)) 1))) |