]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/esh-io.el
esh-module doc fixes.
[gnu-emacs] / lisp / eshell / esh-io.el
index 897f9942d47a8810b76de2bc7932fa8410f25f4a..ef8966f1d7d16dff01d3fcfcb7260badd70ee6f5 100644 (file)
@@ -1,16 +1,15 @@
 ;;; esh-io.el --- I/O management
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2011  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-(provide 'esh-io)
-
-(eval-when-compile (require 'esh-maint))
-
-(defgroup eshell-io nil
-  "Eshell's I/O management code provides a scheme for treating many
-different kinds of objects -- symbols, files, buffers, etc. -- as
-though they were files."
-  :tag "I/O management"
-  :group 'eshell)
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -68,15 +54,30 @@ though they were files."
 ;;   (+ 1 2) > a > b > c   ; prints number to all three files
 ;;   (+ 1 2) > a | wc      ; prints to 'a', and pipes to 'wc'
 
+;;; Code:
+
+(provide 'esh-io)
+
+(eval-when-compile
+  (require 'cl)
+  (require 'eshell))
+
+(defgroup eshell-io nil
+  "Eshell's I/O management code provides a scheme for treating many
+different kinds of objects -- symbols, files, buffers, etc. -- as
+though they were files."
+  :tag "I/O management"
+  :group 'eshell)
+
 ;;; User Variables:
 
 (defcustom eshell-io-load-hook '(eshell-io-initialize)
-  "*A hook that gets run when `eshell-io' is loaded."
+  "A hook that gets run when `eshell-io' is loaded."
   :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
@@ -85,17 +86,17 @@ other buffers) ."
   :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.
@@ -108,7 +109,7 @@ Example:
   :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
@@ -125,7 +126,7 @@ from executing while Emacs is redisplaying."
                       (let ((x-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.
 
@@ -341,8 +342,9 @@ it defaults to `insert'."
        (let* ((exists (get-file-buffer target))
               (buf (find-file-noselect target t)))
          (with-current-buffer buf
-           (if buffer-read-only
+           (if buffer-file-read-only
                (error "Cannot write to read-only file `%s'" target))
+           (setq buffer-read-only nil)
            (set (make-local-variable 'eshell-output-file-buffer)
                 (if (eq exists buf) 0 t))
            (cond ((eq mode 'overwrite)
@@ -382,8 +384,7 @@ it defaults to `insert'."
     (error "Invalid redirection target: %s"
           (eshell-stringify target)))))
 
-(eval-when-compile
-  (defvar grep-null-device))
+(defvar grep-null-device)
 
 (defun eshell-set-output-handle (index mode &optional target)
   "Set handle INDEX, using MODE, to point to TARGET."
@@ -417,6 +418,10 @@ it defaults to `insert'."
 (defvar eshell-print-queue nil)
 (defvar eshell-print-queue-count -1)
 
+(defsubst eshell-print (object)
+  "Output OBJECT to the standard output handle."
+  (eshell-output-object object eshell-output-handle))
+
 (defun eshell-flush (&optional reset-p)
   "Flush out any lines that have been queued for printing.
 Must be called before printing begins with -1 as its argument, and
@@ -445,10 +450,6 @@ after all printing is over with no argument."
          (concat eshell-print-queue (apply 'concat strings))
          eshell-print-queue-count (1+ eshell-print-queue-count))))
 
-(defsubst eshell-print (object)
-  "Output OBJECT to the standard output handle."
-  (eshell-output-object object eshell-output-handle))
-
 (defsubst eshell-error (object)
   "Output OBJECT to the standard error handle."
   (eshell-output-object object eshell-error-handle))
@@ -514,7 +515,4 @@ Returns what was actually sent, or nil if nothing was sent."
        (eshell-output-object-to-target object (car target))
        (setq target (cdr target))))))
 
-;;; Code:
-
-;;; arch-tag: 9ca2080f-d5e0-4b26-aa0b-d59194a905a2
 ;;; esh-io.el ends here