-;;; esh-io.el --- I/O management
+;;; esh-io.el --- I/O management -*- lexical-binding:t -*-
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;; 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
(provide 'esh-io)
+(require 'esh-arg)
+(require 'esh-util)
+
(eval-when-compile
- (require 'cl)
- (require 'eshell))
+ (require 'cl-lib))
(defgroup eshell-io nil
"Eshell's I/O management code provides a scheme for treating many
;;; User Variables:
-(defcustom eshell-io-load-hook '(eshell-io-initialize)
- "*A hook that gets run when `eshell-io' is loaded."
+(defcustom eshell-io-load-hook nil
+ "A hook that gets run when `eshell-io' is loaded."
+ :version "24.1" ; removed eshell-io-initialize
:type 'hook
:group 'eshell-io)
(defcustom eshell-number-of-handles 3
- "*The number of file handles that eshell supports.
+ "The number of file handles that eshell supports.
Currently this is standard input, output and error. But even all of
these Emacs does not currently support with asynchronous processes
\(which is what eshell uses so that you can continue doing work in
:group 'eshell-io)
(defcustom eshell-output-handle 1
- "*The index of the standard output handle."
+ "The index of the standard output handle."
:type 'integer
:group 'eshell-io)
(defcustom eshell-error-handle 2
- "*The index of the standard error handle."
+ "The index of the standard error handle."
:type 'integer
:group 'eshell-io)
(defcustom eshell-buffer-shorthand nil
- "*If non-nil, a symbol name can be used for a buffer in redirection.
+ "If non-nil, a symbol name can be used for a buffer in redirection.
If nil, redirecting to a buffer requires buffer name syntax. If this
variable is set, redirection directly to Lisp symbols will be
impossible.
:group 'eshell-io)
(defcustom eshell-print-queue-size 5
- "*The size of the print queue, for doing buffered printing.
+ "The size of the print queue, for doing buffered printing.
This is basically a speed enhancement, to avoid blocking the Lisp code
from executing while Emacs is redisplaying."
:type 'integer
'eshell-kill-append) t)
("/dev/clip" (lambda (mode)
(if (eq mode 'overwrite)
- (let ((x-select-enable-clipboard t))
+ (let ((gui-select-enable-clipboard t))
(kill-new "")))
'eshell-clipboard-append) t))
- "*Map virtual devices name to Emacs Lisp functions.
+ "Map virtual devices name to Emacs Lisp functions.
If the user specifies any of the filenames above as a redirection
target, the function in the second element will be called.
(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>'."
(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)
command. If nil, then the meta variables for keeping track of the
last execution result should not be changed."
(let ((idx 0))
- (assert (or (not result) (eq (car result) 'quote)))
+ (cl-assert (or (not result) (eq (car result) 'quote)))
(setq eshell-last-command-status exit-code
eshell-last-command-result (cadr result))
(while (< idx eshell-number-of-handles)
(defun eshell-clipboard-append (string)
"Call `kill-append' with STRING, if it is indeed a string."
(if (stringp string)
- (let ((x-select-enable-clipboard t))
+ (let ((gui-select-enable-clipboard t))
(kill-append string nil))))
(defun eshell-get-target (target &optional mode)
(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."
(eshell-output-object-to-target object (car target))
(setq target (cdr target))))))
-;; arch-tag: 9ca2080f-d5e0-4b26-aa0b-d59194a905a2
;;; esh-io.el ends here