1. xemacs
  2. xemacs-21.4

Commits

Vin Shelton  committed bd30865

2 patches from Michael Sperber

  • Participants
  • Parent commits 37cc6c8
  • Branches default

Comments (0)

Files changed (5)

File lisp/ChangeLog

View file
+2009-10-14  Mike Sperber  <mike@xemacs.org>
+
+	* code-files.el (insert-file-contents): Call the file-name handler
+	from Lisp, not from `insert-file-contents-internal', which is too late.
+
 2008-12-28  Vin Shelton  <acs@xemacs.org>
 
 	* XEmacs 21.4.22 is released

File lisp/code-files.el

View file
 See also `insert-file-contents-access-hook',
 `insert-file-contents-pre-hook', `insert-file-contents-error-hook',
 and `insert-file-contents-post-hook'."
-  (let (return-val coding-system used-codesys)
-    ;; OK, first load the file.
-    (condition-case err
-	(progn
-	  (run-hook-with-args 'insert-file-contents-access-hook
-			      filename visit)
-	  ;; determine the coding system to use, as described above.
-	  (setq coding-system
-		(or
-		 ;; #1.
-		 coding-system-for-read
-		 ;; #2.
-		 (run-hook-with-args-until-success
-		  'insert-file-contents-pre-hook
-		  filename visit)
-		 ;; #3.
-		 (find-file-coding-system-for-read-from-filename filename)
-		 ;; #4.
-		 buffer-file-coding-system-for-read
-		 ;; #5.
-		 'raw-text))
-	  (if (consp coding-system)
-	      (setq return-val coding-system)
-	    (if (null (find-coding-system coding-system))
-		(progn
-		  (message
-		   "Invalid coding-system (%s), using 'undecided"
-		   coding-system)
-		  (setq coding-system 'undecided)))
-	    (setq return-val
-		  (insert-file-contents-internal filename visit start end
-						 replace coding-system
-						 ;; store here!
-						 'used-codesys))
-	    ))
-      (file-error
-       (run-hook-with-args 'insert-file-contents-error-hook
-			   filename visit err)
-       (signal (car err) (cdr err))))
-    (setq coding-system used-codesys)
-    ;; call any `post-read-conversion' for the coding system that
-    ;; was used ...
-    (let ((func
-	   (coding-system-property coding-system 'post-read-conversion))
-	  (endmark (make-marker)))
-      (set-marker endmark (+ (point) (nth 1 return-val)))
-      (if func
-	  (unwind-protect
-	      (save-excursion
-		(let (buffer-read-only)
-		  (funcall func (point) (marker-position endmark))))
-	    (if visit
-		(progn
-		  (set-buffer-auto-saved)
-		  (set-buffer-modified-p nil)))))
-      (setcar (cdr return-val) (- (marker-position endmark) (point))))
-    ;; now finally set the buffer's `buffer-file-coding-system'.
-    (if (run-hook-with-args-until-success 'insert-file-contents-post-hook
-					  filename visit return-val)
-	nil
-      (if (local-variable-p 'buffer-file-coding-system (current-buffer))
-	  ;; if buffer-file-coding-system is already local, just
-	  ;; set its eol type to what was found, if it wasn't
-	  ;; set already.
-	  (set-buffer-file-coding-system
-	   (subsidiary-coding-system buffer-file-coding-system
-				     (coding-system-eol-type coding-system)))
-	;; otherwise actually set buffer-file-coding-system.
-	(set-buffer-file-coding-system coding-system)))
-    return-val))
+  (let* ((expanded (substitute-in-file-name filename))
+	 (handler (find-file-name-handler expanded 'insert-file-contents)))
+    (if handler
+	(funcall handler 'insert-file-contents filename visit start end replace)
+      (let (return-val coding-system used-codesys)
+	;; OK, first load the file.
+	(condition-case err
+	    (progn
+	      (run-hook-with-args 'insert-file-contents-access-hook
+				  filename visit)
+	      ;; determine the coding system to use, as described above.
+	      (setq coding-system
+		    (or
+		     ;; #1.
+		     coding-system-for-read
+		     ;; #2.
+		     (run-hook-with-args-until-success
+		      'insert-file-contents-pre-hook
+		      filename visit)
+		     ;; #3.
+		     (find-file-coding-system-for-read-from-filename filename)
+		     ;; #4.
+		     buffer-file-coding-system-for-read
+		     ;; #5.
+		     'raw-text))
+	      (if (consp coding-system)
+		  (setq return-val coding-system)
+		(if (null (find-coding-system coding-system))
+		    (progn
+		      (lwarn 'coding-system 'notice
+			"Invalid coding-system (%s), using 'undecided"
+			coding-system)
+		      (setq coding-system 'undecided)))
+		(setq return-val
+		      (insert-file-contents-internal filename visit start end
+						     replace coding-system
+						     ;; store here!
+						     'used-codesys))
+		))
+	  (file-error
+	   (run-hook-with-args 'insert-file-contents-error-hook
+			       filename visit err)
+	   (signal (car err) (cdr err))))
+	(setq coding-system used-codesys)
+	;; call any `post-read-conversion' for the coding system that
+	;; was used ...
+	(let ((func
+	       (coding-system-property coding-system 'post-read-conversion))
+	      (endmark (make-marker)))
+	  (set-marker endmark (+ (point) (nth 1 return-val)))
+	  (if func
+	      (unwind-protect
+		  (save-excursion
+		    (let (buffer-read-only)
+		      (if (>= (function-max-args func) 2)
+			  ;; #### fuckme!  Someone at FSF changed the calling
+			  ;; convention of post-read-conversion.  We try to
+			  ;; support the old way.  #### Should we kill this?
+			  (funcall func (point) (marker-position endmark))
+			(funcall func (- (marker-position endmark) (point))))))
+		(if visit
+		    (progn
+		      (set-buffer-auto-saved)
+		      (set-buffer-modified-p nil)))))
+	  (setcar (cdr return-val) (- (marker-position endmark) (point))))
+	;; now finally set the buffer's `buffer-file-coding-system' ...
+	(if (run-hook-with-args-until-success 'insert-file-contents-post-hook
+					      filename visit return-val)
+	    nil
+	  (if (local-variable-p 'buffer-file-coding-system (current-buffer))
+	      ;; if buffer-file-coding-system is already local, just
+	      ;; set its eol type to what was found, if it wasn't
+	      ;; set already.
+	      (set-buffer-file-coding-system
+	       (subsidiary-coding-system buffer-file-coding-system
+					 (coding-system-eol-type coding-system)) t)
+	    ;; otherwise actually set buffer-file-coding-system.
+	    (set-buffer-file-coding-system coding-system t)))
+	;; ... and `buffer-file-coding-system-when-loaded'.  the machinations
+	;; of set-buffer-file-coding-system cause the actual coding system
+	;; object to be stored, so do that here, too.
+	(setq buffer-file-coding-system-when-loaded
+	      (get-coding-system coding-system))
+	return-val))))
+
 
 (defvar write-region-pre-hook nil
   "A special hook to decide the coding system used for writing out a file.

File src/ChangeLog

View file
+2009-10-14  Mike Sperber  <mike@xemacs.org>
+
+	* fileio.c (Finsert_file_contents_internal): Don't call the
+	file-name handler for `insert-file-contents' from here, which is
+	too late.  Instead, do it from Lisp.SSper
+
+2009-10-01  Mike Sperber  <mike@xemacs.org>
+
+	* frame-x.c (x_focus_on_frame): Use correct timestamep with
+	XSetInputFocus.
+
 2009-01-31  Vin Shelton  <acs@xemacs.org>
 
 	* regex.c (re_search_2): Really apply Julian Bradfield's patch for

File src/fileio.c

View file
 
   filename = Fexpand_file_name (filename, Qnil);
 
-  /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
-  handler = Ffind_file_name_handler (filename, Qinsert_file_contents);
-  if (!NILP (handler))
-    {
-      val = call6 (handler, Qinsert_file_contents, filename,
-		   visit, start, end, replace);
-      goto handled;
-    }
-
 #ifdef FILE_CODING
   if (!NILP (used_codesys))
     CHECK_SYMBOL (used_codesys);

File src/frame-x.c

View file
 	  XSetInputFocus (XtDisplay (shell_widget),
 			  XtWindow (shell_widget),
 			  RevertToParent,
-			  DEVICE_X_MOUSE_TIMESTAMP
-			  (XDEVICE (FRAME_DEVICE (f))));
+			  CurrentTime);
 	  XFlush (XtDisplay (shell_widget));
 	}
     }