all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* coding cookies not obeyed through auto-compression-mode
@ 2003-01-20 12:08 Dave Love
  2003-01-22  2:41 ` Kenichi Handa
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Love @ 2003-01-20 12:08 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: coding cookies not obeyed through auto-compression-mode
  2003-01-20 12:08 coding cookies not obeyed through auto-compression-mode Dave Love
@ 2003-01-22  2:41 ` Kenichi Handa
  0 siblings, 0 replies; 2+ messages in thread
From: Kenichi Handa @ 2003-01-22  2:41 UTC (permalink / raw)
  Cc: bug-gnu-emacs

In article <rzq8yxgf2gg.fsf@albion.dl.ac.uk>, Dave Love <d.love@dl.ac.uk> 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  <handa@m17n.org>

	* 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-22  2:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-20 12:08 coding cookies not obeyed through auto-compression-mode Dave Love
2003-01-22  2:41 ` Kenichi Handa

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.