comparison lisp/eshell/esh-io.el @ 91204:53108e6cea98

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
author Miles Bader <miles@gnu.org>
date Thu, 06 Dec 2007 09:51:45 +0000
parents f55f9811f5d7 3767c8399782
children 606f2d163a64
comparison
equal deleted inserted replaced
91203:db40129142b2 91204:53108e6cea98
20 ;; You should have received a copy of the GNU General Public License 20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA. 23 ;; Boston, MA 02110-1301, USA.
24 24
25 ;;; Commentary:
26
27 ;; At the moment, only output redirection is supported in Eshell. To
28 ;; use input redirection, the following syntax will work, assuming
29 ;; that the command after the pipe is always an external command:
30 ;;
31 ;; cat <file> | <command>
32 ;;
33 ;; Otherwise, output redirection and piping are provided in a manner
34 ;; consistent with most shells. Therefore, only unique features are
35 ;; mentioned here.
36 ;;
37 ;;;_* Insertion
38 ;;
39 ;; To insert at the location of point in a buffer, use '>>>':
40 ;;
41 ;; echo alpha >>> #<buffer *scratch*>;
42 ;;
43 ;;;_* Pseudo-devices
44 ;;
45 ;; A few pseudo-devices are provided, since Emacs cannot write
46 ;; directly to a UNIX device file:
47 ;;
48 ;; echo alpha > /dev/null ; the bit bucket
49 ;; echo alpha > /dev/kill ; set the kill ring
50 ;; echo alpha >> /dev/clip ; append to the clipboard
51 ;;
52 ;;;_* Multiple output targets
53 ;;
54 ;; Eshell can write to multiple output targets, including pipes.
55 ;; Example:
56 ;;
57 ;; (+ 1 2) > a > b > c ; prints number to all three files
58 ;; (+ 1 2) > a | wc ; prints to 'a', and pipes to 'wc'
59
25 (provide 'esh-io) 60 (provide 'esh-io)
26 61
27 (eval-when-compile (require 'esh-maint)) 62 (eval-when-compile (require 'eshell))
28 63
29 (defgroup eshell-io nil 64 (defgroup eshell-io nil
30 "Eshell's I/O management code provides a scheme for treating many 65 "Eshell's I/O management code provides a scheme for treating many
31 different kinds of objects -- symbols, files, buffers, etc. -- as 66 different kinds of objects -- symbols, files, buffers, etc. -- as
32 though they were files." 67 though they were files."
33 :tag "I/O management" 68 :tag "I/O management"
34 :group 'eshell) 69 :group 'eshell)
35
36 ;;; Commentary:
37
38 ;; At the moment, only output redirection is supported in Eshell. To
39 ;; use input redirection, the following syntax will work, assuming
40 ;; that the command after the pipe is always an external command:
41 ;;
42 ;; cat <file> | <command>
43 ;;
44 ;; Otherwise, output redirection and piping are provided in a manner
45 ;; consistent with most shells. Therefore, only unique features are
46 ;; mentioned here.
47 ;;
48 ;;;_* Insertion
49 ;;
50 ;; To insert at the location of point in a buffer, use '>>>':
51 ;;
52 ;; echo alpha >>> #<buffer *scratch*>;
53 ;;
54 ;;;_* Pseudo-devices
55 ;;
56 ;; A few pseudo-devices are provided, since Emacs cannot write
57 ;; directly to a UNIX device file:
58 ;;
59 ;; echo alpha > /dev/null ; the bit bucket
60 ;; echo alpha > /dev/kill ; set the kill ring
61 ;; echo alpha >> /dev/clip ; append to the clipboard
62 ;;
63 ;;;_* Multiple output targets
64 ;;
65 ;; Eshell can write to multiple output targets, including pipes.
66 ;; Example:
67 ;;
68 ;; (+ 1 2) > a > b > c ; prints number to all three files
69 ;; (+ 1 2) > a | wc ; prints to 'a', and pipes to 'wc'
70 70
71 ;;; User Variables: 71 ;;; User Variables:
72 72
73 (defcustom eshell-io-load-hook '(eshell-io-initialize) 73 (defcustom eshell-io-load-hook '(eshell-io-initialize)
74 "*A hook that gets run when `eshell-io' is loaded." 74 "*A hook that gets run when `eshell-io' is loaded."
415 eshell-error-handle)) t))) 415 eshell-error-handle)) t)))
416 416
417 (defvar eshell-print-queue nil) 417 (defvar eshell-print-queue nil)
418 (defvar eshell-print-queue-count -1) 418 (defvar eshell-print-queue-count -1)
419 419
420 (defsubst eshell-print (object)
421 "Output OBJECT to the standard output handle."
422 (eshell-output-object object eshell-output-handle))
423
420 (defun eshell-flush (&optional reset-p) 424 (defun eshell-flush (&optional reset-p)
421 "Flush out any lines that have been queued for printing. 425 "Flush out any lines that have been queued for printing.
422 Must be called before printing begins with -1 as its argument, and 426 Must be called before printing begins with -1 as its argument, and
423 after all printing is over with no argument." 427 after all printing is over with no argument."
424 (ignore 428 (ignore
442 (if (= eshell-print-queue-count eshell-print-queue-size) 446 (if (= eshell-print-queue-count eshell-print-queue-size)
443 (eshell-flush)) 447 (eshell-flush))
444 (setq eshell-print-queue 448 (setq eshell-print-queue
445 (concat eshell-print-queue (apply 'concat strings)) 449 (concat eshell-print-queue (apply 'concat strings))
446 eshell-print-queue-count (1+ eshell-print-queue-count)))) 450 eshell-print-queue-count (1+ eshell-print-queue-count))))
447
448 (defsubst eshell-print (object)
449 "Output OBJECT to the standard output handle."
450 (eshell-output-object object eshell-output-handle))
451 451
452 (defsubst eshell-error (object) 452 (defsubst eshell-error (object)
453 "Output OBJECT to the standard error handle." 453 "Output OBJECT to the standard error handle."
454 (eshell-output-object object eshell-error-handle)) 454 (eshell-output-object object eshell-error-handle))
455 455