From xemacs-m  Sun Jan 26 19:18:31 1997
Received: from mecca.spd.louisville.edu (mecca.spd.louisville.edu [136.165.40.148])
          by xemacs.org (8.8.4/8.8.4) with SMTP
	  id TAA13462; Sun, 26 Jan 1997 19:18:30 -0600 (CST)
Received: (from tjchol01@localhost) by mecca.spd.louisville.edu (950413.SGI.8.6.12/950213.SGI.AUTOCF) id UAA05280; Sun, 26 Jan 1997 20:18:32 -0500
Date: Sun, 26 Jan 1997 20:18:32 -0500
Message-Id: <199701270118.UAA05280@mecca.spd.louisville.edu>
From: "Tomasz J. Cholewo" <tjchol01@mecca.spd.louisville.edu>
To: xemacs-beta-patches@xemacs.org
CC: xemacs-beta@xemacs.org
Subject: [patch] 20.0-b92 jka-compr-write-region: wrong number of arguments
Mime-Version: 1.0 (generated by tm-edit 7.100)
Content-Type: text/plain; charset=US-ASCII

Hi,

An attempt to write a region to gzip file using jka-compr fails under
xemacs-20.0-b92 (with no Mule support).  After "xemacs -q" and
"M-: (require 'jka-compr)", "M-x write-region" leads to:

  Signaling: (wrong-number-of-arguments #<compiled-function
         (from "jka-compr.elc") (start end file &optional append visit)...
    jka-compr-write-region(1 9 "/usr1/tjchol01/x.gz" nil nil nil)
    apply(jka-compr-write-region (1 9 "/usr1/tjchol01/x.gz" nil nil nil))
    jka-compr-handler(write-region 1 9 "/usr1/tjchol01/x.gz" nil nil nil)
    write-region-internal(1 9 "~/x.gz" nil nil nil nil)              ^^^^
    write-region(1 9 "~/x.gz")                     ^^^^   <- new codesys arg
    call-interactively(write-region)

The reason is that write-region-internal has in 20.0 an additional (wrt
to 19.xx), 7th argument named `codesys' which is passed to functions in
the `file-name-handler-alist' chain (see the `Fwrite_region_internal'
function in fileio.c).

For comparison, in 19.14 it works perfectly. Setting `debug-on-entry' on
`jka-compr-write-region' gives:

  Entering:
  * jka-compr-write-region(1 9 "/usr1/tjchol01/x.gz" nil nil)
    apply(jka-compr-write-region (1 9 "/usr1/tjchol01/x.gz" nil nil))
    jka-compr-handler(write-region 1 9 "/usr1/tjchol01/x.gz" nil nil)
    write-region-internal(1 9 "~/x.gz" nil nil nil) <- only 6 args
    write-region(1 9 "~/x.gz")
    call-interactively(write-region)

  This additional parameter can be a potential source of trouble also
for ange-ftp-write-region, though I didn't manage to activate it.

A simple temporary workaround is to add the codesys argument to the
jka-compr-write-region which is exactly what I have done in the attached
patch.  An alternative approach would be not to pass it to the hook
functions what would avoid compatibility problems with other packages.

Tom

================= CUT HERE =======================
*** xemacs-20.0-b92/lisp/packages/jka-compr.el	Wed Dec 18 17:42:54 1996
--- xemacs-20.0-b93/lisp/packages/jka-compr.el	Sun Jan 26 17:47:27 1997
***************
*** 367,373 ****
      (error nil)))


! (defun jka-compr-write-region (start end file &optional append visit)
    (let* ((filename (expand-file-name file))
  	 (visit-file (if (stringp visit) (expand-file-name visit) filename))
  	 (info (jka-compr-get-compression-info visit-file)))
--- 367,373 ----
      (error nil)))


! (defun jka-compr-write-region (start end file &optional append visit codesys)
    (let* ((filename (expand-file-name file))
  	 (visit-file (if (stringp visit) (expand-file-name visit) filename))
  	 (info (jka-compr-get-compression-info visit-file)))
***************
*** 420,426 ****
  	    (jka-compr-run-real-handler 'write-region
  					(list (point-min) (point-max)
  					      filename
! 					      (and append can-append) 'dont))
  	    (erase-buffer)
  	    (set-buffer cbuf)

--- 420,426 ----
  	    (jka-compr-run-real-handler 'write-region
  					(list (point-min) (point-max)
  					      filename
! 					      (and append can-append) 'dont codesys))
  	    (erase-buffer)
  	    (set-buffer cbuf)

***************
*** 447,453 ****
  	    nil)

  	(jka-compr-run-real-handler 'write-region
! 				    (list start end filename append visit)))))


  (defun jka-compr-insert-file-contents (file &optional visit beg end replace)
--- 447,453 ----
  	    nil)

  	(jka-compr-run-real-handler 'write-region
! 				    (list start end filename append visit codesys)))))


  (defun jka-compr-insert-file-contents (file &optional visit beg end replace)

