don't use function-equal in nadvice
[bpt/emacs.git] / lisp / eshell / esh-io.el
index 9f3cfe0..b7830db 100644 (file)
@@ -1,6 +1,6 @@
-;;; esh-io.el --- I/O management
+;;; esh-io.el --- I/O management  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-201 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
 
 (provide 'esh-io)
 
+(require 'esh-arg)
+(require 'esh-util)
+
 (eval-when-compile
-  (require 'cl-lib)
-  (require 'eshell))
+  (require 'cl-lib))
 
 (defgroup eshell-io nil
   "Eshell's I/O management code provides a scheme for treating many
@@ -116,6 +118,8 @@ from executing while Emacs is redisplaying."
   :type 'integer
   :group 'eshell-io)
 
+(defvar x-select-enable-clipboard)     ; term/common-win
+
 (defcustom eshell-virtual-targets
   '(("/dev/eshell" eshell-interactive-print nil)
     ("/dev/kill" (lambda (mode)
@@ -177,8 +181,8 @@ not be added to this variable."
   (make-local-variable 'eshell-current-redirections)
   (add-hook 'eshell-pre-rewrite-command-hook
            'eshell-strip-redirections nil t)
-  (add-hook 'eshell-post-rewrite-command-hook
-           'eshell-apply-redirections nil t))
+  (add-function :filter-return (local 'eshell-post-rewrite-command-function)
+                #'eshell--apply-redirections))
 
 (defun eshell-parse-redirection ()
   "Parse an output redirection, such as '2>'."
@@ -221,28 +225,27 @@ not be added to this variable."
     (setq eshell-current-redirections
          (cdr eshell-current-redirections))))
 
-(defun eshell-apply-redirections (cmdsym)
+(defun eshell--apply-redirections (cmd)
   "Apply any redirection which were specified for COMMAND."
   (if eshell-current-redirections
-      (set cmdsym
-          (append (list 'progn)
-                  eshell-current-redirections
-                  (list (symbol-value cmdsym))))))
+      `(progn
+         ,@eshell-current-redirections
+         ,cmd)
+    cmd))
 
 (defun eshell-create-handles
-  (standard-output output-mode &optional standard-error error-mode)
+  (stdout output-mode &optional stderr error-mode)
   "Create a new set of file handles for a command.
 The default location for standard output and standard error will go to
-STANDARD-OUTPUT and STANDARD-ERROR, respectively.
+STDOUT and STDERR, respectively.
 OUTPUT-MODE and ERROR-MODE are either `overwrite', `append' or `insert';
 a nil value of mode defaults to `insert'."
   (let ((handles (make-vector eshell-number-of-handles nil))
-       (output-target (eshell-get-target standard-output output-mode))
-       (error-target (eshell-get-target standard-error error-mode)))
+       (output-target (eshell-get-target stdout output-mode))
+        (error-target (eshell-get-target stderr error-mode)))
     (aset handles eshell-output-handle (cons output-target 1))
-    (if standard-error
-       (aset handles eshell-error-handle (cons error-target 1))
-      (aset handles eshell-error-handle (cons output-target 1)))
+    (aset handles eshell-error-handle
+          (cons (if stderr error-target output-target) 1))
     handles))
 
 (defun eshell-protect-handles (handles)
@@ -465,6 +468,8 @@ after all printing is over with no argument."
   (eshell-print object)
   (eshell-print "\n"))
 
+(autoload 'eshell-output-filter "esh-mode")
+
 (defun eshell-output-object-to-target (object target)
   "Insert OBJECT into TARGET.
 Returns what was actually sent, or nil if nothing was sent."