aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii1998-04-15 15:31:30 +0000
committerEli Zaretskii1998-04-15 15:31:30 +0000
commitb48fa57006c67343c5b8b53f7f65b042a5ce543a (patch)
treebf22fedb79a861ab71bfd8582bd1a434efcf6762
parent0b45d07bc22fc6fc26d8c46be5cfde6b76475f05 (diff)
downloademacs-b48fa57006c67343c5b8b53f7f65b042a5ce543a.tar.gz
emacs-b48fa57006c67343c5b8b53f7f65b042a5ce543a.zip
(archive-extract-by-stdout): Don't use
binary-process-output. Bind coding-system-for-read to 'undecided, so coding system is determined on the fly. Bind inherit-process-coding-system to t. (archive-dos-members): Remove. (archive-extract): Don't call archive-check-dos. Handle pkunzip errors. (archive-*-extract): Handle pkzip errors. (archive-check-dos): Remove. (archive-subfile-dos): Remove. (archive-extract): Don't bind archive-subfile-dos. (archive-write-file-member): Don't DOSify DOS-style archive members. (archive-zip-extract): Make pkzip use -o- flag, to make it more silent.
-rw-r--r--lisp/arc-mode.el192
1 files changed, 80 insertions, 112 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 02072c95746..1207a577910 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -119,12 +119,6 @@
119 "ZOO-specific options to archive." 119 "ZOO-specific options to archive."
120 :group 'archive) 120 :group 'archive)
121 121
122
123(defcustom archive-dos-members t
124 "*If non-nil then recognize member files using ^M^J as line terminator."
125 :type 'boolean
126 :group 'archive)
127
128(defcustom archive-tmpdir 122(defcustom archive-tmpdir
129 (expand-file-name 123 (expand-file-name
130 (make-temp-name (if (eq system-type 'ms-dos) "ar" "archive.tmp")) 124 (make-temp-name (if (eq system-type 'ms-dos) "ar" "archive.tmp"))
@@ -222,7 +216,7 @@ Only set to true for msdog systems!"
222 :group 'archive-zip) 216 :group 'archive-zip)
223 217
224(defcustom archive-zip-extract 218(defcustom archive-zip-extract
225 (if archive-zip-use-pkzip '("pkunzip" "-e") '("unzip" "-qq" "-c")) 219 (if archive-zip-use-pkzip '("pkunzip" "-e" "-o-") '("unzip" "-qq" "-c"))
226 "*Program and its options to run in order to extract a zip file member. 220 "*Program and its options to run in order to extract a zip file member.
227Extraction should happen to standard output. Archive and member name will 221Extraction should happen to standard output. Archive and member name will
228be added. If `archive-zip-use-pkzip' is non-nil then this program is 222be added. If `archive-zip-use-pkzip' is non-nil then this program is
@@ -334,11 +328,6 @@ Archive and member name will be added."
334(make-variable-buffer-local 'archive-subfile-mode) 328(make-variable-buffer-local 'archive-subfile-mode)
335(put 'archive-subfile-mode 'permanent-local t) 329(put 'archive-subfile-mode 'permanent-local t)
336 330
337(defvar archive-subfile-dos nil
338 "Negation of `buffer-file-type', which see.")
339(make-variable-buffer-local 'archive-subfile-dos)
340(put 'archive-subfile-dos 'permanent-local t)
341
342(defvar archive-files nil 331(defvar archive-files nil
343 "Vector of file descriptors. 332 "Vector of file descriptors.
344Each descriptor is a vector of the form 333Each descriptor is a vector of the form
@@ -528,8 +517,6 @@ archive.
528 (setq require-final-newline nil) 517 (setq require-final-newline nil)
529 (make-local-variable 'enable-local-variables) 518 (make-local-variable 'enable-local-variables)
530 (setq enable-local-variables nil) 519 (setq enable-local-variables nil)
531 (if (boundp 'default-buffer-file-type)
532 (setq buffer-file-type t))
533 520
534 (make-local-variable 'archive-read-only) 521 (make-local-variable 'archive-read-only)
535 (setq archive-read-only (not (file-writable-p (buffer-file-name)))) 522 (setq archive-read-only (not (file-writable-p (buffer-file-name))))
@@ -657,10 +644,7 @@ archive.
657 )) 644 ))
658 645
659(let* ((item1 '(archive-subfile-mode " Archive")) 646(let* ((item1 '(archive-subfile-mode " Archive"))
660 (item2 '(archive-subfile-dos " Dos")) 647 (items (list item1)))
661 (items (if (memq system-type '(ms-dos windows-nt))
662 (list item1) ; msdog has its own indicator
663 (list item1 item2))))
664 (or (member item1 minor-mode-alist) 648 (or (member item1 minor-mode-alist)
665 (setq minor-mode-alist (append items minor-mode-alist)))) 649 (setq minor-mode-alist (append items minor-mode-alist))))
666;; ------------------------------------------------------------------------- 650;; -------------------------------------------------------------------------
@@ -830,49 +814,73 @@ This function changes the set of information shown for each files."
830 (make-local-variable 'local-write-file-hooks) 814 (make-local-variable 'local-write-file-hooks)
831 (add-hook 'local-write-file-hooks 'archive-write-file-member) 815 (add-hook 'local-write-file-hooks 'archive-write-file-member)
832 (setq archive-subfile-mode descr) 816 (setq archive-subfile-mode descr)
833 (setq archive-subfile-dos nil) 817; (if (boundp 'default-buffer-file-type)
834 (if (boundp 'default-buffer-file-type) 818; (setq buffer-file-type t))
835 (setq buffer-file-type t)) 819 (if (and
836 (if (fboundp extractor) 820 (null
837 (funcall extractor archive ename) 821 (if (fboundp extractor)
838 (archive-*-extract archive ename (symbol-value extractor))) 822 (funcall extractor archive ename)
839 (if archive-dos-members (archive-check-dos)) 823 (archive-*-extract archive ename (symbol-value extractor))))
840 (goto-char (point-min)) 824 just-created)
841 (rename-buffer bufname) 825 (progn
842 (setq buffer-read-only read-only-p) 826 (set-buffer-modified-p nil)
843 (setq buffer-undo-list nil) 827 (kill-buffer buffer))
844 (set-buffer-modified-p nil) 828 (goto-char (point-min))
845 (setq buffer-saved-size (buffer-size)) 829 (rename-buffer bufname)
846 (normal-mode) 830 (setq buffer-read-only read-only-p)
847 ;; Just in case an archive occurs inside another archive. 831 (setq buffer-undo-list nil)
848 (if (eq major-mode 'archive-mode) 832 (set-buffer-modified-p nil)
849 (setq archive-remote t)) 833 (setq buffer-saved-size (buffer-size))
850 (run-hooks 'archive-extract-hooks)) 834 (normal-mode)
851 (archive-maybe-update t)) 835 ;; Just in case an archive occurs inside another archive.
852 (if view-p 836 (if (eq major-mode 'archive-mode)
853 (view-buffer buffer (and just-created 'kill-buffer)) 837 (setq archive-remote t))
854 (if (eq other-window-p 'display) 838 (run-hooks 'archive-extract-hooks))
855 (display-buffer buffer) 839 (archive-maybe-update t)))
856 (if other-window-p 840 (or (not (buffer-name buffer))
857 (switch-to-buffer-other-window buffer) 841 (progn
858 (switch-to-buffer buffer)))))) 842 (if view-p
843 (view-buffer buffer (and just-created 'kill-buffer)))
844 (if (eq other-window-p 'display)
845 (display-buffer buffer)
846 (if other-window-p
847 (switch-to-buffer-other-window buffer)
848 (switch-to-buffer buffer)))))))
859 849
860(defun archive-*-extract (archive name command) 850(defun archive-*-extract (archive name command)
861 (let* ((default-directory (file-name-as-directory archive-tmpdir)) 851 (let* ((default-directory (file-name-as-directory archive-tmpdir))
862 (tmpfile (expand-file-name (file-name-nondirectory name) 852 (tmpfile (expand-file-name (file-name-nondirectory name)
863 default-directory))) 853 default-directory))
854 exit-status success)
864 (make-directory (directory-file-name default-directory) t) 855 (make-directory (directory-file-name default-directory) t)
865 (apply 'call-process 856 (setq exit-status
866 (car command) 857 (apply 'call-process
867 nil 858 (car command)
868 nil 859 nil
869 nil 860 nil
870 (append (cdr command) (list archive name))) 861 nil
871 (insert-file-contents tmpfile) 862 (append (cdr command) (list archive name))))
872 (archive-delete-local tmpfile))) 863 (cond ((and (numberp exit-status) (= exit-status 0))
864 (if (not (file-exists-p tmpfile))
865 (ding (message "`%s': no such file or directory" tmpfile))
866 (insert-file-contents tmpfile)
867 (setq success t)))
868 ((numberp exit-status)
869 (ding
870 (message "`%s' exited with status %d" (car command) exit-status)))
871 ((stringp exit-status)
872 (ding (message "`%s' aborted: %s" (car command) exit-status)))
873 (t
874 (ding (message "`%s' failed" (car command)))))
875 (archive-delete-local tmpfile)
876 success))
873 877
874(defun archive-extract-by-stdout (archive name command) 878(defun archive-extract-by-stdout (archive name command)
875 (let ((binary-process-output t)) ; for Ms-Dos 879 ;; We need the coding system of the output of the extract program,
880 ;; including the EOL encoding, be decoded dynamically, since what
881 ;; the extract program outputs is the contents of some file.
882 (let ((coding-system-for-read (or coding-system-for-read 'undecided))
883 (inherit-process-coding-system t))
876 (apply 'call-process 884 (apply 'call-process
877 (car command) 885 (car command)
878 nil 886 nil
@@ -936,65 +944,25 @@ This function changes the set of information shown for each files."
936;; ------------------------------------------------------------------------- 944;; -------------------------------------------------------------------------
937;; Section: IO stuff 945;; Section: IO stuff
938 946
939(defun archive-check-dos (&optional force)
940 "*Possibly handle a buffer with ^M^J terminated lines."
941 (save-restriction
942 (widen)
943 (save-excursion
944 (goto-char (point-min))
945 (setq archive-subfile-dos
946 (or force (not (search-forward-regexp "[^\r]\n" nil t))))
947 (if (boundp 'default-buffer-file-type)
948 (setq buffer-file-type (not archive-subfile-dos)))
949 (if archive-subfile-dos
950 (let ((modified (buffer-modified-p)))
951 (buffer-disable-undo (current-buffer))
952 (goto-char (point-min))
953 (while (search-forward "\r\n" nil t)
954 (replace-match "\n"))
955 (buffer-enable-undo)
956 (set-buffer-modified-p modified))))))
957
958(defun archive-write-file-member () 947(defun archive-write-file-member ()
959 (if archive-subfile-dos 948 (save-excursion
960 (save-restriction 949 (save-restriction
961 (widen) 950 (message "Updating archive...")
962 (save-excursion 951 (widen)
963 (goto-char (point-min)) 952 (let ((writer (save-excursion (set-buffer archive-superior-buffer)
964 ;; We don't want our ^M^J <--> ^J changes to show in the undo list 953 (archive-name "write-file-member")))
965 (let ((undo-list buffer-undo-list)) 954 (archive (save-excursion (set-buffer archive-superior-buffer)
966 (unwind-protect 955 (buffer-file-name))))
967 (progn 956 (if (fboundp writer)
968 (setq buffer-undo-list t) 957 (funcall writer archive archive-subfile-mode)
969 (while (search-forward "\n" nil t) 958 (archive-*-write-file-member archive
970 (replace-match "\r\n")) 959 archive-subfile-mode
971 (setq archive-subfile-dos nil) 960 (symbol-value writer))))
972 (if (boundp 'default-buffer-file-type) 961 (set-buffer-modified-p nil)
973 (setq buffer-file-type t)) 962 (message "Updating archive...done")
974 ;; OK, we're now have explicit ^M^Js -- save and re-unixfy 963 (set-buffer archive-superior-buffer)
975 (archive-write-file-member)) 964 (revert-buffer)
976 (progn 965 t)))
977 (archive-check-dos t)
978 (setq buffer-undo-list undo-list))))
979 t))
980 (save-excursion
981 (save-restriction
982 (message "Updating archive...")
983 (widen)
984 (let ((writer (save-excursion (set-buffer archive-superior-buffer)
985 (archive-name "write-file-member")))
986 (archive (save-excursion (set-buffer archive-superior-buffer)
987 (buffer-file-name))))
988 (if (fboundp writer)
989 (funcall writer archive archive-subfile-mode)
990 (archive-*-write-file-member archive
991 archive-subfile-mode
992 (symbol-value writer))))
993 (set-buffer-modified-p nil)
994 (message "Updating archive...done")
995 (set-buffer archive-superior-buffer)
996 (revert-buffer)
997 t))))
998 966
999(defun archive-*-write-file-member (archive descr command) 967(defun archive-*-write-file-member (archive descr command)
1000 (let* ((ename (aref descr 0)) 968 (let* ((ename (aref descr 0))