summaryrefslogtreecommitdiff
path: root/lisp/term.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/term.el')
-rw-r--r--lisp/term.el70
1 files changed, 63 insertions, 7 deletions
diff --git a/lisp/term.el b/lisp/term.el
index d57355416aa..2e0e3efc189 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -658,14 +658,12 @@ Buffer local variable.")
(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 @@ is buffer-local.")
(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 @@ Entry to this mode runs the hooks on `term-mode-hook'."
(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 @@ Entry to this mode runs the hooks on `term-mode-hook'."
(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 @@ without any interpretation."
;; 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 @@ buffer. The hook term-exec-hook is run after each exec."
(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 @@ buffer. The hook term-exec-hook is run after each exec."
(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 @@ buffer. The hook term-exec-hook is run after each exec."
(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 @@ the process. Any more args are arguments to PROGRAM."
(provide 'term)
+;;; arch-tag: eee16bc8-2cd7-4147-9534-a5694752f716
;;; term.el ends here