summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2007-05-23 17:32:46 +0000
committerEli Zaretskii <eliz@gnu.org>2007-05-23 17:32:46 +0000
commitdb2ccbc2a82836fdeefef3d29c1d613c79b7d476 (patch)
tree06668b96d7768b84111ddb4f0fe12c07a61bb474 /lisp
parent3c71f17a1cc49223da45c66bf6be81416f11c04c (diff)
downloademacs-db2ccbc2a82836fdeefef3d29c1d613c79b7d476.tar.gz
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/tar-mode.el26
2 files changed, 31 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 88ccc684542..b1763abd2ef 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2007-05-23 Eli Zaretskii <eliz@gnu.org>
+
+ * tar-mode.el (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.
+
2007-05-23 Nikolaj Schumacher <n_schumacher@web.de> (tiny change)
* progmodes/compile.el (compilation-handle-exit):
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index cffc8a4cccc..31854e60407 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."
(goto-char (posn-point (event-end event)))
(tar-extract))
+(defun tar-file-name-handler (op &rest args)
+ "Helper function for `tar-extract'."
+ (or (eq op 'file-exists-p)
+ (let ((file-name-handler-alist nil))
+ (apply op args))))
+
(defun tar-extract (&optional other-window-p)
"In Tar mode, extract this entry of the tar file into its own buffer."
(interactive)
@@ -735,9 +741,19 @@ appear on disk when you save the tar-file's buffer."
(save-excursion
(funcall set-auto-coding-function
name (- (point-max) (point)))))
- (car (find-operation-coding-system
- 'insert-file-contents
- (cons name (current-buffer)) t))))
+ ;; The following binding causes
+ ;; find-buffer-file-type-coding-system
+ ;; (defined on dos-w32.el) to act as if
+ ;; the file being extracted existed, so
+ ;; that the file's contents' encoding and
+ ;; EOL format are auto-detected.
+ (let ((file-name-handler-alist
+ (if (featurep 'dos-w32)
+ '(("" . tar-file-name-handler))
+ file-name-handler-alist)))
+ (car (find-operation-coding-system
+ 'insert-file-contents
+ (cons name (current-buffer)) t)))))
(multibyte enable-multibyte-characters)
(detected (detect-coding-region
(point-min)
@@ -758,7 +774,9 @@ appear on disk when you save the tar-file's buffer."
(coding-system-change-text-conversion
coding 'raw-text)))
(decode-coding-region (point-min) (point-max) coding)
- (set-buffer-file-coding-system coding))
+ ;; Force buffer-file-coding-system to what
+ ;; decode-coding-region actually used.
+ (set-buffer-file-coding-system last-coding-system-used t))
;; Set the default-directory to the dir of the
;; superior buffer.
(setq default-directory