From xemacs-m  Mon Jan 27 22:46:52 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 WAA21494 for <xemacs-beta@xemacs.org>; Mon, 27 Jan 1997 22:46:51 -0600 (CST)
Received: (from tjchol01@localhost) by mecca.spd.louisville.edu (950413.SGI.8.6.12/950213.SGI.AUTOCF) id XAA02120; Mon, 27 Jan 1997 23:46:52 -0500
Date: Mon, 27 Jan 1997 23:46:52 -0500
Message-Id: <199701280446.XAA02120@mecca.spd.louisville.edu>
From: "Tomasz J. Cholewo" <tjchol01@mecca.spd.louisville.edu>
To: xemacs-beta@xemacs.org
Subject: [patch] Re: Continued jka-compr problems
Mime-Version: 1.0 (generated by tm-edit 7.100)
Content-Type: text/plain; charset=US-ASCII

Dan Rich wrote:

> It looks like the patch I sent earlier doesn't quite fix the problem
> (which will teach me to send in a patch before I have fully tested it).

My previous patch also had problems: it worked only when Mule was not
enabled (sigh).   Let's hope that the second attempt will be better.

> The part of this I don't understand is that when write-region-internal
> calls jka-compr-handler the first time it is eating the lockname
> argument (nil), which is causing the rest of the calls to get rather
> strange (lockname != coding-system).  Does anyone know why this might
> be happening?  I'm assuming jka-compr-handler is being called because
> of the settings in file-name-handler-alist, but I don't see what could
> be eating the argument.

The `Fwrite_region_internal' function in fileio.c in 20.0-b92 does not
pass the `lockname' argument to functions in `file-name-handler-alist'
(neither it did in 19.14 nor in 19.15 nor in FSF 19.34b).  I am not sure
but probably adding it there is the best way to end continuing confusion
around this interface at the cost of smaller compatibility with existing
packages.

Both ange-ftp-write-region and jka-compr-write-region functions should
be argument list compatible with the regular write-region.  In 20.0 a
7th argument named `codesys' was added to it.  Unfortunately in
`files-nomule.el' its definition did not reflect it (as in 19.15) which
caused inconsistencies between 20.0 with and without Mule support.

There are probably more packages that would require corrections in case
my patch is accepted.

The following patches attempt to address these problems. (Some minor
typos were also corrected.)  I hope that the unified patch format is also
OK?

Tom

=============== CUT HERE =======================
diff -dwur xemacs-20.0-b92/lisp/dired/ange-ftp.el xemacs-20.0-b93/lisp/dired/ange-ftp.el
--- xemacs-20.0-b92/lisp/dired/ange-ftp.el	Mon Jan 27 23:19:01 1997
+++ xemacs-20.0-b93/lisp/dired/ange-ftp.el	Mon Jan 27 23:19:25 1997
@@ -408,7 +408,7 @@
 ;;; 1. Umask problems:
 ;;;    Be warned that files created by using ange-ftp will take account of the
 ;;;    umask of the ftp daemon process rather than the umask of the creating
-;;;    user.  This is particulary important when logging in as the root user.
+;;;    user.  This is particularly important when logging in as the root user.
 ;;;    The way that I tighten up the ftp daemon's umask under HP-UX is to make
 ;;;    sure that the umask is changed to 027 before I spawn /etc/inetd.  I
 ;;;    suspect that there is something similar on other systems.
@@ -643,7 +643,7 @@
 ;;; which the writers of this program believe could never happen. However,
 ;;; being realists they have put calls to 'error in the program at these
 ;;; points. These errors provide a code, which is an integer, greater than 1.
-;;; To aid debugging.  the error codes, and the functions in which they reside
+;;; To aid debugging the error codes, and the functions in which they reside
 ;;; are listed below.
 ;;;
 ;;; 1: See ange-ftp-ls
@@ -2960,8 +2960,9 @@
   (ange-ftp-save-match-data
     (string-match ange-ftp-binary-file-name-regexp file)))

+;;; 20.0-b92 change (see jka-compr)
 (defun ange-ftp-write-region (start end filename &optional append visit
-			      lockname)
+			      lockname coding-system)
   "Documented as original."
   (interactive "r\nFWrite region to file: ")
   (setq filename (expand-file-name filename))
@@ -2981,7 +2982,7 @@
 		      (mod-p (buffer-modified-p)))
 		  (unwind-protect
 		      (ange-ftp-real-write-region start end temp nil
-						  visit lockname)
+						  visit lockname coding-system)
 		    ;; cleanup forms
 		    (setq buffer-file-name filename)
 		    (if (fboundp 'compute-buffer-file-truename)
@@ -3017,7 +3018,7 @@
 		(set-buffer-modified-p nil)))
 	  (ange-ftp-message "Wrote %s" abbr)
 	  (ange-ftp-add-file-entry filename))
