From: Kenichi Handa <handa@m17n.org>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: coding cookies not obeyed through auto-compression-mode
Date: Wed, 22 Jan 2003 11:41:26 +0900 (JST) [thread overview]
Message-ID: <200301220241.LAA05782@etlken.m17n.org> (raw)
In-Reply-To: <rzq8yxgf2gg.fsf@albion.dl.ac.uk> (message from Dave Love on 20 Jan 2003 12:08:47 +0000)
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
prev parent reply other threads:[~2003-01-22 2:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-20 12:08 coding cookies not obeyed through auto-compression-mode Dave Love
2003-01-22 2:41 ` Kenichi Handa [this message]
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=200301220241.LAA05782@etlken.m17n.org \
--to=handa@m17n.org \
--cc=bug-gnu-emacs@gnu.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).