diff lisp/term.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 2f877ed80fa6
children d8411455de48
line wrap: on
line diff
--- a/lisp/term.el	Thu Apr 15 01:08:34 2004 +0000
+++ b/lisp/term.el	Fri Apr 16 12:51:06 2004 +0000
@@ -658,14 +658,12 @@
 (put 'term-scroll-show-maximum-output 'permanent-local t)
 (put 'term-ptyp 'permanent-local t)
 
-;; True if running under XEmacs (previously Lucid Emacs).
-(defmacro term-is-xemacs ()  '(string-match "Lucid" emacs-version))
 ;; Do FORM if running under XEmacs (previously Lucid Emacs).
 (defmacro term-if-xemacs (&rest forms)
-  (if (term-is-xemacs) (cons 'progn forms)))
+  (if (featurep 'xemacs) (cons 'progn forms)))
 ;; Do FORM if NOT running under XEmacs (previously Lucid Emacs).
 (defmacro term-ifnot-xemacs (&rest forms)
-  (if (not (term-is-xemacs)) (cons 'progn forms)))
+  (if (not (featurep 'xemacs)) (cons 'progn forms)))
 
 (defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map))
 (defmacro term-in-line-mode () '(not (term-in-char-mode)))
@@ -921,6 +919,14 @@
     (define-key term-raw-map [next] 'term-send-next)))
 
 (term-set-escape-char ?\C-c)
+
+(defun term-window-width ()
+  (if (featurep 'xemacs)
+      (1- (window-width))
+    (if window-system
+	(window-width)
+      (1- (window-width)))))
+
 
 (put 'term-mode 'mode-class 'special)
 
@@ -978,8 +984,10 @@
   (make-local-variable 'term-saved-home-marker)
   (make-local-variable 'term-height)
   (make-local-variable 'term-width)
-  (setq term-width (1- (window-width)))
+  (setq term-width (term-window-width))
   (setq term-height (1- (window-height)))
+  (term-ifnot-xemacs
+   (set (make-local-variable 'overflow-newline-into-fringe) nil))
   (make-local-variable 'term-terminal-parameter)
   (make-local-variable 'term-saved-cursor)
   (make-local-variable 'term-last-input-start)
@@ -1114,9 +1122,9 @@
 
 (defun term-check-size (process)
   (if (or (/= term-height (1- (window-height)))
-	  (/= term-width (1- (window-width))))
+	  (/= term-width (term-window-width)))
       (progn
-	(term-reset-size (1- (window-height)) (1- (window-width)))
+	(term-reset-size (1- (window-height)) (term-window-width))
 	(set-process-window-size process term-height term-width))))
 
 (defun term-send-raw-string (chars)
@@ -1170,6 +1178,7 @@
    ;; Give temporary modes such as isearch a chance to turn off.
    (run-hooks 'mouse-leave-buffer-hook)
    (setq this-command 'yank)
+   (mouse-set-point click)
    (term-send-raw-string (current-kill (cond
 					((listp arg) 0)
 					((eq arg '-) -1)
@@ -1288,6 +1297,7 @@
       (goto-char (point-max))
       (set-marker (process-mark proc) (point))
       (set-process-filter proc 'term-emulate-terminal)
+      (set-process-sentinel proc 'term-sentinel)
       ;; Feed it the startfile.
       (cond (startfile
 	     ;;This is guaranteed to wait long enough
@@ -1304,6 +1314,49 @@
     (run-hooks 'term-exec-hook)
     buffer)))
 
+(defun term-sentinel  (proc msg)
+  "Sentinel for term buffers.
+The main purpose is to get rid of the local keymap."
+  (let ((buffer (process-buffer proc)))
+    (if (memq (process-status proc) '(signal exit))
+	(progn
+	  (if (null (buffer-name buffer))
+	      ;; buffer killed
+	      (set-process-buffer proc nil)
+	    (let ((obuf (current-buffer)))
+	      ;; save-excursion isn't the right thing if
+	      ;; process-buffer is current-buffer
+	      (unwind-protect
+		  (progn
+		    ;; Write something in the compilation buffer
+		    ;; and hack its mode line.
+		    (set-buffer buffer)
+		    ;; Get rid of local keymap.
+		    (use-local-map nil)
+		    (term-handle-exit (process-name proc)
+				      msg)
+		    ;; Since the buffer and mode line will show that the
+		    ;; process is dead, we can delete it now.  Otherwise it
+		    ;; will stay around until M-x list-processes.
+		    (delete-process proc))
+		(set-buffer obuf))))
+	  ))))
+
+(defun term-handle-exit (process-name msg)
+  "Write process exit (or other change) message MSG in the current buffer."
+  (let ((buffer-read-only nil)
+	(omax (point-max))
+	(opoint (point)))
+    ;; Record where we put the message, so we can ignore it
+    ;; later on.
+    (goto-char omax)
+    (insert ?\n "Process " process-name " " msg)
+    ;; Force mode line redisplay soon.
+    (force-mode-line-update)
+    (if (and opoint (< opoint omax))
+	(goto-char opoint))))
+
+
 ;;; Name to use for TERM.
 ;;; Using "emacs" loses, because bash disables editing if TERM == emacs.
 (defvar term-term-name "eterm")
@@ -1345,6 +1398,8 @@
 	(process-connection-type t)
 	;; We should suppress conversion of end-of-line format.
 	(inhibit-eol-conversion t)
+	;; inhibit-eol-conversion doesn't seem to do the job, but this does.
+	(coding-system-for-read 'unknown-unix)
 	)
     (apply 'start-process name buffer
 	   "/bin/sh" "-c"
@@ -4018,4 +4073,5 @@
 
 (provide 'term)
 
+;;; arch-tag: eee16bc8-2cd7-4147-9534-a5694752f716
 ;;; term.el ends here