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