comparison lisp/emulators/tpu-edt.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents 54cc21c15cbb
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
133:b27e67717092 134:34a5b81f86ba
4 4
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> 5 ;; Author: Rob Riepel <riepel@networking.stanford.edu>
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> 6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
7 ;; Version: 4.2 7 ;; Version: 4.2
8 ;; Keywords: emulations 8 ;; Keywords: emulations
9
10 ;; Modified for XEmacs by R. Kevin Oberman <oberman@es.net>
9 11
10 ;; This file is part of XEmacs. 12 ;; This file is part of XEmacs.
11 13
12 ;; XEmacs is free software; you can redistribute it and/or modify it 14 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by 15 ;; under the terms of the GNU General Public License as published by
213 ;; (define-key SS3-map "w" 'tpu-paragraph) ; KP7 215 ;; (define-key SS3-map "w" 'tpu-paragraph) ; KP7
214 216
215 ;; ; Repeat the preceding mappings for X-windows. 217 ;; ; Repeat the preceding mappings for X-windows.
216 ;; (cond 218 ;; (cond
217 ;; (window-system 219 ;; (window-system
218 ;; (global-set-key [kp-7] 'tpu-paragraph) ; KP7 220 ;; (global-set-key [kp_7] 'tpu-paragraph) ; KP7
219 ;; (define-key GOLD-map [kp-f1] 'universal-argument))) ; GOLD-PF1 221 ;; (define-key GOLD-map [kp_f1] 'universal-argument))) ; GOLD-PF1
220 222
221 ;; ; Display the TPU-edt version. 223 ;; ; Display the TPU-edt version.
222 ;; (tpu-version) 224 ;; (tpu-version)
223 225
224 226
522 (tpu-unset-match) nil))) 524 (tpu-unset-match) nil)))
523 525
524 (defun tpu-show-match-markers nil 526 (defun tpu-show-match-markers nil
525 "Show the values of the match markers." 527 "Show the values of the match markers."
526 (interactive) 528 (interactive)
529 (setq zmacs-region-stays t)
527 (if (markerp tpu-match-beginning-mark) 530 (if (markerp tpu-match-beginning-mark)
528 (let ((beg (marker-position tpu-match-beginning-mark))) 531 (let ((beg (marker-position tpu-match-beginning-mark)))
529 (message "(%s, %s) in %s -- current %s in %s" 532 (message "(%s, %s) in %s -- current %s in %s"
530 (if beg (1- beg) nil) 533 (if beg (1- beg) nil)
531 (marker-position tpu-match-end-mark) 534 (marker-position tpu-match-end-mark)
605 "The set of user-defined markers (breadcrumbs), as a plist.") 608 "The set of user-defined markers (breadcrumbs), as a plist.")
606 609
607 (defun tpu-drop-breadcrumb (num) 610 (defun tpu-drop-breadcrumb (num)
608 "Drops a breadcrumb that can be returned to later with goto-breadcrumb." 611 "Drops a breadcrumb that can be returned to later with goto-breadcrumb."
609 (interactive "p") 612 (interactive "p")
613 (setq zmacs-region-stays t)
610 (put tpu-breadcrumb-plist num (list (current-buffer) (point))) 614 (put tpu-breadcrumb-plist num (list (current-buffer) (point)))
611 (message "Mark %d set." num)) 615 (message "Mark %d set." num))
612 616
613 (defun tpu-goto-breadcrumb (num) 617 (defun tpu-goto-breadcrumb (num)
614 "Returns to a breadcrumb set with drop-breadcrumb." 618 "Returns to a breadcrumb set with drop-breadcrumb."
615 (interactive "p") 619 (interactive "p")
620 (setq zmacs-region-stays t)
616 (cond ((get tpu-breadcrumb-plist num) 621 (cond ((get tpu-breadcrumb-plist num)
617 (switch-to-buffer (car (get tpu-breadcrumb-plist num))) 622 (switch-to-buffer (car (get tpu-breadcrumb-plist num)))
618 (goto-char (tpu-cadr (get tpu-breadcrumb-plist num))) 623 (goto-char (tpu-cadr (get tpu-breadcrumb-plist num)))
619 (message "mark %d found." num)) 624 (message "mark %d found." num))
620 (t 625 (t
663 (fill-paragraph num)))) 668 (fill-paragraph num))))
664 669
665 (defun tpu-version nil 670 (defun tpu-version nil
666 "Print the TPU-edt version number." 671 "Print the TPU-edt version number."
667 (interactive) 672 (interactive)
673 (setq zmacs-region-stays t)
668 (message 674 (message
669 "TPU-edt version %s by Rob Riepel (riepel@networking.stanford.edu)" 675 "TPU-edt version %s by Rob Riepel (riepel@networking.stanford.edu)"
670 tpu-version)) 676 tpu-version))
671 677
672 (defun tpu-reset-screen-size (height width) 678 (defun tpu-reset-screen-size (height width)
673 "Sets the screen size." 679 "Sets the screen size."
674 (interactive "nnew screen height: \nnnew screen width: ") 680 (interactive "nnew screen height: \nnnew screen width: ")
681 (setq zmacs-region-stays t)
675 (set-screen-height height) 682 (set-screen-height height)
676 (set-screen-width width)) 683 (set-screen-width width))
677 684
678 (defun tpu-toggle-newline-and-indent nil 685 (defun tpu-toggle-newline-and-indent nil
679 "Toggle between 'newline and indent' and 'simple newline'." 686 "Toggle between 'newline and indent' and 'simple newline'."
680 (interactive) 687 (interactive)
688 (setq zmacs-region-stays t)
681 (cond (tpu-newline-and-indent-p 689 (cond (tpu-newline-and-indent-p
682 (setq tpu-newline-and-indent-string "") 690 (setq tpu-newline-and-indent-string "")
683 (setq tpu-newline-and-indent-p nil) 691 (setq tpu-newline-and-indent-p nil)
684 (tpu-local-set-key "\C-m" 'newline)) 692 (tpu-local-set-key "\C-m" 'newline))
685 (t 693 (t
702 (if (tpu-mark) (tpu-unselect t))) 710 (if (tpu-mark) (tpu-unselect t)))
703 711
704 (defun tpu-toggle-overwrite-mode nil 712 (defun tpu-toggle-overwrite-mode nil
705 "Switches in and out of overwrite mode" 713 "Switches in and out of overwrite mode"
706 (interactive) 714 (interactive)
715 (setq zmacs-region-stays t)
707 (cond (overwrite-mode 716 (cond (overwrite-mode
708 (tpu-local-set-key "\177" tpu-saved-delete-func) 717 (tpu-local-set-key "\177" tpu-saved-delete-func)
709 (overwrite-mode 0)) 718 (overwrite-mode 0))
710 (t 719 (t
711 (setq tpu-saved-delete-func (local-key-binding "\177")) 720 (setq tpu-saved-delete-func (local-key-binding "\177"))
714 723
715 (defun tpu-special-insert (num) 724 (defun tpu-special-insert (num)
716 "Insert a character or control code according to 725 "Insert a character or control code according to
717 its ASCII decimal value." 726 its ASCII decimal value."
718 (interactive "P") 727 (interactive "P")
728 (setq zmacs-region-stays t)
719 (if overwrite-mode (delete-char 1)) 729 (if overwrite-mode (delete-char 1))
720 (insert (if num num 0))) 730 (insert (if num num 0)))
721 731
722 (defun tpu-quoted-insert (num) 732 (defun tpu-quoted-insert (num)
723 "Read next input character and insert it. 733 "Read next input character and insert it.
724 This is useful for inserting control characters." 734 This is useful for inserting control characters."
725 (interactive "*p") 735 (interactive "*p")
736 (setq zmacs-region-stays t)
726 (let ((char (read-char)) ) 737 (let ((char (read-char)) )
727 (if overwrite-mode (delete-char num)) 738 (if overwrite-mode (delete-char num))
728 (insert-char char num))) 739 (insert-char char num)))
729 740
730 741
732 ;;; TPU line-mode commands 743 ;;; TPU line-mode commands
733 ;;; 744 ;;;
734 (defun tpu-include (file) 745 (defun tpu-include (file)
735 "TPU-like include file" 746 "TPU-like include file"
736 (interactive "fInclude file: ") 747 (interactive "fInclude file: ")
748 (setq zmacs-region-stays t)
737 (save-excursion 749 (save-excursion
738 (insert-file file) 750 (insert-file file)
739 (message ""))) 751 (message "")))
740 752
741 (defun tpu-get (file) 753 (defun tpu-get (file)
742 "TPU-like get file" 754 "TPU-like get file"
743 (interactive "FFile to get: ") 755 (interactive "FFile to get: ")
756 (setq zmacs-region-stays t)
744 (find-file file)) 757 (find-file file))
745 758
746 (defun tpu-what-line nil 759 (defun tpu-what-line nil
747 "Tells what line the point is on, 760 "Tells what line the point is on,
748 and the total number of lines in the buffer." 761 and the total number of lines in the buffer."
749 (interactive) 762 (interactive)
763 (setq zmacs-region-stays t)
750 (if (eobp) 764 (if (eobp)
751 (message "You are at the End of Buffer. The last line is %d." 765 (message "You are at the End of Buffer. The last line is %d."
752 (count-lines 1 (point-max))) 766 (count-lines 1 (point-max)))
753 (message "Line %d of %d" 767 (message "Line %d of %d"
754 (count-lines 1 (1+ (point))) 768 (count-lines 1 (1+ (point)))
933 (defvar tpu-help-p "p") ; tpu-help "p" symbol 947 (defvar tpu-help-p "p") ; tpu-help "p" symbol
934 948
935 (defun tpu-help nil 949 (defun tpu-help nil
936 "Display TPU-edt help." 950 "Display TPU-edt help."
937 (interactive) 951 (interactive)
952 (setq zmacs-region-stays t)
938 ;; Save current window configuration 953 ;; Save current window configuration
939 (save-window-excursion 954 (save-window-excursion
940 ;; Create and fill help buffer if necessary 955 ;; Create and fill help buffer if necessary
941 (if (not (get-buffer "*TPU-edt Help*")) 956 (if (not (get-buffer "*TPU-edt Help*"))
942 (progn (generate-new-buffer "*TPU-edt Help*") 957 (progn (generate-new-buffer "*TPU-edt Help*")
1005 ;;; Auto-insert 1020 ;;; Auto-insert
1006 ;;; 1021 ;;;
1007 (defun tpu-insert-escape nil 1022 (defun tpu-insert-escape nil
1008 "Inserts an escape character, and so becomes the escape-key alias." 1023 "Inserts an escape character, and so becomes the escape-key alias."
1009 (interactive) 1024 (interactive)
1025 (setq zmacs-region-stays t)
1010 (insert "\e")) 1026 (insert "\e"))
1011 1027
1012 (defun tpu-insert-formfeed nil 1028 (defun tpu-insert-formfeed nil
1013 "Inserts a formfeed character." 1029 "Inserts a formfeed character."
1014 (interactive) 1030 (interactive)
1031 (setq zmacs-region-stays t)
1015 (insert "\C-L")) 1032 (insert "\C-L"))
1016 1033
1017 1034
1018 ;;; 1035 ;;;
1019 ;;; Define key 1036 ;;; Define key
1021 (defvar tpu-saved-control-r nil "Saved value of Control-r.") 1038 (defvar tpu-saved-control-r nil "Saved value of Control-r.")
1022 1039
1023 (defun tpu-end-define-macro-key (key) 1040 (defun tpu-end-define-macro-key (key)
1024 "Ends the current macro definition" 1041 "Ends the current macro definition"
1025 (interactive "kPress the key you want to use to do what was just learned: ") 1042 (interactive "kPress the key you want to use to do what was just learned: ")
1043 (setq zmacs-region-stays t)
1026 (end-kbd-macro nil) 1044 (end-kbd-macro nil)
1027 (global-set-key key last-kbd-macro) 1045 (global-set-key key last-kbd-macro)
1028 (global-set-key "\C-r" tpu-saved-control-r)) 1046 (global-set-key "\C-r" tpu-saved-control-r))
1029 1047
1030 (defun tpu-define-macro-key nil 1048 (defun tpu-define-macro-key nil
1031 "Bind a set of keystrokes to a single key, or key combination." 1049 "Bind a set of keystrokes to a single key, or key combination."
1032 (interactive) 1050 (interactive)
1051 (setq zmacs-region-stays t)
1033 (setq tpu-saved-control-r (global-key-binding "\C-r")) 1052 (setq tpu-saved-control-r (global-key-binding "\C-r"))
1034 (global-set-key "\C-r" 'tpu-end-define-macro-key) 1053 (global-set-key "\C-r" 'tpu-end-define-macro-key)
1035 (start-kbd-macro nil)) 1054 (start-kbd-macro nil))
1036 1055
1037 1056
1052 (save-buffers-kill-emacs t))) 1071 (save-buffers-kill-emacs t)))
1053 1072
1054 (defun tpu-write-current-buffers nil 1073 (defun tpu-write-current-buffers nil
1055 "Save all modified buffers without exiting." 1074 "Save all modified buffers without exiting."
1056 (interactive) 1075 (interactive)
1076 (setq zmacs-region-stays t)
1057 (save-some-buffers t)) 1077 (save-some-buffers t))
1058 1078
1059 (defun tpu-next-buffer nil 1079 (defun tpu-next-buffer nil
1060 "Go to next buffer in ring." 1080 "Go to next buffer in ring."
1061 (interactive) 1081 (interactive)
1077 buffer-list))) 1097 buffer-list)))
1078 1098
1079 (defun tpu-next-window nil 1099 (defun tpu-next-window nil
1080 "Move to the next window." 1100 "Move to the next window."
1081 (interactive) 1101 (interactive)
1102 (setq zmacs-region-stays t)
1082 (if (one-window-p) (message "There is only one window on screen.") 1103 (if (one-window-p) (message "There is only one window on screen.")
1083 (other-window 1))) 1104 (other-window 1)))
1084 1105
1085 (defun tpu-previous-window nil 1106 (defun tpu-previous-window nil
1086 "Move to the previous window." 1107 "Move to the previous window."
1087 (interactive) 1108 (interactive)
1109 (setq zmacs-region-stays t)
1088 (if (one-window-p) (message "There is only one window on screen.") 1110 (if (one-window-p) (message "There is only one window on screen.")
1089 (select-window (previous-window)))) 1111 (select-window (previous-window))))
1090 1112
1091 1113
1092 ;;; 1114 ;;;
1093 ;;; Search 1115 ;;; Search
1094 ;;; 1116 ;;;
1095 (defun tpu-toggle-regexp nil 1117 (defun tpu-toggle-regexp nil
1096 "Switches in and out of regular expression search and replace mode." 1118 "Switches in and out of regular expression search and replace mode."
1097 (interactive) 1119 (interactive)
1120 (setq zmacs-region-stays t)
1098 (setq tpu-regexp-p (not tpu-regexp-p)) 1121 (setq tpu-regexp-p (not tpu-regexp-p))
1099 (tpu-set-search) 1122 (tpu-set-search)
1100 (and (interactive-p) 1123 (and (interactive-p)
1101 (message "Regular expression search and substitute %sabled." 1124 (message "Regular expression search and substitute %sabled."
1102 (if tpu-regexp-p "en" "dis")))) 1125 (if tpu-regexp-p "en" "dis"))))
1110 1133
1111 (defun tpu-search nil 1134 (defun tpu-search nil
1112 "Search for a string or regular expression. 1135 "Search for a string or regular expression.
1113 The search is performed in the current direction." 1136 The search is performed in the current direction."
1114 (interactive) 1137 (interactive)
1138 (setq zmacs-region-stays t)
1115 (tpu-set-search) 1139 (tpu-set-search)
1116 (tpu-search-internal "")) 1140 (tpu-search-internal ""))
1117 1141
1118 (defun tpu-search-forward nil 1142 (defun tpu-search-forward nil
1119 "Search for a string or regular expression. 1143 "Search for a string or regular expression.
1120 The search is begins in the forward direction." 1144 The search is begins in the forward direction."
1121 (interactive) 1145 (interactive)
1146 (setq zmacs-region-stays t)
1122 (setq tpu-searching-forward t) 1147 (setq tpu-searching-forward t)
1123 (tpu-set-search t) 1148 (tpu-set-search t)
1124 (tpu-search-internal "")) 1149 (tpu-search-internal ""))
1125 1150
1126 (defun tpu-search-reverse nil 1151 (defun tpu-search-reverse nil
1127 "Search for a string or regular expression. 1152 "Search for a string or regular expression.
1128 The search is begins in the reverse direction." 1153 The search is begins in the reverse direction."
1129 (interactive) 1154 (interactive)
1155 (setq zmacs-region-stays t)
1130 (setq tpu-searching-forward nil) 1156 (setq tpu-searching-forward nil)
1131 (tpu-set-search t) 1157 (tpu-set-search t)
1132 (tpu-search-internal "")) 1158 (tpu-search-internal ""))
1133 1159
1134 (defun tpu-search-again nil 1160 (defun tpu-search-again nil
1135 "Search for the same string or regular expression as last time. 1161 "Search for the same string or regular expression as last time.
1136 The search is performed in the current direction." 1162 The search is performed in the current direction."
1137 (interactive) 1163 (interactive)
1164 (setq zmacs-region-stays t)
1138 (tpu-search-internal tpu-search-last-string)) 1165 (tpu-search-internal tpu-search-last-string))
1139 1166
1140 ;; tpu-set-search defines the search functions used by the TPU-edt internal 1167 ;; tpu-set-search defines the search functions used by the TPU-edt internal
1141 ;; search function. It should be called whenever the direction changes, or 1168 ;; search function. It should be called whenever the direction changes, or
1142 ;; the regular expression mode is turned on or off. It can also be called 1169 ;; the regular expression mode is turned on or off. It can also be called
1229 1256
1230 (defun tpu-toggle-search-direction nil 1257 (defun tpu-toggle-search-direction nil
1231 "Toggle the TPU-edt search direction. 1258 "Toggle the TPU-edt search direction.
1232 Used for reversing a search in progress." 1259 Used for reversing a search in progress."
1233 (interactive) 1260 (interactive)
1261 (setq zmacs-region-stays t)
1234 (setq tpu-searching-forward (not tpu-searching-forward)) 1262 (setq tpu-searching-forward (not tpu-searching-forward))
1235 (tpu-set-search t) 1263 (tpu-set-search t)
1236 (and (interactive-p) 1264 (and (interactive-p)
1237 (message "Searching %sward." 1265 (message "Searching %sward."
1238 (if tpu-searching-forward "for" "back")))) 1266 (if tpu-searching-forward "for" "back"))))
1239 1267
1240 (defun tpu-search-forward-exit nil 1268 (defun tpu-search-forward-exit nil
1241 "Set search direction forward and exit minibuffer." 1269 "Set search direction forward and exit minibuffer."
1242 (interactive) 1270 (interactive)
1271 (setq zmacs-region-stays t)
1243 (setq tpu-searching-forward t) 1272 (setq tpu-searching-forward t)
1244 (tpu-set-search t) 1273 (tpu-set-search t)
1245 (exit-minibuffer)) 1274 (exit-minibuffer))
1246 1275
1247 (defun tpu-search-backward-exit nil 1276 (defun tpu-search-backward-exit nil
1248 "Set search direction backward and exit minibuffer." 1277 "Set search direction backward and exit minibuffer."
1249 (interactive) 1278 (interactive)
1279 (setq zmacs-region-stays t)
1250 (setq tpu-searching-forward nil) 1280 (setq tpu-searching-forward nil)
1251 (tpu-set-search t) 1281 (tpu-set-search t)
1252 (exit-minibuffer)) 1282 (exit-minibuffer))
1253 1283
1254 1284
1278 ;;; Delete / Cut 1308 ;;; Delete / Cut
1279 ;;; 1309 ;;;
1280 (defun tpu-toggle-rectangle nil 1310 (defun tpu-toggle-rectangle nil
1281 "Toggle rectangular mode for remove and insert." 1311 "Toggle rectangular mode for remove and insert."
1282 (interactive) 1312 (interactive)
1313 (setq zmacs-region-stays t)
1283 (setq tpu-rectangular-p (not tpu-rectangular-p)) 1314 (setq tpu-rectangular-p (not tpu-rectangular-p))
1284 (setq tpu-rectangle-string (if tpu-rectangular-p " Rect" "")) 1315 (setq tpu-rectangle-string (if tpu-rectangular-p " Rect" ""))
1285 (tpu-update-mode-line) 1316 (tpu-update-mode-line)
1286 (and (interactive-p) 1317 (and (interactive-p)
1287 (message "Rectangular cut and paste %sabled." 1318 (message "Rectangular cut and paste %sabled."
1333 1364
1334 (defun tpu-store-text nil 1365 (defun tpu-store-text nil
1335 "Copy the selected region to the cut buffer without deleting it. 1366 "Copy the selected region to the cut buffer without deleting it.
1336 The text is saved for the tpu-paste command." 1367 The text is saved for the tpu-paste command."
1337 (interactive) 1368 (interactive)
1369 (setq zmacs-region-stays t)
1338 (cond ((tpu-mark) 1370 (cond ((tpu-mark)
1339 (cond (tpu-rectangular-p 1371 (cond (tpu-rectangular-p
1340 (save-excursion 1372 (save-excursion
1341 (tpu-arrange-rectangle) 1373 (tpu-arrange-rectangle)
1342 (setq picture-killed-rectangle 1374 (setq picture-killed-rectangle
1383 (defun tpu-delete-current-line (num) 1415 (defun tpu-delete-current-line (num)
1384 "Delete one or specified number of lines after point. 1416 "Delete one or specified number of lines after point.
1385 This includes the newline character at the end of each line. 1417 This includes the newline character at the end of each line.
1386 They are saved for the TPU-edt undelete-lines command." 1418 They are saved for the TPU-edt undelete-lines command."
1387 (interactive "p") 1419 (interactive "p")
1420 (setq zmacs-region-stays t)
1388 (let ((beg (point))) 1421 (let ((beg (point)))
1389 (forward-line num) 1422 (forward-line num)
1390 (if (not (eq (preceding-char) ?\n)) 1423 (if (not (eq (preceding-char) ?\n))
1391 (insert "\n")) 1424 (insert "\n"))
1392 (setq tpu-last-deleted-lines 1425 (setq tpu-last-deleted-lines
1396 (defun tpu-delete-to-eol (num) 1429 (defun tpu-delete-to-eol (num)
1397 "Delete text up to end of line. 1430 "Delete text up to end of line.
1398 With argument, delete up to to Nth line-end past point. 1431 With argument, delete up to to Nth line-end past point.
1399 They are saved for the TPU-edt undelete-lines command." 1432 They are saved for the TPU-edt undelete-lines command."
1400 (interactive "p") 1433 (interactive "p")
1434 (setq zmacs-region-stays t)
1401 (let ((beg (point))) 1435 (let ((beg (point)))
1402 (forward-char 1) 1436 (forward-char 1)
1403 (end-of-line num) 1437 (end-of-line num)
1404 (setq tpu-last-deleted-lines 1438 (setq tpu-last-deleted-lines
1405 (buffer-substring beg (point))) 1439 (buffer-substring beg (point)))
1408 (defun tpu-delete-to-bol (num) 1442 (defun tpu-delete-to-bol (num)
1409 "Delete text back to beginning of line. 1443 "Delete text back to beginning of line.
1410 With argument, delete up to to Nth line-end past point. 1444 With argument, delete up to to Nth line-end past point.
1411 They are saved for the TPU-edt undelete-lines command." 1445 They are saved for the TPU-edt undelete-lines command."
1412 (interactive "p") 1446 (interactive "p")
1447 (setq zmacs-region-stays t)
1413 (let ((beg (point))) 1448 (let ((beg (point)))
1414 (tpu-next-beginning-of-line num) 1449 (tpu-next-beginning-of-line num)
1415 (setq tpu-last-deleted-lines 1450 (setq tpu-last-deleted-lines
1416 (buffer-substring (point) beg)) 1451 (buffer-substring (point) beg))
1417 (delete-region (point) beg))) 1452 (delete-region (point) beg)))
1418 1453
1419 (defun tpu-delete-current-word (num) 1454 (defun tpu-delete-current-word (num)
1420 "Delete one or specified number of words after point. 1455 "Delete one or specified number of words after point.
1421 They are saved for the TPU-edt undelete-words command." 1456 They are saved for the TPU-edt undelete-words command."
1422 (interactive "p") 1457 (interactive "p")
1458 (setq zmacs-region-stays t)
1423 (let ((beg (point))) 1459 (let ((beg (point)))
1424 (tpu-forward-to-word num) 1460 (tpu-forward-to-word num)
1425 (setq tpu-last-deleted-words 1461 (setq tpu-last-deleted-words
1426 (buffer-substring beg (point))) 1462 (buffer-substring beg (point)))
1427 (delete-region beg (point)))) 1463 (delete-region beg (point))))
1428 1464
1429 (defun tpu-delete-previous-word (num) 1465 (defun tpu-delete-previous-word (num)
1430 "Delete one or specified number of words before point. 1466 "Delete one or specified number of words before point.
1431 They are saved for the TPU-edt undelete-words command." 1467 They are saved for the TPU-edt undelete-words command."
1432 (interactive "p") 1468 (interactive "p")
1469 (setq zmacs-region-stays t)
1433 (let ((beg (point))) 1470 (let ((beg (point)))
1434 (tpu-backward-to-word num) 1471 (tpu-backward-to-word num)
1435 (setq tpu-last-deleted-words 1472 (setq tpu-last-deleted-words
1436 (buffer-substring (point) beg)) 1473 (buffer-substring (point) beg))
1437 (delete-region beg (point)))) 1474 (delete-region beg (point))))
1438 1475
1439 (defun tpu-delete-current-char (num) 1476 (defun tpu-delete-current-char (num)
1440 "Delete one or specified number of characters after point. The last 1477 "Delete one or specified number of characters after point. The last
1441 character deleted is saved for the TPU-edt undelete-char command." 1478 character deleted is saved for the TPU-edt undelete-char command."
1442 (interactive "p") 1479 (interactive "p")
1480 (setq zmacs-region-stays t)
1443 (while (and (> num 0) (not (eobp))) 1481 (while (and (> num 0) (not (eobp)))
1444 (setq tpu-last-deleted-char (char-after (point))) 1482 (setq tpu-last-deleted-char (char-after (point)))
1445 (cond (overwrite-mode 1483 (cond (overwrite-mode
1446 (picture-clear-column 1) 1484 (picture-clear-column 1)
1447 (forward-char 1)) 1485 (forward-char 1))
1455 ;;; 1493 ;;;
1456 (defun tpu-paste (num) 1494 (defun tpu-paste (num)
1457 "Insert the last region or rectangle of killed text. 1495 "Insert the last region or rectangle of killed text.
1458 With argument reinserts the text that many times." 1496 With argument reinserts the text that many times."
1459 (interactive "p") 1497 (interactive "p")
1498 (setq zmacs-region-stays t)
1460 (while (> num 0) 1499 (while (> num 0)
1461 (cond (tpu-rectangular-p 1500 (cond (tpu-rectangular-p
1462 (let ((beg (point))) 1501 (let ((beg (point)))
1463 (save-excursion 1502 (save-excursion
1464 (picture-yank-rectangle (not overwrite-mode)) 1503 (picture-yank-rectangle (not overwrite-mode))
1470 1509
1471 (defun tpu-undelete-lines (num) 1510 (defun tpu-undelete-lines (num)
1472 "Insert lines deleted by last TPU-edt line-deletion command. 1511 "Insert lines deleted by last TPU-edt line-deletion command.
1473 With argument reinserts lines that many times." 1512 With argument reinserts lines that many times."
1474 (interactive "p") 1513 (interactive "p")
1514 (setq zmacs-region-stays t)
1475 (let ((beg (point))) 1515 (let ((beg (point)))
1476 (while (> num 0) 1516 (while (> num 0)
1477 (insert tpu-last-deleted-lines) 1517 (insert tpu-last-deleted-lines)
1478 (setq num (1- num))) 1518 (setq num (1- num)))
1479 (goto-char beg))) 1519 (goto-char beg)))
1480 1520
1481 (defun tpu-undelete-words (num) 1521 (defun tpu-undelete-words (num)
1482 "Insert words deleted by last TPU-edt word-deletion command. 1522 "Insert words deleted by last TPU-edt word-deletion command.
1483 With argument reinserts words that many times." 1523 With argument reinserts words that many times."
1484 (interactive "p") 1524 (interactive "p")
1525 (setq zmacs-region-stays t)
1485 (let ((beg (point))) 1526 (let ((beg (point)))
1486 (while (> num 0) 1527 (while (> num 0)
1487 (insert tpu-last-deleted-words) 1528 (insert tpu-last-deleted-words)
1488 (setq num (1- num))) 1529 (setq num (1- num)))
1489 (goto-char beg))) 1530 (goto-char beg)))
1490 1531
1491 (defun tpu-undelete-char (num) 1532 (defun tpu-undelete-char (num)
1492 "Insert character deleted by last TPU-edt character-deletion command. 1533 "Insert character deleted by last TPU-edt character-deletion command.
1493 With argument reinserts the character that many times." 1534 With argument reinserts the character that many times."
1494 (interactive "p") 1535 (interactive "p")
1536 (setq zmacs-region-stays t)
1495 (while (> num 0) 1537 (while (> num 0)
1496 (if overwrite-mode (prog1 (forward-char -1) (delete-char 1))) 1538 (if overwrite-mode (prog1 (forward-char -1) (delete-char 1)))
1497 (insert tpu-last-deleted-char) 1539 (insert tpu-last-deleted-char)
1498 (forward-char -1) 1540 (forward-char -1)
1499 (setq num (1- num)))) 1541 (setq num (1- num))))
1611 (defun tpu-add-at-bol (text) 1653 (defun tpu-add-at-bol (text)
1612 "Add text to the beginning of each line in a region, 1654 "Add text to the beginning of each line in a region,
1613 or each line in the entire buffer if no region is selected." 1655 or each line in the entire buffer if no region is selected."
1614 (interactive 1656 (interactive
1615 (list (tpu-string-prompt "String to add: " 'tpu-add-at-bol-hist))) 1657 (list (tpu-string-prompt "String to add: " 'tpu-add-at-bol-hist)))
1658 (setq zmacs-region-stays t)
1616 (if (string= "" text) (error "No string specified.")) 1659 (if (string= "" text) (error "No string specified."))
1617 (cond ((tpu-mark) 1660 (cond ((tpu-mark)
1618 (save-excursion 1661 (save-excursion
1619 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) 1662 (if (> (point) (tpu-mark)) (exchange-point-and-mark))
1620 (while (and (< (point) (tpu-mark)) (re-search-forward "^" (tpu-mark) t)) 1663 (while (and (< (point) (tpu-mark)) (re-search-forward "^" (tpu-mark) t))
1629 (defun tpu-add-at-eol (text) 1672 (defun tpu-add-at-eol (text)
1630 "Add text to the end of each line in a region, 1673 "Add text to the end of each line in a region,
1631 or each line of the entire buffer if no region is selected." 1674 or each line of the entire buffer if no region is selected."
1632 (interactive 1675 (interactive
1633 (list (tpu-string-prompt "String to add: " 'tpu-add-at-eol-hist))) 1676 (list (tpu-string-prompt "String to add: " 'tpu-add-at-eol-hist)))
1677 (set zmacs-region-stays t)
1634 (if (string= "" text) (error "No string specified.")) 1678 (if (string= "" text) (error "No string specified."))
1635 (cond ((tpu-mark) 1679 (cond ((tpu-mark)
1636 (save-excursion 1680 (save-excursion
1637 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) 1681 (if (> (point) (tpu-mark)) (exchange-point-and-mark))
1638 (while (< (point) (tpu-mark)) 1682 (while (< (point) (tpu-mark))
1647 (end-of-line) (insert text) (forward-line)))))) 1691 (end-of-line) (insert text) (forward-line))))))
1648 1692
1649 (defun tpu-trim-line-ends nil 1693 (defun tpu-trim-line-ends nil
1650 "Removes trailing whitespace from every line in the buffer." 1694 "Removes trailing whitespace from every line in the buffer."
1651 (interactive) 1695 (interactive)
1696 (setq zmacs-region-stays t)
1652 (picture-clean)) 1697 (picture-clean))
1653 1698
1654 1699
1655 ;;; 1700 ;;;
1656 ;;; Movement by character 1701 ;;; Movement by character
1657 ;;; 1702 ;;;
1658 (defun tpu-char (num) 1703 (defun tpu-char (num)
1659 "Move to the next character in the current direction. 1704 "Move to the next character in the current direction.
1660 A repeat count means move that many characters." 1705 A repeat count means move that many characters."
1661 (interactive "p") 1706 (interactive "p")
1707 (setq zmacs-region-stays t)
1662 (if tpu-advance (tpu-forward-char num) (tpu-backward-char num))) 1708 (if tpu-advance (tpu-forward-char num) (tpu-backward-char num)))
1663 1709
1664 (defun tpu-forward-char (num) 1710 (defun tpu-forward-char (num)
1665 "Move right ARG characters (left if ARG is negative)." 1711 "Move right ARG characters (left if ARG is negative)."
1666 (interactive "p") 1712 (interactive "p")
1713 (setq zmacs-region-stays t)
1667 (forward-char num)) 1714 (forward-char num))
1668 1715
1669 (defun tpu-backward-char (num) 1716 (defun tpu-backward-char (num)
1670 "Move left ARG characters (right if ARG is negative)." 1717 "Move left ARG characters (right if ARG is negative)."
1671 (interactive "p") 1718 (interactive "p")
1719 (setq zmacs-region-stays t)
1672 (backward-char num)) 1720 (backward-char num))
1673 1721
1674 1722
1675 ;;; 1723 ;;;
1676 ;;; Movement by word 1724 ;;; Movement by word
1683 1731
1684 (defun tpu-word (num) 1732 (defun tpu-word (num)
1685 "Move to the beginning of the next word in the current direction. 1733 "Move to the beginning of the next word in the current direction.
1686 A repeat count means move that many words." 1734 A repeat count means move that many words."
1687 (interactive "p") 1735 (interactive "p")
1736 (setq zmacs-region-stays t)
1688 (if tpu-advance (tpu-forward-to-word num) (tpu-backward-to-word num))) 1737 (if tpu-advance (tpu-forward-to-word num) (tpu-backward-to-word num)))
1689 1738
1690 (defun tpu-forward-to-word (num) 1739 (defun tpu-forward-to-word (num)
1691 "Move forward until encountering the beginning of a word. 1740 "Move forward until encountering the beginning of a word.
1692 With argument, do this that many times." 1741 With argument, do this that many times."
1693 (interactive "p") 1742 (interactive "p")
1743 (setq zmacs-region-stays t)
1694 (while (and (> num 0) (not (eobp))) 1744 (while (and (> num 0) (not (eobp)))
1695 (let* ((beg (point)) 1745 (let* ((beg (point))
1696 (end (prog2 (end-of-line) (point) (goto-char beg)))) 1746 (end (prog2 (end-of-line) (point) (goto-char beg))))
1697 (cond ((eolp) 1747 (cond ((eolp)
1698 (forward-char 1)) 1748 (forward-char 1))
1706 1756
1707 (defun tpu-backward-to-word (num) 1757 (defun tpu-backward-to-word (num)
1708 "Move backward until encountering the beginning of a word. 1758 "Move backward until encountering the beginning of a word.
1709 With argument, do this that many times." 1759 With argument, do this that many times."
1710 (interactive "p") 1760 (interactive "p")
1761 (setq zmacs-region-stays t)
1711 (while (and (> num 0) (not (bobp))) 1762 (while (and (> num 0) (not (bobp)))
1712 (let* ((beg (point)) 1763 (let* ((beg (point))
1713 (end (prog2 (beginning-of-line) (point) (goto-char beg)))) 1764 (end (prog2 (beginning-of-line) (point) (goto-char beg))))
1714 (cond ((bolp) 1765 (cond ((bolp)
1715 ( forward-char -1)) 1766 ( forward-char -1))
1723 (setq num (1- num)))) 1774 (setq num (1- num))))
1724 1775
1725 (defun tpu-add-word-separators (separators) 1776 (defun tpu-add-word-separators (separators)
1726 "Add new word separators for TPU-edt word commands." 1777 "Add new word separators for TPU-edt word commands."
1727 (interactive "sSeparators: ") 1778 (interactive "sSeparators: ")
1779 (setq zmacs-region-stays t)
1728 (let* ((n 0) (length (length separators))) 1780 (let* ((n 0) (length (length separators)))
1729 (while (< n length) 1781 (while (< n length)
1730 (let ((char (aref separators n)) 1782 (let ((char (aref separators n))
1731 (ss (substring separators n (1+ n)))) 1783 (ss (substring separators n (1+ n))))
1732 (cond ((not (memq char tpu-word-separator-list)) 1784 (cond ((not (memq char tpu-word-separator-list))
1743 (setq n (1+ n)))))) 1795 (setq n (1+ n))))))
1744 1796
1745 (defun tpu-reset-word-separators nil 1797 (defun tpu-reset-word-separators nil
1746 "Reset word separators to default value." 1798 "Reset word separators to default value."
1747 (interactive) 1799 (interactive)
1800 (setq zmacs-region-stays t)
1748 (setq tpu-word-separator-list nil) 1801 (setq tpu-word-separator-list nil)
1749 (setq tpu-skip-chars "^ \t")) 1802 (setq tpu-skip-chars "^ \t"))
1750 1803
1751 (defun tpu-set-word-separators (separators) 1804 (defun tpu-set-word-separators (separators)
1752 "Set new word separators for TPU-edt word commands." 1805 "Set new word separators for TPU-edt word commands."
1753 (interactive "sSeparators: ") 1806 (interactive "sSeparators: ")
1807 (setq zmacs-region-stays t)
1754 (tpu-reset-word-separators) 1808 (tpu-reset-word-separators)
1755 (tpu-add-word-separators separators)) 1809 (tpu-add-word-separators separators))
1756 1810
1757 1811
1758 ;;; 1812 ;;;
1760 ;;; 1814 ;;;
1761 (defun tpu-next-line (num) 1815 (defun tpu-next-line (num)
1762 "Move to next line. 1816 "Move to next line.
1763 Prefix argument serves as a repeat count." 1817 Prefix argument serves as a repeat count."
1764 (interactive "p") 1818 (interactive "p")
1819 (setq zmacs-region-stays t)
1765 (next-line-internal num) 1820 (next-line-internal num)
1766 (setq this-command 'next-line)) 1821 (setq this-command 'next-line))
1767 1822
1768 (defun tpu-previous-line (num) 1823 (defun tpu-previous-line (num)
1769 "Move to previous line. 1824 "Move to previous line.
1770 Prefix argument serves as a repeat count." 1825 Prefix argument serves as a repeat count."
1771 (interactive "p") 1826 (interactive "p")
1827 (setq zmacs-region-stays t)
1772 (next-line-internal (- num)) 1828 (next-line-internal (- num))
1773 (setq this-command 'previous-line)) 1829 (setq this-command 'previous-line))
1774 1830
1775 (defun tpu-next-beginning-of-line (num) 1831 (defun tpu-next-beginning-of-line (num)
1776 "Move to beginning of line; if at beginning, move to beginning of next line. 1832 "Move to beginning of line; if at beginning, move to beginning of next line.
1777 Accepts a prefix argument for the number of lines to move." 1833 Accepts a prefix argument for the number of lines to move."
1778 (interactive "p") 1834 (interactive "p")
1835 (setq zmacs-region-stays t)
1779 (backward-char 1) 1836 (backward-char 1)
1780 (forward-line (- 1 num))) 1837 (forward-line (- 1 num)))
1781 1838
1782 (defun tpu-end-of-line (num) 1839 (defun tpu-end-of-line (num)
1783 "Move to the next end of line in the current direction. 1840 "Move to the next end of line in the current direction.
1784 A repeat count means move that many lines." 1841 A repeat count means move that many lines."
1785 (interactive "p") 1842 (interactive "p")
1843 (setq zmacs-region-stays t)
1786 (if tpu-advance (tpu-next-end-of-line num) (tpu-previous-end-of-line num))) 1844 (if tpu-advance (tpu-next-end-of-line num) (tpu-previous-end-of-line num)))
1787 1845
1788 (defun tpu-next-end-of-line (num) 1846 (defun tpu-next-end-of-line (num)
1789 "Move to end of line; if at end, move to end of next line. 1847 "Move to end of line; if at end, move to end of next line.
1790 Accepts a prefix argument for the number of lines to move." 1848 Accepts a prefix argument for the number of lines to move."
1791 (interactive "p") 1849 (interactive "p")
1850 (setq zmacs-region-stays t)
1792 (forward-char 1) 1851 (forward-char 1)
1793 (end-of-line num)) 1852 (end-of-line num))
1794 1853
1795 (defun tpu-previous-end-of-line (num) 1854 (defun tpu-previous-end-of-line (num)
1796 "Move EOL upward. 1855 "Move EOL upward.
1797 Accepts a prefix argument for the number of lines to move." 1856 Accepts a prefix argument for the number of lines to move."
1798 (interactive "p") 1857 (interactive "p")
1858 (setq zmacs-region-stays t)
1799 (end-of-line (- 1 num))) 1859 (end-of-line (- 1 num)))
1800 1860
1801 (defun tpu-current-end-of-line nil 1861 (defun tpu-current-end-of-line nil
1802 "Move point to end of current line." 1862 "Move point to end of current line."
1803 (interactive) 1863 (interactive)
1864 (setq zmacs-region-stays t)
1804 (let ((beg (point))) 1865 (let ((beg (point)))
1805 (end-of-line) 1866 (end-of-line)
1806 (if (= beg (point)) (message "You are already at the end of a line.")))) 1867 (if (= beg (point)) (message "You are already at the end of a line."))))
1807 1868
1808 (defun tpu-line (num) 1869 (defun tpu-line (num)
1809 "Move to the beginning of the next line in the current direction. 1870 "Move to the beginning of the next line in the current direction.
1810 A repeat count means move that many lines." 1871 A repeat count means move that many lines."
1811 (interactive "p") 1872 (interactive "p")
1873 (setq zmacs-region-stays t)
1812 (if tpu-advance (tpu-forward-line num) (tpu-backward-line num))) 1874 (if tpu-advance (tpu-forward-line num) (tpu-backward-line num)))
1813 1875
1814 (defun tpu-forward-line (num) 1876 (defun tpu-forward-line (num)
1815 "Move to beginning of next line. 1877 "Move to beginning of next line.
1816 Prefix argument serves as a repeat count." 1878 Prefix argument serves as a repeat count."
1817 (interactive "p") 1879 (interactive "p")
1880 (setq zmacs-region-stays t)
1818 (forward-line num)) 1881 (forward-line num))
1819 1882
1820 (defun tpu-backward-line (num) 1883 (defun tpu-backward-line (num)
1821 "Move to beginning of previous line. 1884 "Move to beginning of previous line.
1822 Prefix argument serves as repeat count." 1885 Prefix argument serves as repeat count."
1823 (interactive "p") 1886 (interactive "p")
1887 (setq zmacs-region-stays t)
1824 (or (bolp) (>= 0 num) (setq num (- num 1))) 1888 (or (bolp) (>= 0 num) (setq num (- num 1)))
1825 (forward-line (- num))) 1889 (forward-line (- num)))
1826 1890
1827 1891
1828 ;;; 1892 ;;;
1830 ;;; 1894 ;;;
1831 (defun tpu-paragraph (num) 1895 (defun tpu-paragraph (num)
1832 "Move to the next paragraph in the current direction. 1896 "Move to the next paragraph in the current direction.
1833 A repeat count means move that many paragraphs." 1897 A repeat count means move that many paragraphs."
1834 (interactive "p") 1898 (interactive "p")
1899 (setq zmacs-region-stays t)
1835 (if tpu-advance 1900 (if tpu-advance
1836 (tpu-next-paragraph num) (tpu-previous-paragraph num))) 1901 (tpu-next-paragraph num) (tpu-previous-paragraph num)))
1837 1902
1838 (defun tpu-next-paragraph (num) 1903 (defun tpu-next-paragraph (num)
1839 "Move to beginning of the next paragraph. 1904 "Move to beginning of the next paragraph.
1840 Accepts a prefix argument for the number of paragraphs." 1905 Accepts a prefix argument for the number of paragraphs."
1841 (interactive "p") 1906 (interactive "p")
1907 (setq zmacs-region-stays t)
1842 (beginning-of-line) 1908 (beginning-of-line)
1843 (while (and (not (eobp)) (> num 0)) 1909 (while (and (not (eobp)) (> num 0))
1844 (if (re-search-forward "^[ \t]*$" nil t) 1910 (if (re-search-forward "^[ \t]*$" nil t)
1845 (if (re-search-forward "[^ \t\n]" nil t) 1911 (if (re-search-forward "[^ \t\n]" nil t)
1846 (goto-char (match-beginning 0)) 1912 (goto-char (match-beginning 0))
1851 1917
1852 (defun tpu-previous-paragraph (num) 1918 (defun tpu-previous-paragraph (num)
1853 "Move to beginning of previous paragraph. 1919 "Move to beginning of previous paragraph.
1854 Accepts a prefix argument for the number of paragraphs." 1920 Accepts a prefix argument for the number of paragraphs."
1855 (interactive "p") 1921 (interactive "p")
1922 (setq zmacs-region-stays t)
1856 (end-of-line) 1923 (end-of-line)
1857 (while (and (not (bobp)) (> num 0)) 1924 (while (and (not (bobp)) (> num 0))
1858 (if (not (and (re-search-backward "^[ \t]*$" nil t) 1925 (if (not (and (re-search-backward "^[ \t]*$" nil t)
1859 (re-search-backward "[^ \t\n]" nil t) 1926 (re-search-backward "[^ \t\n]" nil t)
1860 (re-search-backward "^[ \t]*$" nil t) 1927 (re-search-backward "^[ \t]*$" nil t)
1870 ;;; 1937 ;;;
1871 (defun tpu-page (num) 1938 (defun tpu-page (num)
1872 "Move to the next page in the current direction. 1939 "Move to the next page in the current direction.
1873 A repeat count means move that many pages." 1940 A repeat count means move that many pages."
1874 (interactive "p") 1941 (interactive "p")
1942 (setq zmacs-region-stays t)
1875 (if tpu-advance (forward-page num) (backward-page num)) 1943 (if tpu-advance (forward-page num) (backward-page num))
1876 (if (eobp) (recenter -1))) 1944 (if (eobp) (recenter -1)))
1877 1945
1878 1946
1879 ;;; 1947 ;;;
1881 ;;; 1949 ;;;
1882 (defun tpu-scroll-window (num) 1950 (defun tpu-scroll-window (num)
1883 "Scroll the display to the next section in the current direction. 1951 "Scroll the display to the next section in the current direction.
1884 A repeat count means scroll that many sections." 1952 A repeat count means scroll that many sections."
1885 (interactive "p") 1953 (interactive "p")
1954 (setq zmacs-region-stays t)
1886 (if tpu-advance (tpu-scroll-window-up num) (tpu-scroll-window-down num))) 1955 (if tpu-advance (tpu-scroll-window-up num) (tpu-scroll-window-down num)))
1887 1956
1888 (defun tpu-scroll-window-down (num) 1957 (defun tpu-scroll-window-down (num)
1889 "Scroll the display down to the next section. 1958 "Scroll the display down to the next section.
1890 A repeat count means scroll that many sections." 1959 A repeat count means scroll that many sections."
1891 (interactive "p") 1960 (interactive "p")
1961 (setq zmacs-region-stays t)
1892 (let* ((beg (tpu-current-line)) 1962 (let* ((beg (tpu-current-line))
1893 (height (1- (window-height))) 1963 (height (1- (window-height)))
1894 (lines (* num (/ (* height tpu-percent-scroll) 100)))) 1964 (lines (* num (/ (* height tpu-percent-scroll) 100))))
1895 (next-line-internal (- lines)) 1965 (next-line-internal (- lines))
1896 (if (> lines beg) (recenter 0)))) 1966 (if (> lines beg) (recenter 0))))
1897 1967
1898 (defun tpu-scroll-window-up (num) 1968 (defun tpu-scroll-window-up (num)
1899 "Scroll the display up to the next section. 1969 "Scroll the display up to the next section.
1900 A repeat count means scroll that many sections." 1970 A repeat count means scroll that many sections."
1901 (interactive "p") 1971 (interactive "p")
1972 (setq zmacs-region-stays t)
1902 (let* ((beg (tpu-current-line)) 1973 (let* ((beg (tpu-current-line))
1903 (height (1- (window-height))) 1974 (height (1- (window-height)))
1904 (lines (* num (/ (* height tpu-percent-scroll) 100)))) 1975 (lines (* num (/ (* height tpu-percent-scroll) 100))))
1905 (next-line-internal lines) 1976 (next-line-internal lines)
1906 (if (>= (+ lines beg) height) (recenter -1)))) 1977 (if (>= (+ lines beg) height) (recenter -1))))
1907 1978
1908 (defun tpu-pan-right (num) 1979 (defun tpu-pan-right (num)
1909 "Pan right tpu-pan-columns (16 by default). 1980 "Pan right tpu-pan-columns (16 by default).
1910 Accepts a prefix argument for the number of tpu-pan-columns to scroll." 1981 Accepts a prefix argument for the number of tpu-pan-columns to scroll."
1911 (interactive "p") 1982 (interactive "p")
1983 (setq zmacs-region-stays t)
1912 (scroll-left (* tpu-pan-columns num))) 1984 (scroll-left (* tpu-pan-columns num)))
1913 1985
1914 (defun tpu-pan-left (num) 1986 (defun tpu-pan-left (num)
1915 "Pan left tpu-pan-columns (16 by default). 1987 "Pan left tpu-pan-columns (16 by default).
1916 Accepts a prefix argument for the number of tpu-pan-columns to scroll." 1988 Accepts a prefix argument for the number of tpu-pan-columns to scroll."
1917 (interactive "p") 1989 (interactive "p")
1990 (setq zmacs-region-stays t)
1918 (scroll-right (* tpu-pan-columns num))) 1991 (scroll-right (* tpu-pan-columns num)))
1919 1992
1920 (defun tpu-move-to-beginning nil 1993 (defun tpu-move-to-beginning nil
1921 "Move cursor to the beginning of buffer, but don't set the mark." 1994 "Move cursor to the beginning of buffer, but don't set the mark."
1922 (interactive) 1995 (interactive)
1996 (setq zmacs-region-stays t)
1923 (goto-char (point-min))) 1997 (goto-char (point-min)))
1924 1998
1925 (defun tpu-move-to-end nil 1999 (defun tpu-move-to-end nil
1926 "Move cursor to the end of buffer, but don't set the mark." 2000 "Move cursor to the end of buffer, but don't set the mark."
1927 (interactive) 2001 (interactive)
2002 (setq zmacs-region-stays t)
1928 (goto-char (point-max)) 2003 (goto-char (point-max))
1929 (recenter -1)) 2004 (recenter -1))
1930 2005
1931 (defun tpu-goto-percent (perc) 2006 (defun tpu-goto-percent (perc)
1932 "Move point to ARG percentage of the buffer." 2007 "Move point to ARG percentage of the buffer."
1933 (interactive "NGoto-percentage: ") 2008 (interactive "NGoto-percentage: ")
2009 (setq zmacs-region-stays t)
1934 (if (or (> perc 100) (< perc 0)) 2010 (if (or (> perc 100) (< perc 0))
1935 (error "Percentage %d out of range 0 < percent < 100" perc) 2011 (error "Percentage %d out of range 0 < percent < 100" perc)
1936 (goto-char (/ (* (point-max) perc) 100)))) 2012 (goto-char (/ (* (point-max) perc) 100))))
1937 2013
1938 (defun tpu-beginning-of-window nil 2014 (defun tpu-beginning-of-window nil
1939 "Move cursor to top of window." 2015 "Move cursor to top of window."
1940 (interactive) 2016 (interactive)
2017 (setq zmacs-region-stays t)
1941 (move-to-window-line 0)) 2018 (move-to-window-line 0))
1942 2019
1943 (defun tpu-end-of-window nil 2020 (defun tpu-end-of-window nil
1944 "Move cursor to bottom of window." 2021 "Move cursor to bottom of window."
1945 (interactive) 2022 (interactive)
2023 (setq zmacs-region-stays t)
1946 (move-to-window-line -1)) 2024 (move-to-window-line -1))
1947 2025
1948 (defun tpu-line-to-bottom-of-window nil 2026 (defun tpu-line-to-bottom-of-window nil
1949 "Move the current line to the bottom of the window." 2027 "Move the current line to the bottom of the window."
1950 (interactive) 2028 (interactive)
2029 (setq zmacs-region-stays t)
1951 (recenter -1)) 2030 (recenter -1))
1952 2031
1953 (defun tpu-line-to-top-of-window nil 2032 (defun tpu-line-to-top-of-window nil
1954 "Move the current line to the top of the window." 2033 "Move the current line to the top of the window."
1955 (interactive) 2034 (interactive)
2035 (setq zmacs-region-stays t)
1956 (recenter 0)) 2036 (recenter 0))
1957 2037
1958 2038
1959 ;;; 2039 ;;;
1960 ;;; Direction 2040 ;;; Direction
1961 ;;; 2041 ;;;
1962 (defun tpu-advance-direction nil 2042 (defun tpu-advance-direction nil
1963 "Set TPU Advance mode so keypad commands move forward." 2043 "Set TPU Advance mode so keypad commands move forward."
1964 (interactive) 2044 (interactive)
2045 (setq zmacs-region-stays t)
1965 (setq tpu-direction-string " Advance") 2046 (setq tpu-direction-string " Advance")
1966 (setq tpu-advance t) 2047 (setq tpu-advance t)
1967 (setq tpu-reverse nil) 2048 (setq tpu-reverse nil)
1968 (tpu-set-search) 2049 (tpu-set-search)
1969 (tpu-update-mode-line)) 2050 (tpu-update-mode-line))
1970 2051
1971 (defun tpu-backup-direction nil 2052 (defun tpu-backup-direction nil
1972 "Set TPU Backup mode so keypad commands move backward." 2053 "Set TPU Backup mode so keypad commands move backward."
1973 (interactive) 2054 (interactive)
2055 (setq zmacs-region-stays t)
1974 (setq tpu-direction-string " Reverse") 2056 (setq tpu-direction-string " Reverse")
1975 (setq tpu-advance nil) 2057 (setq tpu-advance nil)
1976 (setq tpu-reverse t) 2058 (setq tpu-reverse t)
1977 (tpu-set-search) 2059 (tpu-set-search)
1978 (tpu-update-mode-line)) 2060 (tpu-update-mode-line))
2248 (define-key repeat-complex-command-map "\eOA" 'previous-complex-command) 2330 (define-key repeat-complex-command-map "\eOA" 'previous-complex-command)
2249 (define-key repeat-complex-command-map "\eOB" 'next-complex-command))) 2331 (define-key repeat-complex-command-map "\eOB" 'next-complex-command)))
2250 2332
2251 2333
2252 ;;; 2334 ;;;
2253 ;;; Minibuffer map additions to make KP-enter = RET 2335 ;;; Minibuffer map additions to make KP_enter = RET
2254 ;;; 2336 ;;;
2255 (define-key minibuffer-local-map "\eOM" 'exit-minibuffer) 2337 (define-key minibuffer-local-map "\eOM" 'exit-minibuffer)
2256 (define-key minibuffer-local-ns-map "\eOM" 'exit-minibuffer) 2338 (define-key minibuffer-local-ns-map "\eOM" 'exit-minibuffer)
2257 (define-key minibuffer-local-completion-map "\eOM" 'exit-minibuffer) 2339 (define-key minibuffer-local-completion-map "\eOM" 'exit-minibuffer)
2258 (define-key minibuffer-local-must-match-map "\eOM" 'minibuffer-complete-and-exit) 2340 (define-key minibuffer-local-must-match-map "\eOM" 'minibuffer-complete-and-exit)
2314 (setq tpu-control-keys tpu-style)))))) 2396 (setq tpu-control-keys tpu-style))))))
2315 2397
2316 (defun tpu-toggle-control-keys nil 2398 (defun tpu-toggle-control-keys nil
2317 "Toggles control key bindings between TPU-edt and Emacs." 2399 "Toggles control key bindings between TPU-edt and Emacs."
2318 (interactive) 2400 (interactive)
2401 (setq zmacs-region-stays t)
2319 (tpu-reset-control-keys (not tpu-control-keys)) 2402 (tpu-reset-control-keys (not tpu-control-keys))
2320 (and (interactive-p) 2403 (and (interactive-p)
2321 (message "Control keys function with %s bindings." 2404 (message "Control keys function with %s bindings."
2322 (if tpu-control-keys "TPU-edt" "Emacs")))) 2405 (if tpu-control-keys "TPU-edt" "Emacs"))))
2323 2406
2326 ;;; Emacs version 19 minibuffer history support 2409 ;;; Emacs version 19 minibuffer history support
2327 ;;; 2410 ;;;
2328 (defun tpu-next-history-element (n) 2411 (defun tpu-next-history-element (n)
2329 "Insert the next element of the minibuffer history into the minibuffer." 2412 "Insert the next element of the minibuffer history into the minibuffer."
2330 (interactive "p") 2413 (interactive "p")
2414 (setq zmacs-region-stays t)
2331 (next-history-element n) 2415 (next-history-element n)
2332 (goto-char (point-max))) 2416 (goto-char (point-max)))
2333 2417
2334 (defun tpu-previous-history-element (n) 2418 (defun tpu-previous-history-element (n)
2335 "Insert the previous element of the minibuffer history into the minibuffer." 2419 "Insert the previous element of the minibuffer history into the minibuffer."
2336 (interactive "p") 2420 (interactive "p")
2421 (setq zmacs-region-stays t)
2337 (previous-history-element n) 2422 (previous-history-element n)
2338 (goto-char (point-max))) 2423 (goto-char (point-max)))
2339 2424
2340 (defun tpu-arrow-history nil 2425 (defun tpu-arrow-history nil
2341 "Modify minibuffer maps to use arrows for history recall." 2426 "Modify minibuffer maps to use arrows for history recall."
2342 (interactive) 2427 (interactive)
2428 (setq zmacs-region-stays t)
2343 (let ((loc (where-is-internal 'tpu-previous-line)) (cur nil)) 2429 (let ((loc (where-is-internal 'tpu-previous-line)) (cur nil))
2344 (while (setq cur (car loc)) 2430 (while (setq cur (car loc))
2345 (define-key read-expression-map cur 'tpu-previous-history-element) 2431 (define-key read-expression-map cur 'tpu-previous-history-element)
2346 (define-key minibuffer-local-map cur 'tpu-previous-history-element) 2432 (define-key minibuffer-local-map cur 'tpu-previous-history-element)
2347 (define-key minibuffer-local-ns-map cur 'tpu-previous-history-element) 2433 (define-key minibuffer-local-ns-map cur 'tpu-previous-history-element)
2365 (defun tpu-load-xkeys (file) 2451 (defun tpu-load-xkeys (file)
2366 "Load the TPU-edt X-windows key definitions FILE. 2452 "Load the TPU-edt X-windows key definitions FILE.
2367 If FILE is nil, try to load a default file. The default file names are 2453 If FILE is nil, try to load a default file. The default file names are
2368 `~/.tpu-lucid-keys' for Lucid emacs, and `~/.tpu-keys' for Emacs." 2454 `~/.tpu-lucid-keys' for Lucid emacs, and `~/.tpu-keys' for Emacs."
2369 (interactive "fX key definition file: ") 2455 (interactive "fX key definition file: ")
2456 (setq zmacs-region-stays t)
2370 (cond (file 2457 (cond (file
2371 (setq file (expand-file-name file))) 2458 (setq file (expand-file-name file)))
2372 (tpu-xkeys-file 2459 (tpu-xkeys-file
2373 (setq file (expand-file-name tpu-xkeys-file))) 2460 (setq file (expand-file-name tpu-xkeys-file)))
2374 (tpu-lucid-emacs19-p 2461 (tpu-lucid-emacs19-p
2417 (sit-for 120))))))) 2504 (sit-for 120)))))))
2418 2505
2419 (defun tpu-copy-keyfile (oldname newname) 2506 (defun tpu-copy-keyfile (oldname newname)
2420 "Copy the TPU-edt X key definitions file to the new default name." 2507 "Copy the TPU-edt X key definitions file to the new default name."
2421 (interactive "fOld name: \nFNew name: ") 2508 (interactive "fOld name: \nFNew name: ")
2509 (setq zmacs-region-stays t)
2422 (if (not (get-buffer "*TPU-Notice*")) (generate-new-buffer "*TPU-Notice*")) 2510 (if (not (get-buffer "*TPU-Notice*")) (generate-new-buffer "*TPU-Notice*"))
2423 (set-buffer "*TPU-Notice*") 2511 (set-buffer "*TPU-Notice*")
2424 (erase-buffer) 2512 (erase-buffer)
2425 (insert " 2513 (insert "
2426 NOTICE -- 2514 NOTICE --