bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coding cookies not obeyed through auto-compression-mode


From: Kenichi Handa
Subject: Re: coding cookies not obeyed through auto-compression-mode
Date: Wed, 22 Jan 2003 11:41:26 +0900 (JST)
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)

In article <address@hidden>, Dave Love <address@hidden> 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
address@hidden


2003-01-22  Kenichi Handa  <address@hidden>

        * 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]