changeset 55613:8e3531a00902

2004-05-15 John Wiegley <johnw@newartisans.com> * eshell/esh-io.el (eshell-get-target): whitespace changes. (eshell-output-object-to-target): Improve output speed 20% by not calling `eshell-stringify' if something is already known to be a string.
author John Wiegley <johnw@newartisans.com>
date Sat, 15 May 2004 22:45:35 +0000
parents eee95823e97c
children e1a4e53fbef0
files lisp/eshell/esh-io.el
diffstat 1 files changed, 26 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/eshell/esh-io.el	Sat May 15 22:45:13 2004 +0000
+++ b/lisp/eshell/esh-io.el	Sat May 15 22:45:35 2004 +0000
@@ -333,22 +333,23 @@
   (cond
    ((stringp target)
     (let ((redir (assoc target eshell-virtual-targets)))
-     (if redir
-	 (if (nth 2 redir)
-	     (funcall (nth 1 redir) mode)
-	   (nth 1 redir))
-       (let* ((exists (get-file-buffer target))
-	      (buf (find-file-noselect target t)))
-	 (with-current-buffer buf
-	   (if buffer-read-only
-	       (error "Cannot write to read-only file `%s'" target))
-	   (set (make-local-variable 'eshell-output-file-buffer)
-		(if (eq exists buf) 0 t))
-	   (cond ((eq mode 'overwrite)
-		  (erase-buffer))
-		 ((eq mode 'append)
-		  (goto-char (point-max))))
-	   (point-marker))))))
+      (if redir
+	  (if (nth 2 redir)
+	      (funcall (nth 1 redir) mode)
+	    (nth 1 redir))
+	(let* ((exists (get-file-buffer target))
+	       (buf (find-file-noselect target t)))
+	  (with-current-buffer buf
+	    (if buffer-read-only
+		(error "Cannot write to read-only file `%s'" target))
+	    (set (make-local-variable 'eshell-output-file-buffer)
+		 (if (eq exists buf) 0 t))
+	    (cond ((eq mode 'overwrite)
+		   (erase-buffer))
+		  ((eq mode 'append)
+		   (goto-char (point-max))))
+	    (point-marker))))))
+
    ((or (bufferp target)
 	(and (boundp 'eshell-buffer-shorthand)
 	     (symbol-value 'eshell-buffer-shorthand)
@@ -363,15 +364,18 @@
 	      ((eq mode 'append)
 	       (goto-char (point-max))))
 	(point-marker))))
-   ((functionp target)
-    nil)
+
+   ((functionp target) nil)
+
    ((symbolp target)
     (if (eq mode 'overwrite)
 	(set target nil))
     target)
+
    ((or (eshell-processp target)
 	(markerp target))
     target)
+
    (t
     (error "Illegal redirection target: %s"
 	   (eshell-stringify target)))))
@@ -481,7 +485,8 @@
 	  (let ((moving (= (point) target)))
 	    (save-excursion
 	      (goto-char target)
-	      (setq object (eshell-stringify object))
+	      (unless (stringp object)
+		(setq object (eshell-stringify object)))
 	      (insert-and-inherit object)
 	      (set-marker target (point-marker)))
 	    (if moving
@@ -489,7 +494,8 @@
 
    ((eshell-processp target)
     (when (eq (process-status target) 'run)
-      (setq object (eshell-stringify object))
+      (unless (stringp object)
+	(setq object (eshell-stringify object)))
       (process-send-string target object)))
 
    ((consp target)