diff options
| author | Miles Bader | 2006-06-07 18:05:10 +0000 |
|---|---|---|
| committer | Miles Bader | 2006-06-07 18:05:10 +0000 |
| commit | b883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb (patch) | |
| tree | de3804210a8cd955e0d3b9abc15679480930bc82 /lisp/term.el | |
| parent | 885b7d0991bd4b4b8f4bd1d3cd21c18a697bbce2 (diff) | |
| parent | 26c9afc3239e18b03537faaea33e3e82e28099e6 (diff) | |
| download | emacs-b883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb.tar.gz emacs-b883cdb2fefa8ea9c3b0d82eba7a9ee792f871bb.zip | |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 285-296)
- Update from CVS
- Merge from gnus--rel--5.10
- Update from CVS: admin/FOR-RELEASE: Update refcard section.
* gnus--rel--5.10 (patch 102-104)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
Diffstat (limited to 'lisp/term.el')
| -rw-r--r-- | lisp/term.el | 798 |
1 files changed, 388 insertions, 410 deletions
diff --git a/lisp/term.el b/lisp/term.el index 64f0efc767b..9ecb1efa948 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -660,13 +660,6 @@ Buffer local variable.") | |||
| 660 | (put 'term-scroll-show-maximum-output 'permanent-local t) | 660 | (put 'term-scroll-show-maximum-output 'permanent-local t) |
| 661 | (put 'term-ptyp 'permanent-local t) | 661 | (put 'term-ptyp 'permanent-local t) |
| 662 | 662 | ||
| 663 | ;; Do FORM if running under XEmacs (previously Lucid Emacs). | ||
| 664 | (defmacro term-if-xemacs (&rest forms) | ||
| 665 | (if (featurep 'xemacs) (cons 'progn forms))) | ||
| 666 | ;; Do FORM if NOT running under XEmacs (previously Lucid Emacs). | ||
| 667 | (defmacro term-ifnot-xemacs (&rest forms) | ||
| 668 | (if (not (featurep 'xemacs)) (cons 'progn forms))) | ||
| 669 | |||
| 670 | (defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map)) | 663 | (defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map)) |
| 671 | (defmacro term-in-line-mode () '(not (term-in-char-mode))) | 664 | (defmacro term-in-line-mode () '(not (term-in-char-mode))) |
| 672 | ;; True if currently doing PAGER handling. | 665 | ;; True if currently doing PAGER handling. |
| @@ -725,13 +718,13 @@ Notice that a setting of 0 means 'don't truncate anything'. This variable | |||
| 725 | is buffer-local.") | 718 | is buffer-local.") |
| 726 | ;;; | 719 | ;;; |
| 727 | 720 | ||
| 728 | (term-if-xemacs | 721 | (when (featurep 'xemacs) |
| 729 | (defvar term-terminal-menu | 722 | (defvar term-terminal-menu |
| 730 | '("Terminal" | 723 | '("Terminal" |
| 731 | [ "Character mode" term-char-mode (term-in-line-mode)] | 724 | [ "Character mode" term-char-mode (term-in-line-mode)] |
| 732 | [ "Line mode" term-line-mode (term-in-char-mode)] | 725 | [ "Line mode" term-line-mode (term-in-char-mode)] |
| 733 | [ "Enable paging" term-pager-toggle (not term-pager-count)] | 726 | [ "Enable paging" term-pager-toggle (not term-pager-count)] |
| 734 | [ "Disable paging" term-pager-toggle term-pager-count]))) | 727 | [ "Disable paging" term-pager-toggle term-pager-count]))) |
| 735 | 728 | ||
| 736 | (unless term-mode-map | 729 | (unless term-mode-map |
| 737 | (setq term-mode-map (make-sparse-keymap)) | 730 | (setq term-mode-map (make-sparse-keymap)) |
| @@ -739,10 +732,10 @@ is buffer-local.") | |||
| 739 | (define-key term-mode-map "\en" 'term-next-input) | 732 | (define-key term-mode-map "\en" 'term-next-input) |
| 740 | (define-key term-mode-map "\er" 'term-previous-matching-input) | 733 | (define-key term-mode-map "\er" 'term-previous-matching-input) |
| 741 | (define-key term-mode-map "\es" 'term-next-matching-input) | 734 | (define-key term-mode-map "\es" 'term-next-matching-input) |
| 742 | (term-ifnot-xemacs | 735 | (unless (featurep 'xemacs) |
| 743 | (define-key term-mode-map [?\A-\M-r] | 736 | (define-key term-mode-map [?\A-\M-r] |
| 744 | 'term-previous-matching-input-from-input) | 737 | 'term-previous-matching-input-from-input) |
| 745 | (define-key term-mode-map [?\A-\M-s] 'term-next-matching-input-from-input)) | 738 | (define-key term-mode-map [?\A-\M-s] 'term-next-matching-input-from-input)) |
| 746 | (define-key term-mode-map "\e\C-l" 'term-show-output) | 739 | (define-key term-mode-map "\e\C-l" 'term-show-output) |
| 747 | (define-key term-mode-map "\C-m" 'term-send-input) | 740 | (define-key term-mode-map "\C-m" 'term-send-input) |
| 748 | (define-key term-mode-map "\C-d" 'term-delchar-or-maybe-eof) | 741 | (define-key term-mode-map "\C-d" 'term-delchar-or-maybe-eof) |
| @@ -781,9 +774,7 @@ is buffer-local.") | |||
| 781 | ) | 774 | ) |
| 782 | 775 | ||
| 783 | ;; Menu bars: | 776 | ;; Menu bars: |
| 784 | (term-ifnot-xemacs | 777 | (unless (featurep 'xemacs) |
| 785 | (progn | ||
| 786 | |||
| 787 | ;; terminal: | 778 | ;; terminal: |
| 788 | (let (newmap) | 779 | (let (newmap) |
| 789 | (setq newmap (make-sparse-keymap "Terminal")) | 780 | (setq newmap (make-sparse-keymap "Terminal")) |
| @@ -860,14 +851,14 @@ is buffer-local.") | |||
| 860 | (define-key newmap [] '("BREAK" . term-interrupt-subjob)) | 851 | (define-key newmap [] '("BREAK" . term-interrupt-subjob)) |
| 861 | (define-key term-mode-map [menu-bar signals] | 852 | (define-key term-mode-map [menu-bar signals] |
| 862 | (setq term-signals-menu (cons "Signals" newmap))) | 853 | (setq term-signals-menu (cons "Signals" newmap))) |
| 863 | ))) | 854 | )) |
| 864 | 855 | ||
| 865 | ;; Set up term-raw-map, etc. | 856 | ;; Set up term-raw-map, etc. |
| 866 | 857 | ||
| 867 | (defun term-set-escape-char (c) | 858 | (defun term-set-escape-char (c) |
| 868 | "Change term-escape-char and keymaps that depend on it." | 859 | "Change term-escape-char and keymaps that depend on it." |
| 869 | (if term-escape-char | 860 | (when term-escape-char |
| 870 | (define-key term-raw-map term-escape-char 'term-send-raw)) | 861 | (define-key term-raw-map term-escape-char 'term-send-raw)) |
| 871 | (setq c (make-string 1 c)) | 862 | (setq c (make-string 1 c)) |
| 872 | (define-key term-raw-map c term-raw-escape-map) | 863 | (define-key term-raw-map c term-raw-escape-map) |
| 873 | ;; Define standard bindings in term-raw-escape-map | 864 | ;; Define standard bindings in term-raw-escape-map |
| @@ -899,28 +890,26 @@ is buffer-local.") | |||
| 899 | 890 | ||
| 900 | ;;; Added nearly all the 'grey keys' -mm | 891 | ;;; Added nearly all the 'grey keys' -mm |
| 901 | 892 | ||
| 902 | (progn | 893 | (if (featurep 'xemacs) |
| 903 | (term-if-xemacs | 894 | (define-key term-raw-map [button2] 'term-mouse-paste) |
| 904 | (define-key term-raw-map [button2] 'term-mouse-paste)) | 895 | (define-key term-raw-map [mouse-2] 'term-mouse-paste) |
| 905 | (term-ifnot-xemacs | 896 | (define-key term-raw-map [menu-bar terminal] term-terminal-menu) |
| 906 | (define-key term-raw-map [mouse-2] 'term-mouse-paste) | 897 | (define-key term-raw-map [menu-bar signals] term-signals-menu)) |
| 907 | (define-key term-raw-map [menu-bar terminal] term-terminal-menu) | 898 | (define-key term-raw-map [up] 'term-send-up) |
| 908 | (define-key term-raw-map [menu-bar signals] term-signals-menu)) | 899 | (define-key term-raw-map [down] 'term-send-down) |
| 909 | (define-key term-raw-map [up] 'term-send-up) | 900 | (define-key term-raw-map [right] 'term-send-right) |
| 910 | (define-key term-raw-map [down] 'term-send-down) | 901 | (define-key term-raw-map [left] 'term-send-left) |
| 911 | (define-key term-raw-map [right] 'term-send-right) | 902 | (define-key term-raw-map [delete] 'term-send-del) |
| 912 | (define-key term-raw-map [left] 'term-send-left) | 903 | (define-key term-raw-map [deletechar] 'term-send-del) |
| 913 | (define-key term-raw-map [delete] 'term-send-del) | 904 | (define-key term-raw-map [backspace] 'term-send-backspace) |
| 914 | (define-key term-raw-map [deletechar] 'term-send-del) | 905 | (define-key term-raw-map [home] 'term-send-home) |
| 915 | (define-key term-raw-map [backspace] 'term-send-backspace) | 906 | (define-key term-raw-map [end] 'term-send-end) |
| 916 | (define-key term-raw-map [home] 'term-send-home) | 907 | (define-key term-raw-map [insert] 'term-send-insert) |
| 917 | (define-key term-raw-map [end] 'term-send-end) | 908 | (define-key term-raw-map [S-prior] 'scroll-down) |
| 918 | (define-key term-raw-map [insert] 'term-send-insert) | 909 | (define-key term-raw-map [S-next] 'scroll-up) |
| 919 | (define-key term-raw-map [S-prior] 'scroll-down) | 910 | (define-key term-raw-map [S-insert] 'term-paste) |
| 920 | (define-key term-raw-map [S-next] 'scroll-up) | 911 | (define-key term-raw-map [prior] 'term-send-prior) |
| 921 | (define-key term-raw-map [S-insert] 'term-paste) | 912 | (define-key term-raw-map [next] 'term-send-next)) |
| 922 | (define-key term-raw-map [prior] 'term-send-prior) | ||
| 923 | (define-key term-raw-map [next] 'term-send-next))) | ||
| 924 | 913 | ||
| 925 | (term-set-escape-char ?\C-c) | 914 | (term-set-escape-char ?\C-c) |
| 926 | 915 | ||
| @@ -1112,9 +1101,9 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1112 | ;; Cua-mode's keybindings interfere with the term keybindings, disable it. | 1101 | ;; Cua-mode's keybindings interfere with the term keybindings, disable it. |
| 1113 | (set (make-local-variable 'cua-mode) nil) | 1102 | (set (make-local-variable 'cua-mode) nil) |
| 1114 | (run-mode-hooks 'term-mode-hook) | 1103 | (run-mode-hooks 'term-mode-hook) |
| 1115 | (term-if-xemacs | 1104 | (when (featurep 'xemacs) |
| 1116 | (set-buffer-menubar | 1105 | (set-buffer-menubar |
| 1117 | (append current-menubar (list term-terminal-menu)))) | 1106 | (append current-menubar (list term-terminal-menu)))) |
| 1118 | (or term-input-ring | 1107 | (or term-input-ring |
| 1119 | (setq term-input-ring (make-ring term-input-ring-size))) | 1108 | (setq term-input-ring (make-ring term-input-ring-size))) |
| 1120 | (term-update-mode-line)) | 1109 | (term-update-mode-line)) |
| @@ -1151,16 +1140,15 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1151 | (setq term-start-line-column nil) | 1140 | (setq term-start-line-column nil) |
| 1152 | (setq cur nil found t)) | 1141 | (setq cur nil found t)) |
| 1153 | (setq cur (cdr cur)))))) | 1142 | (setq cur (cdr cur)))))) |
| 1154 | (if (not found) | 1143 | (when (not found) |
| 1155 | (goto-char save-point))) | 1144 | (goto-char save-point))) |
| 1156 | found)) | 1145 | found)) |
| 1157 | 1146 | ||
| 1158 | (defun term-check-size (process) | 1147 | (defun term-check-size (process) |
| 1159 | (if (or (/= term-height (1- (window-height))) | 1148 | (when (or (/= term-height (1- (window-height))) |
| 1160 | (/= term-width (term-window-width))) | 1149 | (/= term-width (term-window-width))) |
| 1161 | (progn | 1150 | (term-reset-size (1- (window-height)) (term-window-width)) |
| 1162 | (term-reset-size (1- (window-height)) (term-window-width)) | 1151 | (set-process-window-size process term-height term-width))) |
| 1163 | (set-process-window-size process term-height term-width)))) | ||
| 1164 | 1152 | ||
| 1165 | (defun term-send-raw-string (chars) | 1153 | (defun term-send-raw-string (chars) |
| 1166 | (let ((proc (get-buffer-process (current-buffer)))) | 1154 | (let ((proc (get-buffer-process (current-buffer)))) |
| @@ -1169,8 +1157,8 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1169 | ;; Note that (term-current-row) must be called *after* | 1157 | ;; Note that (term-current-row) must be called *after* |
| 1170 | ;; (point) has been updated to (process-mark proc). | 1158 | ;; (point) has been updated to (process-mark proc). |
| 1171 | (goto-char (process-mark proc)) | 1159 | (goto-char (process-mark proc)) |
| 1172 | (if (term-pager-enabled) | 1160 | (when (term-pager-enabled) |
| 1173 | (setq term-pager-count (term-current-row))) | 1161 | (setq term-pager-count (term-current-row))) |
| 1174 | (process-send-string proc chars)))) | 1162 | (process-send-string proc chars)))) |
| 1175 | 1163 | ||
| 1176 | (defun term-send-raw () | 1164 | (defun term-send-raw () |
| @@ -1178,9 +1166,9 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1178 | without any interpretation." | 1166 | without any interpretation." |
| 1179 | (interactive) | 1167 | (interactive) |
| 1180 | ;; Convert `return' to C-m, etc. | 1168 | ;; Convert `return' to C-m, etc. |
| 1181 | (if (and (symbolp last-input-char) | 1169 | (when (and (symbolp last-input-char) |
| 1182 | (get last-input-char 'ascii-character)) | 1170 | (get last-input-char 'ascii-character)) |
| 1183 | (setq last-input-char (get last-input-char 'ascii-character))) | 1171 | (setq last-input-char (get last-input-char 'ascii-character))) |
| 1184 | (term-send-raw-string (make-string 1 last-input-char))) | 1172 | (term-send-raw-string (make-string 1 last-input-char))) |
| 1185 | 1173 | ||
| 1186 | (defun term-send-raw-meta () | 1174 | (defun term-send-raw-meta () |
| @@ -1205,19 +1193,19 @@ without any interpretation." | |||
| 1205 | (defun term-mouse-paste (click arg) | 1193 | (defun term-mouse-paste (click arg) |
| 1206 | "Insert the last stretch of killed text at the position clicked on." | 1194 | "Insert the last stretch of killed text at the position clicked on." |
| 1207 | (interactive "e\nP") | 1195 | (interactive "e\nP") |
| 1208 | (term-if-xemacs | 1196 | (if (featurep 'xemacs) |
| 1209 | (term-send-raw-string (or (condition-case () (x-get-selection) (error ())) | 1197 | (term-send-raw-string |
| 1210 | (x-get-cutbuffer) | 1198 | (or (condition-case () (x-get-selection) (error ())) |
| 1211 | (error "No selection or cut buffer available")))) | 1199 | (x-get-cutbuffer) |
| 1212 | (term-ifnot-xemacs | 1200 | (error "No selection or cut buffer available"))) |
| 1213 | ;; Give temporary modes such as isearch a chance to turn off. | 1201 | ;; Give temporary modes such as isearch a chance to turn off. |
| 1214 | (run-hooks 'mouse-leave-buffer-hook) | 1202 | (run-hooks 'mouse-leave-buffer-hook) |
| 1215 | (setq this-command 'yank) | 1203 | (setq this-command 'yank) |
| 1216 | (mouse-set-point click) | 1204 | (mouse-set-point click) |
| 1217 | (term-send-raw-string (current-kill (cond | 1205 | (term-send-raw-string (current-kill (cond |
| 1218 | ((listp arg) 0) | 1206 | ((listp arg) 0) |
| 1219 | ((eq arg '-) -1) | 1207 | ((eq arg '-) -1) |
| 1220 | (t (1- arg))))))) | 1208 | (t (1- arg))))))) |
| 1221 | 1209 | ||
| 1222 | (defun term-paste () | 1210 | (defun term-paste () |
| 1223 | "Insert the last stretch of killed text at point." | 1211 | "Insert the last stretch of killed text at point." |
| @@ -1246,33 +1234,31 @@ Each character you type is sent directly to the inferior without | |||
| 1246 | intervention from Emacs, except for the escape character (usually C-c)." | 1234 | intervention from Emacs, except for the escape character (usually C-c)." |
| 1247 | (interactive) | 1235 | (interactive) |
| 1248 | ;; FIXME: Emit message? Cfr ilisp-raw-message | 1236 | ;; FIXME: Emit message? Cfr ilisp-raw-message |
| 1249 | (if (term-in-line-mode) | 1237 | (when (term-in-line-mode) |
| 1250 | (progn | 1238 | (setq term-old-mode-map (current-local-map)) |
| 1251 | (setq term-old-mode-map (current-local-map)) | 1239 | (use-local-map term-raw-map) |
| 1252 | (use-local-map term-raw-map) | 1240 | |
| 1253 | 1241 | ;; Send existing partial line to inferior (without newline). | |
| 1254 | ;; Send existing partial line to inferior (without newline). | 1242 | (let ((pmark (process-mark (get-buffer-process (current-buffer)))) |
| 1255 | (let ((pmark (process-mark (get-buffer-process (current-buffer)))) | 1243 | (save-input-sender term-input-sender)) |
| 1256 | (save-input-sender term-input-sender)) | 1244 | (when (> (point) pmark) |
| 1257 | (if (> (point) pmark) | 1245 | (unwind-protect |
| 1258 | (unwind-protect | 1246 | (progn |
| 1259 | (progn | 1247 | (setq term-input-sender |
| 1260 | (setq term-input-sender | 1248 | (symbol-function 'term-send-string)) |
| 1261 | (symbol-function 'term-send-string)) | 1249 | (end-of-line) |
| 1262 | (end-of-line) | 1250 | (term-send-input)) |
| 1263 | (term-send-input)) | 1251 | (setq term-input-sender save-input-sender)))) |
| 1264 | (setq term-input-sender save-input-sender)))) | 1252 | (term-update-mode-line))) |
| 1265 | (term-update-mode-line)))) | ||
| 1266 | 1253 | ||
| 1267 | (defun term-line-mode () | 1254 | (defun term-line-mode () |
| 1268 | "Switch to line (\"cooked\") sub-mode of term mode. | 1255 | "Switch to line (\"cooked\") sub-mode of term mode. |
| 1269 | This means that Emacs editing commands work as normally, until | 1256 | This means that Emacs editing commands work as normally, until |
| 1270 | you type \\[term-send-input] which sends the current line to the inferior." | 1257 | you type \\[term-send-input] which sends the current line to the inferior." |
| 1271 | (interactive) | 1258 | (interactive) |
| 1272 | (if (term-in-char-mode) | 1259 | (when (term-in-char-mode) |
| 1273 | (progn | 1260 | (use-local-map term-old-mode-map) |
| 1274 | (use-local-map term-old-mode-map) | 1261 | (term-update-mode-line))) |
| 1275 | (term-update-mode-line)))) | ||
| 1276 | 1262 | ||
| 1277 | (defun term-update-mode-line () | 1263 | (defun term-update-mode-line () |
| 1278 | (setq mode-line-process | 1264 | (setq mode-line-process |
| @@ -1330,7 +1316,7 @@ buffer. The hook term-exec-hook is run after each exec." | |||
| 1330 | (save-excursion | 1316 | (save-excursion |
| 1331 | (set-buffer buffer) | 1317 | (set-buffer buffer) |
| 1332 | (let ((proc (get-buffer-process buffer))) ; Blast any old process. | 1318 | (let ((proc (get-buffer-process buffer))) ; Blast any old process. |
| 1333 | (if proc (delete-process proc))) | 1319 | (when proc (delete-process proc))) |
| 1334 | ;; Crank up a new process | 1320 | ;; Crank up a new process |
| 1335 | (let ((proc (term-exec-1 name buffer command switches))) | 1321 | (let ((proc (term-exec-1 name buffer command switches))) |
| 1336 | (make-local-variable 'term-ptyp) | 1322 | (make-local-variable 'term-ptyp) |
| @@ -1360,29 +1346,28 @@ buffer. The hook term-exec-hook is run after each exec." | |||
| 1360 | "Sentinel for term buffers. | 1346 | "Sentinel for term buffers. |
| 1361 | The main purpose is to get rid of the local keymap." | 1347 | The main purpose is to get rid of the local keymap." |
| 1362 | (let ((buffer (process-buffer proc))) | 1348 | (let ((buffer (process-buffer proc))) |
| 1363 | (if (memq (process-status proc) '(signal exit)) | 1349 | (when (memq (process-status proc) '(signal exit)) |
| 1364 | (progn | 1350 | (if (null (buffer-name buffer)) |
| 1365 | (if (null (buffer-name buffer)) | 1351 | ;; buffer killed |
| 1366 | ;; buffer killed | 1352 | (set-process-buffer proc nil) |
| 1367 | (set-process-buffer proc nil) | 1353 | (let ((obuf (current-buffer))) |
| 1368 | (let ((obuf (current-buffer))) | 1354 | ;; save-excursion isn't the right thing if |
| 1369 | ;; save-excursion isn't the right thing if | 1355 | ;; process-buffer is current-buffer |
| 1370 | ;; process-buffer is current-buffer | 1356 | (unwind-protect |
| 1371 | (unwind-protect | 1357 | (progn |
| 1372 | (progn | 1358 | ;; Write something in the compilation buffer |
| 1373 | ;; Write something in the compilation buffer | 1359 | ;; and hack its mode line. |
| 1374 | ;; and hack its mode line. | 1360 | (set-buffer buffer) |
| 1375 | (set-buffer buffer) | 1361 | ;; Get rid of local keymap. |
| 1376 | ;; Get rid of local keymap. | 1362 | (use-local-map nil) |
| 1377 | (use-local-map nil) | 1363 | (term-handle-exit (process-name proc) |
| 1378 | (term-handle-exit (process-name proc) | 1364 | msg) |
| 1379 | msg) | 1365 | ;; Since the buffer and mode line will show that the |
| 1380 | ;; Since the buffer and mode line will show that the | 1366 | ;; process is dead, we can delete it now. Otherwise it |
| 1381 | ;; process is dead, we can delete it now. Otherwise it | 1367 | ;; will stay around until M-x list-processes. |
| 1382 | ;; will stay around until M-x list-processes. | 1368 | (delete-process proc)) |
| 1383 | (delete-process proc)) | 1369 | (set-buffer obuf))) |
| 1384 | (set-buffer obuf)))) | 1370 | )))) |
| 1385 | )))) | ||
| 1386 | 1371 | ||
| 1387 | (defun term-handle-exit (process-name msg) | 1372 | (defun term-handle-exit (process-name msg) |
| 1388 | "Write process exit (or other change) message MSG in the current buffer." | 1373 | "Write process exit (or other change) message MSG in the current buffer." |
| @@ -1395,8 +1380,8 @@ The main purpose is to get rid of the local keymap." | |||
| 1395 | (insert ?\n "Process " process-name " " msg) | 1380 | (insert ?\n "Process " process-name " " msg) |
| 1396 | ;; Force mode line redisplay soon. | 1381 | ;; Force mode line redisplay soon. |
| 1397 | (force-mode-line-update) | 1382 | (force-mode-line-update) |
| 1398 | (if (and opoint (< opoint omax)) | 1383 | (when (and opoint (< opoint omax)) |
| 1399 | (goto-char opoint)))) | 1384 | (goto-char opoint)))) |
| 1400 | 1385 | ||
| 1401 | 1386 | ||
| 1402 | ;;; Name to use for TERM. | 1387 | ;;; Name to use for TERM. |
| @@ -1519,9 +1504,9 @@ See also `term-input-ignoredups' and `term-write-input-ring'." | |||
| 1519 | nil t)) | 1504 | nil t)) |
| 1520 | (let ((history (buffer-substring (match-beginning 1) | 1505 | (let ((history (buffer-substring (match-beginning 1) |
| 1521 | (match-end 1)))) | 1506 | (match-end 1)))) |
| 1522 | (if (or (null term-input-ignoredups) | 1507 | (when (or (null term-input-ignoredups) |
| 1523 | (ring-empty-p ring) | 1508 | (ring-empty-p ring) |
| 1524 | (not (string-equal (ring-ref ring 0) history))) | 1509 | (not (string-equal (ring-ref ring 0) history))) |
| 1525 | (ring-insert-at-beginning ring history))) | 1510 | (ring-insert-at-beginning ring history))) |
| 1526 | (setq count (1+ count)))) | 1511 | (setq count (1+ count)))) |
| 1527 | (kill-buffer history-buf)) | 1512 | (kill-buffer history-buf)) |
| @@ -1649,15 +1634,15 @@ Moves relative to `term-input-ring-index'." | |||
| 1649 | "Return the string matching REGEXP ARG places along the input ring. | 1634 | "Return the string matching REGEXP ARG places along the input ring. |
| 1650 | Moves relative to `term-input-ring-index'." | 1635 | Moves relative to `term-input-ring-index'." |
| 1651 | (let* ((pos (term-previous-matching-input-string-position regexp arg))) | 1636 | (let* ((pos (term-previous-matching-input-string-position regexp arg))) |
| 1652 | (if pos (ring-ref term-input-ring pos)))) | 1637 | (when pos (ring-ref term-input-ring pos)))) |
| 1653 | 1638 | ||
| 1654 | (defun term-previous-matching-input-string-position | 1639 | (defun term-previous-matching-input-string-position |
| 1655 | (regexp arg &optional start) | 1640 | (regexp arg &optional start) |
| 1656 | "Return the index matching REGEXP ARG places along the input ring. | 1641 | "Return the index matching REGEXP ARG places along the input ring. |
| 1657 | Moves relative to START, or `term-input-ring-index'." | 1642 | Moves relative to START, or `term-input-ring-index'." |
| 1658 | (if (or (not (ring-p term-input-ring)) | 1643 | (when (or (not (ring-p term-input-ring)) |
| 1659 | (ring-empty-p term-input-ring)) | 1644 | (ring-empty-p term-input-ring)) |
| 1660 | (error "No history")) | 1645 | (error "No history")) |
| 1661 | (let* ((len (ring-length term-input-ring)) | 1646 | (let* ((len (ring-length term-input-ring)) |
| 1662 | (motion (if (> arg 0) 1 -1)) | 1647 | (motion (if (> arg 0) 1 -1)) |
| 1663 | (n (mod (- (or start (term-search-start arg)) motion) len)) | 1648 | (n (mod (- (or start (term-search-start arg)) motion) len)) |
| @@ -1676,8 +1661,8 @@ Moves relative to START, or `term-input-ring-index'." | |||
| 1676 | tried-each-ring-item (= n prev))) | 1661 | tried-each-ring-item (= n prev))) |
| 1677 | (setq arg (if (> arg 0) (1- arg) (1+ arg)))) | 1662 | (setq arg (if (> arg 0) (1- arg) (1+ arg)))) |
| 1678 | ;; Now that we know which ring element to use, if we found it, return that. | 1663 | ;; Now that we know which ring element to use, if we found it, return that. |
| 1679 | (if (string-match regexp (ring-ref term-input-ring n)) | 1664 | (when (string-match regexp (ring-ref term-input-ring n)) |
| 1680 | n))) | 1665 | n))) |
| 1681 | 1666 | ||
| 1682 | (defun term-previous-matching-input (regexp arg) | 1667 | (defun term-previous-matching-input (regexp arg) |
| 1683 | "Search backwards through input history for match for REGEXP. | 1668 | "Search backwards through input history for match for REGEXP. |
| @@ -1711,14 +1696,14 @@ If N is negative, find the previous or Nth previous match." | |||
| 1711 | With prefix argument N, search for Nth previous match. | 1696 | With prefix argument N, search for Nth previous match. |
| 1712 | If N is negative, search forwards for the -Nth following match." | 1697 | If N is negative, search forwards for the -Nth following match." |
| 1713 | (interactive "p") | 1698 | (interactive "p") |
| 1714 | (if (not (memq last-command '(term-previous-matching-input-from-input | 1699 | (when (not (memq last-command '(term-previous-matching-input-from-input |
| 1715 | term-next-matching-input-from-input))) | 1700 | term-next-matching-input-from-input))) |
| 1716 | ;; Starting a new search | 1701 | ;; Starting a new search |
| 1717 | (setq term-matching-input-from-input-string | 1702 | (setq term-matching-input-from-input-string |
| 1718 | (buffer-substring | 1703 | (buffer-substring |
| 1719 | (process-mark (get-buffer-process (current-buffer))) | 1704 | (process-mark (get-buffer-process (current-buffer))) |
| 1720 | (point)) | 1705 | (point)) |
| 1721 | term-input-ring-index nil)) | 1706 | term-input-ring-index nil)) |
| 1722 | (term-previous-matching-input | 1707 | (term-previous-matching-input |
| 1723 | (concat "^" (regexp-quote term-matching-input-from-input-string)) | 1708 | (concat "^" (regexp-quote term-matching-input-from-input-string)) |
| 1724 | arg)) | 1709 | arg)) |
| @@ -1750,15 +1735,15 @@ See `term-magic-space' and `term-replace-by-expanded-history-before-point'. | |||
| 1750 | 1735 | ||
| 1751 | Returns t if successful." | 1736 | Returns t if successful." |
| 1752 | (interactive) | 1737 | (interactive) |
| 1753 | (if (and term-input-autoexpand | 1738 | (when (and term-input-autoexpand |
| 1754 | (string-match "[!^]" (funcall term-get-old-input)) | 1739 | (string-match "[!^]" (funcall term-get-old-input)) |
| 1755 | (save-excursion (beginning-of-line) | 1740 | (save-excursion (beginning-of-line) |
| 1756 | (looking-at term-prompt-regexp))) | 1741 | (looking-at term-prompt-regexp))) |
| 1757 | ;; Looks like there might be history references in the command. | 1742 | ;; Looks like there might be history references in the command. |
| 1758 | (let ((previous-modified-tick (buffer-modified-tick))) | 1743 | (let ((previous-modified-tick (buffer-modified-tick))) |
| 1759 | (message "Expanding history references...") | 1744 | (message "Expanding history references...") |
| 1760 | (term-replace-by-expanded-history-before-point silent) | 1745 | (term-replace-by-expanded-history-before-point silent) |
| 1761 | (/= previous-modified-tick (buffer-modified-tick))))) | 1746 | (/= previous-modified-tick (buffer-modified-tick))))) |
| 1762 | 1747 | ||
| 1763 | 1748 | ||
| 1764 | (defun term-replace-by-expanded-history-before-point (silent) | 1749 | (defun term-replace-by-expanded-history-before-point (silent) |
| @@ -2024,17 +2009,17 @@ Similarly for Soar, Scheme, etc." | |||
| 2024 | (delete-region pmark (point)) | 2009 | (delete-region pmark (point)) |
| 2025 | (insert input) | 2010 | (insert input) |
| 2026 | copy)))) | 2011 | copy)))) |
| 2027 | (if (term-pager-enabled) | 2012 | (when (term-pager-enabled) |
| 2028 | (save-excursion | 2013 | (save-excursion |
| 2029 | (goto-char (process-mark proc)) | 2014 | (goto-char (process-mark proc)) |
| 2030 | (setq term-pager-count (term-current-row)))) | 2015 | (setq term-pager-count (term-current-row)))) |
| 2031 | (if (and (funcall term-input-filter history) | 2016 | (when (and (funcall term-input-filter history) |
| 2032 | (or (null term-input-ignoredups) | 2017 | (or (null term-input-ignoredups) |
| 2033 | (not (ring-p term-input-ring)) | 2018 | (not (ring-p term-input-ring)) |
| 2034 | (ring-empty-p term-input-ring) | 2019 | (ring-empty-p term-input-ring) |
| 2035 | (not (string-equal (ring-ref term-input-ring 0) | 2020 | (not (string-equal (ring-ref term-input-ring 0) |
| 2036 | history)))) | 2021 | history)))) |
| 2037 | (ring-insert term-input-ring history)) | 2022 | (ring-insert term-input-ring history)) |
| 2038 | (let ((functions term-input-filter-functions)) | 2023 | (let ((functions term-input-filter-functions)) |
| 2039 | (while functions | 2024 | (while functions |
| 2040 | (funcall (car functions) (concat input "\n")) | 2025 | (funcall (car functions) (concat input "\n")) |
| @@ -2045,13 +2030,12 @@ Similarly for Soar, Scheme, etc." | |||
| 2045 | ;; in case we get output amidst sending the input. | 2030 | ;; in case we get output amidst sending the input. |
| 2046 | (set-marker term-last-input-start pmark) | 2031 | (set-marker term-last-input-start pmark) |
| 2047 | (set-marker term-last-input-end (point)) | 2032 | (set-marker term-last-input-end (point)) |
| 2048 | (if input-is-new | 2033 | (when input-is-new |
| 2049 | (progn | 2034 | ;; Set up to delete, because inferior should echo. |
| 2050 | ;; Set up to delete, because inferior should echo. | 2035 | (when (marker-buffer term-pending-delete-marker) |
| 2051 | (if (marker-buffer term-pending-delete-marker) | 2036 | (delete-region term-pending-delete-marker pmark)) |
| 2052 | (delete-region term-pending-delete-marker pmark)) | 2037 | (set-marker term-pending-delete-marker pmark-val) |
| 2053 | (set-marker term-pending-delete-marker pmark-val) | 2038 | (set-marker (process-mark proc) (point))) |
| 2054 | (set-marker (process-mark proc) (point)))) | ||
| 2055 | (goto-char pmark) | 2039 | (goto-char pmark) |
| 2056 | (funcall term-input-sender proc input))))) | 2040 | (funcall term-input-sender proc input))))) |
| 2057 | 2041 | ||
| @@ -2081,9 +2065,9 @@ Calls `term-get-old-input' to get old input." | |||
| 2081 | "Skip past the text matching regexp term-prompt-regexp. | 2065 | "Skip past the text matching regexp term-prompt-regexp. |
| 2082 | If this takes us past the end of the current line, don't skip at all." | 2066 | If this takes us past the end of the current line, don't skip at all." |
| 2083 | (let ((eol (save-excursion (end-of-line) (point)))) | 2067 | (let ((eol (save-excursion (end-of-line) (point)))) |
| 2084 | (if (and (looking-at term-prompt-regexp) | 2068 | (when (and (looking-at term-prompt-regexp) |
| 2085 | (<= (match-end 0) eol)) | 2069 | (<= (match-end 0) eol)) |
| 2086 | (goto-char (match-end 0))))) | 2070 | (goto-char (match-end 0))))) |
| 2087 | 2071 | ||
| 2088 | 2072 | ||
| 2089 | (defun term-after-pmark-p () | 2073 | (defun term-after-pmark-p () |
| @@ -2112,7 +2096,7 @@ The prompt skip is done by skipping text matching the regular expression | |||
| 2112 | term-prompt-regexp, a buffer local variable." | 2096 | term-prompt-regexp, a buffer local variable." |
| 2113 | (interactive "P") | 2097 | (interactive "P") |
| 2114 | (beginning-of-line) | 2098 | (beginning-of-line) |
| 2115 | (if (null arg) (term-skip-prompt))) | 2099 | (when (null arg) (term-skip-prompt))) |
| 2116 | 2100 | ||
| 2117 | ;;; These two functions are for entering text you don't want echoed or | 2101 | ;;; These two functions are for entering text you don't want echoed or |
| 2118 | ;;; saved -- typically passwords to ftp, telnet, or somesuch. | 2102 | ;;; saved -- typically passwords to ftp, telnet, or somesuch. |
| @@ -2173,10 +2157,10 @@ is additionally sent. String is not saved on term input history list. | |||
| 2173 | Security bug: your string can still be temporarily recovered with | 2157 | Security bug: your string can still be temporarily recovered with |
| 2174 | \\[view-lossage]." | 2158 | \\[view-lossage]." |
| 2175 | (interactive "P") ; Defeat snooping via C-x esc | 2159 | (interactive "P") ; Defeat snooping via C-x esc |
| 2176 | (if (not (stringp str)) | 2160 | (when (not (stringp str)) |
| 2177 | (setq str (term-read-noecho "Non-echoed text: " t))) | 2161 | (setq str (term-read-noecho "Non-echoed text: " t))) |
| 2178 | (if (not proc) | 2162 | (when (not proc) |
| 2179 | (setq proc (get-buffer-process (current-buffer)))) | 2163 | (setq proc (get-buffer-process (current-buffer)))) |
| 2180 | (if (not proc) (error "Current buffer has no process") | 2164 | (if (not proc) (error "Current buffer has no process") |
| 2181 | (setq term-kill-echo-list (nconc term-kill-echo-list | 2165 | (setq term-kill-echo-list (nconc term-kill-echo-list |
| 2182 | (cons str nil))) | 2166 | (cons str nil))) |
| @@ -2268,8 +2252,8 @@ Useful if you accidentally suspend the top-level process." | |||
| 2268 | (interactive) | 2252 | (interactive) |
| 2269 | (let* ((pmark (process-mark (get-buffer-process (current-buffer)))) | 2253 | (let* ((pmark (process-mark (get-buffer-process (current-buffer)))) |
| 2270 | (p-pos (marker-position pmark))) | 2254 | (p-pos (marker-position pmark))) |
| 2271 | (if (> (point) p-pos) | 2255 | (when (> (point) p-pos) |
| 2272 | (kill-region pmark (point))))) | 2256 | (kill-region pmark (point))))) |
| 2273 | 2257 | ||
| 2274 | (defun term-delchar-or-maybe-eof (arg) | 2258 | (defun term-delchar-or-maybe-eof (arg) |
| 2275 | "Delete ARG characters forward, or send an EOF to process if at end of | 2259 | "Delete ARG characters forward, or send an EOF to process if at end of |
| @@ -2277,7 +2261,7 @@ buffer." | |||
| 2277 | (interactive "p") | 2261 | (interactive "p") |
| 2278 | (if (eobp) | 2262 | (if (eobp) |
| 2279 | (process-send-eof) | 2263 | (process-send-eof) |
| 2280 | (delete-char arg))) | 2264 | (delete-char arg))) |
| 2281 | 2265 | ||
| 2282 | (defun term-send-eof () | 2266 | (defun term-send-eof () |
| 2283 | "Send an EOF to the current buffer's process." | 2267 | "Send an EOF to the current buffer's process." |
| @@ -2292,8 +2276,8 @@ If N is negative, find the next or Nth next match." | |||
| 2292 | (interactive (term-regexp-arg "Backward input matching (regexp): ")) | 2276 | (interactive (term-regexp-arg "Backward input matching (regexp): ")) |
| 2293 | (let* ((re (concat term-prompt-regexp ".*" regexp)) | 2277 | (let* ((re (concat term-prompt-regexp ".*" regexp)) |
| 2294 | (pos (save-excursion (end-of-line (if (> arg 0) 0 1)) | 2278 | (pos (save-excursion (end-of-line (if (> arg 0) 0 1)) |
| 2295 | (if (re-search-backward re nil t arg) | 2279 | (when (re-search-backward re nil t arg) |
| 2296 | (point))))) | 2280 | (point))))) |
| 2297 | (if (null pos) | 2281 | (if (null pos) |
| 2298 | (progn (message "Not found") | 2282 | (progn (message "Not found") |
| 2299 | (ding)) | 2283 | (ding)) |
| @@ -2405,15 +2389,15 @@ See `term-prompt-regexp'." | |||
| 2405 | 2389 | ||
| 2406 | (defun term-check-source (fname) | 2390 | (defun term-check-source (fname) |
| 2407 | (let ((buff (get-file-buffer fname))) | 2391 | (let ((buff (get-file-buffer fname))) |
| 2408 | (if (and buff | 2392 | (when (and buff |
| 2409 | (buffer-modified-p buff) | 2393 | (buffer-modified-p buff) |
| 2410 | (y-or-n-p (format "Save buffer %s first? " | 2394 | (y-or-n-p (format "Save buffer %s first? " |
| 2411 | (buffer-name buff)))) | 2395 | (buffer-name buff)))) |
| 2412 | ;; save BUFF. | 2396 | ;; save BUFF. |
| 2413 | (let ((old-buffer (current-buffer))) | 2397 | (let ((old-buffer (current-buffer))) |
| 2414 | (set-buffer buff) | 2398 | (set-buffer buff) |
| 2415 | (save-buffer) | 2399 | (save-buffer) |
| 2416 | (set-buffer old-buffer))))) | 2400 | (set-buffer old-buffer))))) |
| 2417 | 2401 | ||
| 2418 | 2402 | ||
| 2419 | ;;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p) | 2403 | ;;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p) |
| @@ -2508,12 +2492,12 @@ See `term-prompt-regexp'." | |||
| 2508 | ;; Try to position the proc window so you can see the answer. | 2492 | ;; Try to position the proc window so you can see the answer. |
| 2509 | ;; This is bogus code. If you delete the (sit-for 0), it breaks. | 2493 | ;; This is bogus code. If you delete the (sit-for 0), it breaks. |
| 2510 | ;; I don't know why. Wizards invited to improve it. | 2494 | ;; I don't know why. Wizards invited to improve it. |
| 2511 | (if (not (pos-visible-in-window-p proc-pt proc-win)) | 2495 | (when (not (pos-visible-in-window-p proc-pt proc-win)) |
| 2512 | (let ((opoint (window-point proc-win))) | 2496 | (let ((opoint (window-point proc-win))) |
| 2513 | (set-window-point proc-win proc-mark) (sit-for 0) | 2497 | (set-window-point proc-win proc-mark) (sit-for 0) |
| 2514 | (if (not (pos-visible-in-window-p opoint proc-win)) | 2498 | (if (not (pos-visible-in-window-p opoint proc-win)) |
| 2515 | (push-mark opoint) | 2499 | (push-mark opoint) |
| 2516 | (set-window-point proc-win opoint))))))) | 2500 | (set-window-point proc-win opoint))))))) |
| 2517 | 2501 | ||
| 2518 | ;;; Returns the current column in the current screen line. | 2502 | ;;; Returns the current column in the current screen line. |
| 2519 | ;;; Note: (current-column) yields column in buffer line. | 2503 | ;;; Note: (current-column) yields column in buffer line. |
| @@ -2701,16 +2685,15 @@ See `term-prompt-regexp'." | |||
| 2701 | ;; Let's handle the messages. -mm | 2685 | ;; Let's handle the messages. -mm |
| 2702 | 2686 | ||
| 2703 | (let* ((newstr (term-handle-ansi-terminal-messages str))) | 2687 | (let* ((newstr (term-handle-ansi-terminal-messages str))) |
| 2704 | (if (not (eq str newstr)) | 2688 | (when (not (eq str newstr)) |
| 2705 | (setq handled-ansi-message t | 2689 | (setq handled-ansi-message t |
| 2706 | str newstr))) | 2690 | str newstr))) |
| 2707 | (setq str-length (length str)) | 2691 | (setq str-length (length str)) |
| 2708 | 2692 | ||
| 2709 | (if (marker-buffer term-pending-delete-marker) | 2693 | (when (marker-buffer term-pending-delete-marker) |
| 2710 | (progn | 2694 | ;; Delete text following term-pending-delete-marker. |
| 2711 | ;; Delete text following term-pending-delete-marker. | 2695 | (delete-region term-pending-delete-marker (process-mark proc)) |
| 2712 | (delete-region term-pending-delete-marker (process-mark proc)) | 2696 | (set-marker term-pending-delete-marker nil)) |
| 2713 | (set-marker term-pending-delete-marker nil))) | ||
| 2714 | 2697 | ||
| 2715 | (if (eq (window-buffer) (current-buffer)) | 2698 | (if (eq (window-buffer) (current-buffer)) |
| 2716 | (progn | 2699 | (progn |
| @@ -2721,20 +2704,20 @@ See `term-prompt-regexp'." | |||
| 2721 | 2704 | ||
| 2722 | (setq save-marker (copy-marker (process-mark proc))) | 2705 | (setq save-marker (copy-marker (process-mark proc))) |
| 2723 | 2706 | ||
| 2724 | (if (/= (point) (process-mark proc)) | 2707 | (when (/= (point) (process-mark proc)) |
| 2725 | (progn (setq save-point (point-marker)) | 2708 | (setq save-point (point-marker)) |
| 2726 | (goto-char (process-mark proc)))) | 2709 | (goto-char (process-mark proc))) |
| 2727 | 2710 | ||
| 2728 | (save-restriction | 2711 | (save-restriction |
| 2729 | ;; If the buffer is in line mode, and there is a partial | 2712 | ;; If the buffer is in line mode, and there is a partial |
| 2730 | ;; input line, save the line (by narrowing to leave it | 2713 | ;; input line, save the line (by narrowing to leave it |
| 2731 | ;; outside the restriction ) until we're done with output. | 2714 | ;; outside the restriction ) until we're done with output. |
| 2732 | (if (and (> (point-max) (process-mark proc)) | 2715 | (when (and (> (point-max) (process-mark proc)) |
| 2733 | (term-in-line-mode)) | 2716 | (term-in-line-mode)) |
| 2734 | (narrow-to-region (point-min) (process-mark proc))) | 2717 | (narrow-to-region (point-min) (process-mark proc))) |
| 2735 | 2718 | ||
| 2736 | (if term-log-buffer | 2719 | (when term-log-buffer |
| 2737 | (princ str term-log-buffer)) | 2720 | (princ str term-log-buffer)) |
| 2738 | (cond ((eq term-terminal-state 4) ;; Have saved pending output. | 2721 | (cond ((eq term-terminal-state 4) ;; Have saved pending output. |
| 2739 | (setq str (concat term-terminal-parameter str)) | 2722 | (setq str (concat term-terminal-parameter str)) |
| 2740 | (setq term-terminal-parameter nil) | 2723 | (setq term-terminal-parameter nil) |
| @@ -2748,7 +2731,7 @@ See `term-prompt-regexp'." | |||
| 2748 | (setq funny | 2731 | (setq funny |
| 2749 | (string-match "[\r\n\000\007\033\t\b\032\016\017]" | 2732 | (string-match "[\r\n\000\007\033\t\b\032\016\017]" |
| 2750 | str i)) | 2733 | str i)) |
| 2751 | (if (not funny) (setq funny str-length)) | 2734 | (when (not funny) (setq funny str-length)) |
| 2752 | (cond ((> funny i) | 2735 | (cond ((> funny i) |
| 2753 | (cond ((eq term-terminal-state 1) | 2736 | (cond ((eq term-terminal-state 1) |
| 2754 | ;; We are in state 1, we need to wrap | 2737 | ;; We are in state 1, we need to wrap |
| @@ -2822,10 +2805,10 @@ See `term-prompt-regexp'." | |||
| 2822 | (setq count (min term-width | 2805 | (setq count (min term-width |
| 2823 | (+ count 8 (- (mod count 8))))) | 2806 | (+ count 8 (- (mod count 8))))) |
| 2824 | (if (> term-width count) | 2807 | (if (> term-width count) |
| 2825 | (progn | 2808 | (progn |
| 2826 | (term-move-columns | 2809 | (term-move-columns |
| 2827 | (- count (term-current-column))) | 2810 | (- count (term-current-column))) |
| 2828 | (setq term-current-column count)) | 2811 | (setq term-current-column count)) |
| 2829 | (when (> term-width (term-current-column)) | 2812 | (when (> term-width (term-current-column)) |
| 2830 | (term-move-columns | 2813 | (term-move-columns |
| 2831 | (1- (- term-width (term-current-column))))) | 2814 | (1- (- term-width (term-current-column))))) |
| @@ -2967,44 +2950,43 @@ See `term-prompt-regexp'." | |||
| 2967 | (setq term-terminal-previous-parameter-2 -1) | 2950 | (setq term-terminal-previous-parameter-2 -1) |
| 2968 | (setq term-terminal-previous-parameter -1) | 2951 | (setq term-terminal-previous-parameter -1) |
| 2969 | (setq term-terminal-state 0))))) | 2952 | (setq term-terminal-state 0))))) |
| 2970 | (if (term-handling-pager) | 2953 | (when (term-handling-pager) |
| 2971 | ;; Finish stuff to get ready to handle PAGER. | 2954 | ;; Finish stuff to get ready to handle PAGER. |
| 2972 | (progn | 2955 | (if (> (% (current-column) term-width) 0) |
| 2973 | (if (> (% (current-column) term-width) 0) | 2956 | (setq term-terminal-parameter |
| 2974 | (setq term-terminal-parameter | 2957 | (substring str i)) |
| 2975 | (substring str i)) | 2958 | ;; We're at column 0. Goto end of buffer; to compensate, |
| 2976 | ;; We're at column 0. Goto end of buffer; to compensate, | 2959 | ;; prepend a ?\r for later. This looks more consistent. |
| 2977 | ;; prepend a ?\r for later. This looks more consistent. | 2960 | (if (zerop i) |
| 2978 | (if (zerop i) | 2961 | (setq term-terminal-parameter |
| 2979 | (setq term-terminal-parameter | 2962 | (concat "\r" (substring str i))) |
| 2980 | (concat "\r" (substring str i))) | 2963 | (setq term-terminal-parameter (substring str (1- i))) |
| 2981 | (setq term-terminal-parameter (substring str (1- i))) | 2964 | (aset term-terminal-parameter 0 ?\r)) |
| 2982 | (aset term-terminal-parameter 0 ?\r)) | 2965 | (goto-char (point-max))) |
| 2983 | (goto-char (point-max))) | 2966 | (setq term-terminal-state 4) |
| 2984 | (setq term-terminal-state 4) | 2967 | (make-local-variable 'term-pager-old-filter) |
| 2985 | (make-local-variable 'term-pager-old-filter) | 2968 | (setq term-pager-old-filter (process-filter proc)) |
| 2986 | (setq term-pager-old-filter (process-filter proc)) | 2969 | (set-process-filter proc term-pager-filter) |
| 2987 | (set-process-filter proc term-pager-filter) | 2970 | (setq i str-length)) |
| 2988 | (setq i str-length))) | ||
| 2989 | (setq i (1+ i)))) | 2971 | (setq i (1+ i)))) |
| 2990 | 2972 | ||
| 2991 | (if (>= (term-current-row) term-height) | 2973 | (when (>= (term-current-row) term-height) |
| 2992 | (term-handle-deferred-scroll)) | 2974 | (term-handle-deferred-scroll)) |
| 2993 | 2975 | ||
| 2994 | (set-marker (process-mark proc) (point)) | 2976 | (set-marker (process-mark proc) (point)) |
| 2995 | (if save-point | 2977 | (when save-point |
| 2996 | (progn (goto-char save-point) | 2978 | (goto-char save-point) |
| 2997 | (set-marker save-point nil))) | 2979 | (set-marker save-point nil)) |
| 2998 | 2980 | ||
| 2999 | ;; Check for a pending filename-and-line number to display. | 2981 | ;; Check for a pending filename-and-line number to display. |
| 3000 | ;; We do this before scrolling, because we might create a new window. | 2982 | ;; We do this before scrolling, because we might create a new window. |
| 3001 | (if (and term-pending-frame | 2983 | (when (and term-pending-frame |
| 3002 | (eq (window-buffer selected) (current-buffer))) | 2984 | (eq (window-buffer selected) (current-buffer))) |
| 3003 | (progn (term-display-line (car term-pending-frame) | 2985 | (term-display-line (car term-pending-frame) |
| 3004 | (cdr term-pending-frame)) | 2986 | (cdr term-pending-frame)) |
| 3005 | (setq term-pending-frame nil) | 2987 | (setq term-pending-frame nil) |
| 3006 | ;; We have created a new window, so check the window size. | 2988 | ;; We have created a new window, so check the window size. |
| 3007 | (term-check-size proc))) | 2989 | (term-check-size proc)) |
| 3008 | 2990 | ||
| 3009 | ;; Scroll each window displaying the buffer but (by default) | 2991 | ;; Scroll each window displaying the buffer but (by default) |
| 3010 | ;; only if the point matches the process-mark we started with. | 2992 | ;; only if the point matches the process-mark we started with. |
| @@ -3016,50 +2998,47 @@ See `term-prompt-regexp'." | |||
| 3016 | (setq last-win win) | 2998 | (setq last-win win) |
| 3017 | (while (progn | 2999 | (while (progn |
| 3018 | (setq win (next-window win nil t)) | 3000 | (setq win (next-window win nil t)) |
| 3019 | (if (eq (window-buffer win) (process-buffer proc)) | 3001 | (when (eq (window-buffer win) (process-buffer proc)) |
| 3020 | (let ((scroll term-scroll-to-bottom-on-output)) | 3002 | (let ((scroll term-scroll-to-bottom-on-output)) |
| 3021 | (select-window win) | 3003 | (select-window win) |
| 3022 | (if (or (= (point) save-marker) | 3004 | (when (or (= (point) save-marker) |
| 3023 | (eq scroll t) (eq scroll 'all) | 3005 | (eq scroll t) (eq scroll 'all) |
| 3024 | ;; Maybe user wants point to jump to the end. | 3006 | ;; Maybe user wants point to jump to the end. |
| 3025 | (and (eq selected win) | 3007 | (and (eq selected win) |
| 3026 | (or (eq scroll 'this) (not save-point))) | 3008 | (or (eq scroll 'this) (not save-point))) |
| 3027 | (and (eq scroll 'others) | 3009 | (and (eq scroll 'others) |
| 3028 | (not (eq selected win)))) | 3010 | (not (eq selected win)))) |
| 3029 | (progn | 3011 | (goto-char term-home-marker) |
| 3030 | (goto-char term-home-marker) | 3012 | (recenter 0) |
| 3031 | (recenter 0) | 3013 | (goto-char (process-mark proc)) |
| 3032 | (goto-char (process-mark proc)) | 3014 | (if (not (pos-visible-in-window-p (point) win)) |
| 3033 | (if (not (pos-visible-in-window-p (point) win)) | 3015 | (recenter -1))) |
| 3034 | (recenter -1)))) | 3016 | ;; Optionally scroll so that the text |
| 3035 | ;; Optionally scroll so that the text | 3017 | ;; ends at the bottom of the window. |
| 3036 | ;; ends at the bottom of the window. | 3018 | (when (and term-scroll-show-maximum-output |
| 3037 | (if (and term-scroll-show-maximum-output | ||
| 3038 | (>= (point) (process-mark proc))) | 3019 | (>= (point) (process-mark proc))) |
| 3039 | (save-excursion | 3020 | (save-excursion |
| 3040 | (goto-char (point-max)) | 3021 | (goto-char (point-max)) |
| 3041 | (recenter -1))))) | 3022 | (recenter -1))))) |
| 3042 | (not (eq win last-win)))) | 3023 | (not (eq win last-win)))) |
| 3043 | 3024 | ||
| 3044 | ;;; Stolen from comint.el and adapted -mm | 3025 | ;;; Stolen from comint.el and adapted -mm |
| 3045 | (if (> term-buffer-maximum-size 0) | 3026 | (when (> term-buffer-maximum-size 0) |
| 3046 | (save-excursion | 3027 | (save-excursion |
| 3047 | (goto-char (process-mark (get-buffer-process (current-buffer)))) | 3028 | (goto-char (process-mark (get-buffer-process (current-buffer)))) |
| 3048 | (forward-line (- term-buffer-maximum-size)) | 3029 | (forward-line (- term-buffer-maximum-size)) |
| 3049 | (beginning-of-line) | 3030 | (beginning-of-line) |
| 3050 | (delete-region (point-min) (point)))) | 3031 | (delete-region (point-min) (point)))) |
| 3051 | ;;; | ||
| 3052 | |||
| 3053 | (set-marker save-marker nil))))) | 3032 | (set-marker save-marker nil))))) |
| 3054 | 3033 | ||
| 3055 | (defun term-handle-deferred-scroll () | 3034 | (defun term-handle-deferred-scroll () |
| 3056 | (let ((count (- (term-current-row) term-height))) | 3035 | (let ((count (- (term-current-row) term-height))) |
| 3057 | (if (>= count 0) | 3036 | (when (>= count 0) |
| 3058 | (save-excursion | 3037 | (save-excursion |
| 3059 | (goto-char term-home-marker) | 3038 | (goto-char term-home-marker) |
| 3060 | (term-vertical-motion (1+ count)) | 3039 | (term-vertical-motion (1+ count)) |
| 3061 | (set-marker term-home-marker (point)) | 3040 | (set-marker term-home-marker (point)) |
| 3062 | (setq term-current-row (1- term-height)))))) | 3041 | (setq term-current-row (1- term-height)))))) |
| 3063 | 3042 | ||
| 3064 | ;;; Reset the terminal, delete all the content and set the face to the | 3043 | ;;; Reset the terminal, delete all the content and set the face to the |
| 3065 | ;;; default one. | 3044 | ;;; default one. |
| @@ -3170,17 +3149,17 @@ See `term-prompt-regexp'." | |||
| 3170 | (list :background | 3149 | (list :background |
| 3171 | (if (= term-ansi-current-color 0) | 3150 | (if (= term-ansi-current-color 0) |
| 3172 | (face-foreground 'default) | 3151 | (face-foreground 'default) |
| 3173 | (elt ansi-term-color-vector term-ansi-current-color)) | 3152 | (elt ansi-term-color-vector term-ansi-current-color)) |
| 3174 | :foreground | 3153 | :foreground |
| 3175 | (if (= term-ansi-current-bg-color 0) | 3154 | (if (= term-ansi-current-bg-color 0) |
| 3176 | (face-background 'default) | 3155 | (face-background 'default) |
| 3177 | (elt ansi-term-color-vector term-ansi-current-bg-color)))) | 3156 | (elt ansi-term-color-vector term-ansi-current-bg-color)))) |
| 3178 | (when term-ansi-current-bold | 3157 | (when term-ansi-current-bold |
| 3179 | (setq term-current-face | 3158 | (setq term-current-face |
| 3180 | (append '(:weight bold) term-current-face))) | 3159 | (append '(:weight bold) term-current-face))) |
| 3181 | (when term-ansi-current-underline | 3160 | (when term-ansi-current-underline |
| 3182 | (setq term-current-face | 3161 | (setq term-current-face |
| 3183 | (append '(:underline t) term-current-face)))) | 3162 | (append '(:underline t) term-current-face)))) |
| 3184 | (if term-ansi-current-invisible | 3163 | (if term-ansi-current-invisible |
| 3185 | (setq term-current-face | 3164 | (setq term-current-face |
| 3186 | (if (= term-ansi-current-bg-color 0) | 3165 | (if (= term-ansi-current-bg-color 0) |
| @@ -3200,12 +3179,12 @@ See `term-prompt-regexp'." | |||
| 3200 | :background | 3179 | :background |
| 3201 | (elt ansi-term-color-vector term-ansi-current-bg-color))) | 3180 | (elt ansi-term-color-vector term-ansi-current-bg-color))) |
| 3202 | (when term-ansi-current-bold | 3181 | (when term-ansi-current-bold |
| 3203 | (setq term-current-face | 3182 | (setq term-current-face |
| 3204 | (append '(:weight bold) term-current-face))) | 3183 | (append '(:weight bold) term-current-face))) |
| 3205 | (when term-ansi-current-underline | 3184 | (when term-ansi-current-underline |
| 3206 | (setq term-current-face | 3185 | (setq term-current-face |
| 3207 | (append '(:underline t) term-current-face)))))) | 3186 | (append '(:underline t) term-current-face)))))) |
| 3208 | 3187 | ||
| 3209 | ;;; (message "Debug %S" term-current-face) | 3188 | ;;; (message "Debug %S" term-current-face) |
| 3210 | (setq term-ansi-face-already-done nil)) | 3189 | (setq term-ansi-face-already-done nil)) |
| 3211 | 3190 | ||
| @@ -3219,14 +3198,14 @@ See `term-prompt-regexp'." | |||
| 3219 | ;; (eq char ?f) ;; xterm seems to handle this sequence too, not | 3198 | ;; (eq char ?f) ;; xterm seems to handle this sequence too, not |
| 3220 | ;; needed for now | 3199 | ;; needed for now |
| 3221 | ) | 3200 | ) |
| 3222 | (if (<= term-terminal-parameter 0) | 3201 | (when (<= term-terminal-parameter 0) |
| 3223 | (setq term-terminal-parameter 1)) | 3202 | (setq term-terminal-parameter 1)) |
| 3224 | (if (<= term-terminal-previous-parameter 0) | 3203 | (when (<= term-terminal-previous-parameter 0) |
| 3225 | (setq term-terminal-previous-parameter 1)) | 3204 | (setq term-terminal-previous-parameter 1)) |
| 3226 | (if (> term-terminal-previous-parameter term-height) | 3205 | (when (> term-terminal-previous-parameter term-height) |
| 3227 | (setq term-terminal-previous-parameter term-height)) | 3206 | (setq term-terminal-previous-parameter term-height)) |
| 3228 | (if (> term-terminal-parameter term-width) | 3207 | (when (> term-terminal-parameter term-width) |
| 3229 | (setq term-terminal-parameter term-width)) | 3208 | (setq term-terminal-parameter term-width)) |
| 3230 | (term-goto | 3209 | (term-goto |
| 3231 | (1- term-terminal-previous-parameter) | 3210 | (1- term-terminal-previous-parameter) |
| 3232 | (1- term-terminal-parameter))) | 3211 | (1- term-terminal-parameter))) |
| @@ -3443,50 +3422,49 @@ The top-most line is line 0." | |||
| 3443 | ; The page is full, so enter "pager" mode, and wait for input. | 3422 | ; The page is full, so enter "pager" mode, and wait for input. |
| 3444 | 3423 | ||
| 3445 | (defun term-process-pager () | 3424 | (defun term-process-pager () |
| 3446 | (if (not term-pager-break-map) | 3425 | (when (not term-pager-break-map) |
| 3447 | (let* ((map (make-keymap)) | 3426 | (let* ((map (make-keymap)) |
| 3448 | (i 0) tmp) | 3427 | (i 0) tmp) |
| 3449 | ; (while (< i 128) | 3428 | ; (while (< i 128) |
| 3450 | ; (define-key map (make-string 1 i) 'term-send-raw) | 3429 | ; (define-key map (make-string 1 i) 'term-send-raw) |
| 3451 | ; (setq i (1+ i))) | 3430 | ; (setq i (1+ i))) |
| 3452 | (define-key map "\e" | 3431 | (define-key map "\e" |
| 3453 | (lookup-key (current-global-map) "\e")) | 3432 | (lookup-key (current-global-map) "\e")) |
| 3454 | (define-key map "\C-x" | 3433 | (define-key map "\C-x" |
| 3455 | (lookup-key (current-global-map) "\C-x")) | 3434 | (lookup-key (current-global-map) "\C-x")) |
| 3456 | (define-key map "\C-u" | 3435 | (define-key map "\C-u" |
| 3457 | (lookup-key (current-global-map) "\C-u")) | 3436 | (lookup-key (current-global-map) "\C-u")) |
| 3458 | (define-key map " " 'term-pager-page) | 3437 | (define-key map " " 'term-pager-page) |
| 3459 | (define-key map "\r" 'term-pager-line) | 3438 | (define-key map "\r" 'term-pager-line) |
| 3460 | (define-key map "?" 'term-pager-help) | 3439 | (define-key map "?" 'term-pager-help) |
| 3461 | (define-key map "h" 'term-pager-help) | 3440 | (define-key map "h" 'term-pager-help) |
| 3462 | (define-key map "b" 'term-pager-back-page) | 3441 | (define-key map "b" 'term-pager-back-page) |
| 3463 | (define-key map "\177" 'term-pager-back-line) | 3442 | (define-key map "\177" 'term-pager-back-line) |
| 3464 | (define-key map "q" 'term-pager-discard) | 3443 | (define-key map "q" 'term-pager-discard) |
| 3465 | (define-key map "D" 'term-pager-disable) | 3444 | (define-key map "D" 'term-pager-disable) |
| 3466 | (define-key map "<" 'term-pager-bob) | 3445 | (define-key map "<" 'term-pager-bob) |
| 3467 | (define-key map ">" 'term-pager-eob) | 3446 | (define-key map ">" 'term-pager-eob) |
| 3468 | 3447 | ||
| 3469 | ;; Add menu bar. | 3448 | ;; Add menu bar. |
| 3470 | (progn | 3449 | (unless (featurep 'xemacs) |
| 3471 | (term-ifnot-xemacs | 3450 | (define-key map [menu-bar terminal] term-terminal-menu) |
| 3472 | (define-key map [menu-bar terminal] term-terminal-menu) | 3451 | (define-key map [menu-bar signals] term-signals-menu) |
| 3473 | (define-key map [menu-bar signals] term-signals-menu) | 3452 | (setq tmp (make-sparse-keymap "More pages?")) |
| 3474 | (setq tmp (make-sparse-keymap "More pages?")) | 3453 | (define-key tmp [help] '("Help" . term-pager-help)) |
| 3475 | (define-key tmp [help] '("Help" . term-pager-help)) | 3454 | (define-key tmp [disable] |
| 3476 | (define-key tmp [disable] | 3455 | '("Disable paging" . term-fake-pager-disable)) |
| 3477 | '("Disable paging" . term-fake-pager-disable)) | 3456 | (define-key tmp [discard] |
| 3478 | (define-key tmp [discard] | 3457 | '("Discard remaining output" . term-pager-discard)) |
| 3479 | '("Discard remaining output" . term-pager-discard)) | 3458 | (define-key tmp [eob] '("Goto to end" . term-pager-eob)) |
| 3480 | (define-key tmp [eob] '("Goto to end" . term-pager-eob)) | 3459 | (define-key tmp [bob] '("Goto to beginning" . term-pager-bob)) |
| 3481 | (define-key tmp [bob] '("Goto to beginning" . term-pager-bob)) | 3460 | (define-key tmp [line] '("1 line forwards" . term-pager-line)) |
| 3482 | (define-key tmp [line] '("1 line forwards" . term-pager-line)) | 3461 | (define-key tmp [bline] '("1 line backwards" . term-pager-back-line)) |
| 3483 | (define-key tmp [bline] '("1 line backwards" . term-pager-back-line)) | 3462 | (define-key tmp [back] '("1 page backwards" . term-pager-back-page)) |
| 3484 | (define-key tmp [back] '("1 page backwards" . term-pager-back-page)) | 3463 | (define-key tmp [page] '("1 page forwards" . term-pager-page)) |
| 3485 | (define-key tmp [page] '("1 page forwards" . term-pager-page)) | 3464 | (define-key map [menu-bar page] (cons "More pages?" tmp)) |
| 3486 | (define-key map [menu-bar page] (cons "More pages?" tmp)) | 3465 | ) |
| 3487 | )) | ||
| 3488 | 3466 | ||
| 3489 | (setq term-pager-break-map map))) | 3467 | (setq term-pager-break-map map))) |
| 3490 | ; (let ((process (get-buffer-process (current-buffer)))) | 3468 | ; (let ((process (get-buffer-process (current-buffer)))) |
| 3491 | ; (stop-process process)) | 3469 | ; (stop-process process)) |
| 3492 | (setq term-pager-old-local-map (current-local-map)) | 3470 | (setq term-pager-old-local-map (current-local-map)) |
| @@ -3504,8 +3482,8 @@ The top-most line is line 0." | |||
| 3504 | (interactive "p") | 3482 | (interactive "p") |
| 3505 | (let* ((moved (vertical-motion (1+ lines))) | 3483 | (let* ((moved (vertical-motion (1+ lines))) |
| 3506 | (deficit (- lines moved))) | 3484 | (deficit (- lines moved))) |
| 3507 | (if (> moved lines) | 3485 | (when (> moved lines) |
| 3508 | (backward-char)) | 3486 | (backward-char)) |
| 3509 | (cond ((<= deficit 0) ;; OK, had enough in the buffer for request. | 3487 | (cond ((<= deficit 0) ;; OK, had enough in the buffer for request. |
| 3510 | (recenter (1- term-height))) | 3488 | (recenter (1- term-height))) |
| 3511 | ((term-pager-continue deficit))))) | 3489 | ((term-pager-continue deficit))))) |
| @@ -3519,8 +3497,8 @@ The top-most line is line 0." | |||
| 3519 | (defun term-pager-bob () | 3497 | (defun term-pager-bob () |
| 3520 | (interactive) | 3498 | (interactive) |
| 3521 | (goto-char (point-min)) | 3499 | (goto-char (point-min)) |
| 3522 | (if (= (vertical-motion term-height) term-height) | 3500 | (when (= (vertical-motion term-height) term-height) |
| 3523 | (backward-char)) | 3501 | (backward-char)) |
| 3524 | (recenter (1- term-height))) | 3502 | (recenter (1- term-height))) |
| 3525 | 3503 | ||
| 3526 | ; pager mode command to go to end of buffer | 3504 | ; pager mode command to go to end of buffer |
| @@ -3571,7 +3549,7 @@ The top-most line is line 0." | |||
| 3571 | (interactive) | 3549 | (interactive) |
| 3572 | (if (term-pager-enabled) (term-pager-disable) (term-pager-enable))) | 3550 | (if (term-pager-enabled) (term-pager-disable) (term-pager-enable))) |
| 3573 | 3551 | ||
| 3574 | (term-ifnot-xemacs | 3552 | (unless (featurep 'xemacs) |
| 3575 | (defalias 'term-fake-pager-enable 'term-pager-toggle) | 3553 | (defalias 'term-fake-pager-enable 'term-pager-toggle) |
| 3576 | (defalias 'term-fake-pager-disable 'term-pager-toggle) | 3554 | (defalias 'term-fake-pager-disable 'term-pager-toggle) |
| 3577 | (put 'term-char-mode 'menu-enable '(term-in-line-mode)) | 3555 | (put 'term-char-mode 'menu-enable '(term-in-line-mode)) |
| @@ -3624,45 +3602,45 @@ all pending output has been dealt with.")) | |||
| 3624 | (let ((scroll-needed | 3602 | (let ((scroll-needed |
| 3625 | (- (+ (term-current-row) down) | 3603 | (- (+ (term-current-row) down) |
| 3626 | (if (< down 0) term-scroll-start term-scroll-end)))) | 3604 | (if (< down 0) term-scroll-start term-scroll-end)))) |
| 3627 | (if (or (and (< down 0) (< scroll-needed 0)) | 3605 | (when (or (and (< down 0) (< scroll-needed 0)) |
| 3628 | (and (> down 0) (> scroll-needed 0))) | 3606 | (and (> down 0) (> scroll-needed 0))) |
| 3629 | (let ((save-point (copy-marker (point))) (save-top)) | 3607 | (let ((save-point (copy-marker (point))) (save-top)) |
| 3630 | (goto-char term-home-marker) | 3608 | (goto-char term-home-marker) |
| 3631 | (cond (term-scroll-with-delete | 3609 | (cond (term-scroll-with-delete |
| 3632 | (if (< down 0) | 3610 | (if (< down 0) |
| 3633 | (progn | 3611 | (progn |
| 3634 | ;; Delete scroll-needed lines at term-scroll-end, | 3612 | ;; Delete scroll-needed lines at term-scroll-end, |
| 3635 | ;; then insert scroll-needed lines. | 3613 | ;; then insert scroll-needed lines. |
| 3636 | (term-vertical-motion (1- term-scroll-end)) | 3614 | (term-vertical-motion (1- term-scroll-end)) |
| 3637 | (end-of-line) | 3615 | (end-of-line) |
| 3638 | (setq save-top (point)) | 3616 | (setq save-top (point)) |
| 3639 | (term-vertical-motion scroll-needed) | 3617 | (term-vertical-motion scroll-needed) |
| 3640 | (end-of-line) | 3618 | (end-of-line) |
| 3641 | (delete-region save-top (point)) | 3619 | (delete-region save-top (point)) |
| 3642 | (goto-char save-point) | 3620 | (goto-char save-point) |
| 3643 | (setq down (- scroll-needed down)) | 3621 | (setq down (- scroll-needed down)) |
| 3644 | (term-vertical-motion down)) | 3622 | (term-vertical-motion down)) |
| 3645 | ;; Delete scroll-needed lines at term-scroll-start. | 3623 | ;; Delete scroll-needed lines at term-scroll-start. |
| 3646 | (term-vertical-motion term-scroll-start) | 3624 | (term-vertical-motion term-scroll-start) |
| 3647 | (setq save-top (point)) | 3625 | (setq save-top (point)) |
| 3648 | (term-vertical-motion scroll-needed) | ||
| 3649 | (delete-region save-top (point)) | ||
| 3650 | (goto-char save-point) | ||
| 3651 | (term-vertical-motion down) | ||
| 3652 | (term-adjust-current-row-cache (- scroll-needed))) | ||
| 3653 | (setq term-current-column nil) | ||
| 3654 | (term-insert-char ?\n (abs scroll-needed))) | ||
| 3655 | ((and (numberp term-pager-count) | ||
| 3656 | (< (setq term-pager-count (- term-pager-count down)) | ||
| 3657 | 0)) | ||
| 3658 | (setq down 0) | ||
| 3659 | (term-process-pager)) | ||
| 3660 | (t | ||
| 3661 | (term-adjust-current-row-cache (- scroll-needed)) | ||
| 3662 | (term-vertical-motion scroll-needed) | 3626 | (term-vertical-motion scroll-needed) |
| 3663 | (set-marker term-home-marker (point)))) | 3627 | (delete-region save-top (point)) |
| 3664 | (goto-char save-point) | 3628 | (goto-char save-point) |
| 3665 | (set-marker save-point nil)))) | 3629 | (term-vertical-motion down) |
| 3630 | (term-adjust-current-row-cache (- scroll-needed))) | ||
| 3631 | (setq term-current-column nil) | ||
| 3632 | (term-insert-char ?\n (abs scroll-needed))) | ||
| 3633 | ((and (numberp term-pager-count) | ||
| 3634 | (< (setq term-pager-count (- term-pager-count down)) | ||
| 3635 | 0)) | ||
| 3636 | (setq down 0) | ||
| 3637 | (term-process-pager)) | ||
| 3638 | (t | ||
| 3639 | (term-adjust-current-row-cache (- scroll-needed)) | ||
| 3640 | (term-vertical-motion scroll-needed) | ||
| 3641 | (set-marker term-home-marker (point)))) | ||
| 3642 | (goto-char save-point) | ||
| 3643 | (set-marker save-point nil)))) | ||
| 3666 | down) | 3644 | down) |
| 3667 | 3645 | ||
| 3668 | (defun term-down (down &optional check-for-scroll) | 3646 | (defun term-down (down &optional check-for-scroll) |
| @@ -3699,34 +3677,34 @@ all pending output has been dealt with.")) | |||
| 3699 | ;; if the line above point wraps around, add a ?\n to undo the wrapping. | 3677 | ;; if the line above point wraps around, add a ?\n to undo the wrapping. |
| 3700 | ;; FIXME: Probably should be called more than it is. | 3678 | ;; FIXME: Probably should be called more than it is. |
| 3701 | (defun term-unwrap-line () | 3679 | (defun term-unwrap-line () |
| 3702 | (if (not (bolp)) (insert-before-markers ?\n))) | 3680 | (when (not (bolp)) (insert-before-markers ?\n))) |
| 3703 | 3681 | ||
| 3704 | (defun term-erase-in-line (kind) | 3682 | (defun term-erase-in-line (kind) |
| 3705 | (if (= kind 1) ;; erase left of point | 3683 | (when (= kind 1) ;; erase left of point |
| 3706 | (let ((cols (term-horizontal-column)) (saved-point (point))) | 3684 | (let ((cols (term-horizontal-column)) (saved-point (point))) |
| 3707 | (term-vertical-motion 0) | 3685 | (term-vertical-motion 0) |
| 3708 | (delete-region (point) saved-point) | 3686 | (delete-region (point) saved-point) |
| 3709 | (term-insert-char ? cols))) | 3687 | (term-insert-char ? cols))) |
| 3710 | (if (not (eq kind 1)) ;; erase right of point | 3688 | (when (not (eq kind 1)) ;; erase right of point |
| 3711 | (let ((saved-point (point)) | 3689 | (let ((saved-point (point)) |
| 3712 | (wrapped (and (zerop (term-horizontal-column)) | 3690 | (wrapped (and (zerop (term-horizontal-column)) |
| 3713 | (not (zerop (term-current-column)))))) | 3691 | (not (zerop (term-current-column)))))) |
| 3714 | (term-vertical-motion 1) | 3692 | (term-vertical-motion 1) |
| 3715 | (delete-region saved-point (point)) | 3693 | (delete-region saved-point (point)) |
| 3716 | ;; wrapped is true if we're at the beginning of screen line, | 3694 | ;; wrapped is true if we're at the beginning of screen line, |
| 3717 | ;; but not a buffer line. If we delete the current screen line | 3695 | ;; but not a buffer line. If we delete the current screen line |
| 3718 | ;; that will make the previous line no longer wrap, and (because | 3696 | ;; that will make the previous line no longer wrap, and (because |
| 3719 | ;; of the way Emacs display works) point will be at the end of | 3697 | ;; of the way Emacs display works) point will be at the end of |
| 3720 | ;; the previous screen line rather then the beginning of the | 3698 | ;; the previous screen line rather then the beginning of the |
| 3721 | ;; current one. To avoid that, we make sure that current line | 3699 | ;; current one. To avoid that, we make sure that current line |
| 3722 | ;; contain a space, to force the previous line to continue to wrap. | 3700 | ;; contain a space, to force the previous line to continue to wrap. |
| 3723 | ;; We could do this always, but it seems preferable to not add the | 3701 | ;; We could do this always, but it seems preferable to not add the |
| 3724 | ;; extra space when wrapped is false. | 3702 | ;; extra space when wrapped is false. |
| 3725 | (if wrapped | 3703 | (when wrapped |
| 3726 | (insert ? )) | 3704 | (insert ? )) |
| 3727 | (insert ?\n) | 3705 | (insert ?\n) |
| 3728 | (put-text-property saved-point (point) 'face 'default) | 3706 | (put-text-property saved-point (point) 'face 'default) |
| 3729 | (goto-char saved-point)))) | 3707 | (goto-char saved-point)))) |
| 3730 | 3708 | ||
| 3731 | (defun term-erase-in-display (kind) | 3709 | (defun term-erase-in-display (kind) |
| 3732 | "Erases (that is blanks out) part of the window. | 3710 | "Erases (that is blanks out) part of the window. |
| @@ -3932,8 +3910,8 @@ inside of a \"[...]\" (see `skip-chars-forward')." | |||
| 3932 | (let ((limit (point)) | 3910 | (let ((limit (point)) |
| 3933 | (word (concat "[" word-chars "]")) | 3911 | (word (concat "[" word-chars "]")) |
| 3934 | (non-word (concat "[^" word-chars "]"))) | 3912 | (non-word (concat "[^" word-chars "]"))) |
| 3935 | (if (re-search-backward non-word nil 'move) | 3913 | (when (re-search-backward non-word nil 'move) |
| 3936 | (forward-char 1)) | 3914 | (forward-char 1)) |
| 3937 | ;; Anchor the search forwards. | 3915 | ;; Anchor the search forwards. |
| 3938 | (if (or (eolp) (looking-at non-word)) | 3916 | (if (or (eolp) (looking-at non-word)) |
| 3939 | nil | 3917 | nil |
| @@ -3974,10 +3952,10 @@ completions listing is dependent on the value of `term-completion-autolist'. | |||
| 3974 | 3952 | ||
| 3975 | Returns t if successful." | 3953 | Returns t if successful." |
| 3976 | (interactive) | 3954 | (interactive) |
| 3977 | (if (term-match-partial-filename) | 3955 | (when (term-match-partial-filename) |
| 3978 | (prog2 (or (eq (selected-window) (minibuffer-window)) | 3956 | (prog2 (or (eq (selected-window) (minibuffer-window)) |
| 3979 | (message "Completing file name...")) | 3957 | (message "Completing file name...")) |
| 3980 | (term-dynamic-complete-as-filename)))) | 3958 | (term-dynamic-complete-as-filename)))) |
| 3981 | 3959 | ||
| 3982 | (defun term-dynamic-complete-as-filename () | 3960 | (defun term-dynamic-complete-as-filename () |
| 3983 | "Dynamically complete at point as a filename. | 3961 | "Dynamically complete at point as a filename. |
| @@ -4001,7 +3979,7 @@ See `term-dynamic-complete-filename'. Returns t if successful." | |||
| 4001 | (message "No completions of %s" filename) | 3979 | (message "No completions of %s" filename) |
| 4002 | (setq success nil)) | 3980 | (setq success nil)) |
| 4003 | ((eq completion t) ; Means already completed "file". | 3981 | ((eq completion t) ; Means already completed "file". |
| 4004 | (if term-completion-addsuffix (insert " ")) | 3982 | (when term-completion-addsuffix (insert " ")) |
| 4005 | (or mini-flag (message "Sole completion"))) | 3983 | (or mini-flag (message "Sole completion"))) |
| 4006 | ((string-equal completion "") ; Means completion on "directory/". | 3984 | ((string-equal completion "") ; Means completion on "directory/". |
| 4007 | (term-dynamic-list-filename-completions)) | 3985 | (term-dynamic-list-filename-completions)) |
| @@ -4066,7 +4044,7 @@ See also `term-dynamic-complete-filename'." | |||
| 4066 | (message "Sole completion") | 4044 | (message "Sole completion") |
| 4067 | (insert (substring completion (length stub))) | 4045 | (insert (substring completion (length stub))) |
| 4068 | (message "Completed")) | 4046 | (message "Completed")) |
| 4069 | (if term-completion-addsuffix (insert " ")) | 4047 | (when term-completion-addsuffix (insert " ")) |
| 4070 | 'sole)) | 4048 | 'sole)) |
| 4071 | (t ; There's no unique completion. | 4049 | (t ; There's no unique completion. |
| 4072 | (let ((completion (try-completion stub candidates))) | 4050 | (let ((completion (try-completion stub candidates))) |