]> code.delx.au - gnu-emacs/blobdiff - lisp/terminal.el
(shell-command-on-region):
[gnu-emacs] / lisp / terminal.el
index d2a514048cbe35a43069669cfe7c6d6c6d22c9c8..35d5022aaf6e65b6ae8f4625fad1d1c22889db52 100644 (file)
@@ -1,12 +1,15 @@
-;; Terminal emulator for GNU Emacs.
+;;; terminal.el --- terminal emulator for GNU Emacs.
+
 ;; Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc.
-;; Written by Richard Mlynarik, November 1986.
+
+;; Author: Richard Mlynarik <mly@eddie.mit.edu>
+;; Maintainer: FSF
 
 ;; This file is part of GNU Emacs.
 
 ;; 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 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -18,6 +21,8 @@
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Code:
+
 ;;>>TODO
 ;;>> terminfo?
 ;;>> ** Nothing can be done about emacs' meta-lossage **
@@ -26,7 +31,6 @@
 ;;>> One probably wants to do setenv MORE -c when running with
 ;;>>   more-processing enabled.
 
-(provide 'terminal)
 (require 'ehelp)
 
 (defvar terminal-escape-char ?\C-^
@@ -66,7 +70,7 @@ performance.")
 (if terminal-map
     nil
   (let ((map (make-keymap)))
-    (fillarray map 'te-pass-through)
+    (fillarray (car (cdr map)) 'te-pass-through)
     ;(define-key map "\C-l"
     ;  '(lambda () (interactive) (te-pass-through) (redraw-display)))
     (setq terminal-map map)))
@@ -76,7 +80,7 @@ performance.")
     nil
   (let ((map (make-keymap)))
     ;(fillarray map 'te-escape-extended-command-unread)
-    (fillarray map 'undefined)
+    (fillarray (car (cdr map)) 'undefined)
     (let ((s "0"))
       (while (<= (aref s 0) ?9)
        (define-key map s 'digit-argument)
@@ -123,7 +127,7 @@ performance.")
 (if terminal-more-break-map
     nil
   (let ((map (make-keymap)))
-    (fillarray map 'te-more-break-unread)
+    (fillarray (car (cdr map)) 'te-more-break-unread)
     (define-key map (char-to-string help-char) 'te-more-break-help)
     (define-key map " " 'te-more-break-resume)
     (define-key map "\C-l" 'redraw-display)
@@ -227,8 +231,8 @@ Other chars following \"%s\" are interpreted as follows:\n"
   (interactive "cSet escape character to: ")
   (let ((o terminal-escape-char))
     (message (if (= o c)
-                "\"%s\" is escape char"
-                "\"%s\" is now escape; \"%s\" passes though")
+                "\"%s\" is the escape char"
+                "\"%s\" is now the escape; \"%s\" passes through")
             (single-key-description c)
             (single-key-description o))
     (setq terminal-escape-char c)))
@@ -975,13 +979,15 @@ move to start of new line, clear to end of line."
                 (progn (goto-char (point-max))
                        (recenter -1)))))))
 \f
-(defvar te-stty-string "stty -nl new dec echo"
-  "Command string (to be interpreted by \"sh\") which sets the modes
-of the virtual terminal to be appropriate for interactive use.")
+(defvar te-stty-string "stty -nl dec echo"
+  "Shell command to set terminal modes for terminal emulator.")
+;; This used to have `new' in it, but that loses outside BSD
+;; and it's apparently not needed in BSD.
 
 (defvar explicit-shell-file-name nil
   "*If non-nil, is file name to use for explicitly requested inferior shell.")
 
+;;;###autoload
 (defun terminal-emulator (buffer program args &optional width height)
   "Under a display-terminal emulator in BUFFER, run PROGRAM on arguments ARGS.
 ARGS is a list of argument-strings.  Remaining arguments are WIDTH and HEIGHT.
@@ -1078,35 +1084,23 @@ work with `terminfo' we will try to use it."
                      ;;-- For disgusting programs.
                      ;; (VI? What losers need these, I wonder?)
                      "im=:ei=:dm=:ed=:mi:do=^p^j:nl=^p^j:bs:")))
-       (if (fboundp 'start-subprocess)
-           ;; this winning function would do everything, except that
-           ;;  rms doesn't want it.
-           (setq te-process (start-subprocess "terminal-emulator"
-                              program args
-                              'channel-type 'terminal
-                              'filter 'te-filter
-                              'buffer (current-buffer)
-                              'sentinel 'te-sentinel
-                              'modify-environment
-                                (list (cons "TERM" "emacs-virtual")
-                                      (cons "TERMCAP" termcap))))
-         ;; so instead we resort to this...
-         (setq te-process (start-process "terminal-emulator" (current-buffer)
-                            "/bin/sh" "-c"
-                            ;; Yuck!!! Start a shell to set some terminal
-                            ;; control characteristics.  Then start the
-                            ;; "env" program to setup the terminal type
-                            ;; Then finally start the program we wanted.
-                            (format "%s; exec %s TERM=emacs-virtual %s %s"
-                                     te-stty-string
-                                    (te-quote-arg-for-sh
-                                      (concat exec-directory "env"))
-                                    (te-quote-arg-for-sh
-                                      (concat "TERMCAP=" termcap))
-                                    (mapconcat 'te-quote-arg-for-sh
-                                               (cons program args) " "))))
-         (set-process-filter te-process 'te-filter)
-         (set-process-sentinel te-process 'te-sentinel)))
+       (let ((process-environment
+              (cons "TERM=emacs-virtual"
+                    (cons (concat "TERMCAP=" termcap)
+                          process-environment))))
+         (setq te-process
+               (start-process "terminal-emulator" (current-buffer)
+                              "/bin/sh" "-c"
+                              ;; Yuck!!! Start a shell to set some terminal
+                              ;; control characteristics.  Then start the
+                              ;; "env" program to setup the terminal type
+                              ;; Then finally start the program we wanted.
+                              (format "%s; exec %s"
+                                      te-stty-string
+                                      (mapconcat 'te-quote-arg-for-sh
+                                                 (cons program args) " ")))))
+       (set-process-filter te-process 'te-filter)
+       (set-process-sentinel te-process 'te-sentinel))
     (error (fundamental-mode)
           (signal (car err) (cdr err))))
   ;; sigh
@@ -1225,4 +1219,8 @@ of the terminal-emulator"
                                             end
                                             (1+ end)))
                   start (1+ end)))
-          (concat "\"" harder "\"")))))
\ No newline at end of file
+          (concat "\"" harder "\"")))))
+
+(provide 'terminal)
+
+;;; terminal.el ends here