Mercurial > emacs
annotate lisp/emulation/tpu-edt.el @ 11546:66db15ec8ad8
Don't turn on tpu-edt mode.
(tpu-gnu-emacs19-p): Function deleted. Callers changed.
(tpu-load-xkeys): Use file name .tpu-keys by default.
(tpu-gnu-emacs18-p): Function deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 25 Apr 1995 00:37:27 +0000 |
parents | ad36865ac28e |
children | 11a7257fc6fa |
rev | line source |
---|---|
4421 | 1 ;;; tpu-edt.el --- Emacs emulating TPU emulating EDT |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
2 |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
4421 | 4 |
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> | |
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
7 ;; Version: 4.0 |
5140 | 8 ;; Keywords: emulations |
4421 | 9 |
4450 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
4421 | 16 |
4450 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
4421 | 25 |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
26 ;; TPU-edt is based on tpu.el by Jeff Kowalski and Bob Covey. |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
27 |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
28 ;;; Code: |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
29 |
4421 | 30 |
31 ;;; | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
32 ;;; Version Information |
4421 | 33 ;;; |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
34 (defconst tpu-version "4.0" "TPU-edt version number.") |
4421 | 35 |
36 | |
37 ;;; | |
38 ;;; User Configurable Variables | |
39 ;;; | |
40 (defconst tpu-have-ispell t | |
41 "*If non-nil (default), TPU-edt uses ispell for spell checking.") | |
42 | |
43 (defconst tpu-kill-buffers-silently nil | |
44 "*If non-nil, TPU-edt kills modified buffers without asking.") | |
45 | |
46 (defvar tpu-percent-scroll 75 | |
47 "*Percentage of the screen to scroll for next/previous screen commands.") | |
48 | |
49 (defvar tpu-pan-columns 16 | |
50 "*Number of columns the tpu-pan functions scroll left or right.") | |
51 | |
52 | |
53 ;;; | |
54 ;;; Emacs version identifiers - currently referenced by | |
55 ;;; | |
56 ;;; o tpu-mark o tpu-set-mark | |
57 ;;; o tpu-string-prompt o tpu-regexp-prompt | |
58 ;;; o tpu-edt-on o tpu-load-xkeys | |
59 ;;; o tpu-update-mode-line o mode line section | |
60 ;;; | |
61 (defconst tpu-emacs19-p (not (string-lessp emacs-version "19")) | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
62 "Non-nil if we are running Lucid Emacs or version 19.") |
4421 | 63 |
64 (defconst tpu-lucid-emacs19-p | |
65 (and tpu-emacs19-p (string-match "Lucid" emacs-version)) | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
66 "Non-nil if we are running Lucid Emacs version 19.") |
4421 | 67 |
68 | |
69 ;;; | |
70 ;;; Global Keymaps | |
71 ;;; | |
72 (defvar CSI-map (make-sparse-keymap) | |
73 "Maps the CSI function keys on the VT100 keyboard. | |
74 CSI is DEC's name for the sequence <ESC>[.") | |
75 | |
76 (defvar SS3-map (make-sparse-keymap) | |
77 "Maps the SS3 function keys on the VT100 keyboard. | |
78 SS3 is DEC's name for the sequence <ESC>O.") | |
79 | |
80 (defvar GOLD-map (make-keymap) | |
81 "Maps the function keys on the VT100 keyboard preceeded by PF1. | |
82 GOLD is the ASCII 7-bit escape sequence <ESC>OP.") | |
83 | |
84 (defvar GOLD-CSI-map (make-sparse-keymap) | |
85 "Maps the function keys on the VT100 keyboard preceeded by GOLD-CSI.") | |
86 | |
87 (defvar GOLD-SS3-map (make-sparse-keymap) | |
88 "Maps the function keys on the VT100 keyboard preceeded by GOLD-SS3.") | |
89 | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
90 (defvar tpu-global-map nil "TPU-edt global keymap.") |
4421 | 91 (defvar tpu-original-global-map (copy-keymap global-map) |
92 "Original global keymap.") | |
93 | |
94 (and tpu-lucid-emacs19-p | |
95 (defvar minibuffer-local-ns-map (make-sparse-keymap) | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
96 "Hack to give Lucid Emacs the same maps as ordinary Emacs.")) |
4421 | 97 |
98 | |
99 ;;; | |
100 ;;; Global Variables | |
101 ;;; | |
102 (defvar tpu-edt-mode nil | |
103 "If non-nil, TPU-edt mode is active.") | |
104 | |
105 (defvar tpu-last-replaced-text "" | |
106 "Last text deleted by a TPU-edt replace command.") | |
107 (defvar tpu-last-deleted-region "" | |
108 "Last text deleted by a TPU-edt remove command.") | |
109 (defvar tpu-last-deleted-lines "" | |
110 "Last text deleted by a TPU-edt line-delete command.") | |
111 (defvar tpu-last-deleted-words "" | |
112 "Last text deleted by a TPU-edt word-delete command.") | |
113 (defvar tpu-last-deleted-char "" | |
114 "Last character deleted by a TPU-edt character-delete command.") | |
115 | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
116 (defvar tpu-searching-forward t |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
117 "If non-nil, TPU-edt is searching in the forward direction.") |
4421 | 118 (defvar tpu-search-last-string "" |
119 "Last text searched for by the TPU-edt search commands.") | |
120 | |
121 (defvar tpu-regexp-p nil | |
122 "If non-nil, TPU-edt uses regexp search and replace routines.") | |
123 (defvar tpu-rectangular-p nil | |
124 "If non-nil, TPU-edt removes and inserts rectangles.") | |
125 (defvar tpu-advance t | |
126 "True when TPU-edt is operating in the forward direction.") | |
127 (defvar tpu-reverse nil | |
128 "True when TPU-edt is operating in the backward direction.") | |
129 (defvar tpu-control-keys t | |
130 "If non-nil, control keys are set to perform TPU functions.") | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
131 (defvar tpu-xkeys-file nil |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
132 "File containing TPU-edt X key map.") |
4421 | 133 |
134 (defvar tpu-rectangle-string nil | |
135 "Mode line string to identify rectangular mode.") | |
136 (defvar tpu-direction-string nil | |
137 "Mode line string to identify current direction.") | |
138 | |
139 (defvar tpu-add-at-bol-hist nil | |
140 "History variable for tpu-edt-add-at-bol function.") | |
141 (defvar tpu-add-at-eol-hist nil | |
142 "History variable for tpu-edt-add-at-eol function.") | |
143 (defvar tpu-regexp-prompt-hist nil | |
144 "History variable for search and replace functions.") | |
145 | |
146 | |
147 ;;; | |
148 ;;; Buffer Local Variables | |
149 ;;; | |
150 (defvar tpu-newline-and-indent-p nil | |
151 "If non-nil, Return produces a newline and indents.") | |
152 (make-variable-buffer-local 'tpu-newline-and-indent-p) | |
153 | |
154 (defvar tpu-newline-and-indent-string nil | |
155 "Mode line string to identify AutoIndent mode.") | |
156 (make-variable-buffer-local 'tpu-newline-and-indent-string) | |
157 | |
158 (defvar tpu-saved-delete-func nil | |
159 "Saved value of the delete key.") | |
160 (make-variable-buffer-local 'tpu-saved-delete-func) | |
161 | |
162 (defvar tpu-buffer-local-map nil | |
163 "TPU-edt buffer local key map.") | |
164 (make-variable-buffer-local 'tpu-buffer-local-map) | |
165 | |
166 | |
167 ;;; | |
168 ;;; Mode Line - Modify the mode line to show the following | |
169 ;;; | |
170 ;;; o If the mark is set. | |
171 ;;; o Direction of motion. | |
172 ;;; o Active rectangle mode. | |
173 ;;; | |
174 (defvar tpu-original-mode-line mode-line-format) | |
175 (defvar tpu-original-mm-alist minor-mode-alist) | |
176 | |
177 (defvar tpu-mark-flag " ") | |
178 (make-variable-buffer-local 'tpu-mark-flag) | |
179 | |
180 (defun tpu-set-mode-line (for-tpu) | |
181 "Set the mode for TPU-edt, or reset it to default Emacs." | |
182 (cond ((not for-tpu) | |
183 (setq mode-line-format tpu-original-mode-line) | |
184 (setq minor-mode-alist tpu-original-mm-alist)) | |
185 (t | |
186 (setq-default mode-line-format | |
187 (list (purecopy "") | |
188 'mode-line-modified | |
189 'mode-line-buffer-identification | |
190 (purecopy " ") | |
191 'global-mode-string | |
192 (purecopy " ") | |
193 'tpu-mark-flag | |
194 (purecopy " %[(") | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
195 'mode-name 'mode-line-process 'minor-mode-alist |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
196 (purecopy "%n") |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
197 (purecopy ")%]--") |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
198 (purecopy '(line-number-mode "L%l--")) |
4421 | 199 (purecopy '(-3 . "%p")) |
200 (purecopy "-%-"))) | |
201 (or (assq 'tpu-newline-and-indent-p minor-mode-alist) | |
202 (setq minor-mode-alist | |
203 (cons '(tpu-newline-and-indent-p | |
204 tpu-newline-and-indent-string) | |
205 minor-mode-alist))) | |
206 (or (assq 'tpu-rectangular-p minor-mode-alist) | |
207 (setq minor-mode-alist | |
208 (cons '(tpu-rectangular-p tpu-rectangle-string) | |
209 minor-mode-alist))) | |
210 (or (assq 'tpu-direction-string minor-mode-alist) | |
211 (setq minor-mode-alist | |
212 (cons '(tpu-direction-string tpu-direction-string) | |
213 minor-mode-alist)))))) | |
214 | |
215 (defun tpu-update-mode-line nil | |
216 "Make sure mode-line in the current buffer reflects all changes." | |
217 (setq tpu-mark-flag (if (tpu-mark) "M" " ")) | |
218 (cond (tpu-emacs19-p (force-mode-line-update)) | |
219 (t (set-buffer-modified-p (buffer-modified-p)) (sit-for 0)))) | |
220 | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
221 (cond (tpu-lucid-emacs19-p |
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
222 (add-hook 'zmacs-deactivate-region-hook 'tpu-update-mode-line) |
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
223 (add-hook 'zmacs-activate-region-hook 'tpu-update-mode-line)) |
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
224 (tpu-emacs19-p |
4421 | 225 (add-hook 'activate-mark-hook 'tpu-update-mode-line) |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
226 (add-hook 'deactivate-mark-hook 'tpu-update-mode-line))) |
4421 | 227 |
228 | |
229 ;;; | |
230 ;;; Match Markers - | |
231 ;;; | |
232 ;;; Set in: Search | |
233 ;;; | |
234 ;;; Used in: Replace, Substitute, Store-Text, Cut/Remove, | |
235 ;;; Append, and Change-Case | |
236 ;;; | |
237 (defvar tpu-match-beginning-mark (make-marker)) | |
238 (defvar tpu-match-end-mark (make-marker)) | |
239 | |
240 (defun tpu-set-match nil | |
241 "Set markers at match beginning and end." | |
242 ;; Add one to beginning mark so it stays with the first character of | |
243 ;; the string even if characters are added just before the string. | |
244 (setq tpu-match-beginning-mark (copy-marker (1+ (match-beginning 0)))) | |
245 (setq tpu-match-end-mark (copy-marker (match-end 0)))) | |
246 | |
247 (defun tpu-unset-match nil | |
248 "Unset match beginning and end markers." | |
249 (set-marker tpu-match-beginning-mark nil) | |
250 (set-marker tpu-match-end-mark nil)) | |
251 | |
252 (defun tpu-match-beginning nil | |
253 "Returns the location of the last match beginning." | |
254 (1- (marker-position tpu-match-beginning-mark))) | |
255 | |
256 (defun tpu-match-end nil | |
257 "Returns the location of the last match end." | |
258 (marker-position tpu-match-end-mark)) | |
259 | |
260 (defun tpu-check-match nil | |
261 "Returns t if point is between tpu-match markers. | |
262 Otherwise sets the tpu-match markers to nil and returns nil." | |
263 ;; make sure 1- marker is in this buffer | |
264 ;; 2- point is at or after beginning marker | |
265 ;; 3- point is before ending marker, or in the case of | |
266 ;; zero length regions (like bol, or eol) that the | |
267 ;; beginning, end, and point are equal. | |
268 (cond ((and | |
269 (equal (marker-buffer tpu-match-beginning-mark) (current-buffer)) | |
270 (>= (point) (1- (marker-position tpu-match-beginning-mark))) | |
271 (or | |
272 (< (point) (marker-position tpu-match-end-mark)) | |
273 (and (= (1- (marker-position tpu-match-beginning-mark)) | |
274 (marker-position tpu-match-end-mark)) | |
275 (= (marker-position tpu-match-end-mark) (point))))) t) | |
276 (t | |
277 (tpu-unset-match) nil))) | |
278 | |
279 (defun tpu-show-match-markers nil | |
280 "Show the values of the match markers." | |
281 (interactive) | |
282 (if (markerp tpu-match-beginning-mark) | |
283 (let ((beg (marker-position tpu-match-beginning-mark))) | |
284 (message "(%s, %s) in %s -- current %s in %s" | |
285 (if beg (1- beg) nil) | |
286 (marker-position tpu-match-end-mark) | |
287 (marker-buffer tpu-match-end-mark) | |
288 (point) (current-buffer))))) | |
289 | |
290 | |
291 ;;; | |
292 ;;; Utilities | |
293 ;;; | |
294 (defun tpu-caar (thingy) (car (car thingy))) | |
295 (defun tpu-cadr (thingy) (car (cdr thingy))) | |
296 | |
297 (defun tpu-mark nil | |
298 "TPU-edt version of the mark function. | |
299 Return the appropriate value of the mark for the current | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
300 version of Emacs." |
4421 | 301 (cond (tpu-lucid-emacs19-p (mark (not zmacs-regions))) |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
302 (tpu-emacs19-p (and mark-active (mark (not transient-mark-mode)))) |
4421 | 303 (t (mark)))) |
304 | |
305 (defun tpu-set-mark (pos) | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
306 "TPU-edt verion of the `set-mark' function. |
4421 | 307 Sets the mark at POS and activates the region acording to the |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
308 current version of Emacs." |
4421 | 309 (set-mark pos) |
310 (and tpu-lucid-emacs19-p pos (zmacs-activate-region))) | |
311 | |
312 (defun tpu-string-prompt (prompt history-symbol) | |
313 "Read a string with PROMPT." | |
314 (if tpu-emacs19-p | |
315 (read-from-minibuffer prompt nil nil nil history-symbol) | |
316 (read-string prompt))) | |
317 | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
318 (defvar tpu-last-answer nil "Most recent response to tpu-y-or-n-p.") |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
319 |
4421 | 320 (defun tpu-y-or-n-p (prompt &optional not-yes) |
321 "Prompt for a y or n answer with positive default. | |
322 Optional second argument NOT-YES changes default to negative. | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
323 Like Emacs `y-or-n-p', but also accepts space as y and DEL as n." |
4421 | 324 (message (format "%s[%s]" prompt (if not-yes "n" "y"))) |
325 (let ((doit t)) | |
326 (while doit | |
327 (setq doit nil) | |
328 (let ((ans (read-char))) | |
329 (cond ((or (= ans ?y) (= ans ?Y) (= ans ?\ )) | |
330 (setq tpu-last-answer t)) | |
331 ((or (= ans ?n) (= ans ?N) (= ans ?\C-?)) | |
332 (setq tpu-last-answer nil)) | |
333 ((= ans ?\r) (setq tpu-last-answer (not not-yes))) | |
334 (t | |
335 (setq doit t) (beep) | |
336 (message (format "Please answer y or n. %s[%s]" | |
337 prompt (if not-yes "n" "y")))))))) | |
338 tpu-last-answer) | |
339 | |
340 (defun tpu-local-set-key (key func) | |
341 "Replace a key in the TPU-edt local key map. | |
342 Create the key map if necessary." | |
343 (cond ((not (keymapp tpu-buffer-local-map)) | |
344 (setq tpu-buffer-local-map (if (current-local-map) | |
345 (copy-keymap (current-local-map)) | |
346 (make-sparse-keymap))) | |
347 (use-local-map tpu-buffer-local-map))) | |
348 (local-set-key key func)) | |
349 | |
350 (defun tpu-current-line nil | |
351 "Return the vertical position of point in the selected window. | |
352 Top line is 0. Counts each text line only once, even if it wraps." | |
353 (+ (count-lines (window-start) (point)) (if (= (current-column) 0) 1 0) -1)) | |
354 | |
355 | |
356 ;;; | |
357 ;;; Breadcrumbs | |
358 ;;; | |
359 (defvar tpu-breadcrumb-plist nil | |
360 "The set of user-defined markers (breadcrumbs), as a plist.") | |
361 | |
362 (defun tpu-drop-breadcrumb (num) | |
363 "Drops a breadcrumb that can be returned to later with goto-breadcrumb." | |
364 (interactive "p") | |
365 (put tpu-breadcrumb-plist num (list (current-buffer) (point))) | |
366 (message "Mark %d set." num)) | |
367 | |
368 (defun tpu-goto-breadcrumb (num) | |
369 "Returns to a breadcrumb set with drop-breadcrumb." | |
370 (interactive "p") | |
371 (cond ((get tpu-breadcrumb-plist num) | |
372 (switch-to-buffer (car (get tpu-breadcrumb-plist num))) | |
373 (goto-char (tpu-cadr (get tpu-breadcrumb-plist num))) | |
374 (message "mark %d found." num)) | |
375 (t | |
376 (message "mark %d not found." num)))) | |
377 | |
378 | |
379 ;;; | |
380 ;;; Miscellaneous | |
381 ;;; | |
382 (defun tpu-change-case (num) | |
383 "Change the case of the character under the cursor or region. | |
384 Accepts a prefix argument of the number of characters to invert." | |
385 (interactive "p") | |
386 (cond ((tpu-mark) | |
387 (let ((beg (region-beginning)) (end (region-end))) | |
388 (while (> end beg) | |
389 (funcall (if (= (downcase (char-after beg)) (char-after beg)) | |
390 'upcase-region 'downcase-region) | |
391 beg (1+ beg)) | |
392 (setq beg (1+ beg))) | |
393 (tpu-unselect t))) | |
394 ((tpu-check-match) | |
395 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) | |
396 (while (> end beg) | |
397 (funcall (if (= (downcase (char-after beg)) (char-after beg)) | |
398 'upcase-region 'downcase-region) | |
399 beg (1+ beg)) | |
400 (setq beg (1+ beg))) | |
401 (tpu-unset-match))) | |
402 (t | |
403 (while (> num 0) | |
404 (funcall (if (= (downcase (following-char)) (following-char)) | |
405 'upcase-region 'downcase-region) | |
406 (point) (1+ (point))) | |
407 (forward-char (if tpu-reverse -1 1)) | |
408 (setq num (1- num)))))) | |
409 | |
410 (defun tpu-fill (num) | |
411 "Fill paragraph or marked region. | |
412 With argument, fill and justify." | |
413 (interactive "P") | |
414 (cond ((tpu-mark) | |
415 (fill-region (point) (tpu-mark) num) | |
416 (tpu-unselect t)) | |
417 (t | |
418 (fill-paragraph num)))) | |
419 | |
420 (defun tpu-version nil | |
421 "Print the TPU-edt version number." | |
422 (interactive) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
423 (message |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
424 "TPU-edt version %s by Rob Riepel (riepel@networking.stanford.edu)" |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
425 tpu-version)) |
4421 | 426 |
427 (defun tpu-reset-screen-size (height width) | |
428 "Sets the screen size." | |
429 (interactive "nnew screen height: \nnnew screen width: ") | |
430 (set-screen-height height) | |
431 (set-screen-width width)) | |
432 | |
433 (defun tpu-toggle-newline-and-indent nil | |
434 "Toggle between 'newline and indent' and 'simple newline'." | |
435 (interactive) | |
436 (cond (tpu-newline-and-indent-p | |
437 (setq tpu-newline-and-indent-string "") | |
438 (setq tpu-newline-and-indent-p nil) | |
439 (tpu-local-set-key "\C-m" 'newline)) | |
440 (t | |
441 (setq tpu-newline-and-indent-string " AutoIndent") | |
442 (setq tpu-newline-and-indent-p t) | |
443 (tpu-local-set-key "\C-m" 'newline-and-indent))) | |
444 (tpu-update-mode-line) | |
445 (and (interactive-p) | |
446 (message "Carriage return inserts a newline%s" | |
447 (if tpu-newline-and-indent-p " and indents." ".")))) | |
448 | |
449 (defun tpu-spell-check nil | |
450 "Checks the spelling of the region, or of the entire buffer if no | |
451 region is selected." | |
452 (interactive) | |
453 (cond (tpu-have-ispell | |
454 (if (tpu-mark) (ispell-region (tpu-mark) (point)) (ispell-buffer))) | |
455 (t | |
456 (if (tpu-mark) (spell-region (tpu-mark) (point)) (spell-buffer)))) | |
457 (if (tpu-mark) (tpu-unselect t))) | |
458 | |
459 (defun tpu-toggle-overwrite-mode nil | |
460 "Switches in and out of overwrite mode" | |
461 (interactive) | |
462 (cond (overwrite-mode | |
463 (tpu-local-set-key "\177" tpu-saved-delete-func) | |
464 (overwrite-mode 0)) | |
465 (t | |
466 (setq tpu-saved-delete-func (local-key-binding "\177")) | |
467 (tpu-local-set-key "\177" 'picture-backward-clear-column) | |
468 (overwrite-mode 1)))) | |
469 | |
470 (defun tpu-special-insert (num) | |
471 "Insert a character or control code according to | |
472 its ASCII decimal value." | |
473 (interactive "P") | |
474 (if overwrite-mode (delete-char 1)) | |
475 (insert (if num num 0))) | |
476 | |
5186
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
477 (defun tpu-quoted-insert (num) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
478 "Read next input character and insert it. |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
479 This is useful for inserting control characters." |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
480 (interactive "*p") |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
481 (let ((char (read-char)) ) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
482 (if overwrite-mode (delete-char num)) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
483 (insert-char char num))) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
484 |
4421 | 485 |
486 ;;; | |
487 ;;; TPU line-mode commands | |
488 ;;; | |
489 (defun tpu-include (file) | |
490 "TPU-like include file" | |
491 (interactive "fInclude file: ") | |
492 (save-excursion | |
493 (insert-file file) | |
494 (message ""))) | |
495 | |
496 (defun tpu-get (file) | |
497 "TPU-like get file" | |
498 (interactive "FFile to get: ") | |
499 (find-file file)) | |
500 | |
501 (defun tpu-what-line nil | |
502 "Tells what line the point is on, | |
503 and the total number of lines in the buffer." | |
504 (interactive) | |
505 (if (eobp) | |
506 (message "You are at the End of Buffer. The last line is %d." | |
507 (count-lines 1 (point-max))) | |
508 (message "Line %d of %d" | |
509 (count-lines 1 (1+ (point))) | |
510 (count-lines 1 (point-max))))) | |
511 | |
512 (defun tpu-exit nil | |
513 "Exit the way TPU does, save current buffer and ask about others." | |
514 (interactive) | |
515 (if (not (eq (recursion-depth) 0)) | |
516 (exit-recursive-edit) | |
517 (progn (save-buffer) (save-buffers-kill-emacs)))) | |
518 | |
519 (defun tpu-quit nil | |
520 "Quit the way TPU does, ask to make sure changes should be abandoned." | |
521 (interactive) | |
522 (let ((list (buffer-list)) | |
523 (working t)) | |
524 (while (and list working) | |
525 (let ((buffer (car list))) | |
526 (if (and (buffer-file-name buffer) (buffer-modified-p buffer)) | |
527 (if (tpu-y-or-n-p | |
528 "Modifications will not be saved, continue quitting? ") | |
529 (kill-emacs t) (setq working nil))) | |
530 (setq list (cdr list)))) | |
531 (if working (kill-emacs t)))) | |
532 | |
533 | |
534 ;;; | |
535 ;;; Command and Function Aliases | |
536 ;;; | |
537 ;;;###autoload | |
538 (fset 'tpu-edt-mode 'tpu-edt-on) | |
539 (fset 'TPU-EDT-MODE 'tpu-edt-on) | |
540 | |
541 ;;;###autoload | |
542 (fset 'tpu-edt 'tpu-edt-on) | |
543 (fset 'TPU-EDT 'tpu-edt-on) | |
544 | |
545 (fset 'exit 'tpu-exit) | |
546 (fset 'EXIT 'tpu-exit) | |
547 | |
548 (fset 'Get 'tpu-get) | |
549 (fset 'GET 'tpu-get) | |
550 | |
551 (fset 'include 'tpu-include) | |
552 (fset 'INCLUDE 'tpu-include) | |
553 | |
554 (fset 'quit 'tpu-quit) | |
555 (fset 'QUIT 'tpu-quit) | |
556 | |
557 (fset 'spell 'tpu-spell-check) | |
558 (fset 'SPELL 'tpu-spell-check) | |
559 | |
560 (fset 'what\ line 'tpu-what-line) | |
561 (fset 'WHAT\ LINE 'tpu-what-line) | |
562 | |
563 (fset 'replace 'tpu-lm-replace) | |
564 (fset 'REPLACE 'tpu-lm-replace) | |
565 | |
566 (fset 'help 'tpu-help) | |
567 (fset 'HELP 'tpu-help) | |
568 | |
5186
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
569 (fset 'set\ cursor\ free 'tpu-set-cursor-free) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
570 (fset 'SET\ CURSOR\ FREE 'tpu-set-cursor-free) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
571 |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
572 (fset 'set\ cursor\ bound 'tpu-set-cursor-bound) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
573 (fset 'SET\ CURSOR\ BOUND 'tpu-set-cursor-bound) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
574 |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
575 (fset 'set\ scroll\ margins 'tpu-set-scroll-margins) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
576 (fset 'SET\ SCROLL\ MARGINS 'tpu-set-scroll-margins) |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
577 |
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
578 |
4421 | 579 ;; Around emacs version 18.57, function line-move was renamed to |
580 ;; next-line-internal. If we're running under an older emacs, | |
581 ;; make next-line-internal equivalent to line-move. | |
582 | |
583 (if (not (fboundp 'next-line-internal)) (fset 'next-line-internal 'line-move)) | |
584 | |
585 | |
586 ;;; | |
587 ;;; Help | |
588 ;;; | |
589 (defconst tpu-help-keypad-map "\f | |
590 _______________________ _______________________________ | |
591 | HELP | Do | | | | | | | |
592 |KeyDefs| | | | | | | | |
593 |_______|_______________| |_______|_______|_______|_______| | |
594 _______________________ _______________________________ | |
595 | Find |Insert |Remove | | Gold | HELP |FndNxt | Del L | | |
596 | | |Sto Tex| | key |E-Help | Find |Undel L| | |
597 |_______|_______|_______| |_______|_______|_______|_______| | |
598 |Select |Pre Scr|Nex Scr| | Page | Sect |Append | Del W | | |
599 | Reset |Pre Win|Nex Win| | Do | Fill |Replace|Undel W| | |
600 |_______|_______|_______| |_______|_______|_______|_______| | |
601 |Move up| |Forward|Reverse|Remove | Del C | | |
602 | Top | |Bottom | Top |Insert |Undel C| | |
603 _______|_______|_______ |_______|_______|_______|_______| | |
604 |Mov Lef|Mov Dow|Mov Rig| | Word | EOL | Char | | | |
605 |StaOfLi|Bottom |EndOfLi| |ChngCas|Del EOL|SpecIns| Enter | | |
606 |_______|_______|_______| |_______|_______|_______| | | |
607 | Line |Select | Subs | | |
608 | Open Line | Reset | | | |
609 |_______________|_______|_______| | |
610 ") | |
611 | |
612 (defconst tpu-help-text " | |
613 \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\f | |
614 | |
615 Control Characters | |
616 | |
617 ^A toggle insert and overwrite | |
618 ^B recall | |
619 ^E end of line | |
620 | |
621 ^G Cancel current operation | |
622 ^H beginning of line | |
623 ^J delete previous word | |
624 | |
625 ^K learn | |
626 ^L insert page break | |
627 ^R remember (during learn), re-center | |
628 | |
629 ^U delete to beginning of line | |
630 ^V quote | |
631 ^W refresh | |
632 | |
633 ^Z exit | |
634 ^X^X exchange point and mark - useful for checking region boundaries | |
635 | |
636 \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\f | |
637 Gold-<key> Functions | |
638 | |
639 B Next Buffer - display the next buffer (all buffers) | |
640 C Recall - edit and possibly repeat previous commands | |
641 E Exit - save current buffer and ask about others | |
642 | |
643 G Get - load a file into a new edit buffer | |
644 I Include - include a file in this buffer | |
645 K Kill Buffer - abandon edits and delete buffer | |
646 | |
647 M Buffer Menu - display a list of all buffers | |
648 N Next File Buffer - display next buffer containing a file | |
649 O Occur - show following lines containing REGEXP | |
650 | |
651 Q Quit - exit without saving anything | |
652 R Toggle rectangular mode for remove and insert | |
653 S Search and substitute - line mode REPLACE command | |
654 | |
655 U Undo - undo the last edit | |
656 W Write - save current buffer | |
657 X Exit - save all modified buffers and exit | |
658 | |
659 \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\f | |
660 | |
661 *** No more help, use P to view previous screen") | |
662 | |
663 (defvar tpu-help-enter (format "%s" "\eOM")) ; tpu-help enter key symbol | |
664 (defvar tpu-help-return (format "%s" "\r")) ; tpu-help enter key symbol | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
665 (defvar tpu-help-N "N") ; tpu-help "N" symbol |
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
666 (defvar tpu-help-n "n") ; tpu-help "n" symbol |
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
667 (defvar tpu-help-P "P") ; tpu-help "P" symbol |
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
668 (defvar tpu-help-p "p") ; tpu-help "p" symbol |
4421 | 669 |
670 (defun tpu-help nil | |
671 "Display TPU-edt help." | |
672 (interactive) | |
673 ;; Save current window configuration | |
674 (save-window-excursion | |
675 ;; Create and fill help buffer if necessary | |
676 (if (not (get-buffer "*TPU-edt Help*")) | |
677 (progn (generate-new-buffer "*TPU-edt Help*") | |
678 (switch-to-buffer "*TPU-edt Help*") | |
679 (insert tpu-help-keypad-map) | |
680 (insert tpu-help-text) | |
681 (setq buffer-read-only t))) | |
682 | |
683 ;; Display the help buffer | |
684 (switch-to-buffer "*TPU-edt Help*") | |
685 (delete-other-windows) | |
686 (tpu-move-to-beginning) | |
687 (forward-line 1) | |
688 (tpu-line-to-top-of-window) | |
689 | |
690 ;; Prompt for keys to describe, based on screen state (split/not split) | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
691 (let ((key nil) (fkey nil) (split nil)) |
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
692 (while (not (equal tpu-help-return fkey)) |
4421 | 693 (if split |
694 (setq key | |
695 (read-key-sequence | |
696 "Press the key you want help on (RET=exit, ENTER=redisplay, N=next, P=prev): ")) | |
697 (setq key | |
698 (read-key-sequence | |
699 "Press the key you want help on (RET to exit, N next screen, P prev screen): "))) | |
700 | |
701 ;; Process the read key | |
702 ;; | |
703 ;; ENTER - Display just the help window | |
704 ;; N or n - Next help or describe-key screen | |
705 ;; P or p - Previous help or describe-key screen | |
706 ;; RETURN - Exit from TPU-help | |
707 ;; default - describe the key | |
708 ;; | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
709 (setq fkey (format "%s" key)) |
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
710 (cond ((equal tpu-help-enter fkey) |
4421 | 711 (setq split nil) |
712 (delete-other-windows)) | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
713 ((or (equal tpu-help-N fkey) (equal tpu-help-n fkey)) |
4421 | 714 (cond (split |
715 (condition-case nil | |
716 (scroll-other-window 8) | |
717 (error nil))) | |
718 (t | |
719 (forward-page) | |
720 (forward-line 1) | |
721 (tpu-line-to-top-of-window)))) | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
722 ((or (equal tpu-help-P fkey) (equal tpu-help-p fkey)) |
4421 | 723 (cond (split |
724 (condition-case nil | |
725 (scroll-other-window -8) | |
726 (error nil))) | |
727 (t | |
728 (backward-page 2) | |
729 (forward-line 1) | |
730 (tpu-line-to-top-of-window)))) | |
4549
076ad69b0c77
(tpu-help): Use variables for "n" and "p".
Richard M. Stallman <rms@gnu.org>
parents:
4523
diff
changeset
|
731 ((not (equal tpu-help-return fkey)) |
4421 | 732 (setq split t) |
733 (describe-key key) | |
734 ;; If the key is undefined, leave the | |
735 ;; message in the mini-buffer for 3 seconds | |
736 (if (not (key-binding key)) (sit-for 3)))))))) | |
737 | |
738 | |
739 ;;; | |
740 ;;; Auto-insert | |
741 ;;; | |
742 (defun tpu-insert-escape nil | |
743 "Inserts an escape character, and so becomes the escape-key alias." | |
744 (interactive) | |
745 (insert "\e")) | |
746 | |
747 (defun tpu-insert-formfeed nil | |
748 "Inserts a formfeed character." | |
749 (interactive) | |
750 (insert "\C-L")) | |
751 | |
752 | |
753 ;;; | |
754 ;;; Define key | |
755 ;;; | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
756 (defvar tpu-saved-control-r nil "Saved value of Control-r.") |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
757 |
4421 | 758 (defun tpu-end-define-macro-key (key) |
759 "Ends the current macro definition" | |
760 (interactive "kPress the key you want to use to do what was just learned: ") | |
761 (end-kbd-macro nil) | |
762 (global-set-key key last-kbd-macro) | |
763 (global-set-key "\C-r" tpu-saved-control-r)) | |
764 | |
765 (defun tpu-define-macro-key nil | |
766 "Bind a set of keystrokes to a single key, or key combination." | |
767 (interactive) | |
768 (setq tpu-saved-control-r (global-key-binding "\C-r")) | |
769 (global-set-key "\C-r" 'tpu-end-define-macro-key) | |
770 (start-kbd-macro nil)) | |
771 | |
772 | |
773 ;;; | |
774 ;;; Buffers and Windows | |
775 ;;; | |
776 (defun tpu-kill-buffer nil | |
777 "Kills the current buffer. If tpu-kill-buffers-silently is non-nil, | |
778 kills modified buffers without asking." | |
779 (interactive) | |
780 (if tpu-kill-buffers-silently (set-buffer-modified-p nil)) | |
781 (kill-buffer (current-buffer))) | |
782 | |
783 (defun tpu-save-all-buffers-kill-emacs nil | |
784 "Save all buffers and exit emacs." | |
785 (interactive) | |
8155
ad36865ac28e
(tpu-save-all-buffers-kill-emacs):
Richard M. Stallman <rms@gnu.org>
parents:
7982
diff
changeset
|
786 (let ((delete-old-versions t)) |
ad36865ac28e
(tpu-save-all-buffers-kill-emacs):
Richard M. Stallman <rms@gnu.org>
parents:
7982
diff
changeset
|
787 (save-buffers-kill-emacs t))) |
4421 | 788 |
789 (defun tpu-write-current-buffers nil | |
790 "Save all modified buffers without exiting." | |
791 (interactive) | |
792 (save-some-buffers t)) | |
793 | |
794 (defun tpu-next-buffer nil | |
795 "Go to next buffer in ring." | |
796 (interactive) | |
797 (switch-to-buffer (car (reverse (buffer-list))))) | |
798 | |
799 (defun tpu-next-file-buffer nil | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
800 "Go to next buffer in ring that is visiting a file or directory." |
4421 | 801 (interactive) |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
802 (let ((list (tpu-make-file-buffer-list (buffer-list)))) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
803 (setq list (delq (current-buffer) list)) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
804 (if (not list) (error "No other buffers.")) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
805 (switch-to-buffer (car (reverse list))))) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
806 |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
807 (defun tpu-make-file-buffer-list (buffer-list) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
808 "Returns names from BUFFER-LIST excluding those beginning with a space or star." |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
809 (delq nil (mapcar '(lambda (b) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
810 (if (or (= (aref (buffer-name b) 0) ? ) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
811 (= (aref (buffer-name b) 0) ?*)) nil b)) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
812 buffer-list))) |
4421 | 813 |
814 (defun tpu-next-window nil | |
815 "Move to the next window." | |
816 (interactive) | |
817 (if (one-window-p) (message "There is only one window on screen.") | |
818 (other-window 1))) | |
819 | |
820 (defun tpu-previous-window nil | |
821 "Move to the previous window." | |
822 (interactive) | |
823 (if (one-window-p) (message "There is only one window on screen.") | |
824 (select-window (previous-window)))) | |
825 | |
826 | |
827 ;;; | |
828 ;;; Search | |
829 ;;; | |
830 (defun tpu-toggle-regexp nil | |
831 "Switches in and out of regular expression search and replace mode." | |
832 (interactive) | |
833 (setq tpu-regexp-p (not tpu-regexp-p)) | |
834 (tpu-set-search) | |
835 (and (interactive-p) | |
836 (message "Regular expression search and substitute %sabled." | |
837 (if tpu-regexp-p "en" "dis")))) | |
838 | |
839 (defun tpu-regexp-prompt (prompt) | |
840 "Read a string, adding 'RE' to the prompt if tpu-regexp-p is set." | |
841 (let ((re-prompt (concat (if tpu-regexp-p "RE ") prompt))) | |
842 (if tpu-emacs19-p | |
843 (read-from-minibuffer re-prompt nil nil nil 'tpu-regexp-prompt-hist) | |
844 (read-string re-prompt)))) | |
845 | |
846 (defun tpu-search nil | |
847 "Search for a string or regular expression. | |
848 The search is performed in the current direction." | |
849 (interactive) | |
850 (tpu-set-search) | |
851 (tpu-search-internal "")) | |
852 | |
853 (defun tpu-search-forward nil | |
854 "Search for a string or regular expression. | |
855 The search is begins in the forward direction." | |
856 (interactive) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
857 (setq tpu-searching-forward t) |
4421 | 858 (tpu-set-search t) |
859 (tpu-search-internal "")) | |
860 | |
861 (defun tpu-search-reverse nil | |
862 "Search for a string or regular expression. | |
863 The search is begins in the reverse direction." | |
864 (interactive) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
865 (setq tpu-searching-forward nil) |
4421 | 866 (tpu-set-search t) |
867 (tpu-search-internal "")) | |
868 | |
869 (defun tpu-search-again nil | |
870 "Search for the same string or regular expression as last time. | |
871 The search is performed in the current direction." | |
872 (interactive) | |
873 (tpu-search-internal tpu-search-last-string)) | |
874 | |
875 ;; tpu-set-search defines the search functions used by the TPU-edt internal | |
876 ;; search function. It should be called whenever the direction changes, or | |
877 ;; the regular expression mode is turned on or off. It can also be called | |
878 ;; to ensure that the next search will be in the current direction. It is | |
879 ;; called from: | |
880 | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
881 ;; tpu-advance tpu-backup |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
882 ;; tpu-toggle-regexp tpu-toggle-search-direction (t) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
883 ;; tpu-search tpu-lm-replace |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
884 ;; tpu-search-forward (t) tpu-search-reverse (t) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
885 ;; tpu-search-forward-exit (t) tpu-search-backward-exit (t) |
4421 | 886 |
887 (defun tpu-set-search (&optional arg) | |
888 "Set the search functions and set the search direction to the current | |
889 direction. If an argument is specified, don't set the search direction." | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
890 (if (not arg) (setq tpu-searching-forward (if tpu-advance t nil))) |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
891 (cond (tpu-searching-forward |
4421 | 892 (cond (tpu-regexp-p |
893 (fset 'tpu-emacs-search 're-search-forward) | |
894 (fset 'tpu-emacs-rev-search 're-search-backward)) | |
895 (t | |
896 (fset 'tpu-emacs-search 'search-forward) | |
897 (fset 'tpu-emacs-rev-search 'search-backward)))) | |
898 (t | |
899 (cond (tpu-regexp-p | |
900 (fset 'tpu-emacs-search 're-search-backward) | |
901 (fset 'tpu-emacs-rev-search 're-search-forward)) | |
902 (t | |
903 (fset 'tpu-emacs-search 'search-backward) | |
904 (fset 'tpu-emacs-rev-search 'search-forward)))))) | |
905 | |
906 (defun tpu-search-internal (pat &optional quiet) | |
907 "Search for a string or regular expression." | |
908 (setq tpu-search-last-string | |
909 (if (not (string= "" pat)) pat (tpu-regexp-prompt "Search: "))) | |
910 | |
911 (tpu-unset-match) | |
912 (tpu-adjust-search) | |
913 | |
914 (cond ((tpu-emacs-search tpu-search-last-string nil t) | |
915 (tpu-set-match) (goto-char (tpu-match-beginning))) | |
916 | |
917 (t | |
918 (tpu-adjust-search t) | |
919 (let ((found nil) (pos nil)) | |
920 (save-excursion | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
921 (let ((tpu-searching-forward (not tpu-searching-forward))) |
4421 | 922 (tpu-adjust-search) |
923 (setq found (tpu-emacs-rev-search tpu-search-last-string nil t)) | |
924 (setq pos (match-beginning 0)))) | |
925 | |
926 (cond (found | |
927 (cond ((tpu-y-or-n-p | |
928 (format "Found in %s direction. Go there? " | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
929 (if tpu-searching-forward "reverse" "forward"))) |
4421 | 930 (goto-char pos) (tpu-set-match) |
931 (tpu-toggle-search-direction)))) | |
932 | |
933 (t | |
934 (if (not quiet) | |
935 (message | |
936 "%sSearch failed: \"%s\"" | |
937 (if tpu-regexp-p "RE " "") tpu-search-last-string)))))))) | |
938 | |
939 (fset 'tpu-search-internal-core (symbol-function 'tpu-search-internal)) | |
940 | |
941 (defun tpu-adjust-search (&optional arg) | |
942 "For forward searches, move forward a character before searching, | |
943 and backward a character after a failed search. Arg means end of search." | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
944 (if tpu-searching-forward |
4421 | 945 (cond (arg (if (not (bobp)) (forward-char -1))) |
946 (t (if (not (eobp)) (forward-char 1)))))) | |
947 | |
948 (defun tpu-toggle-search-direction nil | |
949 "Toggle the TPU-edt search direction. | |
950 Used for reversing a search in progress." | |
951 (interactive) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
952 (setq tpu-searching-forward (not tpu-searching-forward)) |
4421 | 953 (tpu-set-search t) |
954 (and (interactive-p) | |
955 (message "Searching %sward." | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
956 (if tpu-searching-forward "for" "back")))) |
4421 | 957 |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
958 (defun tpu-search-forward-exit nil |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
959 "Set search direction forward and exit minibuffer." |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
960 (interactive) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
961 (setq tpu-searching-forward t) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
962 (tpu-set-search t) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
963 (exit-minibuffer)) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
964 |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
965 (defun tpu-search-backward-exit nil |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
966 "Set search direction backward and exit minibuffer." |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
967 (interactive) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
968 (setq tpu-searching-forward nil) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
969 (tpu-set-search t) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
970 (exit-minibuffer)) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
971 |
4421 | 972 |
973 ;;; | |
974 ;;; Select / Unselect | |
975 ;;; | |
976 (defun tpu-select (&optional quiet) | |
977 "Sets the mark to define one end of a region." | |
978 (interactive "P") | |
979 (cond ((tpu-mark) | |
980 (tpu-unselect quiet)) | |
981 (t | |
982 (tpu-set-mark (point)) | |
983 (tpu-update-mode-line) | |
984 (if (not quiet) (message "Move the text cursor to select text."))))) | |
985 | |
986 (defun tpu-unselect (&optional quiet) | |
987 "Removes the mark to unselect the current region." | |
988 (interactive "P") | |
989 (setq mark-ring nil) | |
990 (tpu-set-mark nil) | |
991 (tpu-update-mode-line) | |
992 (if (not quiet) (message "Selection canceled."))) | |
993 | |
994 | |
995 ;;; | |
996 ;;; Delete / Cut | |
997 ;;; | |
998 (defun tpu-toggle-rectangle nil | |
999 "Toggle rectangular mode for remove and insert." | |
1000 (interactive) | |
1001 (setq tpu-rectangular-p (not tpu-rectangular-p)) | |
1002 (setq tpu-rectangle-string (if tpu-rectangular-p " Rect" "")) | |
1003 (tpu-update-mode-line) | |
1004 (and (interactive-p) | |
1005 (message "Rectangular cut and paste %sabled." | |
1006 (if tpu-rectangular-p "en" "dis")))) | |
1007 | |
1008 (defun tpu-arrange-rectangle nil | |
1009 "Adjust point and mark to mark upper left and lower right | |
1010 corners of a rectangle." | |
1011 (let ((mc (current-column)) | |
1012 (pc (progn (exchange-point-and-mark) (current-column)))) | |
1013 | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1014 (cond ((> (point) (tpu-mark)) ; point on lower line |
4421 | 1015 (cond ((> pc mc) ; point @ lower-right |
1016 (exchange-point-and-mark)) ; point -> upper-left | |
1017 | |
1018 (t ; point @ lower-left | |
1019 (move-to-column-force mc) ; point -> lower-right | |
1020 (exchange-point-and-mark) ; point -> upper-right | |
1021 (move-to-column-force pc)))) ; point -> upper-left | |
1022 | |
1023 (t ; point on upper line | |
1024 (cond ((> pc mc) ; point @ upper-right | |
1025 (move-to-column-force mc) ; point -> upper-left | |
1026 (exchange-point-and-mark) ; point -> lower-left | |
1027 (move-to-column-force pc) ; point -> lower-right | |
1028 (exchange-point-and-mark))))))) ; point -> upper-left | |
1029 | |
1030 (defun tpu-cut-text nil | |
1031 "Delete the selected region. | |
1032 The text is saved for the tpu-paste command." | |
1033 (interactive) | |
1034 (cond ((tpu-mark) | |
1035 (cond (tpu-rectangular-p | |
1036 (tpu-arrange-rectangle) | |
1037 (picture-clear-rectangle (point) (tpu-mark) (not overwrite-mode)) | |
1038 (tpu-unselect t)) | |
1039 (t | |
1040 (setq tpu-last-deleted-region | |
1041 (buffer-substring (tpu-mark) (point))) | |
1042 (delete-region (tpu-mark) (point)) | |
1043 (tpu-unselect t)))) | |
1044 ((tpu-check-match) | |
1045 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) | |
1046 (setq tpu-last-deleted-region (buffer-substring beg end)) | |
1047 (delete-region beg end) | |
1048 (tpu-unset-match))) | |
1049 (t | |
1050 (error "No selection active.")))) | |
1051 | |
1052 (defun tpu-store-text nil | |
1053 "Copy the selected region to the cut buffer without deleting it. | |
1054 The text is saved for the tpu-paste command." | |
1055 (interactive) | |
1056 (cond ((tpu-mark) | |
1057 (cond (tpu-rectangular-p | |
1058 (save-excursion | |
1059 (tpu-arrange-rectangle) | |
1060 (setq picture-killed-rectangle | |
1061 (extract-rectangle (point) (tpu-mark)))) | |
1062 (tpu-unselect t)) | |
1063 (t | |
1064 (setq tpu-last-deleted-region | |
1065 (buffer-substring (tpu-mark) (point))) | |
1066 (tpu-unselect t)))) | |
1067 ((tpu-check-match) | |
1068 (setq tpu-last-deleted-region | |
1069 (buffer-substring (tpu-match-beginning) (tpu-match-end))) | |
1070 (tpu-unset-match)) | |
1071 (t | |
1072 (error "No selection active.")))) | |
1073 | |
1074 (defun tpu-cut (arg) | |
1075 "Copy selected region to the cut buffer. In the absence of an | |
1076 argument, delete the selected region too." | |
1077 (interactive "P") | |
1078 (if arg (tpu-store-text) (tpu-cut-text))) | |
1079 | |
1080 (defun tpu-append-region (arg) | |
1081 "Append selected region to the tpu-cut buffer. In the absence of an | |
1082 argument, delete the selected region too." | |
1083 (interactive "P") | |
1084 (cond ((tpu-mark) | |
1085 (let ((beg (region-beginning)) (end (region-end))) | |
1086 (setq tpu-last-deleted-region | |
1087 (concat tpu-last-deleted-region | |
1088 (buffer-substring beg end))) | |
1089 (if (not arg) (delete-region beg end)) | |
1090 (tpu-unselect t))) | |
1091 ((tpu-check-match) | |
1092 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) | |
1093 (setq tpu-last-deleted-region | |
1094 (concat tpu-last-deleted-region | |
1095 (buffer-substring beg end))) | |
1096 (if (not arg) (delete-region beg end)) | |
1097 (tpu-unset-match))) | |
1098 (t | |
1099 (error "No selection active.")))) | |
1100 | |
1101 (defun tpu-delete-current-line (num) | |
1102 "Delete one or specified number of lines after point. | |
1103 This includes the newline character at the end of each line. | |
1104 They are saved for the TPU-edt undelete-lines command." | |
1105 (interactive "p") | |
1106 (let ((beg (point))) | |
1107 (forward-line num) | |
1108 (if (not (eq (preceding-char) ?\n)) | |
1109 (insert "\n")) | |
1110 (setq tpu-last-deleted-lines | |
1111 (buffer-substring beg (point))) | |
1112 (delete-region beg (point)))) | |
1113 | |
1114 (defun tpu-delete-to-eol (num) | |
1115 "Delete text up to end of line. | |
1116 With argument, delete up to to Nth line-end past point. | |
1117 They are saved for the TPU-edt undelete-lines command." | |
1118 (interactive "p") | |
1119 (let ((beg (point))) | |
1120 (forward-char 1) | |
1121 (end-of-line num) | |
1122 (setq tpu-last-deleted-lines | |
1123 (buffer-substring beg (point))) | |
1124 (delete-region beg (point)))) | |
1125 | |
1126 (defun tpu-delete-to-bol (num) | |
1127 "Delete text back to beginning of line. | |
1128 With argument, delete up to to Nth line-end past point. | |
1129 They are saved for the TPU-edt undelete-lines command." | |
1130 (interactive "p") | |
1131 (let ((beg (point))) | |
1132 (tpu-next-beginning-of-line num) | |
1133 (setq tpu-last-deleted-lines | |
1134 (buffer-substring (point) beg)) | |
1135 (delete-region (point) beg))) | |
1136 | |
1137 (defun tpu-delete-current-word (num) | |
1138 "Delete one or specified number of words after point. | |
1139 They are saved for the TPU-edt undelete-words command." | |
1140 (interactive "p") | |
1141 (let ((beg (point))) | |
1142 (tpu-forward-to-word num) | |
1143 (setq tpu-last-deleted-words | |
1144 (buffer-substring beg (point))) | |
1145 (delete-region beg (point)))) | |
1146 | |
1147 (defun tpu-delete-previous-word (num) | |
1148 "Delete one or specified number of words before point. | |
1149 They are saved for the TPU-edt undelete-words command." | |
1150 (interactive "p") | |
1151 (let ((beg (point))) | |
1152 (tpu-backward-to-word num) | |
1153 (setq tpu-last-deleted-words | |
1154 (buffer-substring (point) beg)) | |
1155 (delete-region beg (point)))) | |
1156 | |
1157 (defun tpu-delete-current-char (num) | |
1158 "Delete one or specified number of characters after point. The last | |
1159 character deleted is saved for the TPU-edt undelete-char command." | |
1160 (interactive "p") | |
1161 (while (and (> num 0) (not (eobp))) | |
1162 (setq tpu-last-deleted-char (char-after (point))) | |
1163 (cond (overwrite-mode | |
1164 (picture-clear-column 1) | |
1165 (forward-char 1)) | |
1166 (t | |
1167 (delete-char 1))) | |
1168 (setq num (1- num)))) | |
1169 | |
1170 | |
1171 ;;; | |
1172 ;;; Undelete / Paste | |
1173 ;;; | |
1174 (defun tpu-paste (num) | |
1175 "Insert the last region or rectangle of killed text. | |
1176 With argument reinserts the text that many times." | |
1177 (interactive "p") | |
1178 (while (> num 0) | |
1179 (cond (tpu-rectangular-p | |
1180 (let ((beg (point))) | |
1181 (save-excursion | |
1182 (picture-yank-rectangle (not overwrite-mode)) | |
1183 (message "")) | |
1184 (goto-char beg))) | |
1185 (t | |
1186 (insert tpu-last-deleted-region))) | |
1187 (setq num (1- num)))) | |
1188 | |
1189 (defun tpu-undelete-lines (num) | |
1190 "Insert lines deleted by last TPU-edt line-deletion command. | |
1191 With argument reinserts lines that many times." | |
1192 (interactive "p") | |
1193 (let ((beg (point))) | |
1194 (while (> num 0) | |
1195 (insert tpu-last-deleted-lines) | |
1196 (setq num (1- num))) | |
1197 (goto-char beg))) | |
1198 | |
1199 (defun tpu-undelete-words (num) | |
1200 "Insert words deleted by last TPU-edt word-deletion command. | |
1201 With argument reinserts words that many times." | |
1202 (interactive "p") | |
1203 (let ((beg (point))) | |
1204 (while (> num 0) | |
1205 (insert tpu-last-deleted-words) | |
1206 (setq num (1- num))) | |
1207 (goto-char beg))) | |
1208 | |
1209 (defun tpu-undelete-char (num) | |
1210 "Insert character deleted by last TPU-edt character-deletion command. | |
1211 With argument reinserts the character that many times." | |
1212 (interactive "p") | |
1213 (while (> num 0) | |
1214 (if overwrite-mode (prog1 (forward-char -1) (delete-char 1))) | |
1215 (insert tpu-last-deleted-char) | |
1216 (forward-char -1) | |
1217 (setq num (1- num)))) | |
1218 | |
1219 | |
1220 ;;; | |
1221 ;;; Replace and Substitute | |
1222 ;;; | |
1223 (defun tpu-replace nil | |
1224 "Replace the selected region with the contents of the cut buffer." | |
1225 (interactive) | |
1226 (cond ((tpu-mark) | |
1227 (let ((beg (region-beginning)) (end (region-end))) | |
1228 (setq tpu-last-replaced-text (buffer-substring beg end)) | |
1229 (delete-region beg end) | |
1230 (insert tpu-last-deleted-region) | |
1231 (tpu-unselect t))) | |
1232 ((tpu-check-match) | |
1233 (let ((beg (tpu-match-beginning)) (end (tpu-match-end))) | |
1234 (setq tpu-last-replaced-text (buffer-substring beg end)) | |
1235 (replace-match tpu-last-deleted-region | |
1236 (not case-replace) (not tpu-regexp-p)) | |
1237 (tpu-unset-match))) | |
1238 (t | |
1239 (error "No selection active.")))) | |
1240 | |
1241 (defun tpu-substitute (num) | |
1242 "Replace the selected region with the contents of the cut buffer, and | |
1243 repeat most recent search. A numeric argument serves as a repeat count. | |
1244 A negative argument means replace all occurrences of the search string." | |
1245 (interactive "p") | |
1246 (cond ((or (tpu-mark) (tpu-check-match)) | |
1247 (while (and (not (= num 0)) (or (tpu-mark) (tpu-check-match))) | |
1248 (let ((beg (point))) | |
1249 (tpu-replace) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
1250 (if tpu-searching-forward (forward-char -1) (goto-char beg)) |
4421 | 1251 (if (= num 1) (tpu-search-internal tpu-search-last-string) |
1252 (tpu-search-internal-core tpu-search-last-string))) | |
1253 (setq num (1- num)))) | |
1254 (t | |
1255 (error "No selection active.")))) | |
1256 | |
1257 (defun tpu-lm-replace (from to) | |
1258 "Interactively search for OLD-string and substitute NEW-string." | |
1259 (interactive (list (tpu-regexp-prompt "Old String: ") | |
1260 (tpu-regexp-prompt "New String: "))) | |
1261 | |
1262 (let ((doit t) (strings 0)) | |
1263 | |
1264 ;; Can't replace null strings | |
1265 (if (string= "" from) (error "No string to replace.")) | |
1266 | |
1267 ;; Find the first occurrence | |
1268 (tpu-set-search) | |
1269 (tpu-search-internal from t) | |
1270 | |
1271 ;; Loop on replace question - yes, no, all, last, or quit. | |
1272 (while doit | |
1273 (if (not (tpu-check-match)) (setq doit nil) | |
1274 (progn (message "Replace? Type Yes, No, All, Last, or Quit: ") | |
1275 (let ((ans (read-char))) | |
1276 | |
1277 (cond ((or (= ans ?y) (= ans ?Y) (= ans ?\r) (= ans ?\ )) | |
1278 (let ((beg (point))) | |
1279 (replace-match to (not case-replace) (not tpu-regexp-p)) | |
1280 (setq strings (1+ strings)) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
1281 (if tpu-searching-forward (forward-char -1) (goto-char beg))) |
4421 | 1282 (tpu-search-internal from t)) |
1283 | |
1284 ((or (= ans ?n) (= ans ?N) (= ans ?\C-?)) | |
1285 (tpu-search-internal from t)) | |
1286 | |
1287 ((or (= ans ?a) (= ans ?A)) | |
1288 (save-excursion | |
1289 (let ((beg (point))) | |
1290 (replace-match to (not case-replace) (not tpu-regexp-p)) | |
1291 (setq strings (1+ strings)) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
1292 (if tpu-searching-forward (forward-char -1) (goto-char beg))) |
4421 | 1293 (tpu-search-internal-core from t) |
1294 (while (tpu-check-match) | |
1295 (let ((beg (point))) | |
1296 (replace-match to (not case-replace) (not tpu-regexp-p)) | |
1297 (setq strings (1+ strings)) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
1298 (if tpu-searching-forward (forward-char -1) (goto-char beg))) |
4421 | 1299 (tpu-search-internal-core from t))) |
1300 (setq doit nil)) | |
1301 | |
1302 ((or (= ans ?l) (= ans ?L)) | |
1303 (let ((beg (point))) | |
1304 (replace-match to (not case-replace) (not tpu-regexp-p)) | |
1305 (setq strings (1+ strings)) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
1306 (if tpu-searching-forward (forward-char -1) (goto-char beg))) |
4421 | 1307 (setq doit nil)) |
1308 | |
1309 ((or (= ans ?q) (= ans ?Q)) | |
1310 (setq doit nil))))))) | |
1311 | |
1312 (message "Replaced %s occurrence%s." strings | |
1313 (if (not (= 1 strings)) "s" "")))) | |
1314 | |
1315 (defun tpu-emacs-replace (&optional dont-ask) | |
1316 "A TPU-edt interface to the emacs replace functions. If TPU-edt is | |
1317 currently in regular expression mode, the emacs regular expression | |
1318 replace functions are used. If an argument is supplied, replacements | |
1319 are performed without asking. Only works in forward direction." | |
1320 (interactive "P") | |
1321 (cond (dont-ask | |
1322 (setq current-prefix-arg nil) | |
1323 (call-interactively | |
1324 (if tpu-regexp-p 'replace-regexp 'replace-string))) | |
1325 (t | |
1326 (call-interactively | |
1327 (if tpu-regexp-p 'query-replace-regexp 'query-replace))))) | |
1328 | |
1329 (defun tpu-add-at-bol (text) | |
1330 "Add text to the beginning of each line in a region, | |
1331 or each line in the entire buffer if no region is selected." | |
1332 (interactive | |
1333 (list (tpu-string-prompt "String to add: " 'tpu-add-at-bol-hist))) | |
1334 (if (string= "" text) (error "No string specified.")) | |
1335 (cond ((tpu-mark) | |
1336 (save-excursion | |
1337 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) | |
1338 (while (and (< (point) (tpu-mark)) (re-search-forward "^" (tpu-mark) t)) | |
1339 (if (< (point) (tpu-mark)) (replace-match text)))) | |
1340 (tpu-unselect t)) | |
1341 (t | |
1342 (save-excursion | |
1343 (goto-char (point-min)) | |
1344 (while (and (re-search-forward "^" nil t) (not (eobp))) | |
1345 (replace-match text)))))) | |
1346 | |
1347 (defun tpu-add-at-eol (text) | |
1348 "Add text to the end of each line in a region, | |
1349 or each line of the entire buffer if no region is selected." | |
1350 (interactive | |
1351 (list (tpu-string-prompt "String to add: " 'tpu-add-at-eol-hist))) | |
1352 (if (string= "" text) (error "No string specified.")) | |
1353 (cond ((tpu-mark) | |
1354 (save-excursion | |
1355 (if (> (point) (tpu-mark)) (exchange-point-and-mark)) | |
1356 (while (< (point) (tpu-mark)) | |
1357 (end-of-line) | |
1358 (if (<= (point) (tpu-mark)) (insert text)) | |
1359 (forward-line))) | |
1360 (tpu-unselect t)) | |
1361 (t | |
1362 (save-excursion | |
1363 (goto-char (point-min)) | |
1364 (while (not (eobp)) | |
1365 (end-of-line) (insert text) (forward-line)))))) | |
1366 | |
1367 (defun tpu-trim-line-ends nil | |
1368 "Removes trailing whitespace from every line in the buffer." | |
1369 (interactive) | |
1370 (picture-clean)) | |
1371 | |
1372 | |
1373 ;;; | |
1374 ;;; Movement by character | |
1375 ;;; | |
1376 (defun tpu-char (num) | |
1377 "Move to the next character in the current direction. | |
1378 A repeat count means move that many characters." | |
1379 (interactive "p") | |
1380 (if tpu-advance (tpu-forward-char num) (tpu-backward-char num))) | |
1381 | |
1382 (defun tpu-forward-char (num) | |
1383 "Move right ARG characters (left if ARG is negative)." | |
1384 (interactive "p") | |
1385 (forward-char num)) | |
1386 | |
1387 (defun tpu-backward-char (num) | |
1388 "Move left ARG characters (right if ARG is negative)." | |
1389 (interactive "p") | |
1390 (backward-char num)) | |
1391 | |
1392 | |
1393 ;;; | |
1394 ;;; Movement by word | |
1395 ;;; | |
1396 (defconst tpu-word-separator-list '() | |
1397 "List of additional word separators.") | |
1398 (defconst tpu-skip-chars "^ \t" | |
1399 "Characters to skip when moving by word. | |
1400 Additional word separators are added to this string.") | |
1401 | |
1402 (defun tpu-word (num) | |
1403 "Move to the beginning of the next word in the current direction. | |
1404 A repeat count means move that many words." | |
1405 (interactive "p") | |
1406 (if tpu-advance (tpu-forward-to-word num) (tpu-backward-to-word num))) | |
1407 | |
1408 (defun tpu-forward-to-word (num) | |
1409 "Move forward until encountering the beginning of a word. | |
1410 With argument, do this that many times." | |
1411 (interactive "p") | |
1412 (while (and (> num 0) (not (eobp))) | |
1413 (let* ((beg (point)) | |
1414 (end (prog2 (end-of-line) (point) (goto-char beg)))) | |
1415 (cond ((eolp) | |
1416 (forward-char 1)) | |
1417 ((memq (char-after (point)) tpu-word-separator-list) | |
1418 (forward-char 1) | |
1419 (skip-chars-forward " \t" end)) | |
1420 (t | |
1421 (skip-chars-forward tpu-skip-chars end) | |
1422 (skip-chars-forward " \t" end)))) | |
1423 (setq num (1- num)))) | |
1424 | |
1425 (defun tpu-backward-to-word (num) | |
1426 "Move backward until encountering the beginning of a word. | |
1427 With argument, do this that many times." | |
1428 (interactive "p") | |
1429 (while (and (> num 0) (not (bobp))) | |
1430 (let* ((beg (point)) | |
1431 (end (prog2 (beginning-of-line) (point) (goto-char beg)))) | |
1432 (cond ((bolp) | |
1433 ( forward-char -1)) | |
1434 ((memq (char-after (1- (point))) tpu-word-separator-list) | |
1435 (forward-char -1)) | |
1436 (t | |
1437 (skip-chars-backward " \t" end) | |
1438 (skip-chars-backward tpu-skip-chars end) | |
1439 (if (and (not (bolp)) (= ? (char-syntax (char-after (point))))) | |
1440 (forward-char -1))))) | |
1441 (setq num (1- num)))) | |
1442 | |
1443 (defun tpu-add-word-separators (separators) | |
1444 "Add new word separators for TPU-edt word commands." | |
1445 (interactive "sSeparators: ") | |
1446 (let* ((n 0) (length (length separators))) | |
1447 (while (< n length) | |
1448 (let ((char (aref separators n)) | |
1449 (ss (substring separators n (1+ n)))) | |
1450 (cond ((not (memq char tpu-word-separator-list)) | |
1451 (setq tpu-word-separator-list | |
1452 (append ss tpu-word-separator-list)) | |
1453 (cond ((= char ?-) | |
1454 (setq tpu-skip-chars (concat tpu-skip-chars "\\-"))) | |
1455 ((= char ?\\) | |
1456 (setq tpu-skip-chars (concat tpu-skip-chars "\\\\"))) | |
1457 ((= char ?^) | |
1458 (setq tpu-skip-chars (concat tpu-skip-chars "\\^"))) | |
1459 (t | |
1460 (setq tpu-skip-chars (concat tpu-skip-chars ss)))))) | |
1461 (setq n (1+ n)))))) | |
1462 | |
1463 (defun tpu-reset-word-separators nil | |
1464 "Reset word separators to default value." | |
1465 (interactive) | |
1466 (setq tpu-word-separator-list nil) | |
1467 (setq tpu-skip-chars "^ \t")) | |
1468 | |
1469 (defun tpu-set-word-separators (separators) | |
1470 "Set new word separators for TPU-edt word commands." | |
1471 (interactive "sSeparators: ") | |
1472 (tpu-reset-word-separators) | |
1473 (tpu-add-word-separators separators)) | |
1474 | |
1475 | |
1476 ;;; | |
1477 ;;; Movement by line | |
1478 ;;; | |
1479 (defun tpu-next-line (num) | |
1480 "Move to next line. | |
1481 Prefix argument serves as a repeat count." | |
1482 (interactive "p") | |
1483 (next-line-internal num) | |
1484 (setq this-command 'next-line)) | |
1485 | |
1486 (defun tpu-previous-line (num) | |
1487 "Move to previous line. | |
1488 Prefix argument serves as a repeat count." | |
1489 (interactive "p") | |
1490 (next-line-internal (- num)) | |
1491 (setq this-command 'previous-line)) | |
1492 | |
1493 (defun tpu-next-beginning-of-line (num) | |
1494 "Move to beginning of line; if at beginning, move to beginning of next line. | |
1495 Accepts a prefix argument for the number of lines to move." | |
1496 (interactive "p") | |
1497 (backward-char 1) | |
1498 (forward-line (- 1 num))) | |
1499 | |
1500 (defun tpu-end-of-line (num) | |
1501 "Move to the next end of line in the current direction. | |
1502 A repeat count means move that many lines." | |
1503 (interactive "p") | |
1504 (if tpu-advance (tpu-next-end-of-line num) (tpu-previous-end-of-line num))) | |
1505 | |
1506 (defun tpu-next-end-of-line (num) | |
1507 "Move to end of line; if at end, move to end of next line. | |
1508 Accepts a prefix argument for the number of lines to move." | |
1509 (interactive "p") | |
1510 (forward-char 1) | |
1511 (end-of-line num)) | |
1512 | |
1513 (defun tpu-previous-end-of-line (num) | |
1514 "Move EOL upward. | |
1515 Accepts a prefix argument for the number of lines to move." | |
1516 (interactive "p") | |
1517 (end-of-line (- 1 num))) | |
1518 | |
1519 (defun tpu-current-end-of-line nil | |
1520 "Move point to end of current line." | |
1521 (interactive) | |
1522 (let ((beg (point))) | |
1523 (end-of-line) | |
1524 (if (= beg (point)) (message "You are already at the end of a line.")))) | |
1525 | |
1526 (defun tpu-line (num) | |
1527 "Move to the beginning of the next line in the current direction. | |
1528 A repeat count means move that many lines." | |
1529 (interactive "p") | |
1530 (if tpu-advance (tpu-forward-line num) (tpu-backward-line num))) | |
1531 | |
1532 (defun tpu-forward-line (num) | |
1533 "Move to beginning of next line. | |
1534 Prefix argument serves as a repeat count." | |
1535 (interactive "p") | |
1536 (forward-line num)) | |
1537 | |
1538 (defun tpu-backward-line (num) | |
1539 "Move to beginning of previous line. | |
1540 Prefix argument serves as repeat count." | |
1541 (interactive "p") | |
1542 (forward-line (- num))) | |
1543 | |
1544 | |
1545 ;;; | |
1546 ;;; Movement by paragraph | |
1547 ;;; | |
1548 (defun tpu-paragraph (num) | |
1549 "Move to the next paragraph in the current direction. | |
1550 A repeat count means move that many paragraphs." | |
1551 (interactive "p") | |
1552 (if tpu-advance | |
1553 (tpu-next-paragraph num) (tpu-previous-paragraph num))) | |
1554 | |
1555 (defun tpu-next-paragraph (num) | |
1556 "Move to beginning of the next paragraph. | |
1557 Accepts a prefix argument for the number of paragraphs." | |
1558 (interactive "p") | |
1559 (beginning-of-line) | |
1560 (while (and (not (eobp)) (> num 0)) | |
1561 (if (re-search-forward "^[ \t]*$" nil t) | |
1562 (if (re-search-forward "[^ \t\n]" nil t) | |
1563 (goto-char (match-beginning 0)) | |
1564 (goto-char (point-max)))) | |
1565 (setq num (1- num))) | |
1566 (beginning-of-line)) | |
1567 | |
1568 | |
1569 (defun tpu-previous-paragraph (num) | |
1570 "Move to beginning of previous paragraph. | |
1571 Accepts a prefix argument for the number of paragraphs." | |
1572 (interactive "p") | |
1573 (end-of-line) | |
1574 (while (and (not (bobp)) (> num 0)) | |
1575 (if (not (and (re-search-backward "^[ \t]*$" nil t) | |
1576 (re-search-backward "[^ \t\n]" nil t) | |
1577 (re-search-backward "^[ \t]*$" nil t) | |
1578 (progn (re-search-forward "[^ \t\n]" nil t) | |
1579 (goto-char (match-beginning 0))))) | |
1580 (goto-char (point-min))) | |
1581 (setq num (1- num))) | |
1582 (beginning-of-line)) | |
1583 | |
1584 | |
1585 ;;; | |
1586 ;;; Movement by page | |
1587 ;;; | |
1588 (defun tpu-page (num) | |
1589 "Move to the next page in the current direction. | |
1590 A repeat count means move that many pages." | |
1591 (interactive "p") | |
1592 (if tpu-advance (forward-page num) (backward-page num)) | |
1593 (if (eobp) (recenter -1))) | |
1594 | |
1595 | |
1596 ;;; | |
1597 ;;; Scrolling and movement within the buffer | |
1598 ;;; | |
1599 (defun tpu-scroll-window (num) | |
1600 "Scroll the display to the next section in the current direction. | |
1601 A repeat count means scroll that many sections." | |
1602 (interactive "p") | |
1603 (if tpu-advance (tpu-scroll-window-up num) (tpu-scroll-window-down num))) | |
1604 | |
1605 (defun tpu-scroll-window-down (num) | |
1606 "Scroll the display down to the next section. | |
1607 A repeat count means scroll that many sections." | |
1608 (interactive "p") | |
1609 (let* ((beg (tpu-current-line)) | |
1610 (height (1- (window-height))) | |
1611 (lines (* num (/ (* height tpu-percent-scroll) 100)))) | |
1612 (next-line-internal (- lines)) | |
1613 (if (> lines beg) (recenter 0)))) | |
1614 | |
1615 (defun tpu-scroll-window-up (num) | |
1616 "Scroll the display up to the next section. | |
1617 A repeat count means scroll that many sections." | |
1618 (interactive "p") | |
1619 (let* ((beg (tpu-current-line)) | |
1620 (height (1- (window-height))) | |
1621 (lines (* num (/ (* height tpu-percent-scroll) 100)))) | |
1622 (next-line-internal lines) | |
1623 (if (>= (+ lines beg) height) (recenter -1)))) | |
1624 | |
1625 (defun tpu-pan-right (num) | |
1626 "Pan right tpu-pan-columns (16 by default). | |
1627 Accepts a prefix argument for the number of tpu-pan-columns to scroll." | |
1628 (interactive "p") | |
1629 (scroll-left (* tpu-pan-columns num))) | |
1630 | |
1631 (defun tpu-pan-left (num) | |
1632 "Pan left tpu-pan-columns (16 by default). | |
1633 Accepts a prefix argument for the number of tpu-pan-columns to scroll." | |
1634 (interactive "p") | |
1635 (scroll-right (* tpu-pan-columns num))) | |
1636 | |
1637 (defun tpu-move-to-beginning nil | |
1638 "Move cursor to the beginning of buffer, but don't set the mark." | |
1639 (interactive) | |
1640 (goto-char (point-min))) | |
1641 | |
1642 (defun tpu-move-to-end nil | |
1643 "Move cursor to the end of buffer, but don't set the mark." | |
1644 (interactive) | |
1645 (goto-char (point-max)) | |
1646 (recenter -1)) | |
1647 | |
1648 (defun tpu-goto-percent (perc) | |
1649 "Move point to ARG percentage of the buffer." | |
1650 (interactive "NGoto-percentage: ") | |
1651 (if (or (> perc 100) (< perc 0)) | |
1652 (error "Percentage %d out of range 0 < percent < 100" perc) | |
1653 (goto-char (/ (* (point-max) perc) 100)))) | |
1654 | |
1655 (defun tpu-beginning-of-window nil | |
1656 "Move cursor to top of window." | |
1657 (interactive) | |
1658 (move-to-window-line 0)) | |
1659 | |
1660 (defun tpu-end-of-window nil | |
1661 "Move cursor to bottom of window." | |
1662 (interactive) | |
1663 (move-to-window-line -1)) | |
1664 | |
1665 (defun tpu-line-to-bottom-of-window nil | |
1666 "Move the current line to the bottom of the window." | |
1667 (interactive) | |
1668 (recenter -1)) | |
1669 | |
1670 (defun tpu-line-to-top-of-window nil | |
1671 "Move the current line to the top of the window." | |
1672 (interactive) | |
1673 (recenter 0)) | |
1674 | |
1675 | |
1676 ;;; | |
1677 ;;; Direction | |
1678 ;;; | |
1679 (defun tpu-advance-direction nil | |
1680 "Set TPU Advance mode so keypad commands move forward." | |
1681 (interactive) | |
1682 (setq tpu-direction-string " Advance") | |
1683 (setq tpu-advance t) | |
1684 (setq tpu-reverse nil) | |
1685 (tpu-set-search) | |
1686 (tpu-update-mode-line)) | |
1687 | |
1688 (defun tpu-backup-direction nil | |
1689 "Set TPU Backup mode so keypad commands move backward." | |
1690 (interactive) | |
1691 (setq tpu-direction-string " Reverse") | |
1692 (setq tpu-advance nil) | |
1693 (setq tpu-reverse t) | |
1694 (tpu-set-search) | |
1695 (tpu-update-mode-line)) | |
1696 | |
1697 | |
1698 ;;; | |
1699 ;;; Define keymaps | |
1700 ;;; | |
1701 (define-key global-map "\e[" CSI-map) ; CSI map | |
1702 (define-key global-map "\eO" SS3-map) ; SS3 map | |
1703 (define-key SS3-map "P" GOLD-map) ; GOLD map | |
1704 (define-key GOLD-map "\e[" GOLD-CSI-map) ; GOLD-CSI map | |
1705 (define-key GOLD-map "\eO" GOLD-SS3-map) ; GOLD-SS3 map | |
1706 | |
1707 | |
1708 ;;; | |
1709 ;;; CSI-map key definitions | |
1710 ;;; | |
1711 (define-key CSI-map "A" 'tpu-previous-line) ; up | |
1712 (define-key CSI-map "B" 'tpu-next-line) ; down | |
1713 (define-key CSI-map "D" 'tpu-backward-char) ; left | |
1714 (define-key CSI-map "C" 'tpu-forward-char) ; right | |
1715 | |
1716 (define-key CSI-map "1~" 'tpu-search) ; Find | |
1717 (define-key CSI-map "2~" 'tpu-paste) ; Insert Here | |
1718 (define-key CSI-map "3~" 'tpu-cut) ; Remove | |
1719 (define-key CSI-map "4~" 'tpu-select) ; Select | |
1720 (define-key CSI-map "5~" 'tpu-scroll-window-down) ; Prev Screen | |
1721 (define-key CSI-map "6~" 'tpu-scroll-window-up) ; Next Screen | |
1722 | |
1723 (define-key CSI-map "11~" 'nil) ; F1 | |
1724 (define-key CSI-map "12~" 'nil) ; F2 | |
1725 (define-key CSI-map "13~" 'nil) ; F3 | |
1726 (define-key CSI-map "14~" 'nil) ; F4 | |
1727 (define-key CSI-map "15~" 'nil) ; F5 | |
1728 (define-key CSI-map "17~" 'nil) ; F6 | |
1729 (define-key CSI-map "18~" 'nil) ; F7 | |
1730 (define-key CSI-map "19~" 'nil) ; F8 | |
1731 (define-key CSI-map "20~" 'nil) ; F9 | |
1732 (define-key CSI-map "21~" 'tpu-exit) ; F10 | |
1733 (define-key CSI-map "23~" 'tpu-insert-escape) ; F11 (ESC) | |
1734 (define-key CSI-map "24~" 'tpu-next-beginning-of-line) ; F12 (BS) | |
1735 (define-key CSI-map "25~" 'tpu-delete-previous-word) ; F13 (LF) | |
1736 (define-key CSI-map "26~" 'tpu-toggle-overwrite-mode) ; F14 | |
1737 (define-key CSI-map "28~" 'tpu-help) ; HELP | |
1738 (define-key CSI-map "29~" 'execute-extended-command) ; DO | |
1739 (define-key CSI-map "31~" 'tpu-goto-breadcrumb) ; F17 | |
1740 (define-key CSI-map "32~" 'nil) ; F18 | |
1741 (define-key CSI-map "33~" 'nil) ; F19 | |
1742 (define-key CSI-map "34~" 'nil) ; F20 | |
1743 | |
1744 | |
1745 ;;; | |
1746 ;;; SS3-map key definitions | |
1747 ;;; | |
1748 (define-key SS3-map "A" 'tpu-previous-line) ; up | |
1749 (define-key SS3-map "B" 'tpu-next-line) ; down | |
1750 (define-key SS3-map "C" 'tpu-forward-char) ; right | |
1751 (define-key SS3-map "D" 'tpu-backward-char) ; left | |
1752 | |
1753 (define-key SS3-map "Q" 'tpu-help) ; PF2 | |
1754 (define-key SS3-map "R" 'tpu-search-again) ; PF3 | |
1755 (define-key SS3-map "S" 'tpu-delete-current-line) ; PF4 | |
1756 (define-key SS3-map "p" 'tpu-line) ; KP0 | |
1757 (define-key SS3-map "q" 'tpu-word) ; KP1 | |
1758 (define-key SS3-map "r" 'tpu-end-of-line) ; KP2 | |
1759 (define-key SS3-map "s" 'tpu-char) ; KP3 | |
1760 (define-key SS3-map "t" 'tpu-advance-direction) ; KP4 | |
1761 (define-key SS3-map "u" 'tpu-backup-direction) ; KP5 | |
1762 (define-key SS3-map "v" 'tpu-cut) ; KP6 | |
1763 (define-key SS3-map "w" 'tpu-page) ; KP7 | |
1764 (define-key SS3-map "x" 'tpu-scroll-window) ; KP8 | |
1765 (define-key SS3-map "y" 'tpu-append-region) ; KP9 | |
1766 (define-key SS3-map "m" 'tpu-delete-current-word) ; KP- | |
1767 (define-key SS3-map "l" 'tpu-delete-current-char) ; KP, | |
1768 (define-key SS3-map "n" 'tpu-select) ; KP. | |
1769 (define-key SS3-map "M" 'newline) ; KPenter | |
1770 | |
1771 | |
1772 ;;; | |
1773 ;;; GOLD-map key definitions | |
1774 ;;; | |
1775 (define-key GOLD-map "\C-A" 'tpu-toggle-overwrite-mode) ; ^A | |
1776 (define-key GOLD-map "\C-B" 'nil) ; ^B | |
1777 (define-key GOLD-map "\C-C" 'nil) ; ^C | |
1778 (define-key GOLD-map "\C-D" 'nil) ; ^D | |
1779 (define-key GOLD-map "\C-E" 'nil) ; ^E | |
1780 (define-key GOLD-map "\C-F" 'set-visited-file-name) ; ^F | |
1781 (define-key GOLD-map "\C-g" 'keyboard-quit) ; safety first | |
1782 (define-key GOLD-map "\C-h" 'delete-other-windows) ; BS | |
1783 (define-key GOLD-map "\C-i" 'other-window) ; TAB | |
1784 (define-key GOLD-map "\C-J" 'nil) ; ^J | |
1785 (define-key GOLD-map "\C-K" 'tpu-define-macro-key) ; ^K | |
1786 (define-key GOLD-map "\C-l" 'downcase-region) ; ^L | |
1787 (define-key GOLD-map "\C-M" 'nil) ; ^M | |
1788 (define-key GOLD-map "\C-N" 'nil) ; ^N | |
1789 (define-key GOLD-map "\C-O" 'nil) ; ^O | |
1790 (define-key GOLD-map "\C-P" 'nil) ; ^P | |
1791 (define-key GOLD-map "\C-Q" 'nil) ; ^Q | |
1792 (define-key GOLD-map "\C-R" 'nil) ; ^R | |
1793 (define-key GOLD-map "\C-S" 'nil) ; ^S | |
1794 (define-key GOLD-map "\C-T" 'tpu-toggle-control-keys) ; ^T | |
1795 (define-key GOLD-map "\C-u" 'upcase-region) ; ^U | |
1796 (define-key GOLD-map "\C-V" 'nil) ; ^V | |
1797 (define-key GOLD-map "\C-w" 'tpu-write-current-buffers) ; ^W | |
1798 (define-key GOLD-map "\C-X" 'nil) ; ^X | |
1799 (define-key GOLD-map "\C-Y" 'nil) ; ^Y | |
1800 (define-key GOLD-map "\C-Z" 'nil) ; ^Z | |
1801 (define-key GOLD-map " " 'undo) ; SPC | |
1802 (define-key GOLD-map "!" 'nil) ; ! | |
1803 (define-key GOLD-map "#" 'nil) ; # | |
1804 (define-key GOLD-map "$" 'tpu-add-at-eol) ; $ | |
1805 (define-key GOLD-map "%" 'tpu-goto-percent) ; % | |
1806 (define-key GOLD-map "&" 'nil) ; & | |
1807 (define-key GOLD-map "(" 'nil) ; ( | |
1808 (define-key GOLD-map ")" 'nil) ; ) | |
1809 (define-key GOLD-map "*" 'tpu-toggle-regexp) ; * | |
1810 (define-key GOLD-map "+" 'nil) ; + | |
1811 (define-key GOLD-map "," 'tpu-goto-breadcrumb) ; , | |
1812 (define-key GOLD-map "-" 'negative-argument) ; - | |
1813 (define-key GOLD-map "." 'tpu-drop-breadcrumb) ; . | |
1814 (define-key GOLD-map "/" 'tpu-emacs-replace) ; / | |
1815 (define-key GOLD-map "0" 'digit-argument) ; 0 | |
1816 (define-key GOLD-map "1" 'digit-argument) ; 1 | |
1817 (define-key GOLD-map "2" 'digit-argument) ; 2 | |
1818 (define-key GOLD-map "3" 'digit-argument) ; 3 | |
1819 (define-key GOLD-map "4" 'digit-argument) ; 4 | |
1820 (define-key GOLD-map "5" 'digit-argument) ; 5 | |
1821 (define-key GOLD-map "6" 'digit-argument) ; 6 | |
1822 (define-key GOLD-map "7" 'digit-argument) ; 7 | |
1823 (define-key GOLD-map "8" 'digit-argument) ; 8 | |
1824 (define-key GOLD-map "9" 'digit-argument) ; 9 | |
1825 (define-key GOLD-map ":" 'nil) ; : | |
1826 (define-key GOLD-map ";" 'tpu-trim-line-ends) ; ; | |
1827 (define-key GOLD-map "<" 'nil) ; < | |
1828 (define-key GOLD-map "=" 'nil) ; = | |
1829 (define-key GOLD-map ">" 'nil) ; > | |
1830 (define-key GOLD-map "?" 'tpu-spell-check) ; ? | |
1831 (define-key GOLD-map "A" 'tpu-toggle-newline-and-indent) ; A | |
1832 (define-key GOLD-map "B" 'tpu-next-buffer) ; B | |
1833 (define-key GOLD-map "C" 'repeat-complex-command) ; C | |
1834 (define-key GOLD-map "D" 'shell-command) ; D | |
1835 (define-key GOLD-map "E" 'tpu-exit) ; E | |
5186
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
1836 (define-key GOLD-map "F" 'tpu-set-cursor-free) ; F |
4421 | 1837 (define-key GOLD-map "G" 'tpu-get) ; G |
1838 (define-key GOLD-map "H" 'nil) ; H | |
1839 (define-key GOLD-map "I" 'tpu-include) ; I | |
1840 (define-key GOLD-map "K" 'tpu-kill-buffer) ; K | |
1841 (define-key GOLD-map "L" 'tpu-what-line) ; L | |
1842 (define-key GOLD-map "M" 'buffer-menu) ; M | |
1843 (define-key GOLD-map "N" 'tpu-next-file-buffer) ; N | |
1844 (define-key GOLD-map "O" 'occur) ; O | |
1845 (define-key GOLD-map "P" 'lpr-buffer) ; P | |
1846 (define-key GOLD-map "Q" 'tpu-quit) ; Q | |
1847 (define-key GOLD-map "R" 'tpu-toggle-rectangle) ; R | |
1848 (define-key GOLD-map "S" 'replace) ; S | |
1849 (define-key GOLD-map "T" 'tpu-line-to-top-of-window) ; T | |
1850 (define-key GOLD-map "U" 'undo) ; U | |
1851 (define-key GOLD-map "V" 'tpu-version) ; V | |
1852 (define-key GOLD-map "W" 'save-buffer) ; W | |
1853 (define-key GOLD-map "X" 'tpu-save-all-buffers-kill-emacs) ; X | |
1854 (define-key GOLD-map "Y" 'copy-region-as-kill) ; Y | |
1855 (define-key GOLD-map "Z" 'suspend-emacs) ; Z | |
1856 (define-key GOLD-map "[" 'blink-matching-open) ; [ | |
1857 (define-key GOLD-map "\\" 'nil) ; \ | |
1858 (define-key GOLD-map "]" 'blink-matching-open) ; ] | |
1859 (define-key GOLD-map "^" 'tpu-add-at-bol) ; ^ | |
1860 (define-key GOLD-map "_" 'split-window-vertically) ; - | |
1861 (define-key GOLD-map "`" 'what-line) ; ` | |
1862 (define-key GOLD-map "a" 'tpu-toggle-newline-and-indent) ; a | |
1863 (define-key GOLD-map "b" 'tpu-next-buffer) ; b | |
1864 (define-key GOLD-map "c" 'repeat-complex-command) ; c | |
1865 (define-key GOLD-map "d" 'shell-command) ; d | |
1866 (define-key GOLD-map "e" 'tpu-exit) ; e | |
5186
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
1867 (define-key GOLD-map "f" 'tpu-set-cursor-free) ; f |
4421 | 1868 (define-key GOLD-map "g" 'tpu-get) ; g |
1869 (define-key GOLD-map "h" 'nil) ; h | |
1870 (define-key GOLD-map "i" 'tpu-include) ; i | |
1871 (define-key GOLD-map "k" 'tpu-kill-buffer) ; k | |
1872 (define-key GOLD-map "l" 'goto-line) ; l | |
1873 (define-key GOLD-map "m" 'buffer-menu) ; m | |
1874 (define-key GOLD-map "n" 'tpu-next-file-buffer) ; n | |
1875 (define-key GOLD-map "o" 'occur) ; o | |
1876 (define-key GOLD-map "p" 'lpr-region) ; p | |
1877 (define-key GOLD-map "q" 'tpu-quit) ; q | |
1878 (define-key GOLD-map "r" 'tpu-toggle-rectangle) ; r | |
1879 (define-key GOLD-map "s" 'replace) ; s | |
1880 (define-key GOLD-map "t" 'tpu-line-to-top-of-window) ; t | |
1881 (define-key GOLD-map "u" 'undo) ; u | |
1882 (define-key GOLD-map "v" 'tpu-version) ; v | |
1883 (define-key GOLD-map "w" 'save-buffer) ; w | |
1884 (define-key GOLD-map "x" 'tpu-save-all-buffers-kill-emacs) ; x | |
1885 (define-key GOLD-map "y" 'copy-region-as-kill) ; y | |
1886 (define-key GOLD-map "z" 'suspend-emacs) ; z | |
1887 (define-key GOLD-map "{" 'nil) ; { | |
1888 (define-key GOLD-map "|" 'split-window-horizontally) ; | | |
1889 (define-key GOLD-map "}" 'nil) ; } | |
1890 (define-key GOLD-map "~" 'exchange-point-and-mark) ; ~ | |
1891 (define-key GOLD-map "\177" 'delete-window) ; <X] | |
1892 | |
1893 | |
1894 ;;; | |
1895 ;;; GOLD-CSI-map key definitions | |
1896 ;;; | |
1897 (define-key GOLD-CSI-map "A" 'tpu-move-to-beginning) ; up-arrow | |
1898 (define-key GOLD-CSI-map "B" 'tpu-move-to-end) ; down-arrow | |
1899 (define-key GOLD-CSI-map "C" 'end-of-line) ; right-arrow | |
1900 (define-key GOLD-CSI-map "D" 'beginning-of-line) ; left-arrow | |
1901 | |
1902 (define-key GOLD-CSI-map "1~" 'nil) ; Find | |
1903 (define-key GOLD-CSI-map "2~" 'nil) ; Insert Here | |
1904 (define-key GOLD-CSI-map "3~" 'tpu-store-text) ; Remove | |
1905 (define-key GOLD-CSI-map "4~" 'tpu-unselect) ; Select | |
1906 (define-key GOLD-CSI-map "5~" 'tpu-previous-window) ; Prev Screen | |
1907 (define-key GOLD-CSI-map "6~" 'tpu-next-window) ; Next Screen | |
1908 | |
1909 (define-key GOLD-CSI-map "11~" 'nil) ; F1 | |
1910 (define-key GOLD-CSI-map "12~" 'nil) ; F2 | |
1911 (define-key GOLD-CSI-map "13~" 'nil) ; F3 | |
1912 (define-key GOLD-CSI-map "14~" 'nil) ; F4 | |
1913 (define-key GOLD-CSI-map "16~" 'nil) ; F5 | |
1914 (define-key GOLD-CSI-map "17~" 'nil) ; F6 | |
1915 (define-key GOLD-CSI-map "18~" 'nil) ; F7 | |
1916 (define-key GOLD-CSI-map "19~" 'nil) ; F8 | |
1917 (define-key GOLD-CSI-map "20~" 'nil) ; F9 | |
1918 (define-key GOLD-CSI-map "21~" 'nil) ; F10 | |
1919 (define-key GOLD-CSI-map "23~" 'nil) ; F11 | |
1920 (define-key GOLD-CSI-map "24~" 'nil) ; F12 | |
1921 (define-key GOLD-CSI-map "25~" 'nil) ; F13 | |
1922 (define-key GOLD-CSI-map "26~" 'nil) ; F14 | |
1923 (define-key GOLD-CSI-map "28~" 'describe-bindings) ; HELP | |
1924 (define-key GOLD-CSI-map "29~" 'nil) ; DO | |
1925 (define-key GOLD-CSI-map "31~" 'tpu-drop-breadcrumb) ; F17 | |
1926 (define-key GOLD-CSI-map "32~" 'nil) ; F18 | |
1927 (define-key GOLD-CSI-map "33~" 'nil) ; F19 | |
1928 (define-key GOLD-CSI-map "34~" 'nil) ; F20 | |
1929 | |
1930 | |
1931 ;;; | |
1932 ;;; GOLD-SS3-map key definitions | |
1933 ;;; | |
1934 (define-key GOLD-SS3-map "A" 'tpu-move-to-beginning) ; up-arrow | |
1935 (define-key GOLD-SS3-map "B" 'tpu-move-to-end) ; down-arrow | |
1936 (define-key GOLD-SS3-map "C" 'end-of-line) ; right-arrow | |
1937 (define-key GOLD-SS3-map "D" 'beginning-of-line) ; left-arrow | |
1938 | |
1939 (define-key GOLD-SS3-map "P" 'keyboard-quit) ; PF1 | |
1940 (define-key GOLD-SS3-map "Q" 'help-for-help) ; PF2 | |
1941 (define-key GOLD-SS3-map "R" 'tpu-search) ; PF3 | |
1942 (define-key GOLD-SS3-map "S" 'tpu-undelete-lines) ; PF4 | |
1943 (define-key GOLD-SS3-map "p" 'open-line) ; KP0 | |
1944 (define-key GOLD-SS3-map "q" 'tpu-change-case) ; KP1 | |
1945 (define-key GOLD-SS3-map "r" 'tpu-delete-to-eol) ; KP2 | |
1946 (define-key GOLD-SS3-map "s" 'tpu-special-insert) ; KP3 | |
1947 (define-key GOLD-SS3-map "t" 'tpu-move-to-end) ; KP4 | |
1948 (define-key GOLD-SS3-map "u" 'tpu-move-to-beginning) ; KP5 | |
1949 (define-key GOLD-SS3-map "v" 'tpu-paste) ; KP6 | |
1950 (define-key GOLD-SS3-map "w" 'execute-extended-command) ; KP7 | |
1951 (define-key GOLD-SS3-map "x" 'tpu-fill) ; KP8 | |
1952 (define-key GOLD-SS3-map "y" 'tpu-replace) ; KP9 | |
1953 (define-key GOLD-SS3-map "m" 'tpu-undelete-words) ; KP- | |
1954 (define-key GOLD-SS3-map "l" 'tpu-undelete-char) ; KP, | |
1955 (define-key GOLD-SS3-map "n" 'tpu-unselect) ; KP. | |
1956 (define-key GOLD-SS3-map "M" 'tpu-substitute) ; KPenter | |
1957 | |
1958 | |
1959 ;;; | |
1960 ;;; Repeat complex command map additions to make arrows work | |
1961 ;;; | |
1962 (cond ((boundp 'repeat-complex-command-map) | |
1963 (define-key repeat-complex-command-map "\e[A" 'previous-complex-command) | |
1964 (define-key repeat-complex-command-map "\e[B" 'next-complex-command) | |
1965 (define-key repeat-complex-command-map "\eOA" 'previous-complex-command) | |
1966 (define-key repeat-complex-command-map "\eOB" 'next-complex-command))) | |
1967 | |
1968 | |
1969 ;;; | |
1970 ;;; Minibuffer map additions to make KP_enter = RET | |
1971 ;;; | |
1972 (define-key minibuffer-local-map "\eOM" 'exit-minibuffer) | |
1973 (define-key minibuffer-local-ns-map "\eOM" 'exit-minibuffer) | |
1974 (define-key minibuffer-local-completion-map "\eOM" 'exit-minibuffer) | |
1975 (define-key minibuffer-local-must-match-map "\eOM" 'minibuffer-complete-and-exit) | |
1976 (and (boundp 'repeat-complex-command-map) | |
1977 (define-key repeat-complex-command-map "\eOM" 'exit-minibuffer)) | |
1978 | |
1979 | |
1980 ;;; | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1981 ;;; Minibuffer map additions to set search direction |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1982 ;;; |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1983 (define-key minibuffer-local-map "\eOt" 'tpu-search-forward-exit) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1984 (define-key minibuffer-local-map "\eOu" 'tpu-search-backward-exit) |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1985 |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1986 |
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
1987 ;;; |
4421 | 1988 ;;; Map control keys |
1989 ;;; | |
1990 (define-key global-map "\C-\\" 'quoted-insert) ; ^\ | |
1991 (define-key global-map "\C-a" 'tpu-toggle-overwrite-mode) ; ^A | |
1992 (define-key global-map "\C-b" 'repeat-complex-command) ; ^B | |
1993 (define-key global-map "\C-e" 'tpu-current-end-of-line) ; ^E | |
1994 (define-key global-map "\C-h" 'tpu-next-beginning-of-line) ; ^H (BS) | |
1995 (define-key global-map "\C-j" 'tpu-delete-previous-word) ; ^J (LF) | |
1996 (define-key global-map "\C-k" 'tpu-define-macro-key) ; ^K | |
1997 (define-key global-map "\C-l" 'tpu-insert-formfeed) ; ^L (FF) | |
1998 (define-key global-map "\C-r" 'recenter) ; ^R | |
1999 (define-key global-map "\C-u" 'tpu-delete-to-bol) ; ^U | |
5186
d9bd01c95509
(tpu-quoted-insert): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
2000 (define-key global-map "\C-v" 'tpu-quoted-insert) ; ^V |
4421 | 2001 (define-key global-map "\C-w" 'redraw-display) ; ^W |
2002 (define-key global-map "\C-z" 'tpu-exit) ; ^Z | |
2003 | |
2004 | |
2005 ;;; | |
2006 ;;; Functions to reset and toggle the control key bindings | |
2007 ;;; | |
2008 (defun tpu-reset-control-keys (tpu-style) | |
2009 "Set control keys to TPU or emacs style functions." | |
2010 (let* ((tpu (and tpu-style (not tpu-control-keys))) | |
2011 (emacs (and (not tpu-style) tpu-control-keys)) | |
2012 (doit (or tpu emacs))) | |
2013 (cond (doit | |
2014 (if emacs (setq tpu-global-map (copy-keymap global-map))) | |
2015 (let ((map (if tpu | |
2016 (copy-keymap tpu-global-map) | |
2017 (copy-keymap tpu-original-global-map)))) | |
2018 | |
2019 (define-key global-map "\C-\\" (lookup-key map "\C-\\")) ; ^\ | |
2020 (define-key global-map "\C-a" (lookup-key map "\C-a")) ; ^A | |
2021 (define-key global-map "\C-b" (lookup-key map "\C-b")) ; ^B | |
2022 (define-key global-map "\C-e" (lookup-key map "\C-e")) ; ^E | |
2023 (define-key global-map "\C-h" (lookup-key map "\C-h")) ; ^H (BS) | |
2024 (define-key global-map "\C-j" (lookup-key map "\C-j")) ; ^J (LF) | |
2025 (define-key global-map "\C-k" (lookup-key map "\C-k")) ; ^K | |
2026 (define-key global-map "\C-l" (lookup-key map "\C-l")) ; ^L (FF) | |
2027 (define-key global-map "\C-r" (lookup-key map "\C-r")) ; ^R | |
2028 (define-key global-map "\C-u" (lookup-key map "\C-u")) ; ^U | |
2029 (define-key global-map "\C-v" (lookup-key map "\C-v")) ; ^V | |
2030 (define-key global-map "\C-w" (lookup-key map "\C-w")) ; ^W | |
2031 (define-key global-map "\C-z" (lookup-key map "\C-z")) ; ^Z | |
2032 (setq tpu-control-keys tpu-style)))))) | |
2033 | |
2034 (defun tpu-toggle-control-keys nil | |
2035 "Toggles control key bindings between TPU-edt and Emacs." | |
2036 (interactive) | |
2037 (tpu-reset-control-keys (not tpu-control-keys)) | |
2038 (and (interactive-p) | |
2039 (message "Control keys function with %s bindings." | |
2040 (if tpu-control-keys "TPU-edt" "Emacs")))) | |
2041 | |
2042 | |
2043 ;;; | |
2044 ;;; Emacs version 19 minibuffer history support | |
2045 ;;; | |
2046 (defun tpu-next-history-element (n) | |
2047 "Insert the next element of the minibuffer history into the minibuffer." | |
2048 (interactive "p") | |
2049 (next-history-element n) | |
2050 (goto-char (point-max))) | |
2051 | |
2052 (defun tpu-previous-history-element (n) | |
2053 "Insert the previous element of the minibuffer history into the minibuffer." | |
2054 (interactive "p") | |
2055 (previous-history-element n) | |
2056 (goto-char (point-max))) | |
2057 | |
2058 (defun tpu-arrow-history nil | |
2059 "Modify minibuffer maps to use arrows for history recall." | |
2060 (interactive) | |
2061 (let ((loc (where-is-internal 'tpu-previous-line)) (cur nil)) | |
2062 (while (setq cur (car loc)) | |
2063 (define-key read-expression-map cur 'tpu-previous-history-element) | |
2064 (define-key minibuffer-local-map cur 'tpu-previous-history-element) | |
2065 (define-key minibuffer-local-ns-map cur 'tpu-previous-history-element) | |
2066 (define-key minibuffer-local-completion-map cur 'tpu-previous-history-element) | |
2067 (define-key minibuffer-local-must-match-map cur 'tpu-previous-history-element) | |
2068 (setq loc (cdr loc))) | |
2069 | |
2070 (setq loc (where-is-internal 'tpu-next-line)) | |
2071 (while (setq cur (car loc)) | |
2072 (define-key read-expression-map cur 'tpu-next-history-element) | |
2073 (define-key minibuffer-local-map cur 'tpu-next-history-element) | |
2074 (define-key minibuffer-local-ns-map cur 'tpu-next-history-element) | |
2075 (define-key minibuffer-local-completion-map cur 'tpu-next-history-element) | |
2076 (define-key minibuffer-local-must-match-map cur 'tpu-next-history-element) | |
2077 (setq loc (cdr loc))))) | |
2078 | |
2079 | |
2080 ;;; | |
2081 ;;; Emacs version 19 X-windows key definition support | |
2082 ;;; | |
2083 (defun tpu-load-xkeys (file) | |
2084 "Load the TPU-edt X-windows key definitions FILE. | |
2085 If FILE is nil, try to load a default file. The default file names are | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
2086 `~/.tpu-lucid-keys' for Lucid emacs, and `~/.tpu-keys' for Emacs." |
4421 | 2087 (interactive "fX key definition file: ") |
2088 (cond (file | |
2089 (setq file (expand-file-name file))) | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
2090 (tpu-xkeys-file |
4421 | 2091 (setq file (expand-file-name tpu-xkeys-file))) |
2092 (tpu-lucid-emacs19-p | |
11546
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
2093 (setq file (expand-file-name "~/.tpu-lucid-keys"))) |
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
2094 (tpu-emacs19-p |
66db15ec8ad8
Don't turn on tpu-edt mode.
Richard M. Stallman <rms@gnu.org>
parents:
8155
diff
changeset
|
2095 (setq file (expand-file-name "~/.tpu-keys")))) |
4421 | 2096 (cond ((file-readable-p file) |
2097 (load-file file)) | |
2098 (t | |
4523
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
2099 (switch-to-buffer "*scratch*") |
73cc2b215834
(tpu-version): Print version number rather than the RCS revision number.
Richard M. Stallman <rms@gnu.org>
parents:
4450
diff
changeset
|
2100 (erase-buffer) |
4421 | 2101 (insert " |
2102 | |
2103 Ack!! You're running TPU-edt under X-windows without loading an | |
2104 X key definition file. To create a TPU-edt X key definition | |
2105 file, run the tpu-mapper.el program. It came with TPU-edt. It | |
2106 even includes directions on how to use it! Perhaps it's laying | |
2107 around here someplace. ") | |
2108 (let ((file "tpu-mapper.el") | |
2109 (found nil) | |
2110 (path nil) | |
2111 (search-list (append (list (expand-file-name ".")) load-path))) | |
2112 (while (and (not found) search-list) | |
2113 (setq path (concat (car search-list) | |
2114 (if (string-match "/$" (car search-list)) "" "/") | |
2115 file)) | |
2116 (if (and (file-exists-p path) (not (file-directory-p path))) | |
2117 (setq found t)) | |
2118 (setq search-list (cdr search-list))) | |
2119 (cond (found | |
2120 (insert (format | |
2121 "Ah yes, there it is, in \n\n %s \n\n" path)) | |
2122 (if (tpu-y-or-n-p "Do you want to run it now? ") | |
2123 (load-file path))) | |
2124 (t | |
2125 (insert "Nope, I can't seem to find it. :-(\n\n") | |
2126 (sit-for 120))))))) | |
2127 | |
2128 | |
2129 ;;; | |
2130 ;;; Start and Stop TPU-edt | |
2131 ;;; | |
2132 ;;;###autoload | |
2133 (defun tpu-edt-on nil | |
2134 "Turn on TPU/edt emulation." | |
2135 (interactive) | |
2136 (cond | |
2137 ((not tpu-edt-mode) | |
2138 ;; we use picture-mode functions | |
2139 (require 'picture) | |
2140 (tpu-reset-control-keys t) | |
2141 (cond (tpu-emacs19-p | |
2142 (and window-system (tpu-load-xkeys nil)) | |
2143 (tpu-arrow-history)) | |
2144 (t | |
2145 ;; define ispell functions | |
2146 (autoload 'ispell-word "ispell" "Check spelling of word at or before point" t) | |
2147 (autoload 'ispell-complete-word "ispell" "Complete word at or before point" t) | |
2148 (autoload 'ispell-buffer "ispell" "Check spelling of entire buffer" t) | |
2149 (autoload 'ispell-region "ispell" "Check spelling of region" t))) | |
2150 (tpu-set-mode-line t) | |
2151 (tpu-advance-direction) | |
2152 ;; set page delimiter, display line truncation, and scrolling like TPU | |
2153 (setq-default page-delimiter "\f") | |
2154 (setq-default truncate-lines t) | |
2155 (setq scroll-step 1) | |
2156 (setq tpu-edt-mode t)))) | |
2157 | |
2158 (defun tpu-edt-off nil | |
2159 "Turn off TPU/edt emulation. Note that the keypad is left on." | |
2160 (interactive) | |
2161 (cond | |
2162 (tpu-edt-mode | |
2163 (tpu-reset-control-keys nil) | |
2164 (tpu-set-mode-line nil) | |
2165 (setq-default page-delimiter "^\f") | |
2166 (setq-default truncate-lines nil) | |
2167 (setq scroll-step 0) | |
7982
267ab8286077
(tpu-edt-off): Restore original global key map.
Richard M. Stallman <rms@gnu.org>
parents:
7068
diff
changeset
|
2168 (setq global-map (copy-keymap tpu-original-global-map)) |
4421 | 2169 (use-global-map global-map) |
2170 (setq tpu-edt-mode nil)))) | |
2171 | |
2172 (provide 'tpu-edt) | |
2173 | |
2174 ;;; tpu-edt.el ends here |