]> code.delx.au - gnu-emacs/blobdiff - lisp/term.el
* term/rxvt.el (rxvt-register-default-colors): Add support for 88
[gnu-emacs] / lisp / term.el
index bc816e476e1794dc45db6fa03c687fb8ab5419d0..9d6ee5a4e93e30efe2a05a8e76285a0939cdaae8 100644 (file)
@@ -1,6 +1,7 @@
 ;;; term.el --- general command interpreter in a window stuff
 
-;;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Per Bothner <per@bothner.com>
 ;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com>
@@ -21,8 +22,8 @@
 
 ;; 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., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Marck 13 2001
 ;;; Fixes for CJK support by Yong Lu <lyongu@yahoo.com>.
 (require 'ehelp)
 
 (defgroup term nil
-  "General command interpreter in a window"
+  "General command interpreter in a window."
   :group 'processes
   :group 'unix)
 
   :group 'term)
 
 (defvar term-prompt-regexp "^"
-  "Regexp to recognise prompts in the inferior process.
+  "Regexp to recognize prompts in the inferior process.
 Defaults to \"^\", the null string at BOL.
 
 Good choices:
@@ -499,7 +500,7 @@ Good choices:
 This is a good thing to set in mode hooks.")
 
 (defvar term-delimiter-argument-list ()
-  "List of characters to recognise as separate arguments in input.
+  "List of characters to recognize as separate arguments in input.
 Strings comprising a character in this list will separate the arguments
 surrounding them, and also be regarded as arguments in their own right (unlike
 whitespace).  See `term-arguments'.
@@ -570,8 +571,8 @@ This variable is buffer-local."
   "Function that submits old text in term mode.
 This function is called when return is typed while the point is in old text.
 It returns the text to be submitted as process input.  The default is
-term-get-old-input-default, which grabs the current line, and strips off
-leading text matching term-prompt-regexp")
+`term-get-old-input-default', which grabs the current line, and strips off
+leading text matching `term-prompt-regexp'.")
 
 (defvar term-dynamic-complete-functions
   '(term-replace-by-expanded-history term-dynamic-complete-filename)
@@ -585,7 +586,7 @@ This is a good thing to set in mode hooks.")
   (function (lambda (str) (not (string-match "\\`\\s *\\'" str))))
   "Predicate for filtering additions to input history.
 Only inputs answering true to this function are saved on the input
-history list.  Default is to save anything that isn't all whitespace")
+history list.  Default is to save anything that isn't all whitespace.")
 
 (defvar term-input-filter-functions '()
   "Functions to call before input is sent to the process.
@@ -595,9 +596,9 @@ This variable is buffer-local.")
 
 (defvar term-input-sender (function term-simple-send)
   "Function to actually send to PROCESS the STRING submitted by user.
-Usually this is just 'term-simple-send, but if your mode needs to
+Usually this is just `term-simple-send', but if your mode needs to
 massage the input string, this is your hook.  This is called from
-the user command term-send-input.  term-simple-send just sends
+the user command `term-send-input'.  `term-simple-send' just sends
 the string plus a newline.")
 
 (defcustom term-eol-on-send t
@@ -607,16 +608,16 @@ See `term-send-input'."
   :group 'term)
 
 (defcustom term-mode-hook '()
-  "Called upon entry into term-mode
+  "Called upon entry into term mode.
 This is run before the process is cranked up."
   :type 'hook
   :group 'term)
 
 (defcustom term-exec-hook '()
-  "Called each time a process is exec'd by term-exec.
+  "Called each time a process is exec'd by `term-exec'.
 This is called after the process is cranked up.  It is useful for things that
-must be done each time a process is executed in a term-mode buffer (e.g.,
-\(process-kill-without-query)).  In contrast, the term-mode-hook is only
+must be done each time a process is executed in a term mode buffer (e.g.,
+`process-kill-without-query').  In contrast, `term-mode-hook' is only
 executed once when the buffer is created."
   :type 'hook
   :group 'term)
@@ -625,8 +626,8 @@ executed once when the buffer is created."
 (defvar term-raw-map nil
   "Keyboard map for sending characters directly to the inferior process.")
 (defvar term-escape-char nil
-  "Escape character for char-sub-mode of term mode.
-Do not change it directly;  use term-set-escape-char instead.")
+  "Escape character for char sub-mode of term mode.
+Do not change it directly;  use `term-set-escape-char' instead.")
 (defvar term-raw-escape-map nil)
 
 (defvar term-pager-break-map nil)
@@ -684,14 +685,13 @@ Buffer local variable.")
 (defvar term-ansi-at-save-user nil)
 (defvar term-ansi-at-save-pwd nil)
 (defvar term-ansi-at-save-anon nil)
-(defvar term-ansi-current-bold 0)
+(defvar term-ansi-current-bold nil)
 (defvar term-ansi-current-color 0)
-(defvar term-ansi-face-already-done 0)
+(defvar term-ansi-face-already-done nil)
 (defvar term-ansi-current-bg-color 0)
-(defvar term-ansi-current-underline 0)
-(defvar term-ansi-current-highlight 0)
-(defvar term-ansi-current-reverse 0)
-(defvar term-ansi-current-invisible 0)
+(defvar term-ansi-current-underline nil)
+(defvar term-ansi-current-reverse nil)
+(defvar term-ansi-current-invisible nil)
 
 ;;; Four should be enough, if you want more, just add. -mm
 (defvar term-terminal-more-parameters 0)
@@ -712,9 +712,10 @@ Buffer local variable.")
   :group 'term
   :type 'string)
 
+;;; Use the same colors that xterm uses, see `xterm-standard-colors'.
 (defvar ansi-term-color-vector
-  [unspecified "black" "red" "green" "yellow" "blue"
-   "magenta" "cyan" "white"])
+  [unspecified "black" "red3" "green3" "yellow3" "blue2"
+   "magenta3" "cyan3" "white"])
 
 ;;; Inspiration came from comint.el -mm
 (defvar term-buffer-maximum-size 2048
@@ -732,8 +733,7 @@ is buffer-local.")
      [ "Enable paging" term-pager-toggle (not term-pager-count)]
      [ "Disable paging" term-pager-toggle term-pager-count])))
 
-(if term-mode-map
-    nil
+(unless term-mode-map
   (setq term-mode-map (make-sparse-keymap))
   (define-key term-mode-map "\ep" 'term-previous-input)
   (define-key term-mode-map "\en" 'term-next-input)
@@ -888,7 +888,9 @@ is buffer-local.")
        (i 0))
   (while (< i 128)
     (define-key map (make-string 1 i) 'term-send-raw)
-    (define-key esc-map (make-string 1 i) 'term-send-raw-meta)
+    ;; Avoid O and [. They are used in escape sequences for various keys.
+    (unless (or (eq i ?O) (eq i 91))
+               (define-key esc-map (make-string 1 i) 'term-send-raw-meta))
     (setq i (1+ i)))
   (dolist (elm (generic-character-list))
     (define-key map (vector elm) 'term-send-raw))
@@ -911,6 +913,7 @@ is buffer-local.")
     (define-key term-raw-map [right] 'term-send-right)
     (define-key term-raw-map [left] 'term-send-left)
     (define-key term-raw-map [delete] 'term-send-del)
+    (define-key term-raw-map [deletechar] 'term-send-del)
     (define-key term-raw-map [backspace] 'term-send-backspace)
     (define-key term-raw-map [home] 'term-send-home)
     (define-key term-raw-map [end] 'term-send-end)
@@ -939,11 +942,11 @@ is buffer-local.")
                (make-display-table)))
         i)
     ;; avoid changing the display table for ^J
-    (setq i 0) 
+    (setq i 0)
     (while (< i 10)
       (aset dt i (vector i))
       (setq i (1+ i)))
-    (setq i 11) 
+    (setq i 11)
     (while (< i 32)
       (aset dt i (vector i))
       (setq i (1+ i)))
@@ -959,7 +962,8 @@ The interpreter name is same as buffer name, sans the asterisks.
 
 There are two submodes: line mode and char mode.  By default, you are
 in char mode.  In char sub-mode, each character (except
-`term-escape-char') is set immediately.
+`term-escape-char') is sent immediately to the subprocess.
+The escape character is equivalent to the usual meaning of C-x.
 
 In line mode, you send a line of input at a time; use
 \\[term-send-input] to send.
@@ -980,7 +984,7 @@ and `term-scroll-to-bottom-on-output'.
 If you accidentally suspend your process, use \\[term-continue-subjob]
 to continue it.
 
-This mode can be customised to create specific modes for running
+This mode can be customized to create specific modes for running
 particular subprocesses.  This can be done by setting the hooks
 `term-input-filter-functions', `term-input-filter',
 `term-input-sender' and `term-get-old-input' to appropriate functions,
@@ -1061,7 +1065,6 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (make-local-variable 'term-ansi-face-already-done)
   (make-local-variable 'term-ansi-current-bg-color)
   (make-local-variable 'term-ansi-current-underline)
-  (make-local-variable 'term-ansi-current-highlight)
   (make-local-variable 'term-ansi-current-reverse)
   (make-local-variable 'term-ansi-current-invisible)
 
@@ -1100,7 +1103,9 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (make-local-variable 'term-current-face)
   (make-local-variable 'term-pending-frame)
   (setq term-pending-frame nil)
-  (run-hooks 'term-mode-hook)
+  ;; Cua-mode's keybindings interfere with the term keybindings, disable it. 
+  (set (make-local-variable 'cua-mode) nil)
+  (run-mode-hooks 'term-mode-hook)
   (term-if-xemacs
    (set-buffer-menubar
     (append current-menubar (list term-terminal-menu))))
@@ -1271,7 +1276,7 @@ you type \\[term-send-input] which sends the current line to the inferior."
 (defun term-check-proc (buffer)
   "True if there is a process associated w/buffer BUFFER, and
 it is alive (status RUN or STOP).  BUFFER can be either a buffer or the
-name of one"
+name of one."
   (let ((proc (get-buffer-process buffer)))
     (and proc (memq (process-status proc) '(run stop)))))
 
@@ -1401,7 +1406,7 @@ The main purpose is to get rid of the local keymap."
 :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
 :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
 :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m\
-:kb=^?:kD=^[[3~:sc=\E7:rc=\E8:"
+:kb=^?:kD=^[[3~:sc=\E7:rc=\E8:r1=\Ec:"
 ;;; : -undefine ic
 ;;; don't define :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\
   "termcap capabilities supported")
@@ -1572,7 +1577,7 @@ See also `term-read-input-ring'."
       (sit-for 0)
       (message "Hit space to flush")
       (let ((ch (read-event)))
-       (if (eq ch ?\ )
+       (if (eq ch ?\s)
            (set-window-configuration conf)
          (setq unread-command-events (list ch)))))))
 
@@ -2086,7 +2091,7 @@ If this takes us past the end of the current line, don't skip at all."
 (defun term-simple-send (proc string)
   "Default function for sending to PROC input STRING.
 This just sends STRING plus a newline.  To override this,
-set the hook TERM-INPUT-SENDER."
+set the hook `term-input-sender'."
   (term-send-string proc string)
   (term-send-string proc "\n"))
 
@@ -2178,7 +2183,7 @@ Security bug: your string can still be temporarily recovered with
 If your process is choking on big inputs, try lowering the value.")
 
 (defun term-send-string (proc str)
-  "Send PROCESS the contents of STRING as input.
+  "Send to PROC the contents of STR as input.
 This is equivalent to process-send-string, except that long input strings
 are broken up into chunks of size term-input-chunk-size.  Processes
 are given a chance to output between chunks.  This can help prevent processes
@@ -2193,9 +2198,9 @@ from hanging when you send them long inputs on some OS's."
        (setq i next-i)))))
 
 (defun term-send-region (proc start end)
-  "Sends to PROC the region delimited by START and END.
+  "Send to PROC the region delimited by START and END.
 This is a replacement for process-send-region that tries to keep
-your process from hanging on long inputs.  See term-send-string."
+your process from hanging on long inputs.  See `term-send-string'."
   (term-send-string proc (buffer-substring start end)))
 
 \f
@@ -2425,7 +2430,7 @@ See `term-prompt-regexp'."
 ;;; This is pretty stupid about strings.  It decides we're in a string
 ;;; if there's a quote on both sides of point on the current line.
 (defun term-extract-string ()
-  "Returns string around POINT that starts the current line or nil."
+  "Return string around `point' that starts the current line or nil."
   (save-excursion
     (let* ((point (point))
           (bol (progn (beginning-of-line) (point)))
@@ -2508,14 +2513,14 @@ See `term-prompt-regexp'."
 (defun term-horizontal-column ()
   (- (term-current-column) (term-start-line-column)))
 
-;; Calls either vertical-motion or buffer-vertical-motion
+;; Calls either vertical-motion or term-buffer-vertical-motion
 (defmacro term-vertical-motion (count)
   (list 'funcall 'term-vertical-motion count))
 
 ;; An emulation of vertical-motion that is independent of having a window.
 ;; Instead, it uses the term-width variable as the logical window width.
 
-(defun buffer-vertical-motion (count)
+(defun term-buffer-vertical-motion (count)
   (cond ((= count 0)
         (move-to-column (* term-width (/ (current-column) term-width)))
         0)
@@ -2572,7 +2577,16 @@ See `term-prompt-regexp'."
 
 (defun term-move-columns (delta)
   (setq term-current-column (max 0 (+ (term-current-column) delta)))
-  (move-to-column term-current-column t))
+  (let (point-at-eol)
+    (save-excursion
+      (end-of-line)
+      (setq point-at-eol (point)))
+    (move-to-column term-current-column t)
+    ;; If move-to-column extends the current line it will use the face
+    ;; from the last character on the line, set the face for the chars
+    ;; to default.
+    (when (> (point) point-at-eol)
+      (put-text-property point-at-eol (point) 'face 'default))))
 
 ;; Insert COUNT copies of CHAR in the default face.
 (defun term-insert-char (char count)
@@ -2590,7 +2604,7 @@ See `term-prompt-regexp'."
 
 (defun term-adjust-current-row-cache (delta)
   (when term-current-row
-    (setq term-current-row 
+    (setq term-current-row
          (max 0 (+ term-current-row delta)))))
 
 (defun term-terminal-pos ()
@@ -2691,7 +2705,7 @@ See `term-prompt-regexp'."
              (setq term-vertical-motion (symbol-function 'vertical-motion))
              (term-check-size proc))
          (setq term-vertical-motion
-               (symbol-function 'buffer-vertical-motion)))
+               (symbol-function 'term-buffer-vertical-motion)))
 
        (setq save-marker (copy-marker (process-mark proc)))
 
@@ -2770,11 +2784,11 @@ See `term-prompt-regexp'."
                            ;; In insert if the if the current line
                            ;; has become too long it needs to be
                            ;; chopped off.
-                           (when term-insert-mode 
+                           (when term-insert-mode
                              (setq pos (point))
                              (end-of-line)
                              (when (> (current-column) term-width)
-                               (delete-region (- (point) (- (current-column) term-width)) 
+                               (delete-region (- (point) (- (current-column) term-width))
                                               (point)))
                              (goto-char pos)))
                          (setq term-current-column nil)
@@ -2793,15 +2807,15 @@ See `term-prompt-regexp'."
                          (setq count (term-current-column))
                          ;; The line cannot exceed term-width. TAB at
                          ;; the end of a line should not cause wrapping.
-                         (setq count (min term-width 
+                         (setq count (min term-width
                                           (+ count 8 (- (mod count 8)))))
                          (if (> term-width count)
                            (progn
-                             (term-move-columns 
+                             (term-move-columns
                               (- count (term-current-column)))
                              (setq term-current-column count))
                            (when (> term-width (term-current-column))
-                             (term-move-columns 
+                             (term-move-columns
                               (1- (- term-width (term-current-column)))))
                            (when (= term-width (term-current-column))
                              (term-move-columns -1))))
@@ -2892,6 +2906,10 @@ See `term-prompt-regexp'."
                              (term-goto (car term-saved-cursor)
                                         (cdr term-saved-cursor)))
                          (setq term-terminal-state 0))
+                        ((eq char ?c) ;; \Ec - Reset (terminfo: rs1)
+                         ;; This is used by the "clear" program.
+                         (setq term-terminal-state 0)
+                         (term-reset-terminal))
                         ;; The \E#8 reset sequence for xterm. We
                         ;; probably don't need to handle it, but this
                         ;; is the code to parse it.
@@ -3019,40 +3037,56 @@ See `term-prompt-regexp'."
          (set-marker term-home-marker (point))
          (setq term-current-row (1- term-height))))))
 
+;;; Reset the terminal, delete all the content and set the face to the
+;;; default one.
+(defun term-reset-terminal ()
+  (erase-buffer)
+  (setq term-current-row 0)
+  (setq term-current-column 1)
+  (setq term-insert-mode nil)
+  (setq term-current-face nil)
+  (setq term-ansi-current-underline nil)
+  (setq term-ansi-current-bold nil)
+  (setq term-ansi-current-reverse nil)
+  (setq term-ansi-current-color 0)
+  (setq term-ansi-current-invisible nil)
+  (setq term-ansi-face-already-done nil)
+  (setq term-ansi-current-bg-color 0))
+
 ;;; New function to deal with ansi colorized output, as you can see you can
 ;;; have any bold/underline/fg/bg/reverse combination. -mm
 
 (defun term-handle-colors-array (parameter)
   (cond
 
-;;; Bold
+;;; Bold  (terminfo: bold)
    ((eq parameter 1)
-    (setq term-ansi-current-bold 1))
+    (setq term-ansi-current-bold t))
 
 ;;; Underline
    ((eq parameter 4)
-    (setq term-ansi-current-underline 1))
+    (setq term-ansi-current-underline t))
 
 ;;; Blink (unsupported by Emacs), will be translated to bold.
 ;;; This may change in the future though.
    ((eq parameter 5)
-    (setq term-ansi-current-bold 1))
+    (setq term-ansi-current-bold t))
 
 ;;; Reverse
    ((eq parameter 7)
-    (setq term-ansi-current-reverse 1))
+    (setq term-ansi-current-reverse t))
 
 ;;; Invisible
    ((eq parameter 8)
-    (setq term-ansi-current-invisible 1))
+    (setq term-ansi-current-invisible t))
 
 ;;; Reset underline (i.e. terminfo rmul)
    ((eq parameter 24)
-    (setq term-ansi-current-underline 0))
+    (setq term-ansi-current-underline nil))
 
 ;;; Reset reverse (i.e. terminfo rmso)
    ((eq parameter 27)
-    (setq term-ansi-current-reverse 0))
+    (setq term-ansi-current-reverse nil))
 
 ;;; Foreground
    ((and (>= parameter 30) (<= parameter 37))
@@ -3073,12 +3107,12 @@ See `term-prompt-regexp'."
 ;;; 0 (Reset) or unknown (reset anyway)
    (t
     (setq term-current-face nil)
-    (setq term-ansi-current-underline 0)
-    (setq term-ansi-current-bold 0)
-    (setq term-ansi-current-reverse 0)
+    (setq term-ansi-current-underline nil)
+    (setq term-ansi-current-bold nil)
+    (setq term-ansi-current-reverse nil)
     (setq term-ansi-current-color 0)
-    (setq term-ansi-current-invisible 0)
-    (setq term-ansi-face-already-done 1)
+    (setq term-ansi-current-invisible nil)
+    (setq term-ansi-face-already-done t)
     (setq term-ansi-current-bg-color 0)))
 
 ;      (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d"
@@ -3091,9 +3125,9 @@ See `term-prompt-regexp'."
 ;                 term-ansi-current-bg-color)
 
 
-  (if (= term-ansi-face-already-done 0)
-      (if (= term-ansi-current-reverse 1)
-         (if (= term-ansi-current-invisible 1)
+  (unless term-ansi-face-already-done
+      (if term-ansi-current-reverse
+         (if term-ansi-current-invisible
              (setq term-current-face
                    (if (= term-ansi-current-color 0)
                        (list :background
@@ -3115,13 +3149,13 @@ See `term-prompt-regexp'."
                        (if (= term-ansi-current-bg-color 0)
                            (face-background 'default)
                        (elt ansi-term-color-vector term-ansi-current-bg-color))))
-           (if (= term-ansi-current-bold 1)
+           (when term-ansi-current-bold
                (setq term-current-face
                      (append '(:weight bold) term-current-face)))
-           (if (= term-ansi-current-underline 1)
+           (when term-ansi-current-underline
                (setq term-current-face
                      (append '(:underline t) term-current-face))))
-       (if (= term-ansi-current-invisible 1)
+       (if term-ansi-current-invisible
            (setq term-current-face
                  (if (= term-ansi-current-bg-color 0)
                      (list :background
@@ -3139,15 +3173,15 @@ See `term-prompt-regexp'."
                      (elt ansi-term-color-vector term-ansi-current-color)
                      :background
                      (elt ansi-term-color-vector term-ansi-current-bg-color)))
-         (if (= term-ansi-current-bold 1)
+         (when term-ansi-current-bold
              (setq term-current-face
                    (append '(:weight bold) term-current-face)))
-         (if (= term-ansi-current-underline 1)
+         (when term-ansi-current-underline
              (setq term-current-face
                    (append '(:underline t) term-current-face))))))
 
 ;;;    (message "Debug %S" term-current-face)
-  (setq term-ansi-face-already-done 0))
+  (setq term-ansi-face-already-done nil))
 
 
 ;;; Handle a character assuming (eq terminal-state 2) -
@@ -3158,7 +3192,7 @@ See `term-prompt-regexp'."
    ((or (eq char ?H)  ; cursor motion (terminfo: cup)
        ;; (eq char ?f) ; xterm seems to handle this sequence too, not
        ;; needed for now
-       ) 
+       )
     (if (<= term-terminal-parameter 0)
        (setq term-terminal-parameter 1))
     (if (<= term-terminal-previous-parameter 0)
@@ -3179,8 +3213,8 @@ See `term-prompt-regexp'."
     (term-down (max 1 term-terminal-parameter) t))
    ;; \E[C - cursor right (terminfo: cuf)
    ((eq char ?C)
-    (term-move-columns 
-     (max 1 
+    (term-move-columns
+     (max 1
          (if (>= (+ term-terminal-parameter (term-current-column)) term-width)
              (- term-width (term-current-column)  1)
            term-terminal-parameter))))
@@ -3203,7 +3237,7 @@ See `term-prompt-regexp'."
    ((eq char ?P)
     (term-delete-chars (max 1 term-terminal-parameter)))
    ;; \E[@ - insert spaces
-   ((eq char ?@)
+   ((eq char ?@) ;; (terminfo: ich)
     (term-insert-spaces (max 1 term-terminal-parameter)))
    ;; \E[?h - DEC Private Mode Set
    ((eq char ?h)
@@ -3221,7 +3255,7 @@ See `term-prompt-regexp'."
          ))
 
 ;;; Modified to allow ansi coloring -mm
-   ;; \E[m - Set/reset modes, set bg/fg 
+   ;; \E[m - Set/reset modes, set bg/fg
    ;;(terminfo: smso,rmso,smul,rmul,rev,bold,sgr0,invis,op,setab,setaf)
    ((eq char ?m)
     (when (= term-terminal-more-parameters 1)
@@ -3266,7 +3300,7 @@ The top-most line is line 0."
            (not (and (= term-scroll-start 0)
                      (= term-scroll-end term-height)))))
   (term-move-columns (- (term-current-column)))
-  (term-goto 
+  (term-goto
    term-scroll-start (term-current-column)))
 
 ;; (defun term-switch-to-alternate-sub-buffer (set)
@@ -3308,7 +3342,7 @@ The top-most line is line 0."
                (second-colon
                 (string-match ":" string (1+ first-colon)))
                (filename (substring string 1 first-colon))
-               (fileline (string-to-int
+               (fileline (string-to-number
                           (substring string (1+ first-colon) second-colon))))
           (setq term-pending-frame (cons filename fileline))))
        ((= (aref string 0) ?/)
@@ -3664,12 +3698,20 @@ Should only be called when point is at the start of a screen line."
 ;;; at teh end of this screen line to make room.
 
 (defun term-insert-spaces (count)
-  (let ((save-point (point)) (save-eol))
+  (let ((save-point (point)) (save-eol) (point-at-eol))
     (term-vertical-motion 1)
     (if (bolp)
        (backward-char))
     (setq save-eol (point))
+    (save-excursion
+      (end-of-line)
+      (setq point-at-eol (point)))
     (move-to-column (+ (term-start-line-column) (- term-width count)) t)
+    ;; If move-to-column extends the current line it will use the face
+    ;; from the last character on the line, set the face for the chars
+    ;; to default.
+    (when (> (point) (point-at-eol))
+      (put-text-property point-at-eol (point) 'face 'default))
     (if (> save-eol (point))
        (delete-region (point) save-eol))
     (goto-char save-point)
@@ -3807,7 +3849,7 @@ directory tracking functions.")
 
 
 (defun term-word (word-chars)
-  "Return the word of WORD-CHARS at point, or nil if non is found.
+  "Return the word of WORD-CHARS at point, or nil if none is found.
 Word constituents are considered to be those in WORD-CHARS, which is like the
 inside of a \"[...]\" (see `skip-chars-forward')."
   (save-excursion
@@ -3824,7 +3866,7 @@ inside of a \"[...]\" (see `skip-chars-forward')."
 
 
 (defun term-match-partial-filename ()
-  "Return the filename at point, or nil if non is found.
+  "Return the filename at point, or nil if none is found.
 Environment variables are substituted.  See `term-word'."
   (let ((filename (term-word "~/A-Za-z0-9+@:_.$#,={}-")))
     (and filename (substitute-in-file-name filename))))
@@ -3912,9 +3954,9 @@ See `term-dynamic-complete-filename'.  Returns t if successful."
 
 (defun term-replace-by-expanded-filename ()
   "Dynamically expand and complete the filename at point.
-Replace the filename with an expanded, canonicalised and completed replacement.
+Replace the filename with an expanded, canonicalized and completed replacement.
 \"Expanded\" means environment variables (e.g., $HOME) and `~'s are replaced
-with the corresponding directories.  \"Canonicalised\" means `..'  and `.' are
+with the corresponding directories.  \"Canonicalized\" means `..'  and `.' are
 removed, and the filename is made absolute instead of relative.  For expansion
 see `expand-file-name' and `substitute-in-file-name'.  For completion see
 `term-dynamic-complete-filename'."
@@ -4006,7 +4048,7 @@ Typing SPC flushes the help buffer."
          (progn
            (mouse-choose-completion first)
            (set-window-configuration conf))
-       (if (eq first ?\ )
+       (if (eq first ?\s)
            (set-window-configuration conf)
          (setq unread-command-events (listify-key-sequence key)))))))
 
@@ -4140,7 +4182,7 @@ the process.  Any more args are arguments to PROGRAM."
 ;;;   (make-local-variable 'shell-directory-stack)
 ;;;   (setq shell-directory-stack nil)
 ;;;   (add-hook 'term-input-filter-functions 'shell-directory-tracker)
-;;;   (run-hooks 'shell-mode-hook))
+;;;   (run-mode-hooks 'shell-mode-hook))
 ;;;
 ;;;
 ;;; Completion for term-mode users