unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: EOL conversion of files in .tar archives
Date: Tue, 22 May 2007 14:19:14 +0300	[thread overview]
Message-ID: <u1wh9kswd.fsf@gnu.org> (raw)
In-Reply-To: <E1Hpzoi-0001mB-Vh@etlken.m17n.org> (message from Kenichi Handa on Mon, 21 May 2007 13:48:20 +0900)

> From: Kenichi Handa <handa@m17n.org>
> CC: emacs-devel@gnu.org
> Date: Mon, 21 May 2007 13:48:20 +0900
> 
> In article <u1whb5m6p.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Lately I noticed that, in the Windows port of Emacs, visiting files in
> > .tar archives shows them as if they had DOS EOLs, even though the
> > files have Unix EOLs.  (This is not due to some recent change: it
> > looks like Emacs behaved like that since before the pretest.)
> 
> > Is this intentional, or should I debug it?  If the former, can someone
> > explain the rationale?
> 
> I think it is a bug of find-buffer-file-type-coding-system
> (dos-w32.el).  If TARGET is (FILENAME . BUFFER), it should
> assume that the file contents is available.  Could you
> verify that the attached patch is correct?

I'm uneasy about patching find-buffer-file-type-coding-system at this
stage, since it is so widely used.  For example,
decode-coding-inserted-region also invokes
find-operation-coding-system with second argument a cons cell, and it
is not clear to me that your change will DTRT in that case.

I'd like to suggest an alternative change that is local to
tar-mode.el, see below.  It mimics what arc-mode.el does.

This solves the problem with the EOL decoding, but reveals a very
strange phenomenon: dos-w32.el and dos-w32.elc behave differently.
The latter is preloaded into Emacs on Windows, and if I visit a file
inside a tarball (after applying the patch below), plain text files
with Unix EOLs get latin-1-unix buffer-file-coding-system, instead of
the expected undecided-unix.  But if I manually load dos-w32.el and
visit the same file again, its buffer-file-coding-system is now
undecided-unix, as expected!  Is this some problem with the byte
compiler?


Index: lisp/tar-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/tar-mode.el,v
retrieving revision 1.108
diff -u -r1.108 tar-mode.el
--- lisp/tar-mode.el	21 Jan 2007 03:53:10 -0000	1.108
+++ lisp/tar-mode.el	22 May 2007 11:18:19 -0000
@@ -681,6 +681,12 @@
   (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,17 @@
 				  (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 is
+			     ;; auto-detected.
+			     (let ((file-name-handler-alist
+				    '(("" . tar-file-name-handler))))
+			       (car (find-operation-coding-system
+				     'insert-file-contents
+				     (cons name (current-buffer)) t)))))
 			(multibyte enable-multibyte-characters)
 			(detected (detect-coding-region
 				   (point-min)

  parent reply	other threads:[~2007-05-22 11:19 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-20 19:28 EOL conversion of files in .tar archives Eli Zaretskii
2007-05-21  4:48 ` Kenichi Handa
2007-05-21  5:15   ` David Kastrup
2007-05-21 19:54     ` Eli Zaretskii
2007-05-22  8:30     ` Richard Stallman
2007-05-23 18:43       ` Eli Zaretskii
2007-05-21 20:45   ` Eli Zaretskii
2007-05-21 22:58     ` Chong Yidong
2007-05-22  6:39       ` Eli Zaretskii
2007-05-22  6:53         ` David Kastrup
2007-05-22  7:01           ` Eli Zaretskii
2007-05-22 15:49         ` Richard Stallman
2007-05-22 16:25           ` Eli Zaretskii
2007-05-22 14:52       ` Richard Stallman
2007-05-22 21:20         ` David Kastrup
2007-05-22 14:52     ` Richard Stallman
2007-05-22 16:20       ` Eli Zaretskii
2007-05-22 11:19   ` Eli Zaretskii [this message]
2007-05-22 12:21     ` Eli Zaretskii
2007-05-22 21:10       ` Chong Yidong
2007-05-22 21:18         ` Lennart Borgman (gmail)
2007-05-22 21:19           ` Chong Yidong
2007-05-23  6:56           ` Eli Zaretskii
2007-05-23  3:18       ` Chong Yidong
2007-05-23  5:58         ` Kenichi Handa
2007-05-23  7:15         ` Eli Zaretskii
2007-05-23 12:34           ` Eli Zaretskii
2007-05-23 13:01             ` Kenichi Handa
2007-05-23 17:33               ` Eli Zaretskii
2007-05-23 18:02                 ` David Kastrup
2007-05-23 18:32                   ` Eli Zaretskii
2007-05-23 18:43                     ` David Kastrup
2007-05-24  1:01                 ` Kenichi Handa
2007-05-24  7:48                   ` Eli Zaretskii
2007-05-24  8:15                     ` Kenichi Handa
2007-05-24  8:32                       ` Eli Zaretskii
2007-05-27  5:45                         ` Kenichi Handa
2007-05-27 23:21                           ` Richard Stallman
2007-05-28  3:12                             ` Eli Zaretskii
2007-05-29  0:02                               ` Richard Stallman
2007-05-23 13:31             ` Chong Yidong
2007-05-23 17:32               ` Eli Zaretskii
2007-05-22 23:09     ` Richard Stallman
2007-05-23  7:03       ` Eli Zaretskii
2007-05-23 18:56         ` Richard Stallman
2007-05-23  0:59     ` Chong Yidong
2007-05-23 18:45       ` Chong Yidong
2007-05-23 19:31       ` Eli Zaretskii
2007-05-23  1:22     ` Kenichi Handa
2007-05-23  7:10       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u1wh9kswd.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).