remove `declare' macro
[bpt/emacs.git] / lisp / term.el
index a7c50d6..95660ea 100644 (file)
@@ -1,7 +1,7 @@
 ;;; term.el --- general command interpreter in a window stuff
 
-;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2012
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2014 Free Software
+;; Foundation, Inc.
 
 ;; Author: Per Bothner <per@bothner.com>
 ;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com>
@@ -560,6 +560,13 @@ This variable is buffer-local."
   :type 'boolean
   :group 'term)
 
+(defcustom term-suppress-hard-newline nil
+  "Non-nil means interpreter should not break long lines with newlines.
+This means text can automatically reflow if the window is resized."
+  :version "24.4"
+  :type 'boolean
+  :group 'term)
+
 ;; Where gud-display-frame should put the debugging arrow.  This is
 ;; set by the marker-filter, which scans the debugger's output for
 ;; indications of the current pc.
@@ -778,14 +785,14 @@ Buffer local variable.")
 (defcustom term-default-fg-color nil
   "If non-nil, default color for foreground in Term mode."
   :group 'term
-  :type 'string)
+  :type '(choice (const nil) (string :tag "color")))
 (make-obsolete-variable 'term-default-fg-color "use the face `term' instead."
                         "24.3")
 
 (defcustom term-default-bg-color nil
   "If non-nil, default color for foreground in Term mode."
   :group 'term
-  :type 'string)
+  :type '(choice (const nil) (string :tag "color")))
 (make-obsolete-variable 'term-default-bg-color "use the face `term' instead."
                         "24.3")
 
@@ -953,7 +960,7 @@ is buffer-local."
   (when term-escape-char
     ;; Undo previous term-set-escape-char.
     (define-key term-raw-map term-escape-char 'term-send-raw))
-  (setq term-escape-char (vector key))
+  (setq term-escape-char (if (vectorp key) key (vector key)))
   (define-key term-raw-map term-escape-char term-raw-escape-map)
   ;; FIXME: If we later call term-set-escape-char again with another key,
   ;; we should undo this binding.
@@ -968,8 +975,8 @@ is buffer-local."
           (display-graphic-p)
           overflow-newline-into-fringe
           (/= (frame-parameter nil 'right-fringe) 0))
-      (window-width)
-    (1- (window-width))))
+      (window-body-width)
+    (1- (window-body-width))))
 
 \f
 (put 'term-mode 'mode-class 'special)
@@ -1245,15 +1252,14 @@ without any interpretation."
     (setq this-command 'yank)
     (mouse-set-point click)
     (term-send-raw-string
-     (or (cond  ; From `mouse-yank-primary':
-         ((eq system-type 'windows-nt)
-          (or (x-get-selection 'PRIMARY)
-              (x-get-selection-value)))
-         ((fboundp 'x-get-selection-value)
-          (or (x-get-selection-value)
-              (x-get-selection 'PRIMARY)))
-         (t
-          (x-get-selection 'PRIMARY)))
+     ;; From `mouse-yank-primary':
+     (or (if (fboundp 'x-get-selection-value)
+             (if (eq system-type 'windows-nt)
+                 (or (x-get-selection 'PRIMARY)
+                     (x-get-selection-value))
+               (or (x-get-selection-value)
+                   (x-get-selection 'PRIMARY)))
+          (x-get-selection 'PRIMARY))
         (error "No selection is available")))))
 
 (defun term-paste ()
@@ -2828,8 +2834,9 @@ See `term-prompt-regexp'."
                          (setq count (length decoded-substring))
                          (setq temp (- (+ (term-horizontal-column) count)
                                        term-width))
-                         (cond ((<= temp 0)) ;; All count chars fit in line.
-                               ((> count temp) ;; Some chars fit.
+                         (cond ((or term-suppress-hard-newline (<= temp 0)))
+                               ;; All count chars fit in line.
+                               ((> count temp) ;; Some chars fit.
                                 ;; This iteration, handle only what fits.
                                 (setq count (- count temp))
                                 (setq count-bytes
@@ -2929,8 +2936,10 @@ See `term-prompt-regexp'."
                          (let ((end (string-match "\r?$" str i)))
                            (if end
                                (funcall term-command-hook
-                                        (prog1 (substring str (1+ i) end)
-                                          (setq i (match-end 0))))
+                                        (decode-coding-string
+                                         (prog1 (substring str (1+ i) end)
+                                           (setq i (match-end 0)))
+                                         locale-coding-system))
                              (setq term-terminal-parameter (substring str i))
                              (setq term-terminal-state 4)
                              (setq i str-length))))
@@ -3222,18 +3231,24 @@ See `term-prompt-regexp'."
         (let ((color
                (if term-ansi-current-reverse
                    (face-foreground
-                    (elt ansi-term-color-vector term-ansi-current-color))
+                    (elt ansi-term-color-vector term-ansi-current-color)
+                    nil 'default)
                  (face-background
-                  (elt ansi-term-color-vector term-ansi-current-bg-color)))))
+                  (elt ansi-term-color-vector term-ansi-current-bg-color)
+                  nil 'default))))
           (setq term-current-face
                 (list :background color
                       :foreground color))
           ) ;; No need to bother with anything else if it's invisible.
       (setq term-current-face
             (list :foreground
-                  (face-foreground (elt ansi-term-color-vector term-ansi-current-color))
+                  (face-foreground
+                   (elt ansi-term-color-vector term-ansi-current-color)
+                   nil 'default)
                   :background
-                  (face-background (elt ansi-term-color-vector term-ansi-current-bg-color))
+                  (face-background
+                   (elt ansi-term-color-vector term-ansi-current-bg-color)
+                   nil 'default)
                   :inverse-video term-ansi-current-reverse))
 
       (when term-ansi-current-bold
@@ -3617,7 +3632,7 @@ all pending output has been dealt with."))
            (if (< down 0) term-scroll-start term-scroll-end))))
     (when (or (and (< down 0) (< scroll-needed 0))
              (and (> down 0) (> scroll-needed 0)))
-      (let ((save-point (copy-marker (point))) (save-top))
+      (let ((save-point (point-marker)) (save-top))
        (goto-char term-home-marker)
        (cond (term-scroll-with-delete
               (if (< down 0)
@@ -4122,8 +4137,9 @@ Typing SPC flushes the help buffer."
            (and (consp first)
                 (eq (window-buffer (posn-window (event-start first)))
                     (get-buffer "*Completions*"))
-                (eq (key-binding key) 'mouse-choose-completion)))
-         ;; If the user does mouse-choose-completion with the mouse,
+                (memq (key-binding key)
+                       '(mouse-choose-completion choose-completion))))
+         ;; If the user does choose-completion with the mouse,
          ;; execute the command, then delete the completion window.
          (progn
            (choose-completion first)