aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2007-05-23 12:38:59 +0000
committerEli Zaretskii2007-05-23 12:38:59 +0000
commit07e7a05a7f4e424551889e03dd7b345c4a69548f (patch)
tree5918b94a13f853a9edc93ab518994da9001ea67f
parentc96e025abb1ba6924c6d53776636284113c942d1 (diff)
downloademacs-07e7a05a7f4e424551889e03dd7b345c4a69548f.tar.gz
emacs-07e7a05a7f4e424551889e03dd7b345c4a69548f.zip
(tar-file-name-handler): New function.
(tar-extract): Bind file-name-handler-alist to it to force find-buffer-file-type-coding-system behave as if the file being extracted existed. Use last-coding-system-used to force buffer-file-coding-system to what decode-coding-region actually used to decode the file.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/tar-mode.el24
2 files changed, 29 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3ecd84c2a98..5f8f8ef3379 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12007-05-23 Eli Zaretskii <eliz@gnu.org>
2
3 * tar-mode.el (tar-file-name-handler): New function.
4 (tar-extract): Bind file-name-handler-alist to it to force
5 find-buffer-file-type-coding-system behave as if the file being
6 extracted existed. Use last-coding-system-used to force
7 buffer-file-coding-system to what decode-coding-region actually
8 used to decode the file.
9
12007-05-23 Nikolaj Schumacher <n_schumacher@web.de> (tiny change) 102007-05-23 Nikolaj Schumacher <n_schumacher@web.de> (tiny change)
2 11
3 * progmodes/compile.el (compilation-handle-exit): 12 * progmodes/compile.el (compilation-handle-exit):
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index cffc8a4cccc..f5022a9fcd4 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -681,6 +681,12 @@ appear on disk when you save the tar-file's buffer."
681 (goto-char (posn-point (event-end event))) 681 (goto-char (posn-point (event-end event)))
682 (tar-extract)) 682 (tar-extract))
683 683
684(defun tar-file-name-handler (op &rest args)
685 "Helper function for `tar-extract'."
686 (or (eq op 'file-exists-p)
687 (let ((file-name-handler-alist nil))
688 (apply op args))))
689
684(defun tar-extract (&optional other-window-p) 690(defun tar-extract (&optional other-window-p)
685 "In Tar mode, extract this entry of the tar file into its own buffer." 691 "In Tar mode, extract this entry of the tar file into its own buffer."
686 (interactive) 692 (interactive)
@@ -735,9 +741,17 @@ appear on disk when you save the tar-file's buffer."
735 (save-excursion 741 (save-excursion
736 (funcall set-auto-coding-function 742 (funcall set-auto-coding-function
737 name (- (point-max) (point))))) 743 name (- (point-max) (point)))))
738 (car (find-operation-coding-system 744 ;; The following binding causes
739 'insert-file-contents 745 ;; find-buffer-file-type-coding-system
740 (cons name (current-buffer)) t)))) 746 ;; (defined on dos-w32.el) to act as if
747 ;; the file being extracted existed, so
748 ;; that the file's contents' encoding is
749 ;; auto-detected.
750 (let ((file-name-handler-alist
751 '(("" . tar-file-name-handler))))
752 (car (find-operation-coding-system
753 'insert-file-contents
754 (cons name (current-buffer)) t)))))
741 (multibyte enable-multibyte-characters) 755 (multibyte enable-multibyte-characters)
742 (detected (detect-coding-region 756 (detected (detect-coding-region
743 (point-min) 757 (point-min)
@@ -758,7 +772,9 @@ appear on disk when you save the tar-file's buffer."
758 (coding-system-change-text-conversion 772 (coding-system-change-text-conversion
759 coding 'raw-text))) 773 coding 'raw-text)))
760 (decode-coding-region (point-min) (point-max) coding) 774 (decode-coding-region (point-min) (point-max) coding)
761 (set-buffer-file-coding-system coding)) 775 ;; Force buffer-file-coding-system to what
776 ;; decode-coding-region actually used.
777 (set-buffer-file-coding-system last-coding-system-used t))
762 ;; Set the default-directory to the dir of the 778 ;; Set the default-directory to the dir of the
763 ;; superior buffer. 779 ;; superior buffer.
764 (setq default-directory 780 (setq default-directory