aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1995-02-08 01:23:34 +0000
committerKarl Heuer1995-02-08 01:23:34 +0000
commit3bef4fb92fd42b17724086b4dc9cee5a536a1afa (patch)
tree1e52f04a511346118c360b78f422dbf7ce2147d2
parentff6c30e51ee06eab216acce238c2dd46ecd29847 (diff)
downloademacs-3bef4fb92fd42b17724086b4dc9cee5a536a1afa.tar.gz
emacs-3bef4fb92fd42b17724086b4dc9cee5a536a1afa.zip
New enhanced version from <kgallagh@spd.dsccc.com>.
-rw-r--r--lisp/emulation/edt.el2290
1 files changed, 1914 insertions, 376 deletions
diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el
index 372cae13d90..9b37397e415 100644
--- a/lisp/emulation/edt.el
+++ b/lisp/emulation/edt.el
@@ -1,15 +1,12 @@
1;;; edt.el --- EDT emulation in Emacs 1;;; edt.el --- Enhanced EDT Keypad Mode Emulation for GNU Emacs 19
2 2
3;; Copyright (C) 1986, 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4 4
5;; Author: Mike Clarkson <mike@yetti.UUCP> 5;; Author: Kevin Gallagher <kgallagh@spd.dsccc.com>
6;; Maintainer: FSF 6;; Maintainer: Kevin Gallagher <kgallagh@spd.dsccc.com>
7;; Created: 27 Aug 1986 7;; Version: 3.0.2
8;; Keywords: emulations 8;; Keywords: emulations
9 9
10;; This started from public domain code by Mike Clarkson
11;; but has been greatly altered.
12
13;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
14 11
15;; GNU Emacs is free software; you can redistribute it and/or modify 12;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -26,461 +23,2002 @@
26;; along with GNU Emacs; see the file COPYING. If not, write to 23;; along with GNU Emacs; see the file COPYING. If not, write to
27;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 24;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 25
29;;; Commentary: 26;;; Usage:
30 27
31;; Here's my EDT emulation for GNU Emacs that is based on the EDT emulation 28;; See edt-user.doc
32;; for Gosling's Emacs sent out on the net a couple of years ago by Lynn Olson 29
33;; at Tektronics. This emulation was widely distributed as the file edt.ml 30;; ====================================================================
34;; in the maclib directory of most Emacs distributions. 31
35;; 32;;; Electric Help functions are used for keypad help displays. A few
36;; I will gladly take all criticisms and complaints to heart, and will fix what 33;;; picture functions are used in rectangular cut and paste commands.
37;; bugs I can find. As this is my first Emacs Lisp hack, you may have to root 34(require 'ehelp)
38;; out a few nasties hidden in the code. Please let me know if you find any 35(require 'picture)
39;; (sorry, no rewards :-). I would also be interested if there are better, 36
40;; cleaner, faster ways of doing some of the things that I have done. 37;;;;
41;; 38;;;; VARIABLES and CONSTANTS
42;; You must understand some design considerations that I had in mind. 39;;;;
43;; The intention was not really to "emulate" EDT, but rather to take advantage 40
44;; of the years of EDT experience that had accumulated in my right hand, 41(defconst edt-version "3.0.3" "EDT version number.")
45;; while at the same time taking advantage of EMACS.
46;;
47;; Some major differences are:
48;;
49;; HELP is describe-key;
50;; GOLD/HELP is describe-function;
51;; FIND is isearch-forward/backward;
52;; GOLD/HELP is occur-menu, which finds all instances of a search string;
53;; ENTER is other-window;
54;; SUBS is subprocess-command. Note that you have to change this
55;; to `shell' if you are running Un*x;
56;; PAGE is next-paragraph, because that's more useful than page.
57;; SPECINS is copy-to-killring;
58;; GOLD/GOLD is mark-section-wisely, which is my command to mark the
59;; section in a manner consistent with the major-mode. It
60;; uses mark-defun for emacs-lisp, lisp, mark-c-function for C,
61;; and mark-paragraph for other modes.
62;;
63;;
64;; Some subtle differences are:
65;;
66;; APPEND is append-to-buffer. One doesn't append to the kill ring
67;; much and SPECINS is now copy-to-killring;
68;; REPLACE is replace-regexp;
69;; FILL is fill-region-wisely, which uses indent-region for C, lisp
70;; emacs-lisp, and fill-region for others. It asks if you
71;; really want to fill-region in TeX-mode, because I find this
72;; to be very dangerous.
73;; CHNGCASE is case-flip for the character under the cursor only.
74;; I felt that case-flip region is unlikely, as usually you
75;; upcase-region or downcase region. Also, unlike EDT it
76;; is independent of the direction you are going, as that
77;; drives me nuts.
78;;
79;; I use Emacs definition of what a word is. This is considerably different
80;; from what EDT thinks a word is. This is not good for dyed-in-the-wool EDT
81;; fans, but is probably preferable for experienced Emacs users. My assumption
82;; is that the former are a dying breed now that GNU Emacs has made it to VMS,
83;; but let me know how you feel. Also, when you undelete a word it leave the
84;; point at the end of the undeleted text, rather than the beginning. I might
85;; change this as I'm not sure if I like this or not. I'm also not sure if I
86;; want it to set the mark each time you delete a character or word.
87;;
88;; Backspace does not invoke beginning-of-line, because ^H is the help prefix,
89;; and I felt it should be left as such. You can change this if you like.
90;;
91;; The ADVANCE and BACKUP keys do not work as terminators for forward or
92;; backward searches. In Emacs, all search strings are terminated by return.
93;; The searches will however go forward or backward depending on your current
94;; direction. Also, when you change directions, the mode line will not be
95;; updated immediately, but only when you next execute an emacs function.
96;; Personally, I consider this to be a bug, not a feature.
97;;
98;; This should also work with VT-2xx's, though I haven't tested it extensively
99;; on those terminals. It assumes that the CSI-map of vt_200.el has been
100;; defined.
101;;
102;; There are also a whole bunch of GOLD letter, and GOLD character bindings:
103;; look at edtdoc.el for them, or better still, look at the edt.el lisp code,
104;; because after all, in the true Lisp tradition, the source code is *assumed*
105;; to be self-documenting :-)
106;;
107;; Mike Clarkson, ...!allegra \ BITNET: mike@YUYETTI or
108;; CRESS, York University, ...!decvax \ SYMALG@YUSOL
109;; 4700 Keele Street, ...!ihnp4 > !utzoo!yetti!mike
110;; North York, Ontario, ...!linus /
111;; CANADA M3J 1P3. ...!watmath / Phone: +1 (416) 736-2100 x 7767
112;;
113;; Note that I am not on ARPA, and must gateway any ARPA mail through BITNET or
114;; UUCP. If you have a UUCP or BITNET address please use it for communication
115;; so that I can reach you directly. If you have both, the BITNET address
116;; is preferred.
117
118;;; Code:
119 42
120(defvar edt-last-deleted-lines "" 43(defvar edt-last-deleted-lines ""
121 "Last text deleted by an EDT emulation `line-delete' command.") 44 "Last text deleted by an EDT emulation line delete command.")
45
122(defvar edt-last-deleted-words "" 46(defvar edt-last-deleted-words ""
123 "Last text deleted by an EDT emulation `word-delete' command.") 47 "Last text deleted by an EDT emulation word delete command.")
48
124(defvar edt-last-deleted-chars "" 49(defvar edt-last-deleted-chars ""
125 "Last text deleted by an EDT emulation `character-delete' command.") 50 "Last text deleted by an EDT emulation character delete command.")
51
52(defvar edt-last-replaced-key-definition ""
53 "Key definition replaced with edt-define-key or edt-learn command.")
54
55(defvar edt-direction-string ""
56 "Current direction of movement.")
57
58(defvar edt-select-mode nil
59 "Select minor mode.")
60
61(defvar edt-select-mode-text ""
62 "Select mode active text.")
63
64(defconst edt-select-mode-string " Select"
65 "String used to indicated select mode is active.")
66
67(defconst edt-forward-string " ADVANCE"
68 "Direction string indicating forward movement.")
69
70(defconst edt-backward-string " BACKUP"
71 "Direction string indicating backward movement.")
72
73(defvar edt-default-map-active nil
74 "Indicates, when true, that default EDT emulation key bindings are active;
75user-defined custom bindings are active when set to nil.")
76
77(defvar edt-user-map-configured nil
78 "Indicates, when true, that user custom EDT emulation key bindings are
79configured and available for use.")
80
81(defvar edt-keep-current-page-delimiter nil
82 "If set to true, when edt-emulation-on is first invoked,
83modification of the page-delimiter varible to "\f" is suppressed,
84thereby retaining current Emacs setting.")
85
86(defvar edt-use-EDT-control-key-bindings nil
87 "If set to true, EDT control key bindings are defined.
88When true, many standard Emacs control key bindings are overwritten.
89If set to nil (the default), EDT control key bindings are not used.
90Instead, the standard Emacs control key bindings are retained.")
91
92(defvar edt-word-entities '(?\t)
93 "*Specifies the list of word entity characters.")
126 94
127(defun delete-current-line (num) 95;;;
128 "Delete one or specified number of lines after point. 96;;; Emacs version identifiers - currently referenced by
129This includes the newline character at the end of each line. 97;;;
130They are saved for the EDT `undelete-lines' command." 98;;; o edt-emulation-on o edt-load-xkeys
99;;;
100(defconst edt-emacs19-p (not (string-lessp emacs-version "19"))
101 "Non-NIL if we are running Lucid or GNU Emacs version 19.")
102
103(defconst edt-lucid-emacs19-p
104 (and edt-emacs19-p (string-match "Lucid" emacs-version))
105 "Non-NIL if we are running Lucid Emacs version 19.")
106
107(defconst edt-gnu-emacs19-p (and edt-emacs19-p (not edt-lucid-emacs19-p))
108 "Non-NIL if we are running GNU Emacs version 19.")
109
110(defvar edt-xkeys-file nil
111 "File mapping X function keys to LK-201 keyboard function and keypad keys.")
112
113;;;;
114;;;; EDT Emulation Commands
115;;;;
116
117;;; Almost all of EDT's keypad mode commands have equivalent
118;;; counterparts in Emacs. Some behave the same way in Emacs as they
119;;; do in EDT, but most do not.
120;;;
121;;; The following Emacs functions emulate, where practical, the exact
122;;; behavior of the corresponding EDT keypad mode commands. In a few
123;;; cases, the emulation is not exact, but it is close enough for most
124;;; EDT die-hards.
125;;;
126;;; In a very few cases, we chose to use the superior Emacs way of
127;;; handling things. For example, we do not emulate the EDT SUBS
128;;; command. Instead, we chose to use the superior Emacs
129;;; query-replace function.
130;;;
131
132;;;
133;;; PAGE
134;;;
135;;; Emacs uses the regexp assigned to page-delimiter to determine what
136;;; marks a page break. This is normally "^\f", which causes the
137;;; edt-page command to ignore form feeds not located at the beginning
138;;; of a line. To emulate the EDT PAGE command exactly,
139;;; page-delimiter is set to "\f" when EDT emulation is turned on, and
140;;; restored to its original value when EDT emulation is turned off.
141;;; But this can be overridden if the EDT definition is not desired by
142;;; placing
143;;;
144;;; (setq edt-keep-current-page-delimiter t)
145;;;
146;;; in your .emacs file.
147
148(defun edt-page-forward (num)
149 "Move forward to just after next page delimiter.
150Accepts a positive prefix argument for the number of page delimiters to move."
151 (interactive "p")
152 (edt-check-prefix num)
153 (if (eobp)
154 (error "End of buffer")
155 (progn
156 (forward-page num)
157 (if (eobp)
158 (edt-line-to-bottom-of-window)
159 (edt-line-to-top-of-window)))))
160
161(defun edt-page-backward (num)
162 "Move backward to just after previous page delimiter.
163Accepts a positive prefix argument for the number of page delimiters to move."
164 (interactive "p")
165 (edt-check-prefix num)
166 (if (bobp)
167 (error "Beginning of buffer")
168 (progn
169 (backward-page num)
170 (edt-line-to-top-of-window))))
171
172(defun edt-page (num)
173 "Move in current direction to next page delimiter.
174Accepts a positive prefix argument for the number of page delimiters to move."
131 (interactive "p") 175 (interactive "p")
176 (if (equal edt-direction-string edt-forward-string)
177 (edt-page-forward num)
178 (edt-page-backward num)))
179
180;;;
181;;; SECT
182;;;
183;;; EDT defaults a section size to be 16 lines of its one and only
184;;; 24-line window. That's two-thirds of the window at a time. The
185;;; EDT SECT commands moves the cursor, not the window.
186;;;
187;;; This emulation of EDT's SECT moves the cursor approximately two-thirds
188;;; of the current window at a time.
189
190(defun edt-sect-forward (num)
191 "Move cursor forward two-thirds of a window.
192Accepts a positive prefix argument for the number of sections to move."
193 (interactive "p")
194 (edt-check-prefix num)
195 (edt-line-forward (* (* (/ (- (window-height) 1) 3) 2) num)))
196
197(defun edt-sect-backward (num)
198 "Move cursor backward two-thirds of a window.
199Accepts a positive prefix argument for the number of sections to move."
200 (interactive "p")
201 (edt-check-prefix num)
202 (edt-line-backward (* (* (/ (- (window-height) 1) 3) 2) num)))
203
204(defun edt-sect (num)
205 "Move in current direction a full window.
206Accepts a positive prefix argument for the number windows to move."
207 (interactive "p")
208 (if (equal edt-direction-string edt-forward-string)
209 (edt-sect-forward num)
210 (edt-sect-backward num)))
211
212;;;
213;;; BEGINNING OF LINE
214;;;
215;;; EDT's beginning-of-line command is not affected by current
216;;; direction, for some unknown reason.
217
218(defun edt-beginning-of-line (num)
219 "Move backward to next beginning of line mark.
220Accepts a positive prefix argument for the number of BOL marks to move."
221 (interactive "p")
222 (edt-check-prefix num)
223 (if (bolp)
224 (forward-line (* -1 num))
225 (progn
226 (setq num (1- num))
227 (forward-line (* -1 num)))))
228
229;;;
230;;; EOL (End of Line)
231;;;
232
233(defun edt-end-of-line-forward (num)
234 "Move forward to next end of line mark.
235Accepts a positive prefix argument for the number of EOL marks to move."
236 (interactive "p")
237 (edt-check-prefix num)
238 (forward-char)
239 (end-of-line num))
240
241(defun edt-end-of-line-backward (num)
242 "Move backward to next end of line mark.
243Accepts a positive prefix argument for the number of EOL marks to move."
244 (interactive "p")
245 (edt-check-prefix num)
246 (end-of-line (1- num)))
247
248(defun edt-end-of-line (num)
249 "Move in current direction to next end of line mark.
250Accepts a positive prefix argument for the number of EOL marks to move."
251 (interactive "p")
252 (if (equal edt-direction-string edt-forward-string)
253 (edt-end-of-line-forward num)
254 (edt-end-of-line-backward num)))
255
256;;;
257;;; WORD
258;;;
259;;; This one is a tad messy. To emulate EDT's behavior everywhere in
260;;; the file (beginning of file, end of file, beginning of line, end
261;;; of line, etc.) it takes a bit of special handling.
262;;;
263;;; The variable edt-word-entities contains a list of characters which
264;;; are to be viewed as distinct words where ever they appear in the
265;;; buffer. This emulates the EDT line mode command SET ENTITY WORD.
266
267
268(defun edt-one-word-forward ()
269 "Move forward to first character of next word."
270 (interactive)
271 (if (eobp)
272 (error "End of buffer"))
273 (if (eolp)
274 (forward-char)
275 (progn
276 (if (memq (following-char) edt-word-entities)
277 (forward-char)
278 (while (and
279 (not (eolp))
280 (not (eobp))
281 (not (eq ?\ (char-syntax (following-char))))
282 (not (memq (following-char) edt-word-entities)))
283 (forward-char)))
284 (while (and
285 (not (eolp))
286 (not (eobp))
287 (eq ?\ (char-syntax (following-char)))
288 (not (memq (following-char) edt-word-entities)))
289 (forward-char)))))
290
291(defun edt-one-word-backward ()
292 "Move backward to first character of previous word."
293 (interactive)
294 (if (bobp)
295 (error "Beginning of buffer"))
296 (if (bolp)
297 (backward-char)
298 (progn
299 (backward-char)
300 (while (and
301 (not (bolp))
302 (not (bobp))
303 (eq ?\ (char-syntax (following-char)))
304 (not (memq (following-char) edt-word-entities)))
305 (backward-char))
306 (if (not (memq (following-char) edt-word-entities))
307 (while (and
308 (not (bolp))
309 (not (bobp))
310 (not (eq ?\ (char-syntax (preceding-char))))
311 (not (memq (preceding-char) edt-word-entities)))
312 (backward-char))))))
313
314(defun edt-word-forward (num)
315 "Move forward to first character of next word.
316Accepts a positive prefix argument for the number of words to move."
317 (interactive "p")
318 (edt-check-prefix num)
319 (while (> num 0)
320 (edt-one-word-forward)
321 (setq num (1- num))))
322
323(defun edt-word-backward (num)
324 "Move backward to first character of previous word.
325Accepts a positive prefix argument for the number of words to move."
326 (interactive "p")
327 (edt-check-prefix num)
328 (while (> num 0)
329 (edt-one-word-backward)
330 (setq num (1- num))))
331
332(defun edt-word (num)
333 "Move in current direction to first character of next word.
334Accepts a positive prefix argument for the number of words to move."
335 (interactive "p")
336 (if (equal edt-direction-string edt-forward-string)
337 (edt-word-forward num)
338 (edt-word-backward num)))
339
340;;;
341;;; CHAR
342;;;
343
344(defun edt-character (num)
345 "Move in current direction to next character.
346Accepts a positive prefix argument for the number of characters to move."
347 (interactive "p")
348 (edt-check-prefix num)
349 (if (equal edt-direction-string edt-forward-string)
350 (forward-char num)
351 (backward-char num)))
352
353;;;
354;;; LINE
355;;;
356;;; When direction is set to BACKUP, LINE behaves just like BEGINNING
357;;; OF LINE in EDT. So edt-line-backward is not really needed as a
358;;; separate function.
359
360(defun edt-line-backward (num)
361 "Move backward to next beginning of line mark.
362Accepts a positive prefix argument for the number of BOL marks to move."
363 (interactive "p")
364 (edt-beginning-of-line num))
365
366(defun edt-line-forward (num)
367 "Move forward to next beginning of line mark.
368Accepts a positive prefix argument for the number of BOL marks to move."
369 (interactive "p")
370 (edt-check-prefix num)
371 (forward-line num))
372
373(defun edt-line (num)
374 "Move in current direction to next beginning of line mark.
375Accepts a positive prefix argument for the number of BOL marks to move."
376 (interactive "p")
377 (if (equal edt-direction-string edt-forward-string)
378 (edt-line-forward num)
379 (edt-line-backward num)))
380
381;;;
382;;; TOP
383;;;
384
385(defun edt-top ()
386 "Move cursor to the beginning of buffer."
387 (interactive)
388 (goto-char (point-min)))
389
390;;;
391;;; BOTTOM
392;;;
393
394(defun edt-bottom ()
395 "Move cursor to the end of buffer."
396 (interactive)
397 (goto-char (point-max))
398 (edt-line-to-bottom-of-window))
399
400;;;
401;;; FIND
402;;;
403
404(defun edt-find-forward (&optional find)
405 "Find first occurance of a string in the forward direction and save the string."
406 (interactive)
407 (if (not find)
408 (set 'search-last-string (read-string "Search forward: ")))
409 (if (search-forward search-last-string)
410 (search-backward search-last-string)))
411
412(defun edt-find-backward (&optional find)
413 "Find first occurance of a string in the backward direction and save the string."
414 (interactive)
415 (if (not find)
416 (set 'search-last-string (read-string "Search backward: ")))
417 (search-backward search-last-string))
418
419(defun edt-find ()
420 "Find first occurance of string in current direction and save the string."
421 (interactive)
422 (set 'search-last-string (read-string "Search: "))
423 (if (equal edt-direction-string edt-forward-string)
424 (edt-find-forward t)
425 (edt-find-backward t)))
426
427
428;;;
429;;; FNDNXT
430;;;
431
432(defun edt-find-next-forward ()
433 "Find next occurance of a string in forward direction."
434 (interactive)
435 (forward-char 1)
436 (if (search-forward search-last-string nil t)
437 (search-backward search-last-string)
438 (progn
439 (backward-char 1)
440 (error "Search failed: \"%s\"." search-last-string))))
441
442(defun edt-find-next-backward ()
443 "Find next occurance of a string in backward direction."
444 (interactive)
445 (if (eq (search-backward search-last-string nil t) nil)
446 (progn
447 (error "Search failed: \"%s\"." search-last-string))))
448
449(defun edt-find-next ()
450 "Find next occurance of a string in current direction."
451 (interactive)
452 (if (equal edt-direction-string edt-forward-string)
453 (edt-find-next-forward)
454 (edt-find-next-backward)))
455
456;;;
457;;; APPEND
458;;;
459
460(defun edt-append ()
461 "Append this kill region to last killed region."
462 (interactive "*")
463 (edt-check-selection)
464 (append-next-kill)
465 (kill-region (mark) (point))
466 (message "Selected text APPENDED to kill ring"))
467
468;;;
469;;; DEL L
470;;;
471
472(defun edt-delete-line (num)
473 "Delete from cursor up to and including the end of line mark.
474Accepts a positive prefix argument for the number of lines to delete."
475 (interactive "*p")
476 (edt-check-prefix num)
132 (let ((beg (point))) 477 (let ((beg (point)))
133 (forward-line num) 478 (forward-line num)
134 (if (not (eq (preceding-char) ?\n)) 479 (if (not (eq (preceding-char) ?\n))
135 (insert "\n")) 480 (insert "\n"))
136 (setq edt-last-deleted-lines 481 (setq edt-last-deleted-lines
137 (buffer-substring beg (point))) 482 (buffer-substring beg (point)))
138 (delete-region beg (point)))) 483 (delete-region beg (point))))
139 484
140(defun delete-to-eol (num) 485;;;
141 "Delete text up to end of line. 486;;; DEL EOL
142With argument, delete up to to Nth line-end past point. 487;;;
143They are saved for the EDT `undelete-lines' command." 488
144 (interactive "p") 489(defun edt-delete-to-end-of-line (num)
490 "Delete from cursor up to but excluding the end of line mark.
491Accepts a positive prefix argument for the number of lines to delete."
492 (interactive "*p")
493 (edt-check-prefix num)
145 (let ((beg (point))) 494 (let ((beg (point)))
146 (forward-char 1) 495 (forward-char 1)
147 (end-of-line num) 496 (end-of-line num)
148 (setq edt-last-deleted-lines 497 (setq edt-last-deleted-lines
149 (buffer-substring beg (point))) 498 (buffer-substring beg (point)))
150 (delete-region beg (point)))) 499 (delete-region beg (point))))
151 500
152(defun delete-current-word (num) 501;;;
153 "Delete one or specified number of words after point. 502;;; SELECT
154They are saved for the EDT `undelete-words' command." 503;;;
155 (interactive "p") 504
505(defun edt-select-mode (arg)
506 "Turn EDT select mode off if arg is nil; otherwise, turn EDT select mode on.
507In select mode, selected text is highlighted."
508 (if arg
509 (progn
510 (make-local-variable 'edt-select-mode)
511 (setq edt-select-mode 'edt-select-mode-text)
512 (setq rect-start-point (window-point)))
513 (progn
514 (kill-local-variable 'edt-select-mode)))
515 (force-mode-line-update))
516
517(defun edt-select ()
518 "Set mark at cursor and start text selection."
519 (interactive)
520 (set-mark-command nil))
521
522(defun edt-reset ()
523 "Cancel text selection."
524 (interactive)
525 (deactivate-mark))
526
527;;;
528;;; CUT
529;;;
530
531(defun edt-cut ()
532 "Deletes selected text but copies to kill ring."
533 (interactive "*")
534 (edt-check-selection)
535 (kill-region (mark) (point))
536 (message "Selected text CUT to kill ring"))
537
538;;;
539;;; DELETE TO BEGINNING OF LINE
540;;;
541
542(defun edt-delete-to-beginning-of-line (num)
543 "Delete from cursor to beginning of of line.
544Accepts a positive prefix argument for the number of lines to delete."
545 (interactive "*p")
546 (edt-check-prefix num)
156 (let ((beg (point))) 547 (let ((beg (point)))
157 (forward-word num) 548 (edt-beginning-of-line num)
158 (setq edt-last-deleted-words 549 (setq edt-last-deleted-lines
159 (buffer-substring beg (point))) 550 (buffer-substring (point) beg))
160 (delete-region beg (point)))) 551 (delete-region beg (point))))
161 552
162(defun edt-delete-previous-word (num) 553;;;
163 "Delete one or specified number of words before point. 554;;; DEL W
164They are saved for the EDT `undelete-words' command." 555;;;
165 (interactive "p") 556
557(defun edt-delete-word (num)
558 "Delete from cursor up to but excluding first character of next word.
559Accepts a positive prefix argument for the number of words to delete."
560 (interactive "*p")
561 (edt-check-prefix num)
166 (let ((beg (point))) 562 (let ((beg (point)))
167 (forward-word (- num)) 563 (edt-word-forward num)
168 (setq edt-last-deleted-words 564 (setq edt-last-deleted-words (buffer-substring beg (point)))
169 (buffer-substring (point) beg))
170 (delete-region beg (point)))) 565 (delete-region beg (point))))
171 566
172(defun delete-current-char (num) 567;;;
173 "Delete one or specified number of characters after point. 568;;; DELETE TO BEGINNING OF WORD
174They are saved for the EDT `undelete-chars' command." 569;;;
175 (interactive "p") 570
571(defun edt-delete-to-beginning-of-word (num)
572 "Delete from cursor to beginning of word.
573Accepts a positive prefix argument for the number of words to delete."
574 (interactive "*p")
575 (edt-check-prefix num)
576 (let ((beg (point)))
577 (edt-word-backward num)
578 (setq edt-last-deleted-words (buffer-substring (point) beg))
579 (delete-region beg (point))))
580
581;;;
582;;; DEL C
583;;;
584
585(defun edt-delete-character (num)
586 "Delete character under cursor.
587Accepts a positive prefix argument for the number of characters to delete."
588 (interactive "*p")
589 (edt-check-prefix num)
176 (setq edt-last-deleted-chars 590 (setq edt-last-deleted-chars
177 (buffer-substring (point) (min (point-max) (+ (point) num)))) 591 (buffer-substring (point) (min (point-max) (+ (point) num))))
178 (delete-region (point) (min (point-max) (+ (point) num)))) 592 (delete-region (point) (min (point-max) (+ (point) num))))
179 593
180(defun delete-previous-char (num) 594;;;
181 "Delete one or specified number of characters before point. 595;;; DELETE CHAR
182They are saved for the EDT `undelete-chars' command." 596;;;
183 (interactive "p") 597
598(defun edt-delete-previous-character (num)
599 "Delete character in front of cursor.
600Accepts a positive prefix argument for the number of characters to delete."
601 (interactive "*p")
602 (edt-check-prefix num)
184 (setq edt-last-deleted-chars 603 (setq edt-last-deleted-chars
185 (buffer-substring (max (point-min) (- (point) num)) (point))) 604 (buffer-substring (max (point-min) (- (point) num)) (point)))
186 (delete-region (max (point-min) (- (point) num)) (point))) 605 (delete-region (max (point-min) (- (point) num)) (point)))
187 606
188(defun undelete-lines () 607;;;
189 "Yank lines deleted by last EDT `line-delete' command." 608;;; UND L
609;;;
610
611(defun edt-undelete-line ()
612 "Undelete previous deleted line(s)."
613 (interactive "*")
614 (point-to-register 1)
615 (insert edt-last-deleted-lines)
616 (register-to-point 1))
617
618;;;
619;;; UND W
620;;;
621
622(defun edt-undelete-word ()
623 "Yank words deleted by last EDT word-deletion command."
624 (interactive "*")
625 (point-to-register 1)
626 (insert edt-last-deleted-words)
627 (register-to-point 1))
628
629;;;
630;;; UND C
631;;;
632
633(defun edt-undelete-character ()
634 "Yank characters deleted by last EDT character-deletion command."
635 (interactive "*")
636 (point-to-register 1)
637 (insert edt-last-deleted-chars)
638 (register-to-point 1))
639
640;;;
641;;; REPLACE
642;;;
643
644(defun edt-replace ()
645 "Replace marked section with last CUT (killed) text."
646 (interactive "*")
647 (exchange-point-and-mark)
648 (let ((beg (point)))
649 (exchange-point-and-mark)
650 (delete-region beg (point)))
651 (yank))
652
653;;;
654;;; ADVANCE
655;;;
656
657(defun edt-advance ()
658 "Set movement direction forward."
190 (interactive) 659 (interactive)
191 (insert edt-last-deleted-lines)) 660 (setq edt-direction-string edt-forward-string)
661 (edt-update-mode-line)
662 (if (string-equal " *Minibuf"
663 (substring (buffer-name) 0 (min (length (buffer-name)) 9)))
664 (exit-minibuffer)))
665
666;;;
667;;; BACKUP
668;;;
192 669
193(defun undelete-words () 670(defun edt-backup ()
194 "Yank words deleted by last EDT `word-delete' command." 671 "Set movement direction backward."
195 (interactive) 672 (interactive)
196 (insert edt-last-deleted-words)) 673 (setq edt-direction-string edt-backward-string)
674 (edt-update-mode-line)
675 (if (string-equal " *Minibuf"
676 (substring (buffer-name) 0 (min (length (buffer-name)) 9)))
677 (exit-minibuffer)))
678
679;;;
680;;; CHNGCASE
681;;;
682;; This function is based upon Jeff Kowalski's case-flip function in his
683;; tpu.el.
684
685(defun edt-change-case (num)
686 "Change the case of specified characters.
687If text selection IS active, then characters between the cursor and mark are
688changed. If text selection is NOT active, there are two cases. First, if the
689current direction is ADVANCE, then the prefix number of character(s) under and
690following cursor are changed. Second, if the current direction is BACKUP, then
691the prefix number of character(s) before the cursor are changed. Accepts a
692positive prefix for the number of characters to change, but the prefix is
693ignored if text selection is active."
694 (interactive "*p")
695 (edt-check-prefix num)
696 (if edt-select-mode
697 (let ((end (max (mark) (point)))
698 (point-save (point)))
699 (goto-char (min (point) (mark)))
700 (while (not (eq (point) end))
701 (funcall (if (<= ?a (following-char))
702 'upcase-region 'downcase-region)
703 (point) (1+ (point)))
704 (forward-char 1))
705 (goto-char point-save))
706 (progn
707 (if (string= edt-direction-string edt-backward-string)
708 (backward-char num))
709 (while (> num 0)
710 (funcall (if (<= ?a (following-char))
711 'upcase-region 'downcase-region)
712 (point) (1+ (point)))
713 (forward-char 1)
714 (setq num (1- num))))))
197 715
198(defun undelete-chars () 716;;;
199 "Yank characters deleted by last EDT `character-delete' command." 717;;; DEFINE KEY
718;;;
719
720(defun edt-define-key ()
721 "Assign an interactively-callable function to a specified key sequence.
722The current key definition is saved in edt-last-replaced-key-definition.
723Use edt-restore-key to restore last replaced key definition."
200 (interactive) 724 (interactive)
201 (insert edt-last-deleted-chars)) 725 (let (edt-function
726 edt-key-definition-string)
727 (setq edt-key-definition-string
728 (read-key-sequence "Press the key to be defined: "))
729 (if (string-equal "\C-m" edt-key-definition-string)
730 (message "Key not defined")
731 (progn
732 (setq edt-function (read-command "Enter command name: "))
733 (if (string-equal "" edt-function)
734 (message "Key not defined")
735 (progn
736 (setq edt-last-replaced-key-definition
737 (lookup-key (current-global-map) edt-key-definition-string))
738 (define-key (current-global-map)
739 edt-key-definition-string edt-function)))))))
202 740
203(defun next-end-of-line (num) 741;;;
204 "Move to end of line; if at end, move to end of next line. 742;;; FORM FEED INSERT
205Accepts a prefix argument for the number of lines to move." 743;;;
206 (interactive "p")
207 (forward-char)
208 (end-of-line num))
209 744
210(defun previous-end-of-line (num) 745(defun edt-form-feed-insert (num)
211 "Move EOL upward. 746 "Insert form feed character at cursor position.
212Accepts a prefix argument for the number of lines to move." 747Accepts a positive prefix argument for the number of form feeds to insert."
213 (interactive "p") 748 (interactive "*p")
214 (end-of-line (- 1 num))) 749 (edt-check-prefix num)
750 (while (> num 0)
751 (insert ?\f)
752 (setq num (1- num))))
215 753
216(defun forward-to-word (num) 754;;;
217 "Move to next word-beginning, or to Nth following word-beginning." 755;;; TAB INSERT
218 (interactive "p") 756;;;
219 (forward-word (1+ num))
220 (forward-word -1))
221 757
222(defun backward-to-word (num) 758(defun edt-tab-insert (num)
223 "Move back to word-end, or to Nth word-end seen." 759 "Insert tab character at cursor position.
224 (interactive "p") 760Accepts a positive prefix argument for the number of tabs to insert."
225 (forward-word (- (1+ num))) 761 (interactive "*p")
226 (forward-word 1)) 762 (edt-check-prefix num)
763 (while (> num 0)
764 (insert ?\t)
765 (setq num (1- num))))
766
767;;;
768;;; Check Prefix
769;;;
770
771(defun edt-check-prefix (num)
772 "Indicate error if prefix is not positive."
773 (if (<= num 0)
774 (error "Prefix must be positive")))
775
776;;;
777;;; Check Selection
778;;;
779
780(defun edt-check-selection ()
781 "Indicate error if EDT selection is not active."
782 (if (not edt-select-mode)
783 (error "Selection NOT active")))
784
785;;;;
786;;;; ENHANCEMENTS AND ADDITIONS FOR EDT KEYPAD MODE
787;;;;
788
789;;;
790;;; Several enhancements and additions to EDT keypad mode commands are
791;;; provided here. Some of these have been motivated by similar
792;;; TPU/EVE and EVE-Plus commands. Others are new.
793
794(defun edt-version nil
795 "Print the EDT version number."
796 (interactive)
797 (message
798 "EDT version %s by Kevin Gallagher (kgallagh@spd.dsccc.com)"
799 edt-version))
800
801;;;
802;;; CHANGE DIRECTION
803;;;
227 804
228(defun backward-line (num) 805(defun edt-change-direction ()
229 "Move point to start of previous line. 806 "Toggle movement direction."
230Prefix argument serves as repeat-count." 807 (interactive)
808 (if (equal edt-direction-string edt-forward-string)
809 (edt-backup)
810 (edt-advance)))
811
812;;;
813;;; TOGGLE SELECT
814;;;
815
816(defun edt-toggle-select ()
817 "Toggle to start (or cancel) text selection."
818 (interactive)
819 (if edt-select-mode
820 (edt-reset)
821 (edt-select)))
822
823;;;
824;;; SENTENCE
825;;;
826
827(defun edt-sentence-forward (num)
828 "Move forward to start of next sentence.
829Accepts a positive prefix argument for the number of sentences to move."
231 (interactive "p") 830 (interactive "p")
232 (forward-line (- num))) 831 (edt-check-prefix num)
832 (if (eobp)
833 (progn
834 (error "End of buffer"))
835 (progn
836 (forward-sentence num)
837 (edt-one-word-forward))))
233 838
234(defun scroll-window-down (num) 839(defun edt-sentence-backward (num)
235 "Scroll the display down a window-full. 840 "Move backward to next sentence beginning.
236Accepts a prefix argument for the number of window-fulls to scroll." 841Accepts a positive prefix argument for the number of sentences to move."
237 (interactive "p") 842 (interactive "p")
238 (scroll-down (- (* (window-height) num) 2))) 843 (edt-check-prefix num)
844 (if (eobp)
845 (progn
846 (error "End of buffer"))
847 (backward-sentence num)))
239 848
240(defun scroll-window-up (num) 849(defun edt-sentence (num)
241 "Scroll the display up a window-full. 850 "Move in current direction to next sentence.
242Accepts a prefix argument for the number of window-fulls to scroll." 851Accepts a positive prefix argument for the number of sentences to move."
243 (interactive "p") 852 (interactive "p")
244 (scroll-up (- (* (window-height) num) 2))) 853 (if (equal edt-direction-string edt-forward-string)
854 (edt-sentence-forward num)
855 (edt-sentence-backward num)))
856
857;;;
858;;; PARAGRAPH
859;;;
245 860
246(defun next-paragraph (num) 861(defun edt-paragraph-forward (num)
247 "Move to beginning of the next indented paragraph. 862 "Move forward to beginning of paragraph.
248Accepts a prefix argument for the number of paragraphs." 863Accepts a positive prefix argument for the number of paragraphs to move."
249 (interactive "p") 864 (interactive "p")
865 (edt-check-prefix num)
250 (while (> num 0) 866 (while (> num 0)
251 (next-line 1) 867 (next-line 1)
252 (forward-paragraph) 868 (forward-paragraph)
253 (previous-line 1) 869 (previous-line 1)
254 (if (eolp) (next-line 1)) 870 (if (eolp)
871 (next-line 1))
255 (setq num (1- num)))) 872 (setq num (1- num))))
256 873
257(defun previous-paragraph (num) 874(defun edt-paragraph-backward (num)
258 "Move to beginning of previous indented paragraph. 875 "Move backward to beginning of paragraph.
259Accepts a prefix argument for the number of paragraphs." 876Accepts a positive prefix argument for the number of paragraphs to move."
260 (interactive "p") 877 (interactive "p")
878 (edt-check-prefix num)
261 (while (> num 0) 879 (while (> num 0)
262 (backward-paragraph) 880 (backward-paragraph)
263 (previous-line 1) 881 (previous-line 1)
264 (if (eolp) (next-line 1)) 882 (if (eolp) (next-line 1))
265 (setq num (1- num)))) 883 (setq num (1- num))))
266 884
267(defun move-to-beginning () 885(defun edt-paragraph (num)
268 "Move cursor to the beginning of buffer, but don't set the mark." 886 "Move in current direction to next paragraph.
887Accepts a positive prefix argument for the number of paragraph to move."
888 (interactive "p")
889 (if (equal edt-direction-string edt-forward-string)
890 (edt-paragraph-forward num)
891 (edt-paragraph-backward num)))
892
893;;;
894;;; RESTORE KEY
895;;;
896
897(defun edt-restore-key ()
898 "Restore last replaced key definition, which is stored in
899edt-last-replaced-key-definition."
269 (interactive) 900 (interactive)
270 (goto-char (point-min))) 901 (if edt-last-replaced-key-definition
902 (progn
903 (let (edt-key-definition-string)
904 (set 'edt-key-definition-string
905 (read-key-sequence "Press the key to be restored: "))
906 (if (string-equal "\C-m" edt-key-definition-string)
907 (message "Key not restored")
908 (define-key (current-global-map)
909 edt-key-definition-string edt-last-replaced-key-definition))))
910 (error "No replaced key definition to restore!")))
911
912;;;
913;;; WINDOW TOP
914;;;
271 915
272(defun move-to-end () 916(defun edt-window-top ()
273 "Move cursor to the end of buffer, but don't set the mark." 917 "Move the cursor to the top of the window."
274 (interactive) 918 (interactive)
275 (goto-char (point-max))) 919 (let ((start-column (current-column)))
920 (move-to-window-line 0)
921 (move-to-column start-column)))
276 922
277(defun goto-percent (perc) 923;;;
278 "Move point to ARG percentage of the buffer." 924;;; WINDOW BOTTOM
279 (interactive "NGoto-percentage: ") 925;;;
280 (if (or (> perc 100) (< perc 0))
281 (error "Percentage %d out of range 0 < percent < 100" perc)
282 (goto-char (/ (* (point-max) perc) 100))))
283 926
284(defun update-mode-line () 927(defun edt-window-bottom ()
285 "Ensure mode-line reflects all changes." 928 "Move the cursor to the bottom of the window."
286 (set-buffer-modified-p (buffer-modified-p)) 929 (interactive)
287 (sit-for 0)) 930 (let ((start-column (current-column)))
931 (move-to-window-line (- (window-height) 2))
932 (move-to-column start-column)))
933
934;;;
935;;; SCROLL WINDOW LINE
936;;;
937
938(defun edt-scroll-window-forward-line ()
939 "Move window forward one line leaving cursor at relative position in window."
940 (interactive)
941 (scroll-up 1))
942
943(defun edt-scroll-window-backward-line ()
944 "Move window backward one line leaving cursor at relative position in window."
945 (interactive)
946 (scroll-down 1))
947
948(defun edt-scroll-line ()
949 "Move window one line in current direction."
950 (interactive)
951 (if (equal edt-direction-string edt-forward-string)
952 (edt-scroll-window-forward-line)
953 (edt-scroll-window-backward-line)))
288 954
289(defun advance-direction () 955;;;
290 "Set EDT Advance mode so keypad commands move forward." 956;;; SCROLL WINDOW
291 (interactive) 957;;;
292 (setq edt-direction-string " ADVANCE") 958;;; Scroll a window (less one line) at a time. Leave cursor in center of
293 (global-set-key [kp-f3] 'isearch-forward) 959;;; window.
294 (global-set-key [kp-8] 'scroll-window-up) 960
295 (global-set-key [kp-7] 'next-paragraph) 961(defun edt-scroll-window-forward (num)
296 (global-set-key [kp-1] 'forward-to-word) 962 "Scroll forward one window in buffer, less one line.
297 (global-set-key [kp-2] 'next-end-of-line) 963Accepts a positive prefix argument for the number of windows to move."
298 (global-set-key [kp-3] 'forward-char) 964 (interactive "p")
299 (global-set-key [kp-0] 'forward-line) 965 (edt-check-prefix num)
300 (update-mode-line)) 966 (scroll-up (- (* (window-height) num) 2))
301 967 (edt-line-forward (/ (- (window-height) 1) 2)))
302(defun backup-direction () 968
303 "Set EDT Backup mode so keypad commands move backward." 969(defun edt-scroll-window-backward (num)
304 (interactive) 970 "Scroll backward one window in buffer, less one line.
305 (setq edt-direction-string " BACKUP") 971Accepts a positive prefix argument for the number of windows to move."
306 (global-set-key [kp-f3] 'isearch-backward) 972 (interactive "p")
307 (global-set-key [kp-8] 'scroll-window-down) 973 (edt-check-prefix num)
308 (global-set-key [kp-7] 'previous-paragraph) 974 (scroll-down (- (* (window-height) num) 2))
309 (global-set-key [kp-1] 'backward-to-word) 975 (edt-line-backward (/ (- (window-height) 1) 2)))
310 (global-set-key [kp-2] 'previous-end-of-line) 976
311 (global-set-key [kp-3] 'backward-char) 977(defun edt-scroll-window (num)
312 (global-set-key [kp-9] 'backward-line) 978 "Scroll one window in buffer, less one line, in current direction.
313 (update-mode-line)) 979Accepts a positive prefix argument for the number windows to move."
314 980 (interactive "p")
315(defun edt-beginning-of-window () 981 (if (equal edt-direction-string edt-forward-string)
316 "Home cursor to top of window." 982 (edt-scroll-window-forward num)
317 (interactive) 983 (edt-scroll-window-backward num)))
318 (move-to-window-line 0)) 984
985;;;
986;;; LINE TO BOTTOM OF WINDOW
987;;;
319 988
320(defun edt-line-to-bottom-of-window () 989(defun edt-line-to-bottom-of-window ()
321 "Move the current line to the top of the window." 990 "Move the current line to the bottom of the window."
322 (interactive) 991 (interactive)
323 (recenter -1)) 992 (recenter -1))
324 993
994;;;
995;;; LINE TO TOP OF WINDOW
996;;;
997
325(defun edt-line-to-top-of-window () 998(defun edt-line-to-top-of-window ()
326 "Move the current line to the top of the window." 999 "Move the current line to the top of the window."
327 (interactive) 1000 (interactive)
328 (recenter 0)) 1001 (recenter 0))
329 1002
330(defun case-flip-character (num) 1003;;;
331 "Change the case of the character under the cursor. 1004;;; LINE TO MIDDLE OF WINDOW
332Accepts a prefix argument of the number of characters to invert." 1005;;;
333 (interactive "p")
334 (while (> num 0)
335 (funcall (if (let ((ch (following-char)))
336 (= ch (downcase ch)))
337 'upcase-region 'downcase-region)
338 (point) (1+ (point)))
339 (forward-char 1)
340 (setq num (1- num))))
341 1006
342(defun indent-or-fill-region () 1007(defun edt-line-to-middle-of-window ()
343 "Fill region in text modes, indent region in programming language modes." 1008 "Move window so line with cursor is in the middle of the window."
344 (interactive) 1009 (interactive)
1010 (recenter '(4)))
1011
1012;;;
1013;;; GOTO PERCENTAGE
1014;;;
1015
1016(defun edt-goto-percentage (num)
1017 "Move to specified percentage in buffer from top of buffer."
1018 (interactive "NGoto-percentage: ")
1019 (if (or (> num 100) (< num 0))
1020 (error "Percentage %d out of range 0 < percent < 100" num)
1021 (goto-char (/ (* (point-max) num) 100))))
1022
1023;;;
1024;;; FILL REGION
1025;;;
1026
1027(defun edt-fill-region ()
1028 "Fill selected text."
1029 (interactive "*")
1030 (edt-check-selection)
1031 (fill-region (point) (mark)))
1032
1033;;;
1034;;; INDENT OR FILL REGION
1035;;;
1036
1037(defun edt-indent-or-fill-region ()
1038 "Fill region in text modes, indent region in programming language modes."
1039 (interactive "*")
345 (if (string= paragraph-start "^$\\|^\f") 1040 (if (string= paragraph-start "^$\\|^\f")
346 (indent-region (point) (mark) nil) 1041 (indent-region (point) (mark) nil)
347 (fill-region (point) (mark)))) 1042 (fill-region (point) (mark))))
348 1043
349(defun mark-section-wisely () 1044;;;
1045;;; MARK SECTION WISELY
1046;;;
1047
1048(defun edt-mark-section-wisely ()
350 "Mark the section in a manner consistent with the major-mode. 1049 "Mark the section in a manner consistent with the major-mode.
351Uses mark-defun for emacs-lisp, lisp, 1050Uses mark-defun for emacs-lisp and lisp,
352mark-c-function for C, 1051mark-c-function for C,
1052mark-fortran-subsystem for fortran,
353and mark-paragraph for other modes." 1053and mark-paragraph for other modes."
354 (interactive) 1054 (interactive)
355 (cond ((eq major-mode 'emacs-lisp-mode) 1055 (if edt-select-mode
356 (mark-defun)) 1056 (progn
357 ((eq major-mode 'lisp-mode) 1057 (edt-reset))
358 (mark-defun)) 1058 (progn
359 ((eq major-mode 'c-mode) 1059 (cond ((or (eq major-mode 'emacs-lisp-mode)
360 (mark-c-function)) 1060 (eq major-mode 'lisp-mode))
361 (t (mark-paragraph)))) 1061 (mark-defun)
1062 (message "Lisp defun selected"))
1063 ((eq major-mode 'c-mode)
1064 (mark-c-function)
1065 (message "C function selected"))
1066 ((eq major-mode 'fortran-mode)
1067 (mark-fortran-subprogram)
1068 (message "Fortran subprogram selected"))
1069 (t (mark-paragraph)
1070 (message "Paragraph selected"))))))
1071
1072;;;
1073;;; COPY
1074;;;
1075
1076(defun edt-copy ()
1077 "Copy selected region to kill ring, but don't delete it!"
1078 (interactive)
1079 (edt-check-selection)
1080 (copy-region-as-kill (mark) (point))
1081 (edt-reset)
1082 (message "Selected text COPIED to kill ring"))
1083
1084;;;
1085;;; CUT or COPY
1086;;;
1087
1088(defun edt-cut-or-copy ()
1089 "Cuts (or copies) selected text to kill ring.
1090Cuts selected text if buffer-read-only is nil.
1091Copies selected text if buffer-read-only is t."
1092 (interactive)
1093 (if buffer-read-only
1094 (edt-copy)
1095 (edt-cut)))
1096
1097;;;
1098;;; DELETE ENTIRE LINE
1099;;;
1100
1101(defun edt-delete-entire-line ()
1102 "Delete entire line regardless of cursor position in the line."
1103 (interactive "*")
1104 (beginning-of-line)
1105 (edt-delete-line 1))
1106
1107;;;
1108;;; DUPLICATE LINE
1109;;;
1110
1111(defun edt-duplicate-line (num)
1112 "Duplicate a line of text.
1113Accepts a positive prefix argument for the number times to duplicate the line."
1114 (interactive "*p")
1115 (edt-check-prefix num)
1116 (let ((old-column (current-column))
1117 (count num))
1118 (edt-delete-entire-line)
1119 (edt-undelete-line)
1120 (while (> count 0)
1121 (edt-undelete-line)
1122 (setq count (1- count)))
1123 (edt-line-forward num)
1124 (move-to-column old-column)))
1125
1126;;;
1127;;; DUPLICATE WORD
1128;;;
1129
1130(defun edt-duplicate-word()
1131 "Duplicate word (or rest of word) found directly above cursor, if any."
1132 (interactive "*")
1133 (let ((start (point))
1134 (start-column (current-column)))
1135 (forward-line -1)
1136 (move-to-column start-column)
1137 (if (and (not (equal start (point)))
1138 (not (eolp)))
1139 (progn
1140 (if (and (equal ?\t (preceding-char))
1141 (< start-column (current-column)))
1142 (backward-char))
1143 (let ((beg (point)))
1144 (edt-one-word-forward)
1145 (setq edt-last-copied-word (buffer-substring beg (point))))
1146 (forward-line)
1147 (move-to-column start-column)
1148 (insert edt-last-copied-word))
1149 (progn
1150 (if (not (equal start (point)))
1151 (forward-line))
1152 (move-to-column start-column)
1153 (error "Nothing to duplicate!")))))
1154
1155;;;
1156;;; KEY NOT ASSIGNED
1157;;;
1158
1159(defun edt-key-not-assigned ()
1160 "Displays message that key has not been assigned to a function."
1161 (interactive)
1162 (error "Key not assigned"))
1163
1164;;;
1165;;; TOGGLE CAPITALIZATION OF WORD
1166;;;
1167
1168(defun edt-toggle-capitalization-of-word ()
1169 "Toggle the capitalization of the current word and move forward to next."
1170 (interactive "*")
1171 (edt-one-word-forward)
1172 (edt-one-word-backward)
1173 (edt-change-case 1)
1174 (edt-one-word-backward)
1175 (edt-one-word-forward))
1176
1177;;;
1178;;; ELIMINATE ALL TABS
1179;;;
1180
1181(defun edt-eliminate-all-tabs ()
1182 "Convert all tabs to spaces in the entire buffer."
1183 (interactive "*")
1184 (untabify (point-min) (point-max))
1185 (message "TABS converted to SPACES"))
1186
1187;;;
1188;;; DISPLAY THE TIME
1189;;;
1190
1191(defun edt-display-the-time ()
1192 "Display the current time."
1193 (interactive)
1194 (set 'time-string (current-time-string))
1195 (message time-string))
1196
1197;;;
1198;;; LEARN
1199;;;
1200
1201(defun edt-learn ()
1202 "Learn a sequence of key strokes to bind to a key."
1203 (interactive)
1204 (if (eq defining-kbd-macro t)
1205 (edt-remember)
1206 (start-kbd-macro nil)))
1207
1208;;;
1209;;; REMEMBER
1210;;;
1211
1212(defun edt-remember ()
1213 "Store the sequence of key strokes started by edt-learn to a key."
1214 (interactive)
1215 (if (eq defining-kbd-macro nil)
1216 (error "Nothing to remember!")
1217 (progn
1218 (end-kbd-macro nil)
1219 (let (edt-key-definition-string)
1220 (set 'edt-key-definition-string
1221 (read-key-sequence "Enter key for binding: "))
1222 (if (string-equal "\C-m" edt-key-definition-string)
1223 (message "Key sequence not remembered")
1224 (progn
1225 (set 'edt-learn-macro-count (+ edt-learn-macro-count 1))
1226 (setq edt-last-replaced-key-definition
1227 (lookup-key (current-global-map)
1228 edt-key-definition-string))
1229 (define-key (current-global-map) edt-key-definition-string
1230 (name-last-kbd-macro
1231 (intern (concat "last-learned-sequence-"
1232 (int-to-string edt-learn-macro-count)))))))))))
1233
1234;;;
1235;;; EXIT
1236;;;
1237
1238(defun edt-exit ()
1239 "Save current buffer, ask to save other buffers, and then exit Emacs."
1240 (interactive)
1241 (save-buffer)
1242 (save-buffers-kill-emacs))
1243
1244;;;
1245;;; QUIT
1246;;;
1247
1248(defun edt-quit ()
1249 "Quit Emacs without saving changes."
1250 (interactive)
1251 (kill-emacs))
1252
1253;;;
1254;;; SPLIT WINDOW
1255;;;
1256
1257(defun edt-split-window ()
1258 "Split current window and place cursor in the new window."
1259 (interactive)
1260 (split-window)
1261 (other-window 1))
1262
1263;;;
1264;;; UPDATE MODE LINE
1265;;;
1266
1267(defun edt-update-mode-line ()
1268 "Make sure mode-line in the current buffer reflects all changes."
1269 (set-buffer-modified-p (buffer-modified-p))
1270 (sit-for 0))
1271
1272;;;
1273;;; COPY RECTANGLE
1274;;;
1275
1276(defun edt-copy-rectangle ()
1277 "Copy a rectangle of text between mark and cursor to register."
1278 (interactive)
1279 (edt-check-selection)
1280 (copy-rectangle-to-register 3 (region-beginning) (region-end) nil)
1281 (edt-reset)
1282 (message "Selected rectangle COPIED to register"))
1283
1284;;;
1285;;; CUT RECTANGLE
1286;;;
1287
1288(defun edt-cut-rectangle-overstrike-mode ()
1289 "Cut a rectangle of text between mark and cursor to register, replacing
1290characters with spaces and moving cursor back to upper left corner."
1291 (interactive "*")
1292 (edt-check-selection)
1293 (setq edt-rect-start-point (region-beginning))
1294 (picture-clear-rectangle-to-register (region-beginning) (region-end) 3)
1295 (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point)
1296 (message "Selected rectangle CUT to register"))
1297
1298(defun edt-cut-rectangle-insert-mode ()
1299 "Cut a rectangle of text between mark and cursor to register, deleting
1300intermediate text and moving cursor back to upper left corner."
1301 (interactive "*")
1302 (edt-check-selection)
1303 (setq edt-rect-start-point (region-beginning))
1304 (picture-clear-rectangle-to-register (region-beginning) (region-end) 3 t)
1305 (fixup-whitespace)
1306 (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point)
1307 (message "Selected rectangle CUT to register"))
1308
1309(defun edt-cut-rectangle ()
1310 "Cut a rectangular region of text to register.
1311If overwrite mode is active, cut text is replace with whitespace."
1312 (interactive "*")
1313 (if overwrite-mode
1314 (edt-cut-rectangle-overstrike-mode)
1315 (edt-cut-rectangle-insert-mode)))
1316
1317;;;
1318;;; PASTE RECTANGLE
1319;;;
1320
1321(defun edt-paste-rectangle-overstrike-mode ()
1322 "Paste a rectangular region of text from register, replacing text at cursor."
1323 (interactive "*")
1324 (picture-yank-rectangle-from-register 3))
1325
1326(defun edt-paste-rectangle-insert-mode ()
1327 "Paste previously deleted rectangular region, inserting text at cursor."
1328 (interactive "*")
1329 (picture-yank-rectangle-from-register 3 t))
1330
1331(defun edt-paste-rectangle ()
1332 "Paste a rectangular region of text.
1333If overwrite mode is active, existing text is replace with text from register."
1334 (interactive)
1335 (if overwrite-mode
1336 (edt-paste-rectangle-overstrike-mode)
1337 (edt-paste-rectangle-insert-mode)))
1338
1339;;;
1340;;; DOWNCASE REGION
1341;;;
1342
1343(defun edt-lowercase ()
1344 "Change specified characters to lower case.
1345If text selection IS active, then characters between the cursor and
1346mark are changed. If text selection is NOT active, there are two
1347situations. If the current direction is ADVANCE, then the word under
1348the cursor is changed to lower case and the cursor is moved to rest at
1349the beginning of the next word. If the current direction is BACKUP,
1350the word prior to the word under the cursor is changed to lower case
1351and the cursor is left to rest at the beginning of that word."
1352 (interactive "*")
1353 (if edt-select-mode
1354 (progn
1355 (downcase-region (mark) (point)))
1356 (progn
1357 ;; Move to beginning of current word.
1358 (if (and
1359 (not (bobp))
1360 (not (eobp))
1361 (not (bolp))
1362 (not (eolp))
1363 (not (eq ?\ (char-syntax (preceding-char))))
1364 (not (memq (preceding-char) edt-word-entities))
1365 (not (memq (following-char) edt-word-entities)))
1366 (edt-one-word-backward))
1367 (if (equal edt-direction-string edt-backward-string)
1368 (edt-one-word-backward))
1369 (let ((beg (point)))
1370 (edt-one-word-forward)
1371 (downcase-region beg (point)))
1372 (if (equal edt-direction-string edt-backward-string)
1373 (edt-one-word-backward)))))
1374
1375;;;
1376;;; UPCASE REGION
1377;;;
1378
1379(defun edt-uppercase ()
1380 "Change specified characters to upper case.
1381If text selection IS active, then characters between the cursor and
1382mark are changed. If text selection is NOT active, there are two
1383situations. If the current direction is ADVANCE, then the word under
1384the cursor is changed to upper case and the cursor is moved to rest at
1385the beginning of the next word. If the current direction is BACKUP,
1386the word prior to the word under the cursor is changed to upper case
1387and the cursor is left to rest at the beginning of that word."
1388 (interactive "*")
1389 (if edt-select-mode
1390 (progn
1391 (upcase-region (mark) (point)))
1392 (progn
1393 ;; Move to beginning of current word.
1394 (if (and
1395 (not (bobp))
1396 (not (eobp))
1397 (not (bolp))
1398 (not (eolp))
1399 (not (eq ?\ (char-syntax (preceding-char))))
1400 (not (memq (preceding-char) edt-word-entities))
1401 (not (memq (following-char) edt-word-entities)))
1402 (edt-one-word-backward))
1403 (if (equal edt-direction-string edt-backward-string)
1404 (edt-one-word-backward))
1405 (let ((beg (point)))
1406 (edt-one-word-forward)
1407 (upcase-region beg (point)))
1408 (if (equal edt-direction-string edt-backward-string)
1409 (edt-one-word-backward)))))
1410
1411
1412;;;
1413;;; INITIALIZATION COMMANDS.
1414;;;
1415
1416;;;
1417;;; Emacs version 19 X-windows key definition support
1418;;;
1419(defvar edt-last-answer nil "Most recent response to edt-y-or-n-p.")
1420
1421(defun edt-y-or-n-p (prompt &optional not-yes)
1422 "Prompt for a y or n answer with positive default.
1423Optional second argument NOT-YES changes default to negative.
1424Like emacs y-or-n-p, also accepts space as y and DEL as n."
1425 (message (format "%s[%s]" prompt (if not-yes "n" "y")))
1426 (let ((doit t))
1427 (while doit
1428 (setq doit nil)
1429 (let ((ans (read-char)))
1430 (cond ((or (= ans ?y) (= ans ?Y) (= ans ?\ ))
1431 (setq edt-last-answer t))
1432 ((or (= ans ?n) (= ans ?N) (= ans ?\C-?))
1433 (setq edt-last-answer nil))
1434 ((= ans ?\r) (setq edt-last-answer (not not-yes)))
1435 (t
1436 (setq doit t) (beep)
1437 (message (format "Please answer y or n. %s[%s]"
1438 prompt (if not-yes "n" "y"))))))))
1439 edt-last-answer)
1440
1441(defun edt-load-xkeys (file)
1442 "Load the EDT X-windows key definitions FILE.
1443If FILE is nil, try to load a default file. The default file names are
1444~/.edt-lucid-keys for Lucid emacs, and ~/.edt-gnu-keys for GNU emacs."
1445 (interactive "fX key definition file: ")
1446 (cond (file
1447 (setq file (expand-file-name file)))
1448 (edt-xkeys-file
1449 (setq file (expand-file-name edt-xkeys-file)))
1450 (edt-gnu-emacs19-p
1451 (setq file (expand-file-name "~/.edt-gnu-keys")))
1452 (edt-lucid-emacs19-p
1453 (setq file (expand-file-name "~/.edt-lucid-keys"))))
1454 (cond ((file-readable-p file)
1455 (load-file file))
1456 (t
1457 (switch-to-buffer "*scratch*")
1458 (erase-buffer)
1459 (insert "
1460
1461 Ack!! You're running the Enhanced EDT Emulation under X-windows
1462 without loading an EDT X key definition file. To create an EDT X
1463 key definition file, run the edt-mapper.el program. But ONLY run
1464 it from an Emacs loaded without any of your own customizations
1465 found in your .emacs file, etc. Some user customization confuse
1466 the edt-mapper function. To do this, you need to invoke Emacs
1467 as follows:
1468
1469 emacs -q -l edt-mapper.el
1470
1471 The file edt-mapper.el includes these same directions on how to
1472 use it! Perhaps it's laying around here someplace. \n ")
1473 (let ((file "edt-mapper.el")
1474 (found nil)
1475 (path nil)
1476 (search-list (append (list (expand-file-name ".")) load-path)))
1477 (while (and (not found) search-list)
1478 (setq path (concat (car search-list)
1479 (if (string-match "/$" (car search-list)) "" "/")
1480 file))
1481 (if (and (file-exists-p path) (not (file-directory-p path)))
1482 (setq found t))
1483 (setq search-list (cdr search-list)))
1484 (cond (found
1485 (insert (format
1486 "Ah yes, there it is, in \n\n %s \n\n" path))
1487 (if (edt-y-or-n-p "Do you want to run it now? ")
1488 (load-file path)
1489 (error "EDT Emulation not configured.")))
1490 (t
1491 (insert "Nope, I can't seem to find it. :-(\n\n")
1492 (sit-for 20)
1493 (error "EDT Emulation not configured.")))))))
362 1494
363;;; Key Bindings
364;;;###autoload 1495;;;###autoload
365(defun edt-emulation-on () 1496(defun edt-emulation-on ()
366 "Emulate DEC's EDT editor. 1497 "Turn on EDT Emulation."
367Note that many keys are rebound; including nearly all keypad keys. 1498 (interactive)
368Use \\[edt-emulation-off] to undo all rebindings except the keypad keys." 1499 ;; If using MS-DOS, need to load edt-pc.el
369 (interactive) 1500 (if (string-equal system-type "ms-dos")
370 (advance-direction) 1501 (setq edt-term "pc")
371 (edt-bind-gold-keypad) 1502 (setq edt-term (getenv "TERM")))
372 (setq edt-mode-old-c-\\ (lookup-key global-map "\C-\\")) 1503 ;; All DEC VT series terminals are supported by loading edt-vt100.el
373 (global-set-key "\C-\\" 'quoted-insert) 1504 (if (string-equal "vt" (substring edt-term 0 (min (length edt-term) 2)))
374 (setq edt-mode-old-delete (lookup-key global-map "\177")) 1505 (setq edt-term "vt100"))
375 (global-set-key "\177" 'delete-previous-char) ;"Delete" 1506 ;; Load EDT terminal specific configuration file.
376 (setq edt-mode-old-lisp-delete (lookup-key emacs-lisp-mode-map "\177")) 1507 (let ((term edt-term)
377 (define-key emacs-lisp-mode-map "\177" 'delete-previous-char) ;"Delete" 1508 hyphend)
378 (define-key lisp-mode-map "\177" 'delete-previous-char) ;"Delete" 1509 (while (and term
379 (setq edt-mode-old-linefeed (lookup-key global-map "\C-j")) 1510 (not (load (concat "edt-" term) t t)))
380 (global-set-key "\C-j" 'edt-delete-previous-word) ;"LineFeed" 1511 ;; Strip off last hyphen and what follows, then try again
381 (define-key esc-map "?" 'apropos)) ;"<ESC>?" 1512 (if (setq hyphend (string-match "[-_][^-_]+$" term))
382 1513 (setq term (substring term 0 hyphend))
383(defun edt-emulation-off () 1514 (setq term nil)))
384 "Return from EDT emulation to normal Emacs key bindings. 1515 ;; Override terminal-specific file if running X Windows. X Windows support
385The keys redefined by \\[edt-emulation-on] are given their old definitions." 1516 ;; is handled differently in edt-load-xkeys
386 (interactive) 1517 (if window-system
387 (setq edt-direction-string nil) 1518 (edt-load-xkeys nil)
388 (global-set-key "\C-\\" edt-mode-old-c-\\) 1519 (if (null term)
389 (global-set-key "\177" edt-mode-old-delete) ;"Delete" 1520 (error "Unable to load EDT terminal specific file for %s" edt-term)))
390 (define-key emacs-lisp-mode-map "\177" edt-mode-old-lisp-delete) ;"Delete" 1521 (setq edt-term term))
391 (define-key lisp-mode-map "\177" edt-mode-old-lisp-delete) ;"Delete" 1522 (setq edt-orig-transient-mark-mode transient-mark-mode)
392 (global-set-key "\C-j" edt-mode-old-linefeed)) ;"LineFeed" 1523 (add-hook 'activate-mark-hook
393 1524 (function
394(defvar GOLD-map (make-keymap) 1525 (lambda ()
395 "`GOLD-map' maps the function keys on the VT100 keyboard preceded 1526 (edt-select-mode t))))
396by the PF1 key. GOLD is the ASCII the 7-bit escape sequence <ESC>OP.") 1527 (add-hook 'deactivate-mark-hook
397 1528 (function
398(defalias 'GOLD-prefix GOLD-map) 1529 (lambda ()
399 1530 (edt-select-mode nil))))
400(global-set-key [home] 'edt-beginning-of-window) 1531 (if (load "edt-user" t t)
401(global-set-key [kp-f2] 'describe-key) 1532 (edt-user-emulation-setup)
402(global-set-key [kp-f4] 'delete-current-line) 1533 (edt-default-emulation-setup)))
403(global-set-key [kp-9] 'append-to-buffer) 1534
404(global-set-key [kp-subtract] 'delete-current-word) 1535(defun edt-emulation-off()
405(global-set-key [kp-4] 'advance-direction) 1536 "Select original global key bindings, disabling EDT Emulation."
406(global-set-key [kp-5] 'backup-direction) 1537 (interactive)
407(global-set-key [kp-6] 'kill-region) 1538 (use-global-map global-map)
408(global-set-key [kp-separator] 'delete-current-char) 1539 (if (not edt-keep-current-page-delimiter)
409(global-set-key [kp-decimal] 'set-mark-command) 1540 (setq page-delimiter edt-orig-page-delimiter))
410(global-set-key [kp-enter] 'other-window) 1541 (setq edt-direction-string "")
411(global-set-key [kp-f1] 'GOLD-prefix) 1542 (setq edt-select-mode-text nil)
412 1543 (edt-reset)
413;;Bind GOLD/Keyboard keys 1544 (force-mode-line-update t)
414 1545 (setq transient-mark-mode edt-orig-transient-mark-mode)
415(define-key GOLD-map "\C-g" 'keyboard-quit) ; just for safety 1546 (message "Original key bindings restored; EDT Emulation disabled"))
416(define-key GOLD-map "\177" 'delete-window) ;"Delete" 1547
417(define-key GOLD-map "\C-h" 'delete-other-windows) ;"BackSpace" 1548(defun edt-default-emulation-setup (&optional user-setup)
418(define-key GOLD-map "\C-m" 'newline-and-indent) ;"Return" 1549 "Setup emulation of DEC's EDT editor."
419(define-key GOLD-map " " 'undo) ;"Spacebar" 1550 ;; Setup default EDT global map by copying global map bindings.
420(define-key GOLD-map "%" 'goto-percent) ; "%" 1551 ;; This preserves ESC and C-x prefix bindings and other bindings we
421(define-key GOLD-map "=" 'goto-line) ; "=" 1552 ;; wish to retain in EDT emulation mode keymaps. It also permits
422(define-key GOLD-map "`" 'what-line) ; "`" 1553 ;; customization of these bindings in the EDT global maps without
423(define-key GOLD-map "\C-\\" 'split-window-vertically) ; "Control-\" 1554 ;; disturbing the original bindings in global-map.
424 1555 (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix))
425; GOLD letter combinations: 1556 (setq edt-default-global-map (copy-keymap (current-global-map)))
426(define-key GOLD-map "b" 'buffer-menu) ; "b" 1557 (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix)
427(define-key GOLD-map "B" 'buffer-menu) ; "B" 1558 (define-prefix-command 'edt-default-gold-map)
428(define-key GOLD-map "d" 'delete-window) ; "d" 1559 (edt-setup-default-bindings)
429(define-key GOLD-map "D" 'delete-window) ; "D" 1560 ;; If terminal has additional function keys, the terminal-specific
430(define-key GOLD-map "e" 'compile) ; "e" 1561 ;; initialization file can assign bindings to them via the optional
431(define-key GOLD-map "E" 'compile) ; "E" 1562 ;; function edt-setup-extra-default-bindings.
432(define-key GOLD-map "i" 'insert-file) ; "i" 1563 (if (fboundp 'edt-setup-extra-default-bindings)
433(define-key GOLD-map "I" 'insert-file) ; "I" 1564 (edt-setup-extra-default-bindings))
434(define-key GOLD-map "l" 'goto-line) ; "l" 1565 ;; Variable needed by edt-learn.
435(define-key GOLD-map "L" 'goto-line) ; "L" 1566 (setq edt-learn-macro-count 0)
436(define-key GOLD-map "m" 'save-some-buffers) ; "m" 1567 ;; Display EDT text selection active within the mode line
437(define-key GOLD-map "M" 'save-some-buffers) ; "m" 1568 (or (assq 'edt-select-mode minor-mode-alist)
438(define-key GOLD-map "n" 'next-error) ; "n" 1569 (setq minor-mode-alist
439(define-key GOLD-map "N" 'next-error) ; "N" 1570 (cons '(edt-select-mode edt-select-mode) minor-mode-alist)))
440(define-key GOLD-map "o" 'switch-to-buffer-other-window) ; "o" 1571 ;; Display EDT direction of motion within the mode line
441(define-key GOLD-map "O" 'switch-to-buffer-other-window) ; "O" 1572 (or (assq 'edt-direction-string minor-mode-alist)
442(define-key GOLD-map "r" 'revert-file) ; "r" 1573 (setq minor-mode-alist
443(define-key GOLD-map "r" 'revert-file) ; "R" 1574 (cons
444(define-key GOLD-map "s" 'save-buffer) ; "s" 1575 '(edt-direction-string edt-direction-string) minor-mode-alist)))
445(define-key GOLD-map "S" 'save-buffer) ; "S" 1576 (if user-setup
446(define-key GOLD-map "v" 'find-file-other-window) ; "v" 1577 (progn
447(define-key GOLD-map "V" 'find-file-other-window) ; "V" 1578 (setq edt-user-map-configured t)
448(define-key GOLD-map "w" 'write-file) ; "w" 1579 (fset 'edt-emulation-on (symbol-function 'edt-select-user-global-map)))
449(define-key GOLD-map "w" 'write-file) ; "W" 1580 (progn
450;(define-key GOLD-map "z" 'shrink-window) ; "z" 1581 (fset 'edt-emulation-on (symbol-function 'edt-select-default-global-map))
451;(define-key GOLD-map "Z" 'shrink-window) ; "z" 1582 (edt-select-default-global-map))))
452 1583
453;Bind GOLD/Keypad keys 1584(defun edt-user-emulation-setup ()
454(defun edt-bind-gold-keypad () 1585 "Setup user custom emulation of DEC's EDT editor."
455 (define-key GOLD-map [up] 'edt-line-to-top-of-window) 1586 ;; Initialize EDT default bindings.
456 (define-key GOLD-map [down] 'edt-line-to-bottom-of-window) 1587 (edt-default-emulation-setup t)
457 (define-key GOLD-map [left] 'backward-sentence) 1588 ;; Setup user EDT global map by copying default EDT global map bindings.
458 (define-key GOLD-map [right] 'forward-sentence) 1589 (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix))
459 (define-key GOLD-map [kp-f1] 'mark-section-wisely) 1590 (setq edt-user-global-map (copy-keymap edt-default-global-map))
460 (define-key GOLD-map [kp-f2] 'describe-function) 1591 (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix)
461 (define-key GOLD-map [kp-f3] 'occur) 1592 ;; If terminal has additional function keys, the user's initialization
462 (define-key GOLD-map [kp-f4] 'undelete-lines) 1593 ;; file can assign bindings to them via the optional
463 (define-key GOLD-map [kp-0] 'open-line) 1594 ;; function edt-setup-extra-default-bindings.
464 (define-key GOLD-map [kp-1] 'case-flip-character) 1595 (define-prefix-command 'edt-user-gold-map)
465 (define-key GOLD-map [kp-2] 'delete-to-eol) 1596 (fset 'edt-user-gold-map (copy-keymap 'edt-default-gold-map))
466 (define-key GOLD-map [kp-3] 'copy-region-as-kill) 1597 (edt-setup-user-bindings)
467 (define-key GOLD-map [kp-4] 'move-to-end) 1598 (edt-select-user-global-map))
468 (define-key GOLD-map [kp-5] 'move-to-beginning) 1599
469 (define-key GOLD-map [kp-6] 'yank) 1600(defun edt-select-default-global-map()
470 (define-key GOLD-map [kp-7] 'execute-extended-command) 1601 "Select default EDT emulation key bindings."
471 (define-key GOLD-map [kp-8] 'indent-or-fill-region) 1602 (interactive)
472 (define-key GOLD-map [kp-9] 'replace-regexp) 1603 (transient-mark-mode 1)
473 (define-key GOLD-map [kp-subtract] 'undelete-words) 1604 (use-global-map edt-default-global-map)
474 (define-key GOLD-map [kp-separator] 'undelete-chars) 1605 (if (not edt-keep-current-page-delimiter)
475 (define-key GOLD-map [kp-decimal] 'redraw-display) 1606 (progn
476 (define-key GOLD-map [kp-enter] 'shell-command)) 1607 (setq edt-orig-page-delimiter page-delimiter)
477 1608 (setq page-delimiter "\f")))
478;; Make direction of motion show in mode line 1609 (setq edt-default-map-active t)
479;; while EDT emulation is turned on. 1610 (edt-advance)
480;; Note that the keypad is always turned on when in Emacs. 1611 (setq edt-select-mode-text 'edt-select-mode-string)
481 1612 (edt-reset)
482(or (assq 'edt-direction-string minor-mode-alist) 1613 (message "Default EDT keymap active"))
483 (setq minor-mode-alist (cons '(edt-direction-string edt-direction-string) 1614
484 minor-mode-alist))) 1615(defun edt-select-user-global-map()
1616 "Select user EDT emulation custom key bindings."
1617 (interactive)
1618 (if edt-user-map-configured
1619 (progn
1620 (transient-mark-mode 1)
1621 (use-global-map edt-user-global-map)
1622 (if (not edt-keep-current-page-delimiter)
1623 (progn
1624 (setq edt-orig-page-delimiter page-delimiter)
1625 (setq page-delimiter "\f")))
1626 (setq edt-default-map-active nil)
1627 (edt-advance)
1628 (setq edt-select-mode-text 'edt-select-mode-string)
1629 (edt-reset)
1630 (message "User EDT custom keymap active"))
1631 (error "User EDT custom keymap NOT configured!")))
1632
1633(defun edt-switch-global-maps ()
1634 "Toggle between default EDT keymap and user EDT keymap."
1635 (interactive)
1636 (if edt-default-map-active
1637 (edt-select-user-global-map)
1638 (edt-select-default-global-map)))
1639
1640;; There are three key binding functions needed: one for standard keys
1641;; (used to bind control keys, primarily), one for Gold sequences of
1642;; standard keys, and one for function keys.
1643
1644(defun edt-bind-gold-key (key gold-binding &optional default)
1645 "Binds commands to a gold key sequence in the EDT Emulator."
1646 (if default
1647 (define-key 'edt-default-gold-map key gold-binding)
1648 (define-key 'edt-user-gold-map key gold-binding)))
1649
1650(defun edt-bind-standard-key (key gold-binding &optional default)
1651 "Bind commands to a gold key sequence in the default EDT keymap."
1652 (if default
1653 (define-key edt-default-global-map key gold-binding)
1654 (define-key edt-user-global-map key gold-binding)))
1655
1656(defun edt-bind-function-key
1657 (function-key binding gold-binding &optional default)
1658 "Binds function keys in the EDT Emulator."
1659 (catch 'edt-key-not-supported
1660 (let ((key-vector (cdr (assoc function-key *EDT-keys*))))
1661 (if (stringp key-vector)
1662 (throw 'edt-key-not-supported t))
1663 (if (not (null key-vector))
1664 (progn
1665 (if default
1666 (progn
1667 (define-key edt-default-global-map key-vector binding)
1668 (define-key 'edt-default-gold-map key-vector gold-binding))
1669 (progn
1670 (define-key edt-user-global-map key-vector binding)
1671 (define-key 'edt-user-gold-map key-vector gold-binding))))
1672 (error "%s is not a legal function key name" function-key)))))
1673
1674(defun edt-setup-default-bindings ()
1675 "Assigns default EDT Emulation keyboard bindings."
1676
1677 ;; Function Key Bindings: Regular and GOLD.
1678
1679 ;; VT100/VT200/VT300 PF1 (GOLD), PF2, PF3, PF4 Keys
1680 (edt-bind-function-key "PF1" 'edt-default-gold-map 'edt-mark-section-wisely t)
1681 (edt-bind-function-key "PF2" 'edt-electric-keypad-help 'describe-function t)
1682 (edt-bind-function-key "PF3" 'edt-find-next 'edt-find t)
1683 (edt-bind-function-key "PF4" 'edt-delete-line 'edt-undelete-line t)
1684
1685 ;; VT100/VT200/VT300 Arrow Keys
1686 (edt-bind-function-key "UP" 'previous-line 'edt-window-top t)
1687 (edt-bind-function-key "DOWN" 'next-line 'edt-window-bottom t)
1688 (edt-bind-function-key "LEFT" 'backward-char 'edt-sentence-backward t)
1689 (edt-bind-function-key "RIGHT" 'forward-char 'edt-sentence-forward t)
1690
1691 ;; VT100/VT200/VT300 Keypad Keys
1692 (edt-bind-function-key "KP0" 'edt-line 'open-line t)
1693 (edt-bind-function-key "KP1" 'edt-word 'edt-change-case t)
1694 (edt-bind-function-key "KP2" 'edt-end-of-line 'edt-delete-to-end-of-line t)
1695 (edt-bind-function-key "KP3" 'edt-character 'quoted-insert t)
1696 (edt-bind-function-key "KP4" 'edt-advance 'edt-bottom t)
1697 (edt-bind-function-key "KP5" 'edt-backup 'edt-top t)
1698 (edt-bind-function-key "KP6" 'edt-cut 'yank t)
1699 (edt-bind-function-key "KP7" 'edt-page 'execute-extended-command t)
1700 (edt-bind-function-key "KP8" 'edt-sect 'edt-fill-region t)
1701 (edt-bind-function-key "KP9" 'edt-append 'edt-replace t)
1702 (edt-bind-function-key "KP-" 'edt-delete-word 'edt-undelete-word t)
1703 (edt-bind-function-key "KP," 'edt-delete-character 'edt-undelete-character t)
1704 (edt-bind-function-key "KPP" 'edt-select 'edt-reset t)
1705 (edt-bind-function-key "KPE" 'other-window 'query-replace t)
1706
1707 ;; VT200/VT300 Function Keys
1708 ;; (F1 through F5, on the VT220, are not programmable, so we skip
1709 ;; making default bindings to those keys.
1710 (edt-bind-function-key "FIND" 'edt-find-next 'edt-find t)
1711 (edt-bind-function-key "INSERT" 'yank 'edt-key-not-assigned t)
1712 (edt-bind-function-key "REMOVE" 'edt-cut 'edt-copy t)
1713 (edt-bind-function-key "SELECT" 'edt-toggle-select 'edt-key-not-assigned t)
1714 (edt-bind-function-key "NEXT" 'edt-sect-forward 'edt-key-not-assigned t)
1715 (edt-bind-function-key "PREVIOUS" 'edt-sect-backward 'edt-key-not-assigned t)
1716 (edt-bind-function-key "F6" 'edt-key-not-assigned 'edt-key-not-assigned t)
1717 (edt-bind-function-key "F7" 'edt-copy-rectangle 'edt-key-not-assigned t)
1718 (edt-bind-function-key "F8"
1719 'edt-cut-rectangle-overstrike-mode 'edt-paste-rectangle-overstrike-mode t)
1720 (edt-bind-function-key "F9"
1721 'edt-cut-rectangle-insert-mode 'edt-paste-rectangle-insert-mode t)
1722 (edt-bind-function-key "F10" 'edt-cut-rectangle 'edt-paste-rectangle t)
1723 ;; Under X, the F11 key can be bound. If using a VT-200 or higher terminal,
1724 ;; the default emacs terminal support causes the VT F11 key to seem as if it
1725 ;; is an ESC key when in emacs.
1726 (edt-bind-function-key "F11"
1727 'edt-key-not-assigned 'edt-key-not-assigned t)
1728 (edt-bind-function-key "F12"
1729 'edt-beginning-of-line 'delete-other-windows t) ;BS
1730 (edt-bind-function-key "F13"
1731 'edt-delete-to-beginning-of-word 'edt-key-not-assigned t) ;LF
1732 (edt-bind-function-key "F14" 'edt-key-not-assigned 'edt-key-not-assigned t)
1733 (edt-bind-function-key "HELP" 'edt-electric-keypad-help 'edt-key-not-assigned t)
1734 (edt-bind-function-key "DO" 'execute-extended-command 'edt-key-not-assigned t)
1735 (edt-bind-function-key "F17" 'edt-key-not-assigned 'edt-key-not-assigned t)
1736 (edt-bind-function-key "F18" 'edt-key-not-assigned 'edt-key-not-assigned t)
1737 (edt-bind-function-key "F19" 'edt-key-not-assigned 'edt-key-not-assigned t)
1738 (edt-bind-function-key "F20" 'edt-key-not-assigned 'edt-key-not-assigned t)
1739
1740 ;; Control key bindings: Regular and GOLD
1741 ;;
1742 ;; Standard EDT control key bindings conflict with standard Emacs
1743 ;; control key bindings. Normally, the standard Emacs control key
1744 ;; bindings are left unchanged in the default EDT mode. However, if
1745 ;; the variable edt-use-EDT-control-key-bindings is set to true
1746 ;; before invoking edt-emulation-on for the first time, then the
1747 ;; standard EDT bindings (with some enhancements) as defined here are
1748 ;; used, instead.
1749 (if edt-use-EDT-control-key-bindings
1750 (progn
1751 (edt-bind-standard-key "\C-a" 'edt-key-not-assigned t)
1752 (edt-bind-standard-key "\C-b" 'edt-key-not-assigned t)
1753 ;; Leave binding of C-c as original prefix key.
1754 (edt-bind-standard-key "\C-d" 'edt-key-not-assigned t)
1755 (edt-bind-standard-key "\C-e" 'edt-key-not-assigned t)
1756 (edt-bind-standard-key "\C-f" 'edt-key-not-assigned t)
1757 ;; Leave binding of C-g to keyboard-quit
1758; (edt-bind-standard-key "\C-g" 'keyboard-quit t)
1759 ;; Standard EDT binding of C-h. To invoke Emacs help, use
1760 ;; GOLD-C-h instead.
1761 (edt-bind-standard-key "\C-h" 'edt-beginning-of-line t)
1762 (edt-bind-standard-key "\C-i" 'edt-tab-insert t)
1763 (edt-bind-standard-key "\C-j" 'edt-delete-to-beginning-of-word t)
1764 (edt-bind-standard-key "\C-k" 'edt-define-key t)
1765 (edt-bind-gold-key "\C-k" 'edt-restore-key t)
1766 (edt-bind-standard-key "\C-l" 'edt-form-feed-insert t)
1767 ;; Leave binding of C-m to newline.
1768 (edt-bind-standard-key "\C-n" 'edt-set-screen-width-80 t)
1769 (edt-bind-standard-key "\C-o" 'edt-key-not-assigned t)
1770 (edt-bind-standard-key "\C-p" 'edt-key-not-assigned t)
1771 (edt-bind-standard-key "\C-q" 'edt-key-not-assigned t)
1772 ;; Leave binding of C-r to isearch-backward.
1773 ;; Leave binding of C-s to isearch-forward.
1774 (edt-bind-standard-key "\C-t" 'edt-display-the-time t)
1775 (edt-bind-standard-key "\C-u" 'edt-delete-to-beginning-of-line t)
1776 (edt-bind-standard-key "\C-v" 'redraw-display t)
1777 (edt-bind-standard-key "\C-w" 'edt-set-screen-width-132 t)
1778 ;; Leave binding of C-x as original prefix key.
1779 (edt-bind-standard-key "\C-y" 'edt-key-not-assigned t)
1780; (edt-bind-standard-key "\C-z" 'suspend-emacs t)
1781 )
1782 )
1783
1784 ;; GOLD bindings for a few Control keys.
1785 (edt-bind-gold-key "\C-g" 'keyboard-quit t); Just in case.
1786 (edt-bind-gold-key "\C-h" 'help-for-help t)
1787 (edt-bind-gold-key "\C-\\" 'split-window-vertically t)
1788
1789 ;; GOLD bindings for regular keys.
1790 (edt-bind-gold-key "a" 'edt-key-not-assigned t)
1791 (edt-bind-gold-key "A" 'edt-key-not-assigned t)
1792 (edt-bind-gold-key "b" 'buffer-menu t)
1793 (edt-bind-gold-key "B" 'buffer-menu t)
1794 (edt-bind-gold-key "c" 'compile t)
1795 (edt-bind-gold-key "C" 'compile t)
1796 (edt-bind-gold-key "d" 'delete-window t)
1797 (edt-bind-gold-key "D" 'delete-window t)
1798 (edt-bind-gold-key "e" 'edt-exit t)
1799 (edt-bind-gold-key "E" 'edt-exit t)
1800 (edt-bind-gold-key "f" 'find-file t)
1801 (edt-bind-gold-key "F" 'find-file t)
1802 (edt-bind-gold-key "g" 'find-file-other-window t)
1803 (edt-bind-gold-key "G" 'find-file-other-window t)
1804 (edt-bind-gold-key "h" 'edt-electric-keypad-help t)
1805 (edt-bind-gold-key "H" 'edt-electric-keypad-help t)
1806 (edt-bind-gold-key "i" 'insert-file t)
1807 (edt-bind-gold-key "I" 'insert-file t)
1808 (edt-bind-gold-key "j" 'edt-key-not-assigned t)
1809 (edt-bind-gold-key "J" 'edt-key-not-assigned t)
1810 (edt-bind-gold-key "k" 'edt-toggle-capitalization-of-word t)
1811 (edt-bind-gold-key "K" 'edt-toggle-capitalization-of-word t)
1812 (edt-bind-gold-key "l" 'edt-lowercase t)
1813 (edt-bind-gold-key "L" 'edt-lowercase t)
1814 (edt-bind-gold-key "m" 'save-some-buffers t)
1815 (edt-bind-gold-key "M" 'save-some-buffers t)
1816 (edt-bind-gold-key "n" 'next-error t)
1817 (edt-bind-gold-key "N" 'next-error t)
1818 (edt-bind-gold-key "o" 'switch-to-buffer-other-window t)
1819 (edt-bind-gold-key "O" 'switch-to-buffer-other-window t)
1820 (edt-bind-gold-key "p" 'edt-key-not-assigned t)
1821 (edt-bind-gold-key "P" 'edt-key-not-assigned t)
1822 (edt-bind-gold-key "q" 'edt-quit t)
1823 (edt-bind-gold-key "Q" 'edt-quit t)
1824 (edt-bind-gold-key "r" 'revert-file t)
1825 (edt-bind-gold-key "R" 'revert-file t)
1826 (edt-bind-gold-key "s" 'save-buffer t)
1827 (edt-bind-gold-key "S" 'save-buffer t)
1828 (edt-bind-gold-key "t" 'edt-key-not-assigned t)
1829 (edt-bind-gold-key "T" 'edt-key-not-assigned t)
1830 (edt-bind-gold-key "u" 'edt-uppercase t)
1831 (edt-bind-gold-key "U" 'edt-uppercase t)
1832 (edt-bind-gold-key "v" 'find-file-other-window t)
1833 (edt-bind-gold-key "V" 'find-file-other-window t)
1834 (edt-bind-gold-key "w" 'write-file t)
1835 (edt-bind-gold-key "W" 'write-file t)
1836 (edt-bind-gold-key "x" 'edt-key-not-assigned t)
1837 (edt-bind-gold-key "X" 'edt-key-not-assigned t)
1838 (edt-bind-gold-key "y" 'edt-emulation-off t)
1839 (edt-bind-gold-key "Y" 'edt-emulation-off t)
1840 (edt-bind-gold-key "z" 'edt-switch-global-maps t)
1841 (edt-bind-gold-key "Z" 'edt-switch-global-maps t)
1842 (edt-bind-gold-key "1" 'delete-other-windows t)
1843 (edt-bind-gold-key "!" 'edt-key-not-assigned t)
1844 (edt-bind-gold-key "2" 'edt-split-window t)
1845 (edt-bind-gold-key "@" 'edt-key-not-assigned t)
1846 (edt-bind-gold-key "3" 'edt-key-not-assigned t)
1847 (edt-bind-gold-key "#" 'edt-key-not-assigned t)
1848 (edt-bind-gold-key "4" 'edt-key-not-assigned t)
1849 (edt-bind-gold-key "$" 'edt-key-not-assigned t)
1850 (edt-bind-gold-key "5" 'edt-key-not-assigned t)
1851 (edt-bind-gold-key "%" 'edt-goto-percentage t)
1852 (edt-bind-gold-key "6" 'edt-key-not-assigned t)
1853 (edt-bind-gold-key "^" 'edt-key-not-assigned t)
1854 (edt-bind-gold-key "7" 'edt-key-not-assigned t)
1855 (edt-bind-gold-key "&" 'edt-key-not-assigned t)
1856 (edt-bind-gold-key "8" 'edt-key-not-assigned t)
1857 (edt-bind-gold-key "*" 'edt-key-not-assigned t)
1858 (edt-bind-gold-key "9" 'edt-key-not-assigned t)
1859 (edt-bind-gold-key "(" 'edt-key-not-assigned t)
1860 (edt-bind-gold-key "0" 'edt-key-not-assigned t)
1861 (edt-bind-gold-key ")" 'edt-key-not-assigned t)
1862 (edt-bind-gold-key " " 'undo t)
1863 (edt-bind-gold-key "," 'edt-key-not-assigned t)
1864 (edt-bind-gold-key "<" 'edt-key-not-assigned t)
1865 (edt-bind-gold-key "." 'edt-key-not-assigned t)
1866 (edt-bind-gold-key ">" 'edt-key-not-assigned t)
1867 (edt-bind-gold-key "/" 'edt-key-not-assigned t)
1868 (edt-bind-gold-key "?" 'edt-key-not-assigned t)
1869 (edt-bind-gold-key "\\" 'edt-key-not-assigned t)
1870 (edt-bind-gold-key "|" 'edt-key-not-assigned t)
1871 (edt-bind-gold-key ";" 'edt-key-not-assigned t)
1872 (edt-bind-gold-key ":" 'edt-key-not-assigned t)
1873 (edt-bind-gold-key "'" 'edt-key-not-assigned t)
1874 (edt-bind-gold-key "\"" 'edt-key-not-assigned t)
1875 (edt-bind-gold-key "-" 'edt-key-not-assigned t)
1876 (edt-bind-gold-key "_" 'edt-key-not-assigned t)
1877 (edt-bind-gold-key "=" 'goto-line t)
1878 (edt-bind-gold-key "+" 'edt-key-not-assigned t)
1879 (edt-bind-gold-key "[" 'edt-key-not-assigned t)
1880 (edt-bind-gold-key "{" 'edt-key-not-assigned t)
1881 (edt-bind-gold-key "]" 'edt-key-not-assigned t)
1882 (edt-bind-gold-key "}" 'edt-key-not-assigned t)
1883 (edt-bind-gold-key "`" 'what-line t)
1884 (edt-bind-gold-key "~" 'edt-key-not-assigned t)
1885)
1886
1887;;;
1888;;; DEFAULT EDT KEYPAD HELP
1889;;;
1890
1891;;;
1892;;; Upper case commands in the keypad diagram below indicate that the
1893;;; emulation should look and feel very much like EDT. Lower case
1894;;; commands are enhancements and/or additions to the EDT keypad
1895;;; commands or are native Emacs commands.
1896;;;
1897
1898(defun edt-keypad-help ()
1899 "
1900 DEFAULT EDT Keypad Active
1901
1902 F7: Copy Rectangle +----------+----------+----------+----------+
1903 F8: Cut Rect Overstrike |Prev Line |Next Line |Bkwd Char |Frwd Char |
1904 G-F8: Paste Rect Overstrike | (UP) | (DOWN) | (LEFT) | (RIGHT) |
1905 F9: Cut Rect Insert |Window Top|Window Bot|Bkwd Sent |Frwd Sent |
1906 G-F9: Paste Rect Insert +----------+----------+----------+----------+
1907 F10: Cut Rectangle
1908G-F10: Paste Rectangle
1909 F11: ESC
1910 F12: Begining of Line +----------+----------+----------+----------+
1911G-F12: Delete Other Windows | GOLD | HELP | FNDNXT | DEL L |
1912 F13: Delete to Begin of Word | (PF1) | (PF2) | (PF3) | (PF4) |
1913 HELP: Keypad Help |Mark Wisel|Desc Funct| FIND | UND L |
1914 DO: Execute extended command +----------+----------+----------+----------+
1915 | PAGE | SECT | APPEND | DEL W |
1916 C-g: Keyboard Quit | (7) | (8) | (9) | (-) |
1917G-C-g: Keyboard Quit |Ex Ext Cmd|Fill Regio| REPLACE | UND W |
1918 C-h: Beginning of Line +----------+----------+----------+----------+
1919G-C-h: Emacs Help | ADVANCE | BACKUP | CUT | DEL C |
1920 C-i: Tab Insert | (4) | (5) | (6) | (,) |
1921 C-j: Delete to Begin of Word | BOTTOM | TOP | Yank | UND C |
1922 C-k: Define Key +----------+----------+----------+----------+
1923G-C-k: Restore Key | WORD | EOL | CHAR | Next |
1924 C-l: Form Feed Insert | (1) | (2) | (3) | Window |
1925 C-n: Set Screen Width 80 | CHNGCASE | DEL EOL |Quoted Ins| !
1926 C-r: Isearch Backward +---------------------+----------+ (ENTER) |
1927 C-s: Isearch Forward | LINE | SELECT | !
1928 C-t: Display the Time | (0) | (.) | Query |
1929 C-u: Delete to Begin of Line | Open Line | RESET | Replace |
1930 C-v: Redraw Display +---------------------+----------+----------+
1931 C-w: Set Screen Width 132
1932 C-z: Suspend Emacs +----------+----------+----------+
1933G-C-\\: Split Window | FNDNXT | Yank | CUT |
1934 | (FIND) | (INSERT) | (REMOVE) |
1935 G-b: Buffer Menu | FIND | | COPY |
1936 G-c: Compile +----------+----------+----------+
1937 G-d: Delete Window |SELECT/RES|SECT BACKW|SECT FORWA|
1938 G-e: Exit | (SELECT) |(PREVIOUS)| (NEXT) |
1939 G-f: Find File | | | |
1940 G-g: Find File Other Window +----------+----------+----------+
1941 G-h: Keypad Help
1942 G-i: Insert File
1943 G-k: Toggle Capitalization Word
1944 G-l: Downcase Region
1945 G-m: Save Some Buffers
1946 G-n: Next Error
1947 G-o: Switch to Next Window
1948 G-q: Quit
1949 G-r: Revert File
1950 G-s: Save Buffer
1951 G-u: Upcase Region
1952 G-v: Find File Other Window
1953 G-w: Write file
1954 G-y: EDT Emulation OFF
1955 G-z: Switch to User EDT Key Bindings
1956 G-1: Delete Other Windows
1957 G-2: Split Window
1958 G-%: Go to Percentage
1959 G- : Undo (GOLD Spacebar)
1960 G-=: Go to Line
1961 G-`: What line"
1962
1963 (interactive)
1964 (describe-function 'edt-keypad-help))
1965
1966(defun edt-electric-helpify (fun)
1967 (let ((name "*Help*"))
1968 (if (save-window-excursion
1969 (let* ((p (symbol-function 'print-help-return-message))
1970 (b (get-buffer name))
1971 (m (buffer-modified-p b)))
1972 (and b (not (get-buffer-window b))
1973 (setq b nil))
1974 (unwind-protect
1975 (progn
1976 (message "%s..." (capitalize (symbol-name fun)))
1977 (and b
1978 (save-excursion
1979 (set-buffer b)
1980 (set-buffer-modified-p t)))
1981 (fset 'print-help-return-message 'ignore)
1982 (call-interactively fun)
1983 (and (get-buffer name)
1984 (get-buffer-window (get-buffer name))
1985 (or (not b)
1986 (not (eq b (get-buffer name)))
1987 (not (buffer-modified-p b)))))
1988 (fset 'print-help-return-message p)
1989 (and b (buffer-name b)
1990 (save-excursion
1991 (set-buffer b)
1992 (set-buffer-modified-p m))))))
1993 (with-electric-help 'delete-other-windows name t))))
1994
1995(defun edt-electric-keypad-help ()
1996 (interactive)
1997 (edt-electric-helpify 'edt-keypad-help))
1998
1999(defun edt-electric-user-keypad-help ()
2000 (interactive)
2001 (edt-electric-helpify 'edt-user-keypad-help))
2002
2003;;;
2004;;; Generic EDT emulation screen width commands.
2005;;;
2006;; If modification of terminal attributes is desired when invoking these
2007;; commands, then the corresponding terminal specific file will contain a
2008;; re-definition of these commands.
2009
2010(defun edt-set-screen-width-80 ()
2011 "Set screen width to 80 columns."
2012 (interactive)
2013 (set-screen-width 80)
2014 (message "Screen width 80"))
2015
2016(defun edt-set-screen-width-132 ()
2017 "Set screen width to 132 columns."
2018 (interactive)
2019 (set-screen-width 132)
2020 (message "Screen width 132"))
2021
2022(provide 'edt)
485 2023
486;;; edt.el ends here 2024;;; edt.el ends here