1. xemacs
  2. vm

Source

vm / vm-misc.el

Diff from to

File vm-misc.el

 	(goto-char (point-max))
 	(let ((buffer-read-only nil))
 	  (insert string)))
-    (let ((temp-buffer nil)
-	  (coding-system-for-write (vm-line-ending-coding-system)))
+    (let ((temp-buffer nil))
       (unwind-protect
 	  (save-excursion
 	    (setq temp-buffer (generate-new-buffer "*vm-work*"))
 	    ;; correct for VM's uses of this function---
 	    ;; writing out message separators
 	    (setq buffer-file-type nil)
-	    ;; Tell MULE to pick the correct newline conversion.
-	    (if (fboundp 'set-buffer-file-coding-system)
-		(set-buffer-file-coding-system 
-		 (vm-line-ending-coding-system) nil))
 	    (write-region (point-min) (point-max) where t 'quiet))
 	(and temp-buffer (kill-buffer temp-buffer))))))
 
       (t
        (fset 'vm-coding-system-name 'symbol-name)))
 
+(defun vm-get-file-line-ending-coding-system (file)
+  (if (not (or vm-fsfemacs-mule-p vm-xemacs-mule-p vm-xemacs-file-coding-p))
+      nil
+    (let ((coding-system-for-read  (vm-binary-coding-system))
+	  (work-buffer nil))
+      (unwind-protect
+	  (save-excursion
+	    (setq work-buffer (vm-make-work-buffer))
+	    (set-buffer work-buffer)
+	    (condition-case nil
+		(insert-file-contents file nil 0 4096)
+	      (error nil))
+	    (goto-char (point-min))
+	    (cond ((re-search-forward "[^\r]\n" nil t)
+		   (if vm-fsfemacs-mule-p 'raw-text-unix 'no-conversion-unix))
+		  ((re-search-forward "\r[^\n]" nil t)
+		   (if vm-fsfemacs-mule-p 'raw-text-mac 'no-conversion-mac))
+		  ((search-forward "\r\n" nil t)
+		   (if vm-fsfemacs-mule-p 'raw-text-dos 'no-conversion-dos))
+		  (t (vm-line-ending-coding-system))))
+	(and work-buffer (kill-buffer work-buffer))))))
+
 (defun vm-collapse-whitespace ()
   (goto-char (point-min))
   (while (re-search-forward "[ \t\n]+" nil 0)
   (vm-with-string-as-temp-buffer string 'vm-url-decode-buffer))
 
 (defun vm-url-decode-buffer ()
-  (let ((case-fold-search nil)
+  (let ((case-fold-search t)
 	(hex-digit-alist '((?0 .  0)  (?1 .  1)  (?2 .  2)  (?3 .  3)
 			   (?4 .  4)  (?5 .  5)  (?6 .  6)  (?7 .  7)
 			   (?8 .  8)  (?9 .  9)  (?A . 10)  (?B . 11)