From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.bugs Subject: Re: coding cookies not obeyed through auto-compression-mode Date: Wed, 22 Jan 2003 11:41:26 +0900 (JST) Sender: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <200301220241.LAA05782@etlken.m17n.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1043203345 24451 80.91.224.249 (22 Jan 2003 02:42:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 22 Jan 2003 02:42:25 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18bAqN-0006ME-00 for ; Wed, 22 Jan 2003 03:42:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18bAqR-00089n-04 for gnu-bug-gnu-emacs@m.gmane.org; Tue, 21 Jan 2003 21:42:27 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18bAqJ-00087U-00 for bug-gnu-emacs@gnu.org; Tue, 21 Jan 2003 21:42:19 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18bAq4-00080g-00 for bug-gnu-emacs@gnu.org; Tue, 21 Jan 2003 21:42:05 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18bApb-0007s8-00 for bug-gnu-emacs@gnu.org; Tue, 21 Jan 2003 21:41:35 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h0M2fRk22519; Wed, 22 Jan 2003 11:41:27 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h0M2fRR17630; Wed, 22 Jan 2003 11:41:27 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id LAA05782; Wed, 22 Jan 2003 11:41:26 +0900 (JST) Original-To: d.love@dl.ac.uk In-reply-to: (message from Dave Love on 20 Jan 2003 12:08:47 +0000) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:4279 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:4279 In article , Dave Love writes: > In auto-compression-mode, find a compressed file whose plain text has > a coding cookie or coding in the local variables. The cookie is > ignored and the file is decoded in the preferred coding system. > I _think_ this worked once, but that must be long ago. It fails the > same in 21.2 and the development code. > I'm not sure how everything is supposed to interact, so I haven't > looked for a fix. I've just installed the attached changes in CVS HEAD. It is doubtful that the coding cookie worked once. There were no code that handled the coding cookie. By the way, I dared instroduce a new function decode-coding-region-as-inserted-from-file hoping that it is usefull also for the other packages (e.g. tar-mode). --- Ken'ichi HANDA handa@m17n.org 2003-01-22 Kenichi Handa * international/mule.el (decode-coding-region-as-inserted-from-file): New function. * jka-compr.el (jka-compr-insert-file-contents): Read a process output without decoding. Decode the result by decode-coding-region-as-inserted-from-file. Index: mule.el =================================================================== RCS file: /cvs/emacs/lisp/international/mule.el,v retrieving revision 1.174 retrieving revision 1.175 diff -u -c -r1.174 -r1.175 cvs server: conflicting specifications of output style *** mule.el 15 Jan 2003 05:57:31 -0000 1.174 --- mule.el 22 Jan 2003 02:33:07 -0000 1.175 *************** *** 1899,1904 **** --- 1899,1931 ---- (cons (cons regexp coding-system) network-coding-system-alist))))))) + (defun decode-coding-region-as-inserted-from-file (from to filename + &optional + visit beg end replace) + "Decode the region between FROM and TO as if it is read from file FILENAME. + Optional arguments VISIT, BEG, END, and REPLACE are the same as those + of the function `insert-file-contents'." + (save-excursion + (save-restriction + (narrow-to-region from to) + (goto-char (point-min)) + (let ((coding coding-system-for-read)) + (or coding + (setq coding (funcall set-auto-coding-function + filename (- (point-max) (point-min))))) + (or coding + (setq coding (find-operation-coding-system + 'insert-file-contents + filename visit beg end replace))) + (if (coding-system-p coding) + (or enable-multibyte-characters + (setq coding + (coding-system-change-text-conversion coding 'raw-text))) + (setq coding nil)) + (if coding + (decode-coding-region (point-min) (point-max) coding)) + (setq last-coding-system-used coding))))) + (defun make-translation-table (&rest args) "Make a translation table from arguments. A translation table is a char table intended for character Index: jka-compr.el =================================================================== RCS file: /cvs/emacs/lisp/jka-compr.el,v retrieving revision 1.71 retrieving revision 1.72 diff -u -c -r1.71 -r1.72 cvs server: conflicting specifications of output style *** jka-compr.el 1 Sep 2002 13:26:06 -0000 1.71 --- jka-compr.el 22 Jan 2003 02:33:55 -0000 1.72 *************** *** 527,546 **** (local-copy (jka-compr-run-real-handler 'file-local-copy (list filename))) local-file ! size start ! (coding-system-for-read ! (or coding-system-for-read ! ;; If multibyte characters are disabled, ! ;; don't do that conversion. ! (and (null enable-multibyte-characters) ! (or (auto-coding-alist-lookup ! (jka-compr-byte-compiler-base-file-name file)) ! 'raw-text)) ! (let ((coding (find-operation-coding-system ! 'insert-file-contents ! (jka-compr-byte-compiler-base-file-name file)))) ! (and (consp coding) (car coding))) ! 'undecided)) ) (setq local-file (or local-copy filename)) --- 527,533 ---- (local-copy (jka-compr-run-real-handler 'file-local-copy (list filename))) local-file ! size start) (setq local-file (or local-copy filename)) *************** *** 558,564 **** (condition-case error-code ! (progn (if replace (goto-char (point-min))) (setq start (point)) --- 545,551 ---- (condition-case error-code ! (let ((coding-system-for-read 'no-conversion)) (if replace (goto-char (point-min))) (setq start (point)) *************** *** 605,610 **** --- 592,602 ---- local-copy (file-exists-p local-copy) (delete-file local-copy))) + + (decode-region-as-inserted-from-file + (point) (+ (point) size) + (jka-compr-byte-compiler-base-file-name file) + visit beg end replace) (and visit