-      (ange-ftp-real-write-region start end filename append visit lockname))))
+      (ange-ftp-real-write-region start end filename append visit lockname coding-system))))

 (defun ange-ftp-insert-file-contents (filename &optional visit beg end replace)
   "Documented as original."
diff -dwur xemacs-20.0-b92/lisp/packages/jka-compr.el xemacs-20.0-b93/lisp/packages/jka-compr.el
--- 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	Mon Jan 27 23:20:37 1997
@@ -65,7 +65,7 @@
 ;; APPLICATION NOTES:
 ;;
 ;; crypt++
-;;   jka-compr can coexist with crpyt++ if you take all the decompression
+;;   jka-compr can coexist with crypt++ if you take all the decompression
 ;;   entries out of the crypt-encoding-list.  Clearly problems will arise if
 ;;   you have two programs trying to compress/decompress files.  jka-compr
 ;;   will not "work with" crypt++ in the following sense: you won't be able to
@@ -366,8 +366,10 @@
       (delete-file temp)
     (error nil)))

-
-(defun jka-compr-write-region (start end file &optional append visit)
+;;; 20.0-b92 change
+;;; Now receives both `lockname' and `codesys' from Fwrite_region_internal
+;;; what makes it compatible with write-region
+(defun jka-compr-write-region (start end file &optional append visit lockname coding-system)
   (let* ((filename (expand-file-name file))
 	 (visit-file (if (stringp visit) (expand-file-name visit) filename))
 	 (info (jka-compr-get-compression-info visit-file)))
@@ -406,7 +408,7 @@
 	     (message "%s %s..." compress-message base-name))

 	    (jka-compr-run-real-handler 'write-region
-					(list start end temp-file t 'dont))
+					(list start end temp-file t 'dont lockname coding-system))

 	    (jka-compr-call-process compress-program
 				    (concat compress-message
@@ -420,7 +422,7 @@
 	    (jka-compr-run-real-handler 'write-region
 					(list (point-min) (point-max)
 					      filename
-					      (and append can-append) 'dont))
+					      (and append can-append) 'dont lockname coding-system))
 	    (erase-buffer)
 	    (set-buffer cbuf)

@@ -447,7 +449,7 @@
 	    nil)

 	(jka-compr-run-real-handler 'write-region
-				    (list start end filename append visit)))))
+				    (list start end filename append visit lockname coding-system)))))


 (defun jka-compr-insert-file-contents (file &optional visit beg end replace)
diff -dwur xemacs-20.0-b92/lisp/prim/files-nomule.el xemacs-20.0-b93/lisp/prim/files-nomule.el
--- xemacs-20.0-b92/lisp/prim/files-nomule.el	Mon Jan 27 23:18:38 1997
+++ xemacs-20.0-b93/lisp/prim/files-nomule.el	Mon Jan 27 23:19:35 1997
@@ -20,7 +20,7 @@
 ;; Free Software Foundation, 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.

-;;; Synched up with: FSF 19.34 (files.el).
+;;; Synched up with: FSF 19.34 (files.el).   (Is it?  Please check)

 ;;; Commentary:

@@ -46,7 +46,7 @@
 and (2) it puts less data in the undo list."
   (insert-file-contents-internal filename visit beg end replace nil nil))

-(defun write-region (start end filename &optional append visit lockname)
+(defun write-region (start end filename &optional append visit lockname coding-system)
   "Write current region into specified file.
 When called from a program, takes three arguments:
 START, END and FILENAME.  START and END are buffer positions.
@@ -63,7 +63,12 @@
 The optional sixth arg LOCKNAME, if non-nil, specifies the name to
   use for locking and unlocking, overriding FILENAME and VISIT.
 Kludgy feature: if START is a string, then that string is written
-to the file, instead of any buffer contents, and END is ignored."
+to the file, instead of any buffer contents, and END is ignored.
+Optional seventh argument CODING-SYSTEM is meaningful only if support
+  for Mule is present in XEmacs and specifies the coding system
+  used to encode the text when it is written out, and defaults to
+  the value of `file-coding-system' in the current buffer.  When Mule
+  support is not present, the CODING-SYSTEM argument is ignored."
   (interactive "r\nFWrite region to file: ")
   (write-region-internal start end filename append visit lockname nil))

diff -dwur xemacs-20.0-b92/src/fileio.c xemacs-20.0-b93/src/fileio.c
--- xemacs-20.0-b92/src/fileio.c	Mon Jan 27 23:27:24 1997
+++ xemacs-20.0-b93/src/fileio.c	Mon Jan 27 22:29:38 1997
@@ -3393,8 +3393,8 @@

     if (!NILP (handler))
       {
-        Lisp_Object val = call7 (handler, Qwrite_region, start, end,
-                                 filename, append, visit, codesys);
+        Lisp_Object val = call8 (handler, Qwrite_region, start, end,
+                                 filename, append, visit, lockname, codesys);
 	if (visiting)
 	  {
 	    BUF_SAVE_MODIFF (current_buffer) = BUF_MODIFF (current_buffer);

