688 |
(defvar term-ansi-at-save-anon nil) |
(defvar term-ansi-at-save-anon nil) |
689 |
(defvar term-ansi-current-bold 0) |
(defvar term-ansi-current-bold 0) |
690 |
(defvar term-ansi-current-color 0) |
(defvar term-ansi-current-color 0) |
691 |
(defvar term-ansi-face-alredy-done 0) |
(defvar term-ansi-face-already-done 0) |
692 |
(defvar term-ansi-current-bg-color 0) |
(defvar term-ansi-current-bg-color 0) |
693 |
(defvar term-ansi-current-underline 0) |
(defvar term-ansi-current-underline 0) |
694 |
(defvar term-ansi-current-highlight 0) |
(defvar term-ansi-current-highlight 0) |
697 |
(defvar term-ansi-default-fg 0) |
(defvar term-ansi-default-fg 0) |
698 |
(defvar term-ansi-default-bg 0) |
(defvar term-ansi-default-bg 0) |
699 |
(defvar term-ansi-current-temp 0) |
(defvar term-ansi-current-temp 0) |
|
(defvar term-ansi-fg-faces-vector nil) |
|
|
(defvar term-ansi-bg-faces-vector nil) |
|
|
(defvar term-ansi-inv-fg-faces-vector nil) |
|
|
(defvar term-ansi-inv-bg-faces-vector nil) |
|
|
(defvar term-ansi-reverse-faces-vector nil) |
|
700 |
|
|
701 |
;;; Four should be enough, if you want more, just add. -mm |
;;; Four should be enough, if you want more, just add. -mm |
702 |
(defvar term-terminal-more-parameters 0) |
(defvar term-terminal-more-parameters 0) |
707 |
|
|
708 |
;;; faces -mm |
;;; faces -mm |
709 |
|
|
710 |
(defmacro term-ignore-error (&rest body) |
(defcustom term-default-fg-color nil |
711 |
`(condition-case nil |
"Default color for foreground in `term'." |
712 |
(progn ,@body) |
:group 'term |
713 |
(error nil))) |
:type 'string) |
714 |
|
|
715 |
(defvar term-default-fg-color nil) |
(defcustom term-default-bg-color nil |
716 |
(defvar term-default-bg-color nil) |
"Default color for background in `term'." |
717 |
|
:group 'term |
718 |
(when (fboundp 'make-face) |
:type 'string) |
719 |
;;; --- Simple faces --- |
|
720 |
(copy-face 'default 'term-default) |
(defvar ansi-term-color-vector |
721 |
(make-face 'term-default-fg) |
[nil "black" "red" "green" "yellow" "blue" |
722 |
(make-face 'term-default-bg) |
"magenta" "cyan" "white"]) |
|
(make-face 'term-default-fg-inv) |
|
|
(make-face 'term-default-bg-inv) |
|
|
(make-face 'term-bold) |
|
|
(make-face 'term-underline) |
|
|
(make-face 'term-invisible) |
|
|
(make-face 'term-invisible-inv) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-default-fg term-default-fg-color)) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-default-bg term-default-bg-color)) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-default-fg-inv term-default-bg-color)) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-default-bg-inv term-default-fg-color)) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-background 'term-invisible term-default-bg-color)) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-background 'term-invisible-inv term-default-fg-color)) |
|
|
|
|
|
;; Set the colors of the new faces. |
|
|
(term-ignore-error |
|
|
(make-face-bold 'term-bold)) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-underline-p 'term-underline t)) |
|
|
|
|
|
;;; --- Fg faces --- |
|
|
(make-face 'term-black) |
|
|
(make-face 'term-red) |
|
|
(make-face 'term-green) |
|
|
(make-face 'term-yellow) |
|
|
(make-face 'term-blue) |
|
|
(make-face 'term-magenta) |
|
|
(make-face 'term-cyan) |
|
|
(make-face 'term-white) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-black "black")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-red "red")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-green "green")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-yellow "yellow")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-blue "blue")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-magenta "magenta")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-cyan "cyan")) |
|
|
(term-ignore-error |
|
|
(set-face-foreground 'term-white "white")) |
|
|
|
|
|
;;; --- Bg faces --- |
|
|
(make-face 'term-blackbg) |
|
|
(make-face 'term-redbg) |
|
|
(make-face 'term-greenbg) |
|
|
(make-face 'term-yellowbg) |
|
|
(make-face 'term-bluebg) |
|
|
(make-face 'term-magentabg) |
|
|
(make-face 'term-cyanbg) |
|
|
(make-face 'term-whitebg) |
|
|
|
|
|
(term-ignore-error |
|
|
(set-face-background 'term-blackbg "black")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-redbg "red")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-greenbg "green")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-yellowbg "yellow")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-bluebg "blue")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-magentabg "magenta")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-cyanbg "cyan")) |
|
|
(term-ignore-error |
|
|
(set-face-background 'term-whitebg "white"))) |
|
|
|
|
|
(defvar ansi-term-fg-faces-vector |
|
|
[term-default-fg term-black term-red term-green term-yellow term-blue |
|
|
term-magenta term-cyan term-white]) |
|
|
|
|
|
(defvar ansi-term-bg-faces-vector |
|
|
[term-default-bg term-blackbg term-redbg term-greenbg term-yellowbg |
|
|
term-bluebg term-magentabg term-cyanbg term-whitebg]) |
|
|
|
|
|
(defvar ansi-term-inv-bg-faces-vector |
|
|
[term-default-fg-inv term-black term-red term-green term-yellow term-blue |
|
|
term-magenta term-cyan term-white]) |
|
|
|
|
|
(defvar ansi-term-inv-fg-faces-vector |
|
|
[term-default-bg-inv term-blackbg term-redbg term-greenbg term-yellowbg |
|
|
term-bluebg term-magentabg term-cyanbg term-whitebg]) |
|
723 |
|
|
724 |
;;; Inspiration came from comint.el -mm |
;;; Inspiration came from comint.el -mm |
725 |
(defvar term-buffer-maximum-size 2048 |
(defvar term-buffer-maximum-size 2048 |
728 |
Notice that a setting of 0 means 'don't truncate anything'. This variable |
Notice that a setting of 0 means 'don't truncate anything'. This variable |
729 |
is buffer-local.") |
is buffer-local.") |
730 |
;;; |
;;; |
731 |
|
|
732 |
(term-if-xemacs |
(term-if-xemacs |
733 |
(defvar term-terminal-menu |
(defvar term-terminal-menu |
734 |
'("Terminal" |
'("Terminal" |
737 |
[ "Enable paging" term-pager-toggle (not term-pager-count)] |
[ "Enable paging" term-pager-toggle (not term-pager-count)] |
738 |
[ "Disable paging" term-pager-toggle term-pager-count]))) |
[ "Disable paging" term-pager-toggle term-pager-count]))) |
739 |
|
|
|
(put 'term-mode 'mode-class 'special) |
|
|
|
|
|
(defun term-mode () |
|
|
"Major mode for interacting with an inferior interpreter. |
|
|
Interpreter name is same as buffer name, sans the asterisks. |
|
|
In line sub-mode, return at end of buffer sends line as input, |
|
|
while return not at end copies rest of line to end and sends it. |
|
|
In char sub-mode, each character (except `term-escape-char`) is |
|
|
set immediately. |
|
|
|
|
|
This mode is typically customised to create inferior-lisp-mode, |
|
|
shell-mode, etc.. 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, and the variable |
|
|
term-prompt-regexp to the appropriate regular expression. |
|
|
|
|
|
An input history is maintained of size `term-input-ring-size', and |
|
|
can be accessed with the commands \\[term-next-input], |
|
|
\\[term-previous-input], and \\[term-dynamic-list-input-ring]. |
|
|
Input ring history expansion can be achieved with the commands |
|
|
\\[term-replace-by-expanded-history] or \\[term-magic-space]. |
|
|
Input ring expansion is controlled by the variable `term-input-autoexpand', |
|
|
and addition is controlled by the variable `term-input-ignoredups'. |
|
|
|
|
|
Input to, and output from, the subprocess can cause the window to scroll to |
|
|
the end of the buffer. See variables `term-scroll-to-bottom-on-input', |
|
|
and `term-scroll-to-bottom-on-output'. |
|
|
|
|
|
If you accidentally suspend your process, use \\[term-continue-subjob] |
|
|
to continue it. |
|
|
|
|
|
\\{term-mode-map} |
|
|
|
|
|
Entry to this mode runs the hooks on term-mode-hook" |
|
|
(interactive) |
|
|
;; Do not remove this. All major modes must do this. |
|
|
(kill-all-local-variables) |
|
|
(setq major-mode 'term-mode) |
|
|
(setq mode-name "Term") |
|
|
(use-local-map term-mode-map) |
|
|
(make-local-variable 'term-home-marker) |
|
|
(setq term-home-marker (copy-marker 0)) |
|
|
(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-height (1- (window-height))) |
|
|
(make-local-variable 'term-terminal-parameter) |
|
|
(make-local-variable 'term-saved-cursor) |
|
|
(make-local-variable 'term-last-input-start) |
|
|
(setq term-last-input-start (make-marker)) |
|
|
(make-local-variable 'term-last-input-end) |
|
|
(setq term-last-input-end (make-marker)) |
|
|
(make-local-variable 'term-last-input-match) |
|
|
(setq term-last-input-match "") |
|
|
(make-local-variable 'term-prompt-regexp) ; Don't set; default |
|
|
(make-local-variable 'term-input-ring-size) ; ...to global val. |
|
|
(make-local-variable 'term-input-ring) |
|
|
(make-local-variable 'term-input-ring-file-name) |
|
|
(or (and (boundp 'term-input-ring) term-input-ring) |
|
|
(setq term-input-ring (make-ring term-input-ring-size))) |
|
|
(make-local-variable 'term-input-ring-index) |
|
|
(or (and (boundp 'term-input-ring-index) term-input-ring-index) |
|
|
(setq term-input-ring-index nil)) |
|
|
|
|
|
(make-local-variable 'term-command-hook) |
|
|
(setq term-command-hook (symbol-function 'term-command-hook)) |
|
|
|
|
|
;;; I'm not sure these saves are necessary but, since I |
|
|
;;; haven't tested the whole thing on a net connected machine with |
|
|
;;; a properly configured ange-ftp, I've decided to be conservative |
|
|
;;; and put them in. -mm |
|
|
|
|
|
(make-local-variable 'term-ansi-at-host) |
|
|
(setq term-ansi-at-host (system-name)) |
|
|
|
|
|
(make-local-variable 'term-ansi-at-dir) |
|
|
(setq term-ansi-at-dir default-directory) |
|
|
|
|
|
(make-local-variable 'term-ansi-at-message) |
|
|
(setq term-ansi-at-message nil) |
|
|
|
|
|
;;; For user tracking purposes -mm |
|
|
(make-local-variable 'ange-ftp-default-user) |
|
|
(make-local-variable 'ange-ftp-default-password) |
|
|
(make-local-variable 'ange-ftp-generate-anonymous-password) |
|
|
|
|
|
;;; You may want to have different scroll-back sizes -mm |
|
|
(make-local-variable 'term-buffer-maximum-size) |
|
|
|
|
|
;;; Of course these have to be buffer-local -mm |
|
|
(make-local-variable 'term-ansi-current-bold) |
|
|
(make-local-variable 'term-ansi-current-color) |
|
|
(make-local-variable 'term-ansi-face-alredy-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) |
|
|
|
|
|
(make-local-variable 'term-terminal-state) |
|
|
(make-local-variable 'term-kill-echo-list) |
|
|
(make-local-variable 'term-start-line-column) |
|
|
(make-local-variable 'term-current-column) |
|
|
(make-local-variable 'term-current-row) |
|
|
(make-local-variable 'term-log-buffer) |
|
|
(make-local-variable 'term-scroll-start) |
|
|
(make-local-variable 'term-scroll-end) |
|
|
(setq term-scroll-end term-height) |
|
|
(make-local-variable 'term-scroll-with-delete) |
|
|
(make-local-variable 'term-pager-count) |
|
|
(make-local-variable 'term-pager-old-local-map) |
|
|
(make-local-variable 'term-old-mode-map) |
|
|
(make-local-variable 'term-insert-mode) |
|
|
(make-local-variable 'term-dynamic-complete-functions) |
|
|
(make-local-variable 'term-completion-fignore) |
|
|
(make-local-variable 'term-get-old-input) |
|
|
(make-local-variable 'term-matching-input-from-input-string) |
|
|
(make-local-variable 'term-input-autoexpand) |
|
|
(make-local-variable 'term-input-ignoredups) |
|
|
(make-local-variable 'term-delimiter-argument-list) |
|
|
(make-local-variable 'term-input-filter-functions) |
|
|
(make-local-variable 'term-input-filter) |
|
|
(make-local-variable 'term-input-sender) |
|
|
(make-local-variable 'term-eol-on-send) |
|
|
(make-local-variable 'term-scroll-to-bottom-on-output) |
|
|
(make-local-variable 'term-scroll-show-maximum-output) |
|
|
(make-local-variable 'term-ptyp) |
|
|
(make-local-variable 'term-exec-hook) |
|
|
(make-local-variable 'term-vertical-motion) |
|
|
(make-local-variable 'term-pending-delete-marker) |
|
|
(setq term-pending-delete-marker (make-marker)) |
|
|
(make-local-variable 'term-current-face) |
|
|
(make-local-variable 'term-pending-frame) |
|
|
(setq term-pending-frame nil) |
|
|
(run-hooks 'term-mode-hook) |
|
|
(term-if-xemacs |
|
|
(set-buffer-menubar |
|
|
(append current-menubar (list term-terminal-menu)))) |
|
|
(or term-input-ring |
|
|
(setq term-input-ring (make-ring term-input-ring-size))) |
|
|
(term-update-mode-line)) |
|
|
|
|
740 |
(if term-mode-map |
(if term-mode-map |
741 |
nil |
nil |
742 |
(setq term-mode-map (make-sparse-keymap)) |
(setq term-mode-map (make-sparse-keymap)) |
769 |
(define-key term-mode-map "\C-c\C-j" 'term-line-mode) |
(define-key term-mode-map "\C-c\C-j" 'term-line-mode) |
770 |
(define-key term-mode-map "\C-c\C-q" 'term-pager-toggle) |
(define-key term-mode-map "\C-c\C-q" 'term-pager-toggle) |
771 |
|
|
|
|
|
772 |
; ;; completion: |
; ;; completion: |
773 |
; (define-key term-mode-map [menu-bar completion] |
; (define-key term-mode-map [menu-bar completion] |
774 |
; (cons "Complete" (make-sparse-keymap "Complete"))) |
; (cons "Complete" (make-sparse-keymap "Complete"))) |
866 |
(define-key term-mode-map [menu-bar signals] |
(define-key term-mode-map [menu-bar signals] |
867 |
(setq term-signals-menu (cons "Signals" newmap))) |
(setq term-signals-menu (cons "Signals" newmap))) |
868 |
))) |
))) |
869 |
|
|
870 |
|
;; Set up term-raw-map, etc. |
871 |
|
|
872 |
|
(defun term-set-escape-char (c) |
873 |
|
"Change term-escape-char and keymaps that depend on it." |
874 |
|
(if term-escape-char |
875 |
|
(define-key term-raw-map term-escape-char 'term-send-raw)) |
876 |
|
(setq c (make-string 1 c)) |
877 |
|
(define-key term-raw-map c term-raw-escape-map) |
878 |
|
;; Define standard bindings in term-raw-escape-map |
879 |
|
(define-key term-raw-escape-map "\C-v" |
880 |
|
(lookup-key (current-global-map) "\C-v")) |
881 |
|
(define-key term-raw-escape-map "\C-u" |
882 |
|
(lookup-key (current-global-map) "\C-u")) |
883 |
|
(define-key term-raw-escape-map c 'term-send-raw) |
884 |
|
(define-key term-raw-escape-map "\C-q" 'term-pager-toggle) |
885 |
|
;; The keybinding for term-char-mode is needed by the menubar code. |
886 |
|
(define-key term-raw-escape-map "\C-k" 'term-char-mode) |
887 |
|
(define-key term-raw-escape-map "\C-j" 'term-line-mode) |
888 |
|
;; It's convenient to have execute-extended-command here. |
889 |
|
(define-key term-raw-escape-map [?\M-x] 'execute-extended-command)) |
890 |
|
|
891 |
|
(let* ((map (make-keymap)) |
892 |
|
(esc-map (make-keymap)) |
893 |
|
(i 0)) |
894 |
|
(while (< i 128) |
895 |
|
(define-key map (make-string 1 i) 'term-send-raw) |
896 |
|
(define-key esc-map (make-string 1 i) 'term-send-raw-meta) |
897 |
|
(setq i (1+ i))) |
898 |
|
(dolist (elm (generic-character-list)) |
899 |
|
(define-key map (vector elm) 'term-send-raw)) |
900 |
|
(define-key map "\e" esc-map) |
901 |
|
(setq term-raw-map map) |
902 |
|
(setq term-raw-escape-map |
903 |
|
(copy-keymap (lookup-key (current-global-map) "\C-x"))) |
904 |
|
|
905 |
|
;;; Added nearly all the 'grey keys' -mm |
906 |
|
|
907 |
|
(progn |
908 |
|
(term-if-xemacs |
909 |
|
(define-key term-raw-map [button2] 'term-mouse-paste)) |
910 |
|
(term-ifnot-xemacs |
911 |
|
(define-key term-raw-map [mouse-2] 'term-mouse-paste) |
912 |
|
(define-key term-raw-map [menu-bar terminal] term-terminal-menu) |
913 |
|
(define-key term-raw-map [menu-bar signals] term-signals-menu)) |
914 |
|
(define-key term-raw-map [up] 'term-send-up) |
915 |
|
(define-key term-raw-map [down] 'term-send-down) |
916 |
|
(define-key term-raw-map [right] 'term-send-right) |
917 |
|
(define-key term-raw-map [left] 'term-send-left) |
918 |
|
(define-key term-raw-map [delete] 'term-send-del) |
919 |
|
(define-key term-raw-map [backspace] 'term-send-backspace) |
920 |
|
(define-key term-raw-map [home] 'term-send-home) |
921 |
|
(define-key term-raw-map [end] 'term-send-end) |
922 |
|
(define-key term-raw-map [prior] 'term-send-prior) |
923 |
|
(define-key term-raw-map [next] 'term-send-next))) |
924 |
|
|
925 |
|
(term-set-escape-char ?\C-c) |
926 |
|
|
927 |
|
(put 'term-mode 'mode-class 'special) |
928 |
|
|
929 |
|
(defun term-mode () |
930 |
|
"Major mode for interacting with an inferior interpreter. |
931 |
|
The interpreter name is same as buffer name, sans the asterisks. |
932 |
|
|
933 |
|
There are two submodes: line mode and char mode. By default, you are |
934 |
|
in char mode. In char sub-mode, each character (except |
935 |
|
`term-escape-char') is set immediately. |
936 |
|
|
937 |
|
In line mode, you send a line of input at a time; use |
938 |
|
\\[term-send-input] to send. |
939 |
|
|
940 |
|
In line mode, this maintains an input history of size |
941 |
|
`term-input-ring-size', and you can access it with the commands |
942 |
|
\\[term-next-input], \\[term-previous-input], and |
943 |
|
\\[term-dynamic-list-input-ring]. Input ring history expansion can be |
944 |
|
achieved with the commands \\[term-replace-by-expanded-history] or |
945 |
|
\\[term-magic-space]. Input ring expansion is controlled by the |
946 |
|
variable `term-input-autoexpand', and addition is controlled by the |
947 |
|
variable `term-input-ignoredups'. |
948 |
|
|
949 |
|
Input to, and output from, the subprocess can cause the window to scroll to |
950 |
|
the end of the buffer. See variables `term-scroll-to-bottom-on-input', |
951 |
|
and `term-scroll-to-bottom-on-output'. |
952 |
|
|
953 |
|
If you accidentally suspend your process, use \\[term-continue-subjob] |
954 |
|
to continue it. |
955 |
|
|
956 |
|
This mode can be customised to create specific modes for running |
957 |
|
particular subprocesses. This can be done by setting the hooks |
958 |
|
`term-input-filter-functions', `term-input-filter', |
959 |
|
`term-input-sender' and `term-get-old-input' to appropriate functions, |
960 |
|
and the variable `term-prompt-regexp' to the appropriate regular |
961 |
|
expression. |
962 |
|
|
963 |
|
Commands in raw mode: |
964 |
|
|
965 |
|
\\{term-raw-map} |
966 |
|
|
967 |
|
Commands in line mode: |
968 |
|
|
969 |
|
\\{term-mode-map} |
970 |
|
|
971 |
|
Entry to this mode runs the hooks on `term-mode-hook'." |
972 |
|
(interactive) |
973 |
|
;; Do not remove this. All major modes must do this. |
974 |
|
(kill-all-local-variables) |
975 |
|
(setq major-mode 'term-mode) |
976 |
|
(setq mode-name "Term") |
977 |
|
(use-local-map term-mode-map) |
978 |
|
(make-local-variable 'term-home-marker) |
979 |
|
(setq term-home-marker (copy-marker 0)) |
980 |
|
(make-local-variable 'term-saved-home-marker) |
981 |
|
(make-local-variable 'term-height) |
982 |
|
(make-local-variable 'term-width) |
983 |
|
(setq term-width (1- (window-width))) |
984 |
|
(setq term-height (1- (window-height))) |
985 |
|
(make-local-variable 'term-terminal-parameter) |
986 |
|
(make-local-variable 'term-saved-cursor) |
987 |
|
(make-local-variable 'term-last-input-start) |
988 |
|
(setq term-last-input-start (make-marker)) |
989 |
|
(make-local-variable 'term-last-input-end) |
990 |
|
(setq term-last-input-end (make-marker)) |
991 |
|
(make-local-variable 'term-last-input-match) |
992 |
|
(setq term-last-input-match "") |
993 |
|
(make-local-variable 'term-prompt-regexp) ; Don't set; default |
994 |
|
(make-local-variable 'term-input-ring-size) ; ...to global val. |
995 |
|
(make-local-variable 'term-input-ring) |
996 |
|
(make-local-variable 'term-input-ring-file-name) |
997 |
|
(or (and (boundp 'term-input-ring) term-input-ring) |
998 |
|
(setq term-input-ring (make-ring term-input-ring-size))) |
999 |
|
(make-local-variable 'term-input-ring-index) |
1000 |
|
(or (and (boundp 'term-input-ring-index) term-input-ring-index) |
1001 |
|
(setq term-input-ring-index nil)) |
1002 |
|
|
1003 |
|
(make-local-variable 'term-command-hook) |
1004 |
|
(setq term-command-hook (symbol-function 'term-command-hook)) |
1005 |
|
|
1006 |
|
;;; I'm not sure these saves are necessary but, since I |
1007 |
|
;;; haven't tested the whole thing on a net connected machine with |
1008 |
|
;;; a properly configured ange-ftp, I've decided to be conservative |
1009 |
|
;;; and put them in. -mm |
1010 |
|
|
1011 |
|
(make-local-variable 'term-ansi-at-host) |
1012 |
|
(setq term-ansi-at-host (system-name)) |
1013 |
|
|
1014 |
|
(make-local-variable 'term-ansi-at-dir) |
1015 |
|
(setq term-ansi-at-dir default-directory) |
1016 |
|
|
1017 |
|
(make-local-variable 'term-ansi-at-message) |
1018 |
|
(setq term-ansi-at-message nil) |
1019 |
|
|
1020 |
|
;;; For user tracking purposes -mm |
1021 |
|
(make-local-variable 'ange-ftp-default-user) |
1022 |
|
(make-local-variable 'ange-ftp-default-password) |
1023 |
|
(make-local-variable 'ange-ftp-generate-anonymous-password) |
1024 |
|
|
1025 |
|
;;; You may want to have different scroll-back sizes -mm |
1026 |
|
(make-local-variable 'term-buffer-maximum-size) |
1027 |
|
|
1028 |
|
;;; Of course these have to be buffer-local -mm |
1029 |
|
(make-local-variable 'term-ansi-current-bold) |
1030 |
|
(make-local-variable 'term-ansi-current-color) |
1031 |
|
(make-local-variable 'term-ansi-face-already-done) |
1032 |
|
(make-local-variable 'term-ansi-current-bg-color) |
1033 |
|
(make-local-variable 'term-ansi-current-underline) |
1034 |
|
(make-local-variable 'term-ansi-current-highlight) |
1035 |
|
(make-local-variable 'term-ansi-current-reverse) |
1036 |
|
(make-local-variable 'term-ansi-current-invisible) |
1037 |
|
|
1038 |
|
(make-local-variable 'term-terminal-state) |
1039 |
|
(make-local-variable 'term-kill-echo-list) |
1040 |
|
(make-local-variable 'term-start-line-column) |
1041 |
|
(make-local-variable 'term-current-column) |
1042 |
|
(make-local-variable 'term-current-row) |
1043 |
|
(make-local-variable 'term-log-buffer) |
1044 |
|
(make-local-variable 'term-scroll-start) |
1045 |
|
(make-local-variable 'term-scroll-end) |
1046 |
|
(setq term-scroll-end term-height) |
1047 |
|
(make-local-variable 'term-scroll-with-delete) |
1048 |
|
(make-local-variable 'term-pager-count) |
1049 |
|
(make-local-variable 'term-pager-old-local-map) |
1050 |
|
(make-local-variable 'term-old-mode-map) |
1051 |
|
(make-local-variable 'term-insert-mode) |
1052 |
|
(make-local-variable 'term-dynamic-complete-functions) |
1053 |
|
(make-local-variable 'term-completion-fignore) |
1054 |
|
(make-local-variable 'term-get-old-input) |
1055 |
|
(make-local-variable 'term-matching-input-from-input-string) |
1056 |
|
(make-local-variable 'term-input-autoexpand) |
1057 |
|
(make-local-variable 'term-input-ignoredups) |
1058 |
|
(make-local-variable 'term-delimiter-argument-list) |
1059 |
|
(make-local-variable 'term-input-filter-functions) |
1060 |
|
(make-local-variable 'term-input-filter) |
1061 |
|
(make-local-variable 'term-input-sender) |
1062 |
|
(make-local-variable 'term-eol-on-send) |
1063 |
|
(make-local-variable 'term-scroll-to-bottom-on-output) |
1064 |
|
(make-local-variable 'term-scroll-show-maximum-output) |
1065 |
|
(make-local-variable 'term-ptyp) |
1066 |
|
(make-local-variable 'term-exec-hook) |
1067 |
|
(make-local-variable 'term-vertical-motion) |
1068 |
|
(make-local-variable 'term-pending-delete-marker) |
1069 |
|
(setq term-pending-delete-marker (make-marker)) |
1070 |
|
(make-local-variable 'term-current-face) |
1071 |
|
(make-local-variable 'term-pending-frame) |
1072 |
|
(setq term-pending-frame nil) |
1073 |
|
(run-hooks 'term-mode-hook) |
1074 |
|
(term-if-xemacs |
1075 |
|
(set-buffer-menubar |
1076 |
|
(append current-menubar (list term-terminal-menu)))) |
1077 |
|
(or term-input-ring |
1078 |
|
(setq term-input-ring (make-ring term-input-ring-size))) |
1079 |
|
(term-update-mode-line)) |
1080 |
|
|
1081 |
(defun term-reset-size (height width) |
(defun term-reset-size (height width) |
1082 |
(setq term-height height) |
(setq term-height height) |
1083 |
(setq term-width width) |
(setq term-width width) |
1190 |
(defun term-send-next () (interactive) (term-send-raw-string "\e[6~")) |
(defun term-send-next () (interactive) (term-send-raw-string "\e[6~")) |
1191 |
(defun term-send-del () (interactive) (term-send-raw-string "\C-?")) |
(defun term-send-del () (interactive) (term-send-raw-string "\C-?")) |
1192 |
(defun term-send-backspace () (interactive) (term-send-raw-string "\C-H")) |
(defun term-send-backspace () (interactive) (term-send-raw-string "\C-H")) |
1193 |
|
|
|
(defun term-set-escape-char (c) |
|
|
"Change term-escape-char and keymaps that depend on it." |
|
|
(if term-escape-char |
|
|
(define-key term-raw-map term-escape-char 'term-send-raw)) |
|
|
(setq c (make-string 1 c)) |
|
|
(define-key term-raw-map c term-raw-escape-map) |
|
|
;; Define standard bindings in term-raw-escape-map |
|
|
(define-key term-raw-escape-map "\C-x" |
|
|
(lookup-key (current-global-map) "\C-x")) |
|
|
(define-key term-raw-escape-map "\C-v" |
|
|
(lookup-key (current-global-map) "\C-v")) |
|
|
(define-key term-raw-escape-map "\C-u" |
|
|
(lookup-key (current-global-map) "\C-u")) |
|
|
(define-key term-raw-escape-map c 'term-send-raw) |
|
|
(define-key term-raw-escape-map "\C-q" 'term-pager-toggle) |
|
|
;; The keybinding for term-char-mode is needed by the menubar code. |
|
|
(define-key term-raw-escape-map "\C-k" 'term-char-mode) |
|
|
(define-key term-raw-escape-map "\C-j" 'term-line-mode) |
|
|
;; It's convenient to have execute-extended-command here. |
|
|
(define-key term-raw-escape-map [?\M-x] 'execute-extended-command)) |
|
|
|
|
1194 |
(defun term-char-mode () |
(defun term-char-mode () |
1195 |
"Switch to char (\"raw\") sub-mode of term mode. |
"Switch to char (\"raw\") sub-mode of term mode. |
1196 |
Each character you type is sent directly to the inferior without |
Each character you type is sent directly to the inferior without |
1197 |
intervention from Emacs, except for the escape character (usually C-c)." |
intervention from Emacs, except for the escape character (usually C-c)." |
1198 |
(interactive) |
(interactive) |
|
(if (not term-raw-map) |
|
|
(let* ((map (make-keymap)) |
|
|
(esc-map (make-keymap)) |
|
|
(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) |
|
|
(setq i (1+ i))) |
|
|
(dolist (elm (generic-character-list)) |
|
|
(define-key map (vector elm) 'term-send-raw)) |
|
|
(define-key map "\e" esc-map) |
|
|
(setq term-raw-map map) |
|
|
(setq term-raw-escape-map |
|
|
(copy-keymap (lookup-key (current-global-map) "\C-x"))) |
|
|
|
|
|
;;; Added nearly all the 'grey keys' -mm |
|
|
|
|
|
(progn |
|
|
(term-if-xemacs |
|
|
(define-key term-raw-map [button2] 'term-mouse-paste)) |
|
|
(term-ifnot-xemacs |
|
|
(define-key term-raw-map [mouse-2] 'term-mouse-paste) |
|
|
(define-key term-raw-map [menu-bar terminal] term-terminal-menu) |
|
|
(define-key term-raw-map [menu-bar signals] term-signals-menu)) |
|
|
(define-key term-raw-map [up] 'term-send-up) |
|
|
(define-key term-raw-map [down] 'term-send-down) |
|
|
(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 [backspace] 'term-send-backspace) |
|
|
(define-key term-raw-map [home] 'term-send-home) |
|
|
(define-key term-raw-map [end] 'term-send-end) |
|
|
(define-key term-raw-map [prior] 'term-send-prior) |
|
|
(define-key term-raw-map [next] 'term-send-next)) |
|
|
|
|
|
|
|
|
(term-set-escape-char ?\C-c))) |
|
1199 |
;; FIXME: Emit message? Cfr ilisp-raw-message |
;; FIXME: Emit message? Cfr ilisp-raw-message |
1200 |
(if (term-in-line-mode) |
(if (term-in-line-mode) |
1201 |
(progn |
(progn |
1258 |
|
|
1259 |
;;;###autoload |
;;;###autoload |
1260 |
(defun term (program) |
(defun term (program) |
1261 |
"Start a terminal-emulator in a new buffer." |
"Start a terminal-emulator in a new buffer. |
1262 |
|
The buffer is in Term mode; see `term-mode' for the |
1263 |
|
commands to use in that buffer. |
1264 |
|
|
1265 |
|
\\<term-raw-map>Type \\[switch-to-buffer] to switch to another buffer." |
1266 |
(interactive (list (read-from-minibuffer "Run program: " |
(interactive (list (read-from-minibuffer "Run program: " |
1267 |
(or explicit-shell-file-name |
(or explicit-shell-file-name |
1268 |
(getenv "ESHELL") |
(getenv "ESHELL") |
2688 |
(term-move-columns columns) |
(term-move-columns columns) |
2689 |
(delete-region pos (point)))) |
(delete-region pos (point)))) |
2690 |
(setq term-current-column nil) |
(setq term-current-column nil) |
2691 |
|
|
2692 |
(put-text-property old-point (point) |
(put-text-property old-point (point) |
2693 |
'face term-current-face) |
'face term-current-face) |
2694 |
;; If the last char was written in last column, |
;; If the last char was written in last column, |
2955 |
|
|
2956 |
;;; 0 (Reset) or unknown (reset anyway) |
;;; 0 (Reset) or unknown (reset anyway) |
2957 |
(t |
(t |
2958 |
(setq term-current-face |
(setq term-current-face nil) |
|
(list 'term-default-fg 'term-default-bg)) |
|
2959 |
(setq term-ansi-current-underline 0) |
(setq term-ansi-current-underline 0) |
2960 |
(setq term-ansi-current-bold 0) |
(setq term-ansi-current-bold 0) |
2961 |
(setq term-ansi-current-reverse 0) |
(setq term-ansi-current-reverse 0) |
2962 |
(setq term-ansi-current-color 0) |
(setq term-ansi-current-color 0) |
2963 |
(setq term-ansi-current-invisible 0) |
(setq term-ansi-current-invisible 0) |
2964 |
(setq term-ansi-face-alredy-done 1) |
(setq term-ansi-face-already-done 1) |
2965 |
(setq term-ansi-current-bg-color 0))) |
(setq term-ansi-current-bg-color 0))) |
2966 |
|
|
2967 |
; (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d" |
; (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d" |
2969 |
; term-ansi-current-reverse |
; term-ansi-current-reverse |
2970 |
; term-ansi-current-bold |
; term-ansi-current-bold |
2971 |
; term-ansi-current-invisible |
; term-ansi-current-invisible |
2972 |
; term-ansi-face-alredy-done |
; term-ansi-face-already-done |
2973 |
; term-ansi-current-color |
; term-ansi-current-color |
2974 |
; term-ansi-current-bg-color) |
; term-ansi-current-bg-color) |
2975 |
|
|
2976 |
|
|
2977 |
(if (= term-ansi-face-alredy-done 0) |
(if (= term-ansi-face-already-done 0) |
2978 |
(if (= term-ansi-current-reverse 1) |
(if (= term-ansi-current-reverse 1) |
2979 |
(progn |
(if (= term-ansi-current-invisible 1) |
2980 |
(if (= term-ansi-current-invisible 1) |
(setq term-current-face |
2981 |
(if (= term-ansi-current-color 0) |
(if (= term-ansi-current-color 0) |
2982 |
(setq term-current-face |
(list :background |
2983 |
'(term-default-bg-inv term-default-fg)) |
term-default-fg-color |
2984 |
(setq term-current-face |
:foreground |
2985 |
(list (elt ansi-term-inv-fg-faces-vector term-ansi-current-color) |
term-default-fg-color) |
2986 |
(elt ansi-term-inv-bg-faces-vector term-ansi-current-color)))) |
(list :background |
2987 |
;; No need to bother with anything else if it's invisible |
(elt ansi-term-color-vector term-ansi-current-color) |
2988 |
(progn |
:foreground |
2989 |
|
(elt ansi-term-color-vector term-ansi-current-color))) |
2990 |
|
;; No need to bother with anything else if it's invisible |
2991 |
|
) |
2992 |
|
(setq term-current-face |
2993 |
|
(list :background |
2994 |
|
(elt ansi-term-color-vector term-ansi-current-color) |
2995 |
|
:foreground |
2996 |
|
(elt ansi-term-color-vector term-ansi-current-bg-color))) |
2997 |
|
(if (= term-ansi-current-bold 1) |
2998 |
(setq term-current-face |
(setq term-current-face |
2999 |
(list (elt ansi-term-inv-fg-faces-vector term-ansi-current-color) |
(append '(:weight bold) term-current-face))) |
3000 |
(elt ansi-term-inv-bg-faces-vector term-ansi-current-bg-color))) |
(if (= term-ansi-current-underline 1) |
|
(if (= term-ansi-current-bold 1) |
|
|
(setq term-current-face |
|
|
(append '(term-bold) term-current-face))) |
|
|
(if (= term-ansi-current-underline 1) |
|
|
(setq term-current-face |
|
|
(append '(term-underline) term-current-face)))))) |
|
|
(if (= term-ansi-current-invisible 1) |
|
|
(if (= term-ansi-current-bg-color 0) |
|
3001 |
(setq term-current-face |
(setq term-current-face |
3002 |
'(term-default-fg-inv term-default-bg)) |
(append '(:underline t) term-current-face)))) |
3003 |
(setq term-current-face |
(if (= term-ansi-current-invisible 1) |
3004 |
(list (elt ansi-term-fg-faces-vector term-ansi-current-bg-color) |
(setq term-current-face |
3005 |
(elt ansi-term-bg-faces-vector term-ansi-current-bg-color)))) |
(if (= term-ansi-current-bg-color 0) |
3006 |
;; No need to bother with anything else if it's invisible |
(list :background |
3007 |
|
term-default-bg-color |
3008 |
|
:foreground |
3009 |
|
term-default-bg-color) |
3010 |
|
(list :foreground |
3011 |
|
(elt ansi-term-color-vector term-ansi-current-bg-color) |
3012 |
|
:background |
3013 |
|
(elt ansi-term-color-vector term-ansi-current-bg-color))) |
3014 |
|
;; No need to bother with anything else if it's invisible |
3015 |
|
) |
3016 |
(setq term-current-face |
(setq term-current-face |
3017 |
(list (elt ansi-term-fg-faces-vector term-ansi-current-color) |
(list :foreground |
3018 |
(elt ansi-term-bg-faces-vector term-ansi-current-bg-color))) |
(elt ansi-term-color-vector term-ansi-current-color) |
3019 |
|
:background |
3020 |
|
(elt ansi-term-color-vector term-ansi-current-bg-color))) |
3021 |
(if (= term-ansi-current-bold 1) |
(if (= term-ansi-current-bold 1) |
3022 |
(setq term-current-face |
(setq term-current-face |
3023 |
(append '(term-bold) term-current-face))) |
(append '(:weight bold) term-current-face))) |
3024 |
(if (= term-ansi-current-underline 1) |
(if (= term-ansi-current-underline 1) |
3025 |
(setq term-current-face |
(setq term-current-face |
3026 |
(append '(term-underline) term-current-face)))))) |
(append '(:underline t) term-current-face)))))) |
3027 |
|
|
3028 |
; (message "Debug %S" term-current-face) |
; (message "Debug %S" term-current-face) |
3029 |
|
|
3030 |
(setq term-ansi-face-alredy-done 0)) |
(setq term-ansi-face-already-done 0)) |
3031 |
|
|
3032 |
|
|
3033 |
;;; Handle a character assuming (eq terminal-state 2) - |
;;; Handle a character assuming (eq terminal-state 2) - |
3166 |
;; Default value for the symbol term-command-hook. |
;; Default value for the symbol term-command-hook. |
3167 |
|
|
3168 |
(defun term-command-hook (string) |
(defun term-command-hook (string) |
3169 |
(cond ((= (aref string 0) ?\032) |
(cond ((equal string "") |
3170 |
|
t) |
3171 |
|
((= (aref string 0) ?\032) |
3172 |
;; gdb (when invoked with -fullname) prints: |
;; gdb (when invoked with -fullname) prints: |
3173 |
;; \032\032FULLFILENAME:LINENUMBER:CHARPOS:BEG_OR_MIDDLE:PC\n |
;; \032\032FULLFILENAME:LINENUMBER:CHARPOS:BEG_OR_MIDDLE:PC\n |
3174 |
(let* ((first-colon (string-match ":" string 1)) |
(let* ((first-colon (string-match ":" string 1)) |
3739 |
(t (car term-completion-addsuffix)))) |
(t (car term-completion-addsuffix)))) |
3740 |
(filesuffix (cond ((not term-completion-addsuffix) "") |
(filesuffix (cond ((not term-completion-addsuffix) "") |
3741 |
((not (consp term-completion-addsuffix)) " ") |
((not (consp term-completion-addsuffix)) " ") |
3742 |
(t (cdr term-completion-addsuffix)))) |
(t (cdr term-completion-addsuffix)))) |
3743 |
(filename (or (term-match-partial-filename) "")) |
(filename (or (term-match-partial-filename) "")) |
3744 |
(pathdir (file-name-directory filename)) |
(pathdir (file-name-directory filename)) |
3745 |
(pathnondir (file-name-nondirectory filename)) |
(pathnondir (file-name-nondirectory filename)) |