Commit | Line | Data |
---|---|---|
e8af40ee | 1 | ;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs 19 |
1a06eabd | 2 | |
5fd6d89f | 3 | ;; Copyright (C) 1986, 1992, 1993, 1994, 1995, 2000, 2001, 2002, 2003, |
8b72699e | 4 | ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
3a801d0c | 5 | |
6687ffc7 EZ |
6 | ;; Author: Kevin Gallagher <Kevin.Gallagher@boeing.com> |
7 | ;; Maintainer: Kevin Gallagher <Kevin.Gallagher@boeing.com> | |
fd7fa35a | 8 | ;; Keywords: emulations |
e5167999 | 9 | |
4bf7f5d1 RS |
10 | ;; This file is part of GNU Emacs. |
11 | ||
12 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
f3e03a42 | 13 | ;; it under the terms of the GNU General Public License as published |
e0085d62 | 14 | ;; by the Free Software Foundation; either version 3, or (at your |
f3e03a42 | 15 | ;; option) any later version. |
4bf7f5d1 | 16 | |
f3e03a42 GM |
17 | ;; GNU Emacs is distributed in the hope that it will be useful, but |
18 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | ;; General Public License for more details. | |
4bf7f5d1 RS |
21 | |
22 | ;; You should have received a copy of the GNU General Public License | |
b578f267 | 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3a35cf56 LK |
24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 | ;; Boston, MA 02110-1301, USA. | |
4bf7f5d1 | 26 | |
3bef4fb9 | 27 | |
f3e03a42 GM |
28 | \f |
29 | ;;; Commentary: | |
a1506d29 | 30 | ;; |
f3e03a42 GM |
31 | |
32 | ;; This is Version 4.0 of the EDT Emulation for Emacs 19 and above. | |
33 | ;; It comes with special functions which replicate nearly all of EDT's | |
34 | ;; keypad mode behavior. It sets up default keypad and function key | |
35 | ;; bindings which closely match those found in EDT. Support is | |
36 | ;; provided so that users may reconfigure most keypad and function key | |
37 | ;; bindings to their own liking. | |
38 | ||
39 | ;; NOTE: Version 4.0 contains several enhancements. See the | |
40 | ;; Enhancement section below for the details. | |
41 | ||
42 | ;; Getting Started: | |
43 | ||
a1506d29 | 44 | ;; To start the EDT Emulation, first start Emacs and then enter |
f3e03a42 GM |
45 | ;; |
46 | ;; M-x edt-emulation-on | |
a1506d29 | 47 | ;; |
f3e03a42 GM |
48 | ;; to begin the emulation. After initialization is complete, the |
49 | ;; following message will appear below the status line informing you | |
50 | ;; that the emulation has been enabled: "Default EDT keymap active". | |
51 | ||
52 | ;; You can have the EDT Emulation start up automatically, each time | |
53 | ;; you initiate a GNU Emacs session, by adding the following line to | |
54 | ;; your .emacs file: | |
55 | ;; | |
56 | ;; (add-hook term-setup-hook 'edt-emulation-on) | |
57 | ||
58 | ;; IMPORTANT: Be sure to read the file, edt-user.doc, located in the | |
59 | ;; Emacs "etc" directory. It contains very helpful user information. | |
60 | ||
61 | ;; The EDT emulation consists of the following files: | |
a1506d29 | 62 | ;; |
f3e03a42 GM |
63 | ;; edt-user.doc - User Instructions and Sample Customization File |
64 | ;; edt.el - EDT Emulation Functions and Default Configuration | |
65 | ;; edt-lk201.el - Built-in support for DEC LK-201 Keyboards | |
66 | ;; edt-vt100.el - Built-in support for DEC VT-100 (and above) terminals | |
67 | ;; edt-pc.el - Built-in support for PC 101 Keyboards under MS-DOS | |
a1506d29 | 68 | ;; edt-mapper.el - Create an EDT LK-201 Map File for Keyboards Without |
f3e03a42 GM |
69 | ;; Built-in Support |
70 | ||
71 | ;; Enhancements: | |
72 | ||
73 | ;; Version 4.0 contains the following enhancements: | |
74 | ||
75 | ;; 1. Scroll margins at the top and bottom of the window are now | |
76 | ;; supported. (The design was copied from tpu-extras.el.) By | |
77 | ;; default, this feature is enabled, with the top margin set to | |
78 | ;; 10% of the window and the bottom margin set to 15% of the | |
79 | ;; window. To change these settings, you can invoke the function | |
80 | ;; edt-set-scroll-margins in your .emacs file. For example, the | |
81 | ;; following line | |
82 | ;; | |
83 | ;; (edt-set-scroll-margins "20%" "25%") | |
a1506d29 | 84 | ;; |
f3e03a42 GM |
85 | ;; sets the top margin to 20% of the window and the bottom margin |
86 | ;; to 25% of the window. To disable this feature, set each | |
87 | ;; margin to 0%. You can also invoke edt-set-scroll-margins | |
88 | ;; interactively while EDT Emulation is active to change the | |
89 | ;; settings for that session. | |
90 | ;; | |
91 | ;; NOTE: Another way to set the scroll margins is to use the | |
92 | ;; Emacs customization feature (not available in Emacs 19) to set | |
93 | ;; the following two variables directly: | |
a1506d29 | 94 | ;; |
f3e03a42 GM |
95 | ;; edt-top-scroll-margin and edt-bottom-scroll-margin |
96 | ;; | |
97 | ;; Enter the Emacs `customize' command. First select the Editing | |
98 | ;; group and then select the Emulations group. Finally, select | |
99 | ;; the Edt group and follow the directions. | |
a1506d29 | 100 | ;; |
f3e03a42 GM |
101 | ;; 2. The SUBS command is now supported and bound to GOLD-Enter by |
102 | ;; default. (This design was copied from tpu-edt.el.) Note, in | |
103 | ;; earlier versions of EDT Emulation, GOLD-Enter was assigned to | |
104 | ;; the Emacs function `query-replace'. The binding of | |
105 | ;; `query-replace' has been moved to GOLD-/. If you prefer to | |
106 | ;; restore `query-replace' to GOLD-Enter, then use an EDT user | |
107 | ;; customization file, edt-user.el, to do this. See edt-user.doc | |
108 | ;; for details. | |
109 | ||
110 | ;; 3. EDT Emulation now also works in XEmacs, including the | |
111 | ;; highlighting of selected text. | |
112 | ||
113 | ;; 4. If you access a workstation using an X Server, observe that | |
114 | ;; the initialization file generated by edt-mapper.el will now | |
115 | ;; contain the name of the X Server vendor. This is a | |
116 | ;; convenience for those who have access to their Unix account | |
117 | ;; from more than one type of X Server. Since different X | |
118 | ;; Servers typically require different EDT emulation | |
119 | ;; initialization files, edt-mapper.el will now generate these | |
120 | ;; different initialization files and save them with different | |
121 | ;; names. Then, the correct initialization file for the | |
122 | ;; particular X server in use is loaded correctly automatically. | |
123 | ||
124 | ;; 5. Also, edt-mapper.el is now capable of binding an ASCII key | |
125 | ;; sequence, providing the ASCII key sequence prefix is already | |
126 | ;; known by Emacs to be a prefix. As a result of providing this | |
127 | ;; support, some terminal/keyboard/window system configurations, | |
128 | ;; which don't have a complete set of sensible function key | |
129 | ;; bindings built into Emacs in `function-key-map', can still be | |
130 | ;; configured for use with EDT Emulation. (Note: In a few rare | |
131 | ;; circumstances this does not work properly. In particular, it | |
132 | ;; does not work if a subset of the leading ASCII characters in a | |
133 | ;; key sequence are recognized by Emacs as having an existing | |
134 | ;; binding. For example, if the keypad 7 (KP-7) key generates | |
135 | ;; the sequence \"<ESC>Ow\" and \"<ESC>O\" is already bound to a | |
136 | ;; function, pressing KP-7 when told to do so by edt-mapper.el | |
137 | ;; will result in edt-mapper.el incorrectly mapping \"<ESC>O\" to | |
138 | ;; KP-7 and \"w\" to KP-8. If something like this happens to | |
139 | ;; you, it is probably a bug in the support for your keyboard | |
140 | ;; within Emacs OR a bug in the Unix termcap/terminfo support for | |
141 | ;; your terminal OR a bug in the terminal emulation software you | |
142 | ;; are using.) | |
143 | ||
144 | ;; 6. The edt-quit function (bound to GOLD-q by default) has been | |
145 | ;; modified to warn the user when file-related buffer | |
146 | ;; modifications exist. It now cautions the user that those | |
147 | ;; modifications will be lost if the user quits without saving | |
148 | ;; those buffers. | |
149 | ||
150 | ||
151 | ;;; History: | |
a1506d29 | 152 | ;; |
f3e03a42 | 153 | ;; Version 4.0 2000 Added New Features and Fixed a Few Bugs |
a1506d29 | 154 | ;; |
3bef4fb9 | 155 | |
3bef4fb9 | 156 | \f |
f3e03a42 GM |
157 | ;;; Code: |
158 | ||
3bef4fb9 KH |
159 | ;;; Electric Help functions are used for keypad help displays. A few |
160 | ;;; picture functions are used in rectangular cut and paste commands. | |
f3e03a42 | 161 | |
3bef4fb9 KH |
162 | (require 'ehelp) |
163 | (require 'picture) | |
164 | ||
165 | ;;;; | |
166 | ;;;; VARIABLES and CONSTANTS | |
167 | ;;;; | |
168 | ||
71c37e3f MR |
169 | (defgroup edt nil |
170 | "Emacs emulating EDT." | |
171 | :prefix "edt-" | |
172 | :group 'emulations) | |
f3e03a42 | 173 | |
3eb8967a | 174 | ;; To silence the byte-compiler |
153ef845 DN |
175 | (defvar *EDT-keys*) |
176 | (defvar edt-default-global-map) | |
177 | (defvar edt-last-copied-word) | |
178 | (defvar edt-learn-macro-count) | |
179 | (defvar edt-orig-page-delimiter) | |
180 | (defvar edt-orig-transient-mark-mode) | |
181 | (defvar edt-rect-start-point) | |
182 | (defvar edt-user-global-map) | |
183 | (defvar rect-start-point) | |
184 | (defvar time-string) | |
185 | (defvar zmacs-region-stays) | |
3eb8967a | 186 | |
f3e03a42 GM |
187 | ;;; |
188 | ;;; Version Information | |
189 | ;;; | |
190 | (defconst edt-version "4.0" "EDT Emulation version number.") | |
191 | ||
192 | ;;; | |
193 | ;;; User Configurable Variables | |
194 | ;;; | |
195 | ||
bca3689a MR |
196 | (defcustom edt-keep-current-page-delimiter nil |
197 | "*Emacs MUST be restarted for a change in value to take effect! | |
f3e03a42 GM |
198 | Non-nil leaves Emacs value of `page-delimiter' unchanged within EDT |
199 | Emulation. If set to nil (the default), the `page-delimiter' variable | |
200 | is set to \"\\f\" when edt-emulation-on is first invoked. This | |
201 | setting replicates EDT's page delimiter behavior. The original value | |
202 | is restored when edt-emulation-off is called." | |
bca3689a MR |
203 | :type 'boolean |
204 | :group 'edt) | |
a1506d29 | 205 | |
bca3689a MR |
206 | (defcustom edt-use-EDT-control-key-bindings nil |
207 | "*Emacs MUST be restarted for a change in value to take effect! | |
f3e03a42 GM |
208 | Non-nil causes the control key bindings to be replaced with EDT |
209 | bindings. If set to nil (the default), EDT control key bindings are | |
210 | not used and the current Emacs control key bindings are retained for | |
211 | use within the EDT emulation." | |
bca3689a MR |
212 | :type 'boolean |
213 | :group 'edt) | |
f3e03a42 | 214 | |
bca3689a | 215 | (defcustom edt-word-entities '(?\t) |
a1506d29 | 216 | "*Specifies the list of EDT word entity characters. |
f3e03a42 GM |
217 | The default list, (\?\\t), contains just the TAB character, which |
218 | emulates EDT. Characters are specified in the list using their | |
219 | decimal ASCII values. A question mark, followed by the actual | |
220 | character, can be used to indicate the numerical value of the | |
221 | character, instead of the actual decimal value. So, ?A means the | |
222 | numerical value for the letter A, \?/ means the numerical value for /, | |
223 | etc. Several unprintable and special characters have special | |
224 | representations, which you can also use: | |
225 | ||
226 | \?\\b specifies BS, C-h | |
227 | \?\\t specifies TAB, C-i | |
228 | \?\\n specifies LFD, C-j | |
229 | \?\\v specifies VTAB, C-k | |
230 | \?\\f specifies FF, C-l | |
231 | \?\\r specifies CR, C-m | |
232 | \?\\e specifies ESC, C-[ | |
233 | \?\\\\ specifies \\ | |
234 | ||
235 | In EDT Emulation movement-by-word commands, each character in the list | |
236 | will be treated as if it were a separate word." | |
bca3689a MR |
237 | :type '(repeat integer) |
238 | :group 'edt) | |
f3e03a42 | 239 | |
bca3689a MR |
240 | (defcustom edt-top-scroll-margin 10 |
241 | "*Scroll margin at the top of the screen. | |
f3e03a42 GM |
242 | Interpreted as a percent of the current window size with a default |
243 | setting of 10%. If set to 0, top scroll margin is disabled." | |
bca3689a MR |
244 | :type 'integer |
245 | :group 'edt) | |
f3e03a42 | 246 | |
bca3689a MR |
247 | (defcustom edt-bottom-scroll-margin 15 |
248 | "*Scroll margin at the bottom of the screen. | |
f3e03a42 GM |
249 | Interpreted as a percent of the current window size with a default |
250 | setting of 15%. If set to 0, bottom scroll margin is disabled." | |
bca3689a MR |
251 | :type 'integer |
252 | :group 'edt) | |
f3e03a42 GM |
253 | |
254 | ;;; | |
255 | ;;; Internal Variables | |
256 | ;;; | |
257 | ||
4bf7f5d1 | 258 | (defvar edt-last-deleted-lines "" |
f3e03a42 | 259 | "Last text deleted by the EDT emulation DEL L command.") |
3bef4fb9 | 260 | |
4bf7f5d1 | 261 | (defvar edt-last-deleted-words "" |
f3e03a42 | 262 | "Last text deleted by the EDT emulation DEL W command.") |
3bef4fb9 | 263 | |
4bf7f5d1 | 264 | (defvar edt-last-deleted-chars "" |
f3e03a42 GM |
265 | "Last text deleted by the EDT emulation DEL C command.") |
266 | ||
267 | (defvar edt-find-last-text "" | |
268 | "Last text found by the EDT emulation FIND command.") | |
3bef4fb9 | 269 | |
f3e03a42 GM |
270 | (defvar edt-match-beginning-mark (make-marker) |
271 | "Used internally by the EDT emulation SUBS command.") | |
272 | ||
273 | (defvar edt-match-end-mark (make-marker) | |
274 | "Used internally by the EDT emulation SUBS command.") | |
275 | ||
276 | (defvar edt-last-replaced-key-definition nil | |
277 | "Key definition replaced with `edt-define-key' or `edt-learn' command.") | |
3bef4fb9 KH |
278 | |
279 | (defvar edt-direction-string "" | |
e4360875 | 280 | "String indicating current direction of movement.") |
3bef4fb9 KH |
281 | |
282 | (defvar edt-select-mode nil | |
e4360875 | 283 | "Non-nil means select mode is active.") |
3bef4fb9 | 284 | |
f3e03a42 GM |
285 | (defvar edt-select-mode-current "" |
286 | "Text displayed in mode line to indicate the state of EDT select mode. | |
287 | When select mode is inactive, it is set to an empty string.") | |
3bef4fb9 KH |
288 | |
289 | (defconst edt-select-mode-string " Select" | |
f3e03a42 | 290 | "Used in mode line to indicate select mode is active.") |
3bef4fb9 KH |
291 | |
292 | (defconst edt-forward-string " ADVANCE" | |
e4360875 | 293 | "Direction string in mode line to indicate forward movement.") |
3bef4fb9 KH |
294 | |
295 | (defconst edt-backward-string " BACKUP" | |
e4360875 | 296 | "Direction string in mode line to indicate backward movement.") |
3bef4fb9 KH |
297 | |
298 | (defvar edt-default-map-active nil | |
e4360875 | 299 | "Non-nil indicates that default EDT emulation key bindings are active. |
f0529b5b | 300 | nil means user-defined custom bindings are active.") |
3bef4fb9 KH |
301 | |
302 | (defvar edt-user-map-configured nil | |
e4360875 | 303 | "Non-nil indicates that user custom EDT key bindings are configured. |
f3e03a42 | 304 | This means that an edt-user.el file was found in the user's `load-path'.") |
3bef4fb9 | 305 | |
f3e03a42 GM |
306 | (defvar edt-term nil |
307 | "Specifies the terminal type, if applicable.") | |
4bf7f5d1 | 308 | |
3bef4fb9 KH |
309 | ;;; |
310 | ;;; Emacs version identifiers - currently referenced by | |
311 | ;;; | |
f3e03a42 | 312 | ;;; o edt-emulation-on o edt-load-keys |
3bef4fb9 | 313 | ;;; |
4ea0e84a | 314 | (defconst edt-emacs-variant (if (featurep 'emacs) "gnu" "xemacs") |
f3e03a42 GM |
315 | "Indicates Emacs variant: GNU Emacs or XEmacs \(aka Lucid Emacs\).") |
316 | ||
4ea0e84a | 317 | (defconst edt-window-system (if (featurep 'emacs) window-system (console-type)) |
f3e03a42 GM |
318 | "Indicates window system \(in GNU Emacs\) or console type \(in XEmacs\).") |
319 | ||
320 | (defconst edt-xserver (if (eq edt-window-system 'x) | |
4ea0e84a | 321 | (if (featurep 'xemacs) |
6687ffc7 EZ |
322 | ;; The Cygwin window manager has a `/' in its |
323 | ;; name, which breaks the generated file name of | |
324 | ;; the custom key map file. Replace `/' with a | |
325 | ;; `-' to work around that. | |
326 | (replace-in-string (x-server-vendor) "[ /]" "-") | |
327 | (subst-char-in-string ?/ ?- (subst-char-in-string ? ?- (x-server-vendor)))) | |
f3e03a42 GM |
328 | nil) |
329 | "Indicates X server vendor name, if applicable.") | |
330 | ||
331 | (defvar edt-keys-file nil | |
332 | "User's custom keypad and function keys mappings to emulate LK-201 keyboard.") | |
4668b9f9 RS |
333 | |
334 | (defvar edt-last-copied-word nil | |
335 | "Last word that the user copied.") | |
336 | ||
337 | (defvar zmacs-region-stays) | |
3bef4fb9 KH |
338 | \f |
339 | ;;;; | |
340 | ;;;; EDT Emulation Commands | |
341 | ;;;; | |
342 | ||
f3e03a42 GM |
343 | ;;; Almost all of EDT's keypad mode commands have equivalent Emacs |
344 | ;;; function counterparts. But many of these counterparts behave | |
345 | ;;; somewhat differently in Emacs. | |
3bef4fb9 | 346 | ;;; |
f3e03a42 GM |
347 | ;;; So, the following Emacs functions emulate, where practical, the |
348 | ;;; exact behavior of the corresponding EDT keypad mode commands. In | |
349 | ;;; a few cases, the emulation is not exact, but it should be close | |
350 | ;;; enough for most EDT die-hards. | |
3bef4fb9 KH |
351 | ;;; |
352 | ||
353 | ;;; | |
354 | ;;; PAGE | |
355 | ;;; | |
356 | ;;; Emacs uses the regexp assigned to page-delimiter to determine what | |
357 | ;;; marks a page break. This is normally "^\f", which causes the | |
358 | ;;; edt-page command to ignore form feeds not located at the beginning | |
359 | ;;; of a line. To emulate the EDT PAGE command exactly, | |
360 | ;;; page-delimiter is set to "\f" when EDT emulation is turned on, and | |
361 | ;;; restored to its original value when EDT emulation is turned off. | |
362 | ;;; But this can be overridden if the EDT definition is not desired by | |
363 | ;;; placing | |
364 | ;;; | |
365 | ;;; (setq edt-keep-current-page-delimiter t) | |
366 | ;;; | |
367 | ;;; in your .emacs file. | |
368 | ||
369 | (defun edt-page-forward (num) | |
370 | "Move forward to just after next page delimiter. | |
f3e03a42 | 371 | Argument NUM is the number of page delimiters to move." |
3bef4fb9 KH |
372 | (interactive "p") |
373 | (edt-check-prefix num) | |
374 | (if (eobp) | |
375 | (error "End of buffer") | |
f3e03a42 GM |
376 | (progn |
377 | (forward-page num) | |
378 | (if (eobp) | |
379 | (edt-line-to-bottom-of-window) | |
380 | (edt-line-to-top-of-window))))) | |
3bef4fb9 KH |
381 | |
382 | (defun edt-page-backward (num) | |
383 | "Move backward to just after previous page delimiter. | |
f3e03a42 | 384 | Argument NUM is the number of page delimiters to move." |
3bef4fb9 KH |
385 | (interactive "p") |
386 | (edt-check-prefix num) | |
387 | (if (bobp) | |
388 | (error "Beginning of buffer") | |
f3e03a42 GM |
389 | (progn |
390 | (backward-page num) | |
391 | (edt-line-to-top-of-window) | |
4ea0e84a | 392 | (if (featurep 'xemacs) (setq zmacs-region-stays t))))) |
3bef4fb9 KH |
393 | |
394 | (defun edt-page (num) | |
395 | "Move in current direction to next page delimiter. | |
f3e03a42 | 396 | Argument NUM is the number of page delimiters to move." |
4bf7f5d1 | 397 | (interactive "p") |
3bef4fb9 KH |
398 | (if (equal edt-direction-string edt-forward-string) |
399 | (edt-page-forward num) | |
f3e03a42 | 400 | (edt-page-backward num))) |
3bef4fb9 KH |
401 | |
402 | ;;; | |
403 | ;;; SECT | |
404 | ;;; | |
405 | ;;; EDT defaults a section size to be 16 lines of its one and only | |
406 | ;;; 24-line window. That's two-thirds of the window at a time. The | |
f3e03a42 | 407 | ;;; EDT SECT commands moves the cursor, not the window. |
a1506d29 | 408 | ;;; |
f3e03a42 GM |
409 | ;;; This emulation of EDT's SECT moves the cursor approximately |
410 | ;;; two-thirds of the current window at a time. | |
3bef4fb9 KH |
411 | |
412 | (defun edt-sect-forward (num) | |
f3e03a42 GM |
413 | "Move cursor forward two-thirds of a window's number of lines. |
414 | Argument NUM is the number of sections to move." | |
3bef4fb9 KH |
415 | (interactive "p") |
416 | (edt-check-prefix num) | |
417 | (edt-line-forward (* (* (/ (- (window-height) 1) 3) 2) num))) | |
418 | ||
f3e03a42 | 419 | |
3bef4fb9 KH |
420 | (defun edt-sect-backward (num) |
421 | "Move cursor backward two-thirds of a window. | |
f3e03a42 | 422 | Argument NUM is the number of sections to move." |
3bef4fb9 KH |
423 | (interactive "p") |
424 | (edt-check-prefix num) | |
425 | (edt-line-backward (* (* (/ (- (window-height) 1) 3) 2) num))) | |
426 | ||
427 | (defun edt-sect (num) | |
428 | "Move in current direction a full window. | |
f3e03a42 | 429 | Argument NUM is the number of sections to move." |
3bef4fb9 KH |
430 | (interactive "p") |
431 | (if (equal edt-direction-string edt-forward-string) | |
432 | (edt-sect-forward num) | |
f3e03a42 | 433 | (edt-sect-backward num))) |
3bef4fb9 KH |
434 | |
435 | ;;; | |
436 | ;;; BEGINNING OF LINE | |
437 | ;;; | |
438 | ;;; EDT's beginning-of-line command is not affected by current | |
439 | ;;; direction, for some unknown reason. | |
440 | ||
441 | (defun edt-beginning-of-line (num) | |
442 | "Move backward to next beginning of line mark. | |
f3e03a42 | 443 | Argument NUM is the number of BOL marks to move." |
3bef4fb9 KH |
444 | (interactive "p") |
445 | (edt-check-prefix num) | |
f3e03a42 GM |
446 | (let ((beg (edt-current-line))) |
447 | (if (bolp) | |
448 | (forward-line (* -1 num)) | |
3bef4fb9 | 449 | (progn |
f3e03a42 GM |
450 | (setq num (1- num)) |
451 | (forward-line (* -1 num)))) | |
452 | (edt-top-check beg num)) | |
4ea0e84a | 453 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 454 | |
3bef4fb9 KH |
455 | |
456 | ;;; | |
457 | ;;; EOL (End of Line) | |
458 | ;;; | |
459 | ||
460 | (defun edt-end-of-line-forward (num) | |
461 | "Move forward to next end of line mark. | |
f3e03a42 | 462 | Argument NUM is the number of EOL marks to move." |
3bef4fb9 KH |
463 | (interactive "p") |
464 | (edt-check-prefix num) | |
f3e03a42 GM |
465 | (let ((beg (edt-current-line))) |
466 | (forward-char) | |
467 | (end-of-line num) | |
468 | (edt-bottom-check beg num)) | |
4ea0e84a | 469 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 470 | |
3bef4fb9 KH |
471 | |
472 | (defun edt-end-of-line-backward (num) | |
473 | "Move backward to next end of line mark. | |
f3e03a42 | 474 | Argument NUM is the number of EOL marks to move." |
3bef4fb9 KH |
475 | (interactive "p") |
476 | (edt-check-prefix num) | |
f3e03a42 GM |
477 | (let ((beg (edt-current-line))) |
478 | (end-of-line (1- num)) | |
479 | (edt-top-check beg num)) | |
4ea0e84a | 480 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 481 | |
3bef4fb9 KH |
482 | |
483 | (defun edt-end-of-line (num) | |
484 | "Move in current direction to next end of line mark. | |
f3e03a42 | 485 | Argument NUM is the number of EOL marks to move." |
3bef4fb9 KH |
486 | (interactive "p") |
487 | (if (equal edt-direction-string edt-forward-string) | |
488 | (edt-end-of-line-forward num) | |
f3e03a42 | 489 | (edt-end-of-line-backward num))) |
3bef4fb9 KH |
490 | |
491 | ;;; | |
492 | ;;; WORD | |
493 | ;;; | |
494 | ;;; This one is a tad messy. To emulate EDT's behavior everywhere in | |
495 | ;;; the file (beginning of file, end of file, beginning of line, end | |
f3e03a42 | 496 | ;;; of line, etc.) it takes a bit of special handling. |
a1506d29 | 497 | ;;; |
3bef4fb9 KH |
498 | ;;; The variable edt-word-entities contains a list of characters which |
499 | ;;; are to be viewed as distinct words where ever they appear in the | |
f3e03a42 | 500 | ;;; buffer. This emulates the EDT line mode command SET ENTITY WORD. |
3bef4fb9 KH |
501 | |
502 | ||
503 | (defun edt-one-word-forward () | |
504 | "Move forward to first character of next word." | |
505 | (interactive) | |
506 | (if (eobp) | |
507 | (error "End of buffer")) | |
508 | (if (eolp) | |
509 | (forward-char) | |
f3e03a42 GM |
510 | (progn |
511 | (if (memq (following-char) edt-word-entities) | |
512 | (forward-char) | |
513 | (while (and | |
514 | (not (eolp)) | |
515 | (not (eobp)) | |
516 | (not (eq ?\ (char-syntax (following-char)))) | |
517 | (not (memq (following-char) edt-word-entities))) | |
518 | (forward-char))) | |
519 | (while (and | |
520 | (not (eolp)) | |
521 | (not (eobp)) | |
522 | (eq ?\ (char-syntax (following-char))) | |
523 | (not (memq (following-char) edt-word-entities))) | |
524 | (forward-char)))) | |
4ea0e84a | 525 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
526 | |
527 | (defun edt-one-word-backward () | |
528 | "Move backward to first character of previous word." | |
529 | (interactive) | |
530 | (if (bobp) | |
531 | (error "Beginning of buffer")) | |
532 | (if (bolp) | |
533 | (backward-char) | |
f3e03a42 GM |
534 | (progn |
535 | (backward-char) | |
536 | (while (and | |
537 | (not (bolp)) | |
538 | (not (bobp)) | |
539 | (eq ?\ (char-syntax (following-char))) | |
540 | (not (memq (following-char) edt-word-entities))) | |
541 | (backward-char)) | |
542 | (if (not (memq (following-char) edt-word-entities)) | |
543 | (while (and | |
544 | (not (bolp)) | |
545 | (not (bobp)) | |
546 | (not (eq ?\ (char-syntax (preceding-char)))) | |
547 | (not (memq (preceding-char) edt-word-entities))) | |
548 | (backward-char))))) | |
4ea0e84a | 549 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
550 | |
551 | (defun edt-word-forward (num) | |
552 | "Move forward to first character of next word. | |
f3e03a42 | 553 | Argument NUM is the number of words to move." |
3bef4fb9 KH |
554 | (interactive "p") |
555 | (edt-check-prefix num) | |
556 | (while (> num 0) | |
557 | (edt-one-word-forward) | |
558 | (setq num (1- num)))) | |
559 | ||
560 | (defun edt-word-backward (num) | |
561 | "Move backward to first character of previous word. | |
f3e03a42 | 562 | Argument NUM is the number of words to move." |
3bef4fb9 KH |
563 | (interactive "p") |
564 | (edt-check-prefix num) | |
565 | (while (> num 0) | |
566 | (edt-one-word-backward) | |
567 | (setq num (1- num)))) | |
568 | ||
569 | (defun edt-word (num) | |
570 | "Move in current direction to first character of next word. | |
f3e03a42 | 571 | Argument NUM is the number of words to move." |
3bef4fb9 KH |
572 | (interactive "p") |
573 | (if (equal edt-direction-string edt-forward-string) | |
574 | (edt-word-forward num) | |
f3e03a42 | 575 | (edt-word-backward num))) |
3bef4fb9 KH |
576 | |
577 | ;;; | |
578 | ;;; CHAR | |
579 | ;;; | |
580 | ||
581 | (defun edt-character (num) | |
582 | "Move in current direction to next character. | |
f3e03a42 | 583 | Argument NUM is the number of characters to move." |
3bef4fb9 KH |
584 | (interactive "p") |
585 | (edt-check-prefix num) | |
586 | (if (equal edt-direction-string edt-forward-string) | |
587 | (forward-char num) | |
f3e03a42 | 588 | (backward-char num)) |
4ea0e84a | 589 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
590 | |
591 | ;;; | |
592 | ;;; LINE | |
593 | ;;; | |
594 | ;;; When direction is set to BACKUP, LINE behaves just like BEGINNING | |
595 | ;;; OF LINE in EDT. So edt-line-backward is not really needed as a | |
596 | ;;; separate function. | |
597 | ||
598 | (defun edt-line-backward (num) | |
599 | "Move backward to next beginning of line mark. | |
f3e03a42 | 600 | Argument NUM is the number of BOL marks to move." |
3bef4fb9 KH |
601 | (interactive "p") |
602 | (edt-beginning-of-line num)) | |
603 | ||
604 | (defun edt-line-forward (num) | |
605 | "Move forward to next beginning of line mark. | |
f3e03a42 | 606 | Argument NUM is the number of BOL marks to move." |
3bef4fb9 KH |
607 | (interactive "p") |
608 | (edt-check-prefix num) | |
f3e03a42 GM |
609 | (let ((beg (edt-current-line))) |
610 | (forward-line num) | |
611 | (edt-bottom-check beg num)) | |
4ea0e84a | 612 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
613 | |
614 | (defun edt-line (num) | |
615 | "Move in current direction to next beginning of line mark. | |
f3e03a42 | 616 | Argument NUM is the number of BOL marks to move." |
3bef4fb9 KH |
617 | (interactive "p") |
618 | (if (equal edt-direction-string edt-forward-string) | |
619 | (edt-line-forward num) | |
f3e03a42 GM |
620 | (edt-line-backward num))) |
621 | ||
622 | ;;; | |
623 | ;;; UP and DOWN Arrows | |
624 | ;;; | |
625 | ||
626 | (defun edt-next-line (num) | |
627 | "Move cursor down one line. | |
628 | Argument NUM is the number of lines to move." | |
629 | (interactive "p") | |
630 | (edt-check-prefix num) | |
631 | (let ((beg (edt-current-line))) | |
7caf6803 | 632 | (forward-line num) |
f3e03a42 | 633 | (edt-bottom-check beg num)) |
4ea0e84a | 634 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 GM |
635 | |
636 | (defun edt-previous-line (num) | |
637 | "Move cursor up one line. | |
638 | Argument NUM is the number of lines to move." | |
639 | (interactive "p") | |
640 | (edt-check-prefix num) | |
641 | (let ((beg (edt-current-line))) | |
7caf6803 | 642 | (forward-line (- num)) |
f3e03a42 | 643 | (edt-top-check beg num)) |
4ea0e84a | 644 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 645 | |
3bef4fb9 KH |
646 | |
647 | ;;; | |
648 | ;;; TOP | |
649 | ;;; | |
650 | ||
651 | (defun edt-top () | |
652 | "Move cursor to the beginning of buffer." | |
653 | (interactive) | |
f3e03a42 | 654 | (goto-char (point-min)) |
4ea0e84a | 655 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
656 | |
657 | ;;; | |
658 | ;;; BOTTOM | |
659 | ;;; | |
660 | ||
661 | (defun edt-bottom () | |
662 | "Move cursor to the end of buffer." | |
663 | (interactive) | |
664 | (goto-char (point-max)) | |
665 | (edt-line-to-bottom-of-window)) | |
666 | ||
667 | ;;; | |
668 | ;;; FIND | |
669 | ;;; | |
670 | ||
671 | (defun edt-find-forward (&optional find) | |
f3e03a42 GM |
672 | "Find first occurrence of a string in forward direction and save it. |
673 | Optional argument FIND is t is this function is called from `edt-find'." | |
3bef4fb9 KH |
674 | (interactive) |
675 | (if (not find) | |
f3e03a42 GM |
676 | (set 'edt-find-last-text (read-string "Search forward: "))) |
677 | (let* ((left nil) | |
678 | (beg (edt-current-line)) | |
679 | (height (window-height)) | |
680 | (top-percent | |
681 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
682 | (bottom-percent | |
683 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
684 | (top-margin (/ (* height top-percent) 100)) | |
685 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
686 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
687 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
688 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
689 | (far (save-excursion | |
690 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
691 | (if (search-forward edt-find-last-text) | |
692 | (progn | |
693 | (search-backward edt-find-last-text) | |
694 | (edt-set-match) | |
695 | (cond((> (point) far) | |
696 | (setq left (save-excursion (forward-line height))) | |
697 | (if (= 0 left) (recenter top-margin) | |
698 | (recenter (- left bottom-up-margin)))) | |
699 | (t | |
700 | (and (> (point) bottom) (recenter bottom-margin))))))) | |
4ea0e84a | 701 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
702 | |
703 | (defun edt-find-backward (&optional find) | |
f3e03a42 GM |
704 | "Find first occurrence of a string in the backward direction and save it. |
705 | Optional argument FIND is t if this function is called from `edt-find'." | |
3bef4fb9 KH |
706 | (interactive) |
707 | (if (not find) | |
f3e03a42 GM |
708 | (set 'edt-find-last-text (read-string "Search backward: "))) |
709 | (let* ((left nil) | |
710 | (beg (edt-current-line)) | |
711 | (height (window-height)) | |
712 | (top-percent | |
713 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
714 | (bottom-percent | |
715 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
716 | (top-margin (/ (* height top-percent) 100)) | |
717 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
718 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
719 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
720 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
721 | (far (save-excursion | |
722 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
723 | (if (search-backward edt-find-last-text) | |
724 | (edt-set-match)) | |
725 | (and (< (point) top) (recenter (min beg top-margin)))) | |
4ea0e84a | 726 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
727 | |
728 | (defun edt-find () | |
896b7329 | 729 | "Find first occurrence of string in current direction and save it." |
3bef4fb9 | 730 | (interactive) |
f3e03a42 | 731 | (set 'edt-find-last-text (read-string "Search: ")) |
3bef4fb9 KH |
732 | (if (equal edt-direction-string edt-forward-string) |
733 | (edt-find-forward t) | |
734 | (edt-find-backward t))) | |
a1506d29 | 735 | |
3bef4fb9 KH |
736 | |
737 | ;;; | |
738 | ;;; FNDNXT | |
739 | ;;; | |
740 | ||
741 | (defun edt-find-next-forward () | |
896b7329 | 742 | "Find next occurrence of a string in forward direction." |
3bef4fb9 | 743 | (interactive) |
f3e03a42 GM |
744 | (let* ((left nil) |
745 | (beg (edt-current-line)) | |
746 | (height (window-height)) | |
747 | (top-percent | |
748 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
749 | (bottom-percent | |
750 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
751 | (top-margin (/ (* height top-percent) 100)) | |
752 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
753 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
754 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
755 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
756 | (far (save-excursion | |
757 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
758 | (forward-char 1) | |
759 | (if (search-forward edt-find-last-text nil t) | |
760 | (progn | |
761 | (search-backward edt-find-last-text) | |
762 | (edt-set-match) | |
763 | (cond((> (point) far) | |
764 | (setq left (save-excursion (forward-line height))) | |
765 | (if (= 0 left) (recenter top-margin) | |
766 | (recenter (- left bottom-up-margin)))) | |
767 | (t | |
768 | (and (> (point) bottom) (recenter bottom-margin))))) | |
3bef4fb9 | 769 | (progn |
f3e03a42 GM |
770 | (backward-char 1) |
771 | (error "Search failed: \"%s\"" edt-find-last-text)))) | |
4ea0e84a | 772 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
773 | |
774 | (defun edt-find-next-backward () | |
896b7329 | 775 | "Find next occurrence of a string in backward direction." |
3bef4fb9 | 776 | (interactive) |
f3e03a42 GM |
777 | (let* ((left nil) |
778 | (beg (edt-current-line)) | |
779 | (height (window-height)) | |
780 | (top-percent | |
781 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
782 | (bottom-percent | |
783 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
784 | (top-margin (/ (* height top-percent) 100)) | |
785 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
786 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
787 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
788 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
789 | (far (save-excursion | |
790 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
791 | (if (not (search-backward edt-find-last-text nil t)) | |
792 | (error "Search failed: \"%s\"" edt-find-last-text) | |
3bef4fb9 | 793 | (progn |
f3e03a42 GM |
794 | (edt-set-match) |
795 | (and (< (point) top) (recenter (min beg top-margin)))))) | |
4ea0e84a | 796 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
797 | |
798 | (defun edt-find-next () | |
896b7329 | 799 | "Find next occurrence of a string in current direction." |
3bef4fb9 KH |
800 | (interactive) |
801 | (if (equal edt-direction-string edt-forward-string) | |
802 | (edt-find-next-forward) | |
f3e03a42 | 803 | (edt-find-next-backward))) |
a1506d29 | 804 | |
3bef4fb9 KH |
805 | ;;; |
806 | ;;; APPEND | |
807 | ;;; | |
808 | ||
809 | (defun edt-append () | |
810 | "Append this kill region to last killed region." | |
811 | (interactive "*") | |
812 | (edt-check-selection) | |
813 | (append-next-kill) | |
814 | (kill-region (mark) (point)) | |
815 | (message "Selected text APPENDED to kill ring")) | |
816 | ||
817 | ;;; | |
818 | ;;; DEL L | |
819 | ;;; | |
820 | ||
821 | (defun edt-delete-line (num) | |
822 | "Delete from cursor up to and including the end of line mark. | |
f3e03a42 | 823 | Argument NUM is the number of lines to delete." |
3bef4fb9 KH |
824 | (interactive "*p") |
825 | (edt-check-prefix num) | |
4bf7f5d1 RS |
826 | (let ((beg (point))) |
827 | (forward-line num) | |
828 | (if (not (eq (preceding-char) ?\n)) | |
3bef4fb9 | 829 | (insert "\n")) |
4bf7f5d1 | 830 | (setq edt-last-deleted-lines |
3bef4fb9 | 831 | (buffer-substring beg (point))) |
4bf7f5d1 RS |
832 | (delete-region beg (point)))) |
833 | ||
3bef4fb9 KH |
834 | ;;; |
835 | ;;; DEL EOL | |
836 | ;;; | |
837 | ||
838 | (defun edt-delete-to-end-of-line (num) | |
839 | "Delete from cursor up to but excluding the end of line mark. | |
f3e03a42 | 840 | Argument NUM is the number of lines to delete." |
3bef4fb9 KH |
841 | (interactive "*p") |
842 | (edt-check-prefix num) | |
4bf7f5d1 RS |
843 | (let ((beg (point))) |
844 | (forward-char 1) | |
845 | (end-of-line num) | |
846 | (setq edt-last-deleted-lines | |
3bef4fb9 | 847 | (buffer-substring beg (point))) |
4bf7f5d1 RS |
848 | (delete-region beg (point)))) |
849 | ||
3bef4fb9 KH |
850 | ;;; |
851 | ;;; SELECT | |
852 | ;;; | |
853 | ||
854 | (defun edt-select-mode (arg) | |
e4360875 | 855 | "Turn EDT select mode off if ARG is nil; otherwise, turn EDT select mode on. |
3bef4fb9 KH |
856 | In select mode, selected text is highlighted." |
857 | (if arg | |
858 | (progn | |
859 | (make-local-variable 'edt-select-mode) | |
f3e03a42 | 860 | (setq edt-select-mode 'edt-select-mode-current) |
3bef4fb9 KH |
861 | (setq rect-start-point (window-point))) |
862 | (progn | |
863 | (kill-local-variable 'edt-select-mode))) | |
864 | (force-mode-line-update)) | |
865 | ||
866 | (defun edt-select () | |
867 | "Set mark at cursor and start text selection." | |
f3e03a42 GM |
868 | (interactive) |
869 | (set-mark-command nil)) | |
3bef4fb9 KH |
870 | |
871 | (defun edt-reset () | |
872 | "Cancel text selection." | |
873 | (interactive) | |
4ea0e84a | 874 | (if (featurep 'emacs) |
f3e03a42 GM |
875 | (deactivate-mark) |
876 | (zmacs-deactivate-region))) | |
3bef4fb9 KH |
877 | |
878 | ;;; | |
879 | ;;; CUT | |
880 | ;;; | |
881 | ||
882 | (defun edt-cut () | |
883 | "Deletes selected text but copies to kill ring." | |
884 | (interactive "*") | |
885 | (edt-check-selection) | |
886 | (kill-region (mark) (point)) | |
887 | (message "Selected text CUT to kill ring")) | |
888 | ||
889 | ;;; | |
890 | ;;; DELETE TO BEGINNING OF LINE | |
891 | ;;; | |
892 | ||
893 | (defun edt-delete-to-beginning-of-line (num) | |
e4360875 | 894 | "Delete from cursor to beginning of line. |
f3e03a42 | 895 | Argument NUM is the number of lines to delete." |
3bef4fb9 KH |
896 | (interactive "*p") |
897 | (edt-check-prefix num) | |
4bf7f5d1 | 898 | (let ((beg (point))) |
3bef4fb9 KH |
899 | (edt-beginning-of-line num) |
900 | (setq edt-last-deleted-lines | |
901 | (buffer-substring (point) beg)) | |
4bf7f5d1 RS |
902 | (delete-region beg (point)))) |
903 | ||
3bef4fb9 KH |
904 | ;;; |
905 | ;;; DEL W | |
906 | ;;; | |
907 | ||
908 | (defun edt-delete-word (num) | |
909 | "Delete from cursor up to but excluding first character of next word. | |
f3e03a42 | 910 | Argument NUM is the number of words to delete." |
3bef4fb9 KH |
911 | (interactive "*p") |
912 | (edt-check-prefix num) | |
4bf7f5d1 | 913 | (let ((beg (point))) |
3bef4fb9 KH |
914 | (edt-word-forward num) |
915 | (setq edt-last-deleted-words (buffer-substring beg (point))) | |
4bf7f5d1 RS |
916 | (delete-region beg (point)))) |
917 | ||
3bef4fb9 KH |
918 | ;;; |
919 | ;;; DELETE TO BEGINNING OF WORD | |
920 | ;;; | |
921 | ||
922 | (defun edt-delete-to-beginning-of-word (num) | |
923 | "Delete from cursor to beginning of word. | |
f3e03a42 | 924 | Argument NUM is the number of words to delete." |
3bef4fb9 KH |
925 | (interactive "*p") |
926 | (edt-check-prefix num) | |
927 | (let ((beg (point))) | |
928 | (edt-word-backward num) | |
929 | (setq edt-last-deleted-words (buffer-substring (point) beg)) | |
930 | (delete-region beg (point)))) | |
931 | ||
932 | ;;; | |
933 | ;;; DEL C | |
934 | ;;; | |
935 | ||
936 | (defun edt-delete-character (num) | |
937 | "Delete character under cursor. | |
f3e03a42 | 938 | Argument NUM is the number of characters to delete." |
3bef4fb9 KH |
939 | (interactive "*p") |
940 | (edt-check-prefix num) | |
4bf7f5d1 | 941 | (setq edt-last-deleted-chars |
3bef4fb9 | 942 | (buffer-substring (point) (min (point-max) (+ (point) num)))) |
4bf7f5d1 RS |
943 | (delete-region (point) (min (point-max) (+ (point) num)))) |
944 | ||
3bef4fb9 KH |
945 | ;;; |
946 | ;;; DELETE CHAR | |
947 | ;;; | |
948 | ||
949 | (defun edt-delete-previous-character (num) | |
950 | "Delete character in front of cursor. | |
f3e03a42 | 951 | Argument NUM is the number of characters to delete." |
3bef4fb9 KH |
952 | (interactive "*p") |
953 | (edt-check-prefix num) | |
4bf7f5d1 | 954 | (setq edt-last-deleted-chars |
3bef4fb9 | 955 | (buffer-substring (max (point-min) (- (point) num)) (point))) |
4bf7f5d1 RS |
956 | (delete-region (max (point-min) (- (point) num)) (point))) |
957 | ||
3bef4fb9 KH |
958 | ;;; |
959 | ;;; UND L | |
960 | ;;; | |
961 | ||
962 | (defun edt-undelete-line () | |
963 | "Undelete previous deleted line(s)." | |
964 | (interactive "*") | |
965 | (point-to-register 1) | |
966 | (insert edt-last-deleted-lines) | |
967 | (register-to-point 1)) | |
968 | ||
969 | ;;; | |
970 | ;;; UND W | |
971 | ;;; | |
972 | ||
973 | (defun edt-undelete-word () | |
e4360875 | 974 | "Undelete previous deleted word(s)." |
3bef4fb9 KH |
975 | (interactive "*") |
976 | (point-to-register 1) | |
977 | (insert edt-last-deleted-words) | |
978 | (register-to-point 1)) | |
979 | ||
980 | ;;; | |
981 | ;;; UND C | |
982 | ;;; | |
983 | ||
984 | (defun edt-undelete-character () | |
e4360875 | 985 | "Undelete previous deleted character(s)." |
3bef4fb9 KH |
986 | (interactive "*") |
987 | (point-to-register 1) | |
988 | (insert edt-last-deleted-chars) | |
989 | (register-to-point 1)) | |
990 | ||
991 | ;;; | |
992 | ;;; REPLACE | |
993 | ;;; | |
994 | ||
995 | (defun edt-replace () | |
996 | "Replace marked section with last CUT (killed) text." | |
997 | (interactive "*") | |
f3e03a42 GM |
998 | (if (edt-check-match) |
999 | (replace-match (car kill-ring-yank-pointer)) | |
1000 | (progn | |
1001 | (exchange-point-and-mark) | |
1002 | (let ((beg (point))) | |
1003 | (exchange-point-and-mark) | |
1004 | (delete-region beg (point))) | |
1005 | (yank)))) | |
1006 | ||
1007 | ;;; | |
1008 | ;;; SUBS | |
1009 | ;;; | |
1010 | ||
1011 | (defun edt-substitute (num) | |
1012 | "Replace the selected region with the contents of the CUT buffer and. | |
1013 | Repeat the most recent FIND command. (The Emacs kill ring is used as | |
a1506d29 | 1014 | the CUT buffer.) |
f3e03a42 | 1015 | Argument NUM is the repeat count. A positive value indicates the of times |
669858fb | 1016 | to repeat the substitution. A negative argument means replace all occurrences |
f3e03a42 GM |
1017 | of the search text." |
1018 | (interactive "p") | |
1019 | (cond ((or edt-select-mode (edt-check-match)) | |
1020 | (while (and (not (= num 0)) (or edt-select-mode (edt-check-match))) | |
1021 | (edt-replace) | |
1022 | (edt-find-next) | |
1023 | (setq num (1- num)))) | |
1024 | (t | |
1025 | (error "No selection active")))) | |
1026 | ||
1027 | (defun edt-set-match nil | |
1028 | "Set markers at match beginning and end." | |
1029 | ;; Add one to beginning mark so it stays with the first character of | |
1030 | ;; the string even if characters are added just before the string. | |
1031 | (setq edt-match-beginning-mark (copy-marker (1+ (match-beginning 0)))) | |
1032 | (setq edt-match-end-mark (copy-marker (match-end 0)))) | |
1033 | ||
1034 | (defun edt-unset-match nil | |
1035 | "Unset match beginning and end markers." | |
1036 | (set-marker edt-match-beginning-mark nil) | |
1037 | (set-marker edt-match-end-mark nil)) | |
1038 | ||
1039 | (defun edt-match-beginning nil | |
1040 | "Return the location of the last match beginning." | |
1041 | (1- (marker-position edt-match-beginning-mark))) | |
1042 | ||
1043 | (defun edt-match-end nil | |
1044 | "Return the location of the last match end." | |
1045 | (marker-position edt-match-end-mark)) | |
1046 | ||
1047 | (defun edt-check-match nil | |
1048 | "Return t if point is between edt-match markers. | |
1049 | Otherwise sets the edt-match markers to nil and returns nil." | |
1050 | ;; make sure 1- marker is in this buffer | |
1051 | ;; 2- point is at or after beginning marker | |
1052 | ;; 3- point is before ending marker, or in the case of | |
1053 | ;; zero length regions (like bol, or eol) that the | |
1054 | ;; beginning, end, and point are equal. | |
1055 | (cond ((and | |
1056 | (equal (marker-buffer edt-match-beginning-mark) (current-buffer)) | |
1057 | (>= (point) (1- (marker-position edt-match-beginning-mark))) | |
1058 | (or | |
1059 | (< (point) (marker-position edt-match-end-mark)) | |
1060 | (and (= (1- (marker-position edt-match-beginning-mark)) | |
1061 | (marker-position edt-match-end-mark)) | |
1062 | (= (marker-position edt-match-end-mark) (point))))) t) | |
1063 | (t | |
1064 | (edt-unset-match) nil))) | |
1065 | ||
1066 | (defun edt-show-match-markers nil | |
1067 | "Show the values of the match markers." | |
1068 | (interactive) | |
1069 | (if (markerp edt-match-beginning-mark) | |
1070 | (let ((beg (marker-position edt-match-beginning-mark))) | |
1071 | (message "(%s, %s) in %s -- current %s in %s" | |
1072 | (if beg (1- beg) nil) | |
1073 | (marker-position edt-match-end-mark) | |
1074 | (marker-buffer edt-match-end-mark) | |
1075 | (point) (current-buffer))))) | |
1076 | ||
3bef4fb9 KH |
1077 | |
1078 | ;;; | |
1079 | ;;; ADVANCE | |
1080 | ;;; | |
1081 | ||
1082 | (defun edt-advance () | |
e4360875 KH |
1083 | "Set movement direction forward. |
1084 | Also, execute command specified if in Minibuffer." | |
4bf7f5d1 | 1085 | (interactive) |
3bef4fb9 | 1086 | (setq edt-direction-string edt-forward-string) |
ca341104 | 1087 | (force-mode-line-update) |
f3e03a42 | 1088 | (if (string-equal " *Minibuf" |
3bef4fb9 | 1089 | (substring (buffer-name) 0 (min (length (buffer-name)) 9))) |
f3e03a42 | 1090 | (exit-minibuffer)) |
4ea0e84a | 1091 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 1092 | |
a1506d29 | 1093 | |
3bef4fb9 KH |
1094 | ;;; |
1095 | ;;; BACKUP | |
1096 | ;;; | |
4bf7f5d1 | 1097 | |
3bef4fb9 | 1098 | (defun edt-backup () |
e4360875 KH |
1099 | "Set movement direction backward. |
1100 | Also, execute command specified if in Minibuffer." | |
4bf7f5d1 | 1101 | (interactive) |
3bef4fb9 | 1102 | (setq edt-direction-string edt-backward-string) |
ca341104 | 1103 | (force-mode-line-update) |
f3e03a42 | 1104 | (if (string-equal " *Minibuf" |
3bef4fb9 | 1105 | (substring (buffer-name) 0 (min (length (buffer-name)) 9))) |
f3e03a42 | 1106 | (exit-minibuffer)) |
4ea0e84a | 1107 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
f3e03a42 | 1108 | |
3bef4fb9 KH |
1109 | |
1110 | ;;; | |
1111 | ;;; CHNGCASE | |
1112 | ;;; | |
f3e03a42 | 1113 | ;; This function is based upon Jeff Kowalski's case-flip function in his |
3bef4fb9 KH |
1114 | ;; tpu.el. |
1115 | ||
1116 | (defun edt-change-case (num) | |
1117 | "Change the case of specified characters. | |
1118 | If text selection IS active, then characters between the cursor and mark are | |
1119 | changed. If text selection is NOT active, there are two cases. First, if the | |
1120 | current direction is ADVANCE, then the prefix number of character(s) under and | |
1121 | following cursor are changed. Second, if the current direction is BACKUP, then | |
1122 | the prefix number of character(s) before the cursor are changed. Accepts a | |
1123 | positive prefix for the number of characters to change, but the prefix is | |
f3e03a42 GM |
1124 | ignored if text selection is active. |
1125 | Argument NUM is the numbers of consecutive characters to change." | |
3bef4fb9 KH |
1126 | (interactive "*p") |
1127 | (edt-check-prefix num) | |
1128 | (if edt-select-mode | |
1129 | (let ((end (max (mark) (point))) | |
1130 | (point-save (point))) | |
1131 | (goto-char (min (point) (mark))) | |
1132 | (while (not (eq (point) end)) | |
1133 | (funcall (if (<= ?a (following-char)) | |
1134 | 'upcase-region 'downcase-region) | |
1135 | (point) (1+ (point))) | |
1136 | (forward-char 1)) | |
1137 | (goto-char point-save)) | |
f3e03a42 GM |
1138 | (progn |
1139 | (if (string= edt-direction-string edt-backward-string) | |
1140 | (backward-char num)) | |
1141 | (while (> num 0) | |
1142 | (funcall (if (<= ?a (following-char)) | |
1143 | 'upcase-region 'downcase-region) | |
1144 | (point) (1+ (point))) | |
1145 | (forward-char 1) | |
1146 | (setq num (1- num)))))) | |
4bf7f5d1 | 1147 | |
3bef4fb9 KH |
1148 | ;;; |
1149 | ;;; DEFINE KEY | |
1150 | ;;; | |
1151 | ||
1152 | (defun edt-define-key () | |
1153 | "Assign an interactively-callable function to a specified key sequence. | |
f3e03a42 GM |
1154 | The current key definition is saved in `edt-last-replaced-key-definition'. |
1155 | Use `edt-restore-key' to restore last replaced key definition." | |
4bf7f5d1 | 1156 | (interactive) |
4ea0e84a | 1157 | (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
3bef4fb9 | 1158 | (let (edt-function |
f3e03a42 GM |
1159 | edt-key-definition) |
1160 | (setq edt-key-definition | |
1161 | (read-key-sequence "Press the key to be defined: ")) | |
4ea0e84a | 1162 | (if (if (featurep 'emacs) |
f3e03a42 GM |
1163 | (string-equal "\C-m" edt-key-definition) |
1164 | (string-equal "\C-m" (events-to-keys edt-key-definition))) | |
1165 | (message "Key not defined") | |
1166 | (progn | |
1167 | (setq edt-function (read-command "Enter command name: ")) | |
1168 | (if (string-equal "" edt-function) | |
1169 | (message "Key not defined") | |
1170 | (progn | |
1171 | (setq edt-last-replaced-key-definition | |
1172 | (lookup-key (current-global-map) edt-key-definition)) | |
1173 | (define-key (current-global-map) | |
1174 | edt-key-definition edt-function))))))) | |
4bf7f5d1 | 1175 | |
3bef4fb9 KH |
1176 | ;;; |
1177 | ;;; FORM FEED INSERT | |
1178 | ;;; | |
4bf7f5d1 | 1179 | |
3bef4fb9 KH |
1180 | (defun edt-form-feed-insert (num) |
1181 | "Insert form feed character at cursor position. | |
f3e03a42 | 1182 | Argument NUM is the number of form feeds to insert." |
3bef4fb9 KH |
1183 | (interactive "*p") |
1184 | (edt-check-prefix num) | |
1185 | (while (> num 0) | |
1186 | (insert ?\f) | |
1187 | (setq num (1- num)))) | |
4bf7f5d1 | 1188 | |
3bef4fb9 KH |
1189 | ;;; |
1190 | ;;; TAB INSERT | |
1191 | ;;; | |
4bf7f5d1 | 1192 | |
3bef4fb9 KH |
1193 | (defun edt-tab-insert (num) |
1194 | "Insert tab character at cursor position. | |
b9d67a77 | 1195 | Argument NUM is the number of tabs to insert." |
3bef4fb9 KH |
1196 | (interactive "*p") |
1197 | (edt-check-prefix num) | |
1198 | (while (> num 0) | |
1199 | (insert ?\t) | |
1200 | (setq num (1- num)))) | |
1201 | ||
1202 | ;;; | |
1203 | ;;; Check Prefix | |
1204 | ;;; | |
1205 | ||
1206 | (defun edt-check-prefix (num) | |
f3e03a42 GM |
1207 | "Indicate error if prefix is not positive. |
1208 | Argument NUM is the prefix value tested." | |
3bef4fb9 KH |
1209 | (if (<= num 0) |
1210 | (error "Prefix must be positive"))) | |
a1506d29 | 1211 | |
3bef4fb9 KH |
1212 | ;;; |
1213 | ;;; Check Selection | |
1214 | ;;; | |
1215 | ||
1216 | (defun edt-check-selection () | |
1217 | "Indicate error if EDT selection is not active." | |
1218 | (if (not edt-select-mode) | |
1219 | (error "Selection NOT active"))) | |
f3e03a42 GM |
1220 | |
1221 | ;;; | |
1222 | ;;; Scroll Margins | |
1223 | ;;; | |
1224 | ||
1225 | (defun edt-top-check (beg lines) | |
1226 | "Enforce scroll margin at the top of screen. | |
1227 | Argument BEG is the starting line number before cursor was moved. | |
1228 | Argument LINES is the number of lines the cursor moved toward the top." | |
1229 | (let ((margin (/ (* (window-height) edt-top-scroll-margin) 100))) | |
1230 | (cond ((< beg margin) (recenter beg)) | |
1231 | ((< (- beg lines) margin) (recenter margin))))) | |
1232 | ||
1233 | (defun edt-bottom-check (beg lines) | |
1234 | "Enforce scroll margin at the bottom of screen. | |
1235 | Argument BEG is the starting line number before cursor was moved. | |
1236 | Argument LINES is the number of lines the cursor moved toward the bottom." | |
1237 | (let* ((height (window-height)) | |
1238 | (margin (+ 1 (/ (* height edt-bottom-scroll-margin) 100))) | |
1239 | ;; subtract 1 from height because it includes mode line | |
1240 | (difference (- height margin 1))) | |
1241 | (cond ((> beg difference) (recenter beg)) | |
4ea0e84a | 1242 | ((and (featurep 'xemacs) (> (+ beg lines 1) difference)) |
f3e03a42 GM |
1243 | (recenter (- margin))) |
1244 | ((> (+ beg lines) difference) (recenter (- margin)))))) | |
1245 | ||
1246 | (defun edt-current-line nil | |
1247 | "Return the vertical position of point in the selected window. | |
1248 | Top line is 0. Counts each text line only once, even if it wraps." | |
1249 | (+ (count-lines (window-start) (point)) (if (= (current-column) 0) 1 0) -1)) | |
1250 | ||
1251 | ;;;###autoload | |
1252 | (defun edt-set-scroll-margins (top bottom) | |
1253 | "Set scroll margins. | |
1254 | Argument TOP is the top margin in number of lines or percent of window. | |
1255 | Argument BOTTOM is the bottom margin in number of lines or percent of window." | |
1256 | (interactive | |
1257 | "sEnter top scroll margin (N lines or N%% or RETURN for current value): \ | |
1258 | \nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): ") | |
1259 | ;; set top scroll margin | |
1260 | (or (string= top "") | |
1261 | (if (string= "%" (substring top -1)) | |
027a4b6b | 1262 | (setq edt-top-scroll-margin (string-to-number top)) |
f3e03a42 | 1263 | (setq edt-top-scroll-margin |
027a4b6b | 1264 | (/ (1- (+ (* (string-to-number top) 100) (window-height))) |
f3e03a42 GM |
1265 | (window-height))))) |
1266 | ;; set bottom scroll margin | |
1267 | (or (string= bottom "") | |
1268 | (if (string= "%" (substring bottom -1)) | |
027a4b6b | 1269 | (setq edt-bottom-scroll-margin (string-to-number bottom)) |
f3e03a42 | 1270 | (setq edt-bottom-scroll-margin |
027a4b6b | 1271 | (/ (1- (+ (* (string-to-number bottom) 100) (window-height))) |
f3e03a42 GM |
1272 | (window-height))))) |
1273 | ;; report scroll margin settings if running interactively | |
1274 | (and (interactive-p) | |
1275 | (message "Scroll margins set. Top = %s%%, Bottom = %s%%" | |
1276 | edt-top-scroll-margin edt-bottom-scroll-margin))) | |
1277 | ||
3bef4fb9 KH |
1278 | \f |
1279 | ;;;; | |
1280 | ;;;; ENHANCEMENTS AND ADDITIONS FOR EDT KEYPAD MODE | |
1281 | ;;;; | |
1282 | ||
a1506d29 | 1283 | ;;; |
3bef4fb9 KH |
1284 | ;;; Several enhancements and additions to EDT keypad mode commands are |
1285 | ;;; provided here. Some of these have been motivated by similar | |
1286 | ;;; TPU/EVE and EVE-Plus commands. Others are new. | |
1287 | ||
3bef4fb9 KH |
1288 | ;;; |
1289 | ;;; CHANGE DIRECTION | |
1290 | ;;; | |
4bf7f5d1 | 1291 | |
3bef4fb9 KH |
1292 | (defun edt-change-direction () |
1293 | "Toggle movement direction." | |
1294 | (interactive) | |
f3e03a42 | 1295 | (if (equal edt-direction-string edt-forward-string) |
3bef4fb9 | 1296 | (edt-backup) |
f3e03a42 | 1297 | (edt-advance))) |
3bef4fb9 KH |
1298 | |
1299 | ;;; | |
1300 | ;;; TOGGLE SELECT | |
1301 | ;;; | |
1302 | ||
1303 | (defun edt-toggle-select () | |
1304 | "Toggle to start (or cancel) text selection." | |
1305 | (interactive) | |
1306 | (if edt-select-mode | |
1307 | (edt-reset) | |
1308 | (edt-select))) | |
1309 | ||
1310 | ;;; | |
1311 | ;;; SENTENCE | |
1312 | ;;; | |
1313 | ||
1314 | (defun edt-sentence-forward (num) | |
1315 | "Move forward to start of next sentence. | |
f3e03a42 | 1316 | Argument NUM is the positive number of sentences to move." |
4bf7f5d1 | 1317 | (interactive "p") |
3bef4fb9 | 1318 | (edt-check-prefix num) |
f3e03a42 GM |
1319 | (let* ((left nil) |
1320 | (beg (edt-current-line)) | |
1321 | (height (window-height)) | |
1322 | (top-percent | |
1323 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
1324 | (bottom-percent | |
1325 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
1326 | (top-margin (/ (* height top-percent) 100)) | |
1327 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
1328 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
1329 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
1330 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
1331 | (far (save-excursion | |
1332 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
1333 | (if (eobp) | |
1334 | (progn | |
1335 | (error "End of buffer")) | |
3bef4fb9 | 1336 | (progn |
f3e03a42 GM |
1337 | (forward-sentence num) |
1338 | (forward-word 1) | |
1339 | (backward-sentence))) | |
1340 | (cond((> (point) far) | |
1341 | (setq left (save-excursion (forward-line height))) | |
1342 | (if (= 0 left) (recenter top-margin) | |
1343 | (recenter (- left bottom-up-margin)))) | |
1344 | (t | |
1345 | (and (> (point) bottom) (recenter bottom-margin))))) | |
4ea0e84a | 1346 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1347 | |
3bef4fb9 KH |
1348 | (defun edt-sentence-backward (num) |
1349 | "Move backward to next sentence beginning. | |
f3e03a42 | 1350 | Argument NUM is the positive number of sentences to move." |
4bf7f5d1 | 1351 | (interactive "p") |
3bef4fb9 | 1352 | (edt-check-prefix num) |
f3e03a42 GM |
1353 | (let* ((left nil) |
1354 | (beg (edt-current-line)) | |
1355 | (height (window-height)) | |
1356 | (top-percent | |
1357 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
1358 | (bottom-percent | |
1359 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
1360 | (top-margin (/ (* height top-percent) 100)) | |
1361 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
1362 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
1363 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
1364 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
1365 | (far (save-excursion | |
1366 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
1367 | (if (eobp) | |
1368 | (progn | |
1369 | (error "End of buffer")) | |
1370 | (backward-sentence num)) | |
1371 | (and (< (point) top) (recenter (min beg top-margin)))) | |
4ea0e84a | 1372 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1373 | |
3bef4fb9 KH |
1374 | (defun edt-sentence (num) |
1375 | "Move in current direction to next sentence. | |
f3e03a42 | 1376 | Argument NUM is the positive number of sentences to move." |
4bf7f5d1 | 1377 | (interactive "p") |
3bef4fb9 KH |
1378 | (if (equal edt-direction-string edt-forward-string) |
1379 | (edt-sentence-forward num) | |
f3e03a42 | 1380 | (edt-sentence-backward num))) |
3bef4fb9 KH |
1381 | |
1382 | ;;; | |
1383 | ;;; PARAGRAPH | |
1384 | ;;; | |
4bf7f5d1 | 1385 | |
3bef4fb9 KH |
1386 | (defun edt-paragraph-forward (num) |
1387 | "Move forward to beginning of paragraph. | |
f3e03a42 | 1388 | Argument NUM is the positive number of paragraphs to move." |
4bf7f5d1 | 1389 | (interactive "p") |
3bef4fb9 | 1390 | (edt-check-prefix num) |
f3e03a42 GM |
1391 | (let* ((left nil) |
1392 | (beg (edt-current-line)) | |
1393 | (height (window-height)) | |
1394 | (top-percent | |
1395 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
1396 | (bottom-percent | |
1397 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
1398 | (top-margin (/ (* height top-percent) 100)) | |
1399 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
1400 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
1401 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
1402 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
1403 | (far (save-excursion | |
1404 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
1405 | (while (> num 0) | |
1406 | (forward-paragraph (+ num 1)) | |
1407 | (start-of-paragraph-text) | |
1408 | (if (eolp) | |
7caf6803 | 1409 | (forward-line 1)) |
f3e03a42 GM |
1410 | (setq num (1- num))) |
1411 | (cond((> (point) far) | |
1412 | (setq left (save-excursion (forward-line height))) | |
1413 | (if (= 0 left) (recenter top-margin) | |
1414 | (recenter (- left bottom-up-margin)))) | |
1415 | (t | |
1416 | (and (> (point) bottom) (recenter bottom-margin))))) | |
4ea0e84a | 1417 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1418 | |
3bef4fb9 KH |
1419 | (defun edt-paragraph-backward (num) |
1420 | "Move backward to beginning of paragraph. | |
f3e03a42 | 1421 | Argument NUM is the positive number of paragraphs to move." |
4bf7f5d1 | 1422 | (interactive "p") |
3bef4fb9 | 1423 | (edt-check-prefix num) |
f3e03a42 GM |
1424 | (let* ((left nil) |
1425 | (beg (edt-current-line)) | |
1426 | (height (window-height)) | |
1427 | (top-percent | |
1428 | (if (= 0 edt-top-scroll-margin) 10 edt-top-scroll-margin)) | |
1429 | (bottom-percent | |
1430 | (if (= 0 edt-bottom-scroll-margin) 15 edt-bottom-scroll-margin)) | |
1431 | (top-margin (/ (* height top-percent) 100)) | |
1432 | (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100))) | |
1433 | (bottom-margin (max beg (- height bottom-up-margin 1))) | |
1434 | (top (save-excursion (move-to-window-line top-margin) (point))) | |
1435 | (bottom (save-excursion (move-to-window-line bottom-margin) (point))) | |
1436 | (far (save-excursion | |
1437 | (goto-char bottom) (forward-line (- height 2)) (point)))) | |
1438 | (while (> num 0) | |
1439 | (start-of-paragraph-text) | |
1440 | (setq num (1- num))) | |
1441 | (and (< (point) top) (recenter (min beg top-margin)))) | |
4ea0e84a | 1442 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1443 | |
3bef4fb9 KH |
1444 | (defun edt-paragraph (num) |
1445 | "Move in current direction to next paragraph. | |
f3e03a42 | 1446 | Argument NUM is the positive number of paragraphs to move." |
3bef4fb9 KH |
1447 | (interactive "p") |
1448 | (if (equal edt-direction-string edt-forward-string) | |
1449 | (edt-paragraph-forward num) | |
f3e03a42 | 1450 | (edt-paragraph-backward num))) |
3bef4fb9 KH |
1451 | |
1452 | ;;; | |
1453 | ;;; RESTORE KEY | |
1454 | ;;; | |
1455 | ||
1456 | (defun edt-restore-key () | |
e4360875 | 1457 | "Restore last replaced key definition. |
f3e03a42 | 1458 | Definition is stored in `edt-last-replaced-key-definition'." |
4bf7f5d1 | 1459 | (interactive) |
4ea0e84a | 1460 | (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
3bef4fb9 KH |
1461 | (if edt-last-replaced-key-definition |
1462 | (progn | |
f3e03a42 GM |
1463 | (let (edt-key-definition) |
1464 | (set 'edt-key-definition | |
3bef4fb9 | 1465 | (read-key-sequence "Press the key to be restored: ")) |
4ea0e84a | 1466 | (if (if (featurep 'emacs) |
f3e03a42 GM |
1467 | (string-equal "\C-m" edt-key-definition) |
1468 | (string-equal "\C-m" (events-to-keys edt-key-definition))) | |
1469 | (message "Key not restored") | |
1470 | (progn | |
1471 | (define-key (current-global-map) | |
1472 | edt-key-definition edt-last-replaced-key-definition) | |
4ea0e84a | 1473 | (if (featurep 'emacs) |
f3e03a42 GM |
1474 | (message "Key definition for %s has been restored." |
1475 | edt-key-definition) | |
1476 | (message "Key definition for %s has been restored." | |
1477 | (events-to-keys edt-key-definition))))))) | |
1478 | (error "No replaced key definition to restore!"))) | |
3bef4fb9 KH |
1479 | |
1480 | ;;; | |
1481 | ;;; WINDOW TOP | |
1482 | ;;; | |
4bf7f5d1 | 1483 | |
3bef4fb9 KH |
1484 | (defun edt-window-top () |
1485 | "Move the cursor to the top of the window." | |
4bf7f5d1 | 1486 | (interactive) |
3bef4fb9 KH |
1487 | (let ((start-column (current-column))) |
1488 | (move-to-window-line 0) | |
f3e03a42 | 1489 | (move-to-column start-column)) |
4ea0e84a | 1490 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1491 | |
3bef4fb9 KH |
1492 | ;;; |
1493 | ;;; WINDOW BOTTOM | |
1494 | ;;; | |
4bf7f5d1 | 1495 | |
3bef4fb9 KH |
1496 | (defun edt-window-bottom () |
1497 | "Move the cursor to the bottom of the window." | |
1498 | (interactive) | |
1499 | (let ((start-column (current-column))) | |
1500 | (move-to-window-line (- (window-height) 2)) | |
f3e03a42 | 1501 | (move-to-column start-column)) |
4ea0e84a | 1502 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
1503 | |
1504 | ;;; | |
1505 | ;;; SCROLL WINDOW LINE | |
1506 | ;;; | |
1507 | ||
1508 | (defun edt-scroll-window-forward-line () | |
e4360875 | 1509 | "Move window forward one line leaving cursor at position in window." |
3bef4fb9 | 1510 | (interactive) |
f3e03a42 | 1511 | (scroll-up 1) |
4ea0e84a | 1512 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
1513 | |
1514 | (defun edt-scroll-window-backward-line () | |
e4360875 | 1515 | "Move window backward one line leaving cursor at position in window." |
3bef4fb9 | 1516 | (interactive) |
f3e03a42 | 1517 | (scroll-down 1) |
4ea0e84a | 1518 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
1519 | |
1520 | (defun edt-scroll-line () | |
1521 | "Move window one line in current direction." | |
1522 | (interactive) | |
1523 | (if (equal edt-direction-string edt-forward-string) | |
1524 | (edt-scroll-window-forward-line) | |
f3e03a42 | 1525 | (edt-scroll-window-backward-line))) |
4bf7f5d1 | 1526 | |
3bef4fb9 KH |
1527 | ;;; |
1528 | ;;; SCROLL WINDOW | |
1529 | ;;; | |
f3e03a42 GM |
1530 | ;;; Scroll a window (less one line) at a time. Leave cursor in center of |
1531 | ;;; window. | |
3bef4fb9 KH |
1532 | |
1533 | (defun edt-scroll-window-forward (num) | |
1534 | "Scroll forward one window in buffer, less one line. | |
f3e03a42 | 1535 | Argument NUM is the positive number of windows to move." |
3bef4fb9 KH |
1536 | (interactive "p") |
1537 | (edt-check-prefix num) | |
1538 | (scroll-up (- (* (window-height) num) 2)) | |
1539 | (edt-line-forward (/ (- (window-height) 1) 2))) | |
1540 | ||
1541 | (defun edt-scroll-window-backward (num) | |
1542 | "Scroll backward one window in buffer, less one line. | |
f3e03a42 | 1543 | Argument NUM is the positive number of windows to move." |
3bef4fb9 KH |
1544 | (interactive "p") |
1545 | (edt-check-prefix num) | |
1546 | (scroll-down (- (* (window-height) num) 2)) | |
1547 | (edt-line-backward (/ (- (window-height) 1) 2))) | |
1548 | ||
1549 | (defun edt-scroll-window (num) | |
1550 | "Scroll one window in buffer, less one line, in current direction. | |
f3e03a42 | 1551 | Argument NUM is the positive number of windows to move." |
3bef4fb9 KH |
1552 | (interactive "p") |
1553 | (if (equal edt-direction-string edt-forward-string) | |
1554 | (edt-scroll-window-forward num) | |
f3e03a42 | 1555 | (edt-scroll-window-backward num))) |
3bef4fb9 KH |
1556 | |
1557 | ;;; | |
1558 | ;;; LINE TO BOTTOM OF WINDOW | |
1559 | ;;; | |
4bf7f5d1 RS |
1560 | |
1561 | (defun edt-line-to-bottom-of-window () | |
3bef4fb9 | 1562 | "Move the current line to the bottom of the window." |
4bf7f5d1 | 1563 | (interactive) |
f3e03a42 | 1564 | (recenter -1) |
4ea0e84a | 1565 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1566 | |
3bef4fb9 KH |
1567 | ;;; |
1568 | ;;; LINE TO TOP OF WINDOW | |
1569 | ;;; | |
1570 | ||
4bf7f5d1 RS |
1571 | (defun edt-line-to-top-of-window () |
1572 | "Move the current line to the top of the window." | |
1573 | (interactive) | |
f3e03a42 | 1574 | (recenter 0) |
4ea0e84a | 1575 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
4bf7f5d1 | 1576 | |
3bef4fb9 KH |
1577 | ;;; |
1578 | ;;; LINE TO MIDDLE OF WINDOW | |
1579 | ;;; | |
4bf7f5d1 | 1580 | |
3bef4fb9 KH |
1581 | (defun edt-line-to-middle-of-window () |
1582 | "Move window so line with cursor is in the middle of the window." | |
4bf7f5d1 | 1583 | (interactive) |
f3e03a42 | 1584 | (recenter '(4)) |
4ea0e84a | 1585 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
1586 | |
1587 | ;;; | |
1588 | ;;; GOTO PERCENTAGE | |
1589 | ;;; | |
1590 | ||
1591 | (defun edt-goto-percentage (num) | |
f3e03a42 GM |
1592 | "Move to specified percentage in buffer from top of buffer. |
1593 | Argument NUM is the percentage into the buffer to move." | |
3bef4fb9 KH |
1594 | (interactive "NGoto-percentage: ") |
1595 | (if (or (> num 100) (< num 0)) | |
1596 | (error "Percentage %d out of range 0 < percent < 100" num) | |
f3e03a42 | 1597 | (goto-char (/ (* (point-max) num) 100))) |
4ea0e84a | 1598 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 KH |
1599 | |
1600 | ;;; | |
1601 | ;;; FILL REGION | |
1602 | ;;; | |
1603 | ||
1604 | (defun edt-fill-region () | |
1605 | "Fill selected text." | |
f3e03a42 | 1606 | (interactive "*") |
3bef4fb9 KH |
1607 | (edt-check-selection) |
1608 | (fill-region (point) (mark))) | |
1609 | ||
1610 | ;;; | |
1611 | ;;; INDENT OR FILL REGION | |
1612 | ;;; | |
1613 | ||
1614 | (defun edt-indent-or-fill-region () | |
1615 | "Fill region in text modes, indent region in programming language modes." | |
f3e03a42 | 1616 | (interactive "*") |
dabbbb65 | 1617 | (if (string= paragraph-start "$\\|\f") |
4bf7f5d1 | 1618 | (indent-region (point) (mark) nil) |
f3e03a42 | 1619 | (fill-region (point) (mark)))) |
4bf7f5d1 | 1620 | |
153ef845 | 1621 | |
5cec3056 | 1622 | (declare-function c-mark-function "cc-cmds" ()) |
3bef4fb9 KH |
1623 | ;;; |
1624 | ;;; MARK SECTION WISELY | |
1625 | ;;; | |
1626 | ||
1627 | (defun edt-mark-section-wisely () | |
f3e03a42 | 1628 | "Mark the section in a manner consistent with the `major-mode'. |
4668b9f9 RS |
1629 | Uses `mark-defun' for Emacs-Lisp and Lisp, and for Fortran, |
1630 | `c-mark-function' for C, | |
f3e03a42 | 1631 | and `mark-paragraph' for other modes." |
4bf7f5d1 | 1632 | (interactive) |
3bef4fb9 KH |
1633 | (if edt-select-mode |
1634 | (progn | |
1635 | (edt-reset)) | |
f3e03a42 GM |
1636 | (progn |
1637 | (cond ((or (eq major-mode 'emacs-lisp-mode) | |
4668b9f9 | 1638 | (eq major-mode 'fortran-mode) |
f3e03a42 GM |
1639 | (eq major-mode 'lisp-mode)) |
1640 | (mark-defun) | |
1641 | (message "Lisp defun selected")) | |
1642 | ((eq major-mode 'c-mode) | |
4668b9f9 | 1643 | (c-mark-function) |
f3e03a42 | 1644 | (message "C function selected")) |
f3e03a42 GM |
1645 | (t (mark-paragraph) |
1646 | (message "Paragraph selected")))))) | |
3bef4fb9 KH |
1647 | |
1648 | ;;; | |
1649 | ;;; COPY | |
1650 | ;;; | |
1651 | ||
1652 | (defun edt-copy () | |
1653 | "Copy selected region to kill ring, but don't delete it!" | |
1654 | (interactive) | |
1655 | (edt-check-selection) | |
1656 | (copy-region-as-kill (mark) (point)) | |
1657 | (edt-reset) | |
1658 | (message "Selected text COPIED to kill ring")) | |
1659 | ||
1660 | ;;; | |
1661 | ;;; CUT or COPY | |
1662 | ;;; | |
1663 | ||
1664 | (defun edt-cut-or-copy () | |
1665 | "Cuts (or copies) selected text to kill ring. | |
f3e03a42 GM |
1666 | Cuts selected text if `buffer-read-only' is nil. |
1667 | Copies selected text if `buffer-read-only' is t." | |
3bef4fb9 KH |
1668 | (interactive) |
1669 | (if buffer-read-only | |
1670 | (edt-copy) | |
f3e03a42 | 1671 | (edt-cut))) |
3bef4fb9 KH |
1672 | |
1673 | ;;; | |
1674 | ;;; DELETE ENTIRE LINE | |
1675 | ;;; | |
1676 | ||
1677 | (defun edt-delete-entire-line () | |
1678 | "Delete entire line regardless of cursor position in the line." | |
1679 | (interactive "*") | |
1680 | (beginning-of-line) | |
1681 | (edt-delete-line 1)) | |
1682 | ||
1683 | ;;; | |
1684 | ;;; DUPLICATE LINE | |
1685 | ;;; | |
1686 | ||
1687 | (defun edt-duplicate-line (num) | |
f3e03a42 GM |
1688 | "Duplicate the line of text containing the cursor. |
1689 | Argument NUM is the number of times to duplicate the line." | |
3bef4fb9 KH |
1690 | (interactive "*p") |
1691 | (edt-check-prefix num) | |
1692 | (let ((old-column (current-column)) | |
1693 | (count num)) | |
1694 | (edt-delete-entire-line) | |
1695 | (edt-undelete-line) | |
1696 | (while (> count 0) | |
1697 | (edt-undelete-line) | |
1698 | (setq count (1- count))) | |
1699 | (edt-line-forward num) | |
1700 | (move-to-column old-column))) | |
1701 | ||
1702 | ;;; | |
1703 | ;;; DUPLICATE WORD | |
1704 | ;;; | |
1705 | ||
1706 | (defun edt-duplicate-word() | |
1707 | "Duplicate word (or rest of word) found directly above cursor, if any." | |
1708 | (interactive "*") | |
1709 | (let ((start (point)) | |
1710 | (start-column (current-column))) | |
1711 | (forward-line -1) | |
1712 | (move-to-column start-column) | |
1713 | (if (and (not (equal start (point))) | |
1714 | (not (eolp))) | |
1715 | (progn | |
1716 | (if (and (equal ?\t (preceding-char)) | |
1717 | (< start-column (current-column))) | |
1718 | (backward-char)) | |
1719 | (let ((beg (point))) | |
1720 | (edt-one-word-forward) | |
1721 | (setq edt-last-copied-word (buffer-substring beg (point)))) | |
1722 | (forward-line) | |
1723 | (move-to-column start-column) | |
1724 | (insert edt-last-copied-word)) | |
f3e03a42 GM |
1725 | (progn |
1726 | (if (not (equal start (point))) | |
1727 | (forward-line)) | |
1728 | (move-to-column start-column) | |
1729 | (error "Nothing to duplicate!"))))) | |
3bef4fb9 KH |
1730 | |
1731 | ;;; | |
1732 | ;;; KEY NOT ASSIGNED | |
1733 | ;;; | |
1734 | ||
1735 | (defun edt-key-not-assigned () | |
1736 | "Displays message that key has not been assigned to a function." | |
1737 | (interactive) | |
1738 | (error "Key not assigned")) | |
1739 | ||
1740 | ;;; | |
1741 | ;;; TOGGLE CAPITALIZATION OF WORD | |
1742 | ;;; | |
1743 | ||
1744 | (defun edt-toggle-capitalization-of-word () | |
1745 | "Toggle the capitalization of the current word and move forward to next." | |
1746 | (interactive "*") | |
1747 | (edt-one-word-forward) | |
1748 | (edt-one-word-backward) | |
1749 | (edt-change-case 1) | |
1750 | (edt-one-word-backward) | |
1751 | (edt-one-word-forward)) | |
1752 | ||
1753 | ;;; | |
1754 | ;;; ELIMINATE ALL TABS | |
1755 | ;;; | |
1756 | ||
1757 | (defun edt-eliminate-all-tabs () | |
1758 | "Convert all tabs to spaces in the entire buffer." | |
1759 | (interactive "*") | |
1760 | (untabify (point-min) (point-max)) | |
1761 | (message "TABS converted to SPACES")) | |
1762 | ||
1763 | ;;; | |
1764 | ;;; DISPLAY THE TIME | |
1765 | ;;; | |
1766 | ||
1767 | (defun edt-display-the-time () | |
1768 | "Display the current time." | |
1769 | (interactive) | |
4ea0e84a | 1770 | (if (featurep 'xemacs) (setq zmacs-region-stays t)) |
4668b9f9 | 1771 | (message "%s" (current-time-string))) |
3bef4fb9 KH |
1772 | |
1773 | ;;; | |
1774 | ;;; LEARN | |
1775 | ;;; | |
1776 | ||
1777 | (defun edt-learn () | |
1778 | "Learn a sequence of key strokes to bind to a key." | |
1779 | (interactive) | |
1780 | (if (eq defining-kbd-macro t) | |
1781 | (edt-remember) | |
f3e03a42 | 1782 | (start-kbd-macro nil))) |
3bef4fb9 KH |
1783 | |
1784 | ;;; | |
1785 | ;;; REMEMBER | |
1786 | ;;; | |
1787 | ||
1788 | (defun edt-remember () | |
f3e03a42 | 1789 | "Store the sequence of key strokes started by `edt-learn' to a key." |
3bef4fb9 KH |
1790 | (interactive) |
1791 | (if (eq defining-kbd-macro nil) | |
1792 | (error "Nothing to remember!") | |
f3e03a42 GM |
1793 | (progn |
1794 | (end-kbd-macro nil) | |
1795 | (let (edt-key-definition) | |
1796 | (set 'edt-key-definition | |
1797 | (read-key-sequence "Enter key for binding: ")) | |
4ea0e84a | 1798 | (if (if (featurep 'emacs) |
f3e03a42 GM |
1799 | (string-equal "\C-m" edt-key-definition) |
1800 | (string-equal "\C-m" (events-to-keys edt-key-definition))) | |
1801 | (message "Key sequence not remembered") | |
1802 | (progn | |
1803 | (set 'edt-learn-macro-count (+ edt-learn-macro-count 1)) | |
1804 | (setq edt-last-replaced-key-definition | |
1805 | (lookup-key (current-global-map) | |
1806 | edt-key-definition)) | |
1807 | (define-key (current-global-map) edt-key-definition | |
1808 | (name-last-kbd-macro | |
1809 | (intern (concat "last-learned-sequence-" | |
1810 | (int-to-string edt-learn-macro-count))))))))))) | |
3bef4fb9 KH |
1811 | |
1812 | ;;; | |
1813 | ;;; EXIT | |
1814 | ;;; | |
1815 | ||
1816 | (defun edt-exit () | |
1817 | "Save current buffer, ask to save other buffers, and then exit Emacs." | |
1818 | (interactive) | |
1819 | (save-buffer) | |
1820 | (save-buffers-kill-emacs)) | |
1821 | ||
a1506d29 | 1822 | ;;; |
3bef4fb9 KH |
1823 | ;;; QUIT |
1824 | ;;; | |
1825 | ||
1826 | (defun edt-quit () | |
f3e03a42 GM |
1827 | "Quit Emacs without saving buffer modifications. |
1828 | Warn user that modifications will be lost." | |
3bef4fb9 | 1829 | (interactive) |
f3e03a42 GM |
1830 | (let ((list (buffer-list)) |
1831 | (working t)) | |
1832 | (while (and list working) | |
1833 | (let ((buffer (car list))) | |
1834 | (if (and (buffer-file-name buffer) (buffer-modified-p buffer)) | |
1835 | (if (edt-y-or-n-p | |
1836 | "Modifications will not be saved, continue quitting? ") | |
1837 | (kill-emacs) | |
1838 | (setq working nil))) | |
1839 | (setq list (cdr list)))) | |
a1506d29 | 1840 | (if working (kill-emacs)))) |
3bef4fb9 | 1841 | |
a1506d29 | 1842 | ;;; |
3bef4fb9 KH |
1843 | ;;; SPLIT WINDOW |
1844 | ;;; | |
1845 | ||
1846 | (defun edt-split-window () | |
1847 | "Split current window and place cursor in the new window." | |
1848 | (interactive) | |
1849 | (split-window) | |
f3e03a42 | 1850 | (other-window 1) |
4ea0e84a | 1851 | (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
3bef4fb9 | 1852 | |
3bef4fb9 KH |
1853 | ;;; |
1854 | ;;; COPY RECTANGLE | |
1855 | ;;; | |
1856 | ||
1857 | (defun edt-copy-rectangle () | |
1858 | "Copy a rectangle of text between mark and cursor to register." | |
1859 | (interactive) | |
1860 | (edt-check-selection) | |
1861 | (copy-rectangle-to-register 3 (region-beginning) (region-end) nil) | |
1862 | (edt-reset) | |
1863 | (message "Selected rectangle COPIED to register")) | |
1864 | ||
1865 | ;;; | |
1866 | ;;; CUT RECTANGLE | |
1867 | ;;; | |
1868 | ||
1869 | (defun edt-cut-rectangle-overstrike-mode () | |
e4360875 KH |
1870 | "Cut a rectangle of text between mark and cursor to register. |
1871 | Replace cut characters with spaces and moving cursor back to | |
1872 | upper left corner." | |
3bef4fb9 KH |
1873 | (interactive "*") |
1874 | (edt-check-selection) | |
1875 | (setq edt-rect-start-point (region-beginning)) | |
1876 | (picture-clear-rectangle-to-register (region-beginning) (region-end) 3) | |
1877 | (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point) | |
1878 | (message "Selected rectangle CUT to register")) | |
1879 | ||
1880 | (defun edt-cut-rectangle-insert-mode () | |
e4360875 KH |
1881 | "Cut a rectangle of text between mark and cursor to register. |
1882 | Move cursor back to upper left corner." | |
f3e03a42 | 1883 | (interactive "*") |
3bef4fb9 KH |
1884 | (edt-check-selection) |
1885 | (setq edt-rect-start-point (region-beginning)) | |
1886 | (picture-clear-rectangle-to-register (region-beginning) (region-end) 3 t) | |
1887 | (fixup-whitespace) | |
1888 | (set-window-point (get-buffer-window (window-buffer)) edt-rect-start-point) | |
1889 | (message "Selected rectangle CUT to register")) | |
1890 | ||
1891 | (defun edt-cut-rectangle () | |
1892 | "Cut a rectangular region of text to register. | |
e4360875 | 1893 | If overwrite mode is active, cut text is replaced with whitespace." |
3bef4fb9 KH |
1894 | (interactive "*") |
1895 | (if overwrite-mode | |
1896 | (edt-cut-rectangle-overstrike-mode) | |
f3e03a42 | 1897 | (edt-cut-rectangle-insert-mode))) |
3bef4fb9 KH |
1898 | |
1899 | ;;; | |
1900 | ;;; PASTE RECTANGLE | |
1901 | ;;; | |
1902 | ||
1903 | (defun edt-paste-rectangle-overstrike-mode () | |
1904 | "Paste a rectangular region of text from register, replacing text at cursor." | |
f3e03a42 | 1905 | (interactive "*") |
3bef4fb9 KH |
1906 | (picture-yank-rectangle-from-register 3)) |
1907 | ||
1908 | (defun edt-paste-rectangle-insert-mode () | |
1909 | "Paste previously deleted rectangular region, inserting text at cursor." | |
1910 | (interactive "*") | |
1911 | (picture-yank-rectangle-from-register 3 t)) | |
1912 | ||
1913 | (defun edt-paste-rectangle () | |
1914 | "Paste a rectangular region of text. | |
1915 | If overwrite mode is active, existing text is replace with text from register." | |
1916 | (interactive) | |
1917 | (if overwrite-mode | |
1918 | (edt-paste-rectangle-overstrike-mode) | |
f3e03a42 | 1919 | (edt-paste-rectangle-insert-mode))) |
3bef4fb9 KH |
1920 | |
1921 | ;;; | |
1922 | ;;; DOWNCASE REGION | |
1923 | ;;; | |
1924 | ||
1925 | (defun edt-lowercase () | |
1926 | "Change specified characters to lower case. | |
1927 | If text selection IS active, then characters between the cursor and | |
1928 | mark are changed. If text selection is NOT active, there are two | |
1929 | situations. If the current direction is ADVANCE, then the word under | |
1930 | the cursor is changed to lower case and the cursor is moved to rest at | |
1931 | the beginning of the next word. If the current direction is BACKUP, | |
1932 | the word prior to the word under the cursor is changed to lower case | |
1933 | and the cursor is left to rest at the beginning of that word." | |
1934 | (interactive "*") | |
1935 | (if edt-select-mode | |
1936 | (progn | |
1937 | (downcase-region (mark) (point))) | |
f3e03a42 GM |
1938 | (progn |
1939 | ;; Move to beginning of current word. | |
1940 | (if (and | |
1941 | (not (bobp)) | |
1942 | (not (eobp)) | |
1943 | (not (bolp)) | |
1944 | (not (eolp)) | |
1945 | (not (eq ?\ (char-syntax (preceding-char)))) | |
1946 | (not (memq (preceding-char) edt-word-entities)) | |
1947 | (not (memq (following-char) edt-word-entities))) | |
1948 | (edt-one-word-backward)) | |
1949 | (if (equal edt-direction-string edt-backward-string) | |
1950 | (edt-one-word-backward)) | |
1951 | (let ((beg (point))) | |
1952 | (edt-one-word-forward) | |
1953 | (downcase-region beg (point))) | |
1954 | (if (equal edt-direction-string edt-backward-string) | |
1955 | (edt-one-word-backward))))) | |
3bef4fb9 KH |
1956 | |
1957 | ;;; | |
1958 | ;;; UPCASE REGION | |
1959 | ;;; | |
1960 | ||
1961 | (defun edt-uppercase () | |
1962 | "Change specified characters to upper case. | |
1963 | If text selection IS active, then characters between the cursor and | |
1964 | mark are changed. If text selection is NOT active, there are two | |
1965 | situations. If the current direction is ADVANCE, then the word under | |
1966 | the cursor is changed to upper case and the cursor is moved to rest at | |
1967 | the beginning of the next word. If the current direction is BACKUP, | |
1968 | the word prior to the word under the cursor is changed to upper case | |
1969 | and the cursor is left to rest at the beginning of that word." | |
1970 | (interactive "*") | |
1971 | (if edt-select-mode | |
1972 | (progn | |
1973 | (upcase-region (mark) (point))) | |
f3e03a42 GM |
1974 | (progn |
1975 | ;; Move to beginning of current word. | |
1976 | (if (and | |
1977 | (not (bobp)) | |
1978 | (not (eobp)) | |
1979 | (not (bolp)) | |
1980 | (not (eolp)) | |
1981 | (not (eq ?\ (char-syntax (preceding-char)))) | |
1982 | (not (memq (preceding-char) edt-word-entities)) | |
1983 | (not (memq (following-char) edt-word-entities))) | |
1984 | (edt-one-word-backward)) | |
1985 | (if (equal edt-direction-string edt-backward-string) | |
1986 | (edt-one-word-backward)) | |
1987 | (let ((beg (point))) | |
1988 | (edt-one-word-forward) | |
1989 | (upcase-region beg (point))) | |
1990 | (if (equal edt-direction-string edt-backward-string) | |
1991 | (edt-one-word-backward))))) | |
1992 | ||
1993 | ;;; | |
1994 | ;;; Functions used in loading LK-201 key mapping file. | |
1995 | ;;; | |
1996 | (defvar edt-last-answer nil | |
1997 | "Most recent response to `edt-y-or-n-p'.") | |
3bef4fb9 KH |
1998 | |
1999 | (defun edt-y-or-n-p (prompt &optional not-yes) | |
2000 | "Prompt for a y or n answer with positive default. | |
f3e03a42 GM |
2001 | Like Emacs `y-or-n-p', also accepts space as y and DEL as n. |
2002 | Argument PROMPT is the prompt string. | |
2003 | Optional argument NOT-YES changes the default to negative." | |
f0685fda | 2004 | (message "%s[%s]" prompt (if not-yes "n" "y")) |
3bef4fb9 KH |
2005 | (let ((doit t)) |
2006 | (while doit | |
2007 | (setq doit nil) | |
2008 | (let ((ans (read-char))) | |
2009 | (cond ((or (= ans ?y) (= ans ?Y) (= ans ?\ )) | |
2010 | (setq edt-last-answer t)) | |
2011 | ((or (= ans ?n) (= ans ?N) (= ans ?\C-?)) | |
2012 | (setq edt-last-answer nil)) | |
2013 | ((= ans ?\r) (setq edt-last-answer (not not-yes))) | |
2014 | (t | |
2015 | (setq doit t) (beep) | |
f0685fda KH |
2016 | (message "Please answer y or n. %s[%s]" |
2017 | prompt (if not-yes "n" "y"))))))) | |
3bef4fb9 | 2018 | edt-last-answer) |
f3e03a42 GM |
2019 | \f |
2020 | ;;; | |
2021 | ;;; INITIALIZATION COMMANDS. | |
2022 | ;;; | |
3bef4fb9 | 2023 | |
f3e03a42 GM |
2024 | ;;; |
2025 | ;;; Function used to load LK-201 key mapping file generated by edt-mapper.el. | |
2026 | ;;; | |
2027 | (defun edt-load-keys (file) | |
a1506d29 | 2028 | "Load the LK-201 key mapping FILE generated by edt-mapper.el. |
f3e03a42 GM |
2029 | If FILE is nil, which is the normal case, try to load a default file. |
2030 | The default file names are based upon the window system, terminal | |
2031 | type, and version of Emacs in use: GNU Emacs or XEmacs (aka Lucid | |
2032 | Emacs). If a default file does not exist, ask user if one should be | |
2033 | created." | |
2034 | (interactive "fKey definition file: ") | |
3bef4fb9 KH |
2035 | (cond (file |
2036 | (setq file (expand-file-name file))) | |
f3e03a42 GM |
2037 | (edt-keys-file |
2038 | (setq file (expand-file-name edt-keys-file))) | |
2039 | (t | |
2040 | (setq file | |
2041 | (expand-file-name | |
2042 | (concat | |
2043 | "~/.edt-" edt-emacs-variant | |
2044 | (if edt-term (concat "-" edt-term)) | |
2045 | (if edt-xserver (concat "-" edt-xserver)) | |
a1506d29 | 2046 | (if edt-window-system |
f3e03a42 GM |
2047 | (concat "-" (upcase (symbol-name edt-window-system)))) |
2048 | "-keys"))))) | |
3bef4fb9 KH |
2049 | (cond ((file-readable-p file) |
2050 | (load-file file)) | |
2051 | (t | |
2052 | (switch-to-buffer "*scratch*") | |
2053 | (erase-buffer) | |
2054 | (insert " | |
2055 | ||
f3e03a42 | 2056 | Ack!! You're running the Enhanced EDT Emulation without loading an |
a1506d29 | 2057 | EDT key mapping file. To create an EDT key mapping file, run the |
f3e03a42 GM |
2058 | edt-mapper.el program. It is safest to run it from an Emacs loaded |
2059 | without any of your own customizations found in your .emacs file, etc. | |
2060 | The reason for this is that some user customizations confuse edt-mapper. | |
2061 | You can do this by quitting Emacs and then invoking Emacs again as | |
2062 | follows: | |
3bef4fb9 KH |
2063 | |
2064 | emacs -q -l edt-mapper.el | |
a1506d29 | 2065 | |
f3e03a42 GM |
2066 | [NOTE: If you do nothing out of the ordinary in your .emacs file, and |
2067 | the search for edt-mapper.el is successful, you can try running it now.] | |
2068 | ||
3bef4fb9 | 2069 | The file edt-mapper.el includes these same directions on how to |
5d137be3 | 2070 | use it! Perhaps it's lying around here someplace. \n ") |
3bef4fb9 KH |
2071 | (let ((file "edt-mapper.el") |
2072 | (found nil) | |
2073 | (path nil) | |
2074 | (search-list (append (list (expand-file-name ".")) load-path))) | |
2075 | (while (and (not found) search-list) | |
2076 | (setq path (concat (car search-list) | |
2077 | (if (string-match "/$" (car search-list)) "" "/") | |
2078 | file)) | |
2079 | (if (and (file-exists-p path) (not (file-directory-p path))) | |
2080 | (setq found t)) | |
2081 | (setq search-list (cdr search-list))) | |
2082 | (cond (found | |
2083 | (insert (format | |
2084 | "Ah yes, there it is, in \n\n %s \n\n" path)) | |
2085 | (if (edt-y-or-n-p "Do you want to run it now? ") | |
2086 | (load-file path) | |
f3e03a42 | 2087 | (error "EDT Emulation not configured"))) |
3bef4fb9 KH |
2088 | (t |
2089 | (insert "Nope, I can't seem to find it. :-(\n\n") | |
2090 | (sit-for 20) | |
f3e03a42 GM |
2091 | (error "EDT Emulation not configured"))))))) |
2092 | ||
2093 | ;;; | |
2094 | ;;; Turning the EDT Emulation on and off. | |
2095 | ;;; | |
4bf7f5d1 | 2096 | |
f9f9507e | 2097 | ;;;###autoload |
4bf7f5d1 | 2098 | (defun edt-emulation-on () |
3bef4fb9 KH |
2099 | "Turn on EDT Emulation." |
2100 | (interactive) | |
f3e03a42 GM |
2101 | ;; If using pc window system (MS-DOS), set terminal type to pc. |
2102 | ;; If not a window system (GNU) or a tty window system (XEmacs), | |
2103 | ;; get terminal type. | |
2104 | (if (eq edt-window-system 'pc) | |
3bef4fb9 | 2105 | (setq edt-term "pc") |
f3e03a42 GM |
2106 | (if (or (not edt-window-system) (eq edt-window-system 'tty)) |
2107 | (setq edt-term (getenv "TERM")))) | |
2108 | ;; Look for for terminal configuration file for this terminal type. | |
2109 | ;; Otherwise, load the user's custom configuration file. | |
2110 | (if (or (not edt-window-system) (memq edt-window-system '(pc tty))) | |
2111 | (progn | |
2112 | ;; Load terminal-specific configuration file, if it exists for this | |
2113 | ;; terminal type. Note: All DEC VT series terminals are supported | |
2114 | ;; by the same terminal configuration file: edt-vt100.el. | |
2115 | (if (string-equal "vt" (substring edt-term 0 (min (length edt-term) 2))) | |
2116 | (setq edt-term "vt100")) | |
2117 | (let ((term edt-term) | |
2118 | hyphend) | |
2119 | (while (and term | |
2120 | (not (load (concat "edt-" term) t t))) | |
2121 | ;; Strip off last hyphen and what follows, then try again | |
2122 | (if (setq hyphend (string-match "[-_][^-_]+$" term)) | |
2123 | (setq term (substring term 0 hyphend)) | |
2124 | (setq term nil))) | |
2125 | ;; If no terminal-specific configuration file exists, load user's | |
2126 | ;; custom EDT terminal configuration file. | |
2127 | ;; If this is a pc running MS-DOS, then custom configuration files | |
2128 | ;; are not supported. So, if the file is missing, issue an error | |
2129 | ;; message. | |
2130 | (if (null term) | |
2131 | (if (equal edt-term "pc") | |
2132 | (error "Unable to find EDT terminal specific file edt-pc.el") | |
2133 | (edt-load-keys nil)) | |
2134 | (setq edt-term term)))) | |
2135 | (edt-load-keys nil)) | |
2136 | ;; Make highlighting of selected text work properly for EDT commands. | |
4ea0e84a | 2137 | (if (featurep 'emacs) |
f3e03a42 GM |
2138 | (progn |
2139 | (setq edt-orig-transient-mark-mode transient-mark-mode) | |
2140 | (add-hook 'activate-mark-hook | |
2141 | (function | |
2142 | (lambda () | |
2143 | (edt-select-mode t)))) | |
2144 | (add-hook 'deactivate-mark-hook | |
2145 | (function | |
2146 | (lambda () | |
2147 | (edt-select-mode nil))))) | |
2148 | (progn | |
2149 | (add-hook 'zmacs-activate-region-hook | |
2150 | (function | |
2151 | (lambda () | |
2152 | (edt-select-mode t)))) | |
2153 | (add-hook 'zmacs-deactivate-region-hook | |
2154 | (function | |
2155 | (lambda () | |
2156 | (edt-select-mode nil)))))) | |
2157 | ;; Load user's EDT custom key bindings file, if it exists. | |
2158 | ;; Otherwise, use the default bindings. | |
3bef4fb9 KH |
2159 | (if (load "edt-user" t t) |
2160 | (edt-user-emulation-setup) | |
2161 | (edt-default-emulation-setup))) | |
2162 | ||
2163 | (defun edt-emulation-off() | |
2164 | "Select original global key bindings, disabling EDT Emulation." | |
2165 | (interactive) | |
2166 | (use-global-map global-map) | |
2167 | (if (not edt-keep-current-page-delimiter) | |
2168 | (setq page-delimiter edt-orig-page-delimiter)) | |
2169 | (setq edt-direction-string "") | |
f3e03a42 | 2170 | (setq edt-select-mode-current nil) |
3bef4fb9 KH |
2171 | (edt-reset) |
2172 | (force-mode-line-update t) | |
4ea0e84a | 2173 | (if (featurep 'emacs) |
f3e03a42 | 2174 | (setq transient-mark-mode edt-orig-transient-mark-mode)) |
3bef4fb9 KH |
2175 | (message "Original key bindings restored; EDT Emulation disabled")) |
2176 | ||
2177 | (defun edt-default-emulation-setup (&optional user-setup) | |
f3e03a42 GM |
2178 | "Setup emulation of DEC's EDT editor. |
2179 | Optional argument USER-SETUP non-nil means called from function | |
2180 | `edt-user-emulation-setup'." | |
3bef4fb9 KH |
2181 | ;; Setup default EDT global map by copying global map bindings. |
2182 | ;; This preserves ESC and C-x prefix bindings and other bindings we | |
2183 | ;; wish to retain in EDT emulation mode keymaps. It also permits | |
2184 | ;; customization of these bindings in the EDT global maps without | |
2185 | ;; disturbing the original bindings in global-map. | |
2186 | (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix)) | |
2187 | (setq edt-default-global-map (copy-keymap (current-global-map))) | |
4ea0e84a | 2188 | (if (featurep 'emacs) |
f3e03a42 GM |
2189 | (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) |
2190 | (define-key edt-default-global-map [escape] 'edt-default-ESC-prefix)) | |
3bef4fb9 KH |
2191 | (define-prefix-command 'edt-default-gold-map) |
2192 | (edt-setup-default-bindings) | |
2193 | ;; If terminal has additional function keys, the terminal-specific | |
2194 | ;; initialization file can assign bindings to them via the optional | |
2195 | ;; function edt-setup-extra-default-bindings. | |
2196 | (if (fboundp 'edt-setup-extra-default-bindings) | |
2197 | (edt-setup-extra-default-bindings)) | |
2198 | ;; Variable needed by edt-learn. | |
2199 | (setq edt-learn-macro-count 0) | |
2200 | ;; Display EDT text selection active within the mode line | |
2201 | (or (assq 'edt-select-mode minor-mode-alist) | |
f3e03a42 | 2202 | (setq minor-mode-alist |
3bef4fb9 KH |
2203 | (cons '(edt-select-mode edt-select-mode) minor-mode-alist))) |
2204 | ;; Display EDT direction of motion within the mode line | |
2205 | (or (assq 'edt-direction-string minor-mode-alist) | |
2206 | (setq minor-mode-alist | |
2207 | (cons | |
f3e03a42 | 2208 | '(edt-direction-string edt-direction-string) minor-mode-alist))) |
3bef4fb9 KH |
2209 | (if user-setup |
2210 | (progn | |
2211 | (setq edt-user-map-configured t) | |
2212 | (fset 'edt-emulation-on (symbol-function 'edt-select-user-global-map))) | |
f3e03a42 GM |
2213 | (progn |
2214 | (fset 'edt-emulation-on (symbol-function 'edt-select-default-global-map)) | |
2215 | (edt-select-default-global-map)))) | |
3bef4fb9 KH |
2216 | |
2217 | (defun edt-user-emulation-setup () | |
2218 | "Setup user custom emulation of DEC's EDT editor." | |
2219 | ;; Initialize EDT default bindings. | |
2220 | (edt-default-emulation-setup t) | |
2221 | ;; Setup user EDT global map by copying default EDT global map bindings. | |
2222 | (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix)) | |
2223 | (setq edt-user-global-map (copy-keymap edt-default-global-map)) | |
4ea0e84a | 2224 | (if (featurep 'emacs) |
f3e03a42 GM |
2225 | (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) |
2226 | (define-key edt-user-global-map [escape] 'edt-user-ESC-prefix)) | |
3bef4fb9 KH |
2227 | ;; If terminal has additional function keys, the user's initialization |
2228 | ;; file can assign bindings to them via the optional | |
2229 | ;; function edt-setup-extra-default-bindings. | |
2230 | (define-prefix-command 'edt-user-gold-map) | |
2231 | (fset 'edt-user-gold-map (copy-keymap 'edt-default-gold-map)) | |
0dcd12a1 GM |
2232 | ;; This is a function that the user can define for custom bindings. |
2233 | ;; See etc/edt-user.doc. | |
2234 | (if (fboundp 'edt-setup-user-bindings) | |
2235 | (edt-setup-user-bindings)) | |
3bef4fb9 KH |
2236 | (edt-select-user-global-map)) |
2237 | ||
2238 | (defun edt-select-default-global-map() | |
2239 | "Select default EDT emulation key bindings." | |
2240 | (interactive) | |
4ea0e84a | 2241 | (if (featurep 'emacs) |
f3e03a42 | 2242 | (transient-mark-mode 1)) |
3bef4fb9 KH |
2243 | (use-global-map edt-default-global-map) |
2244 | (if (not edt-keep-current-page-delimiter) | |
2245 | (progn | |
2246 | (setq edt-orig-page-delimiter page-delimiter) | |
2247 | (setq page-delimiter "\f"))) | |
2248 | (setq edt-default-map-active t) | |
2249 | (edt-advance) | |
f3e03a42 | 2250 | (setq edt-select-mode-current 'edt-select-mode-string) |
3bef4fb9 KH |
2251 | (edt-reset) |
2252 | (message "Default EDT keymap active")) | |
2253 | ||
2254 | (defun edt-select-user-global-map() | |
2255 | "Select user EDT emulation custom key bindings." | |
2256 | (interactive) | |
2257 | (if edt-user-map-configured | |
2258 | (progn | |
4ea0e84a | 2259 | (if (featurep 'emacs) |
f3e03a42 | 2260 | (transient-mark-mode 1)) |
3bef4fb9 KH |
2261 | (use-global-map edt-user-global-map) |
2262 | (if (not edt-keep-current-page-delimiter) | |
2263 | (progn | |
2264 | (setq edt-orig-page-delimiter page-delimiter) | |
2265 | (setq page-delimiter "\f"))) | |
2266 | (setq edt-default-map-active nil) | |
2267 | (edt-advance) | |
f3e03a42 | 2268 | (setq edt-select-mode-current 'edt-select-mode-string) |
3bef4fb9 KH |
2269 | (edt-reset) |
2270 | (message "User EDT custom keymap active")) | |
f3e03a42 | 2271 | (error "User EDT custom keymap NOT configured!"))) |
3bef4fb9 KH |
2272 | |
2273 | (defun edt-switch-global-maps () | |
2274 | "Toggle between default EDT keymap and user EDT keymap." | |
2275 | (interactive) | |
f3e03a42 GM |
2276 | (if edt-default-map-active |
2277 | (edt-select-user-global-map) | |
3bef4fb9 KH |
2278 | (edt-select-default-global-map))) |
2279 | ||
f3e03a42 GM |
2280 | ;; |
2281 | ;; Functions used to set up DEFAULT bindings to EDT emulation functions. | |
2282 | ;; | |
2283 | ||
2284 | (defun edt-bind-function-key-default (function-key binding gold-binding) | |
2285 | "Binds LK-201 function keys to default bindings in the EDT Emulator. | |
2286 | Argument FUNCTION-KEY is the name of the function key or keypad function key. | |
2287 | Argument BINDING is the Emacs function to be bound to <KEY>. | |
2288 | Argument GOLD-BINDING is the Emacs function to be bound to GOLD <KEY>." | |
2289 | (let ((key (cdr (assoc function-key *EDT-keys*)))) | |
2290 | (if (and key (not (equal key ""))) | |
2291 | (progn | |
2292 | (define-key edt-default-global-map key binding) | |
2293 | (define-key 'edt-default-gold-map key gold-binding))))) | |
2294 | ||
2295 | (defun edt-bind-key-default (key binding) | |
2296 | "Bind key sequences to default bindings in the EDT Emulator. | |
2297 | Argument KEY is the name of a standard key or a function key. | |
2298 | Argument BINDING is the Emacs function to be bound to <KEY>." | |
2299 | (define-key edt-default-global-map key binding)) | |
2300 | ||
2301 | (defun edt-bind-gold-key-default (key gold-binding) | |
2302 | "Binds <GOLD> key sequences to default bindings in the EDT Emulator. | |
2303 | Argument KEY is the name of a standard key or a function key. | |
2304 | Argument GOLD-BINDING is the Emacs function to be bound to GOLD <KEY>." | |
2305 | (define-key 'edt-default-gold-map key gold-binding)) | |
2306 | ||
2307 | ;; | |
2308 | ;; Functions used to set up USER CUSTOM bindings to EDT emulation functions. | |
2309 | ;; | |
2310 | (defun edt-bind-function-key (function-key binding gold-binding) | |
2311 | "Binds LK-201 function keys to custom bindings in the EDT Emulator. | |
2312 | Argument FUNCTION-KEY is the name of the function key or keypad function key. | |
2313 | Argument BINDING is the Emacs function to be bound to <KEY>. | |
2314 | Argument GOLD-BINDING is the Emacs function to be bound to GOLD <KEY>." | |
2315 | (let ((key (cdr (assoc function-key *EDT-keys*)))) | |
2316 | (if (and key (not (equal key ""))) | |
2317 | (progn | |
2318 | (define-key edt-user-global-map key binding) | |
2319 | (define-key 'edt-user-gold-map key gold-binding))))) | |
2320 | ||
2321 | (defun edt-bind-key (key binding) | |
2322 | "Bind standard key sequences to custom bindings in the EDT Emulator. | |
2323 | Argument KEY is the name of a key. It can be a standard key or a function key. | |
2324 | Argument BINDING is the Emacs function to be bound to <KEY>." | |
2325 | (define-key edt-user-global-map key binding)) | |
2326 | ||
2327 | ;; For backward compatibility to existing edt-user.el files. | |
2328 | (fset 'edt-bind-standard-key (symbol-function 'edt-bind-key)) | |
2329 | ||
2330 | (defun edt-bind-gold-key (key gold-binding) | |
2331 | "Binds <GOLD> standard key sequences to custom bindings in the EDT Emulator. | |
2332 | Argument KEY is the name of a standard key or a function key. | |
2333 | Argument GOLD-BINDING is the Emacs function to be bound to GOLD <KEY>." | |
2334 | (define-key 'edt-user-gold-map key gold-binding)) | |
3bef4fb9 KH |
2335 | |
2336 | (defun edt-setup-default-bindings () | |
2337 | "Assigns default EDT Emulation keyboard bindings." | |
2338 | ||
2339 | ;; Function Key Bindings: Regular and GOLD. | |
2340 | ||
2341 | ;; VT100/VT200/VT300 PF1 (GOLD), PF2, PF3, PF4 Keys | |
f3e03a42 GM |
2342 | (edt-bind-function-key-default "PF1" |
2343 | 'edt-default-gold-map 'edt-mark-section-wisely) | |
2344 | (edt-bind-function-key-default "PF2" | |
2345 | 'edt-electric-keypad-help 'describe-function) | |
2346 | (edt-bind-function-key-default "PF3" 'edt-find-next 'edt-find) | |
2347 | (edt-bind-function-key-default "PF4" 'edt-delete-line 'edt-undelete-line) | |
3bef4fb9 KH |
2348 | |
2349 | ;; VT100/VT200/VT300 Arrow Keys | |
f3e03a42 GM |
2350 | (edt-bind-function-key-default "UP" 'edt-previous-line 'edt-window-top) |
2351 | (edt-bind-function-key-default "DOWN" 'edt-next-line 'edt-window-bottom) | |
2352 | (edt-bind-function-key-default "LEFT" 'backward-char 'edt-sentence-backward) | |
2353 | (edt-bind-function-key-default "RIGHT" 'forward-char 'edt-sentence-forward) | |
3bef4fb9 KH |
2354 | |
2355 | ;; VT100/VT200/VT300 Keypad Keys | |
f3e03a42 GM |
2356 | (edt-bind-function-key-default "KP0" 'edt-line 'open-line) |
2357 | (edt-bind-function-key-default "KP1" 'edt-word 'edt-change-case) | |
2358 | (edt-bind-function-key-default "KP2" | |
2359 | 'edt-end-of-line 'edt-delete-to-end-of-line) | |
2360 | (edt-bind-function-key-default "KP3" 'edt-character 'quoted-insert) | |
2361 | (edt-bind-function-key-default "KP4" 'edt-advance 'edt-bottom) | |
2362 | (edt-bind-function-key-default "KP5" 'edt-backup 'edt-top) | |
2363 | (edt-bind-function-key-default "KP6" 'edt-cut 'yank) | |
2364 | (edt-bind-function-key-default "KP7" 'edt-page 'execute-extended-command) | |
2365 | (edt-bind-function-key-default "KP8" 'edt-sect 'edt-fill-region) | |
2366 | (edt-bind-function-key-default "KP9" 'edt-append 'edt-replace) | |
2367 | (edt-bind-function-key-default "KP-" 'edt-delete-word 'edt-undelete-word) | |
2368 | (edt-bind-function-key-default "KP," | |
2369 | 'edt-delete-character 'edt-undelete-character) | |
2370 | (edt-bind-function-key-default "KPP" 'edt-select 'edt-reset) | |
2371 | (edt-bind-function-key-default "KPE" 'other-window 'edt-substitute) | |
3bef4fb9 KH |
2372 | |
2373 | ;; VT200/VT300 Function Keys | |
2374 | ;; (F1 through F5, on the VT220, are not programmable, so we skip | |
f3e03a42 GM |
2375 | ;; making default bindings to those keys. |
2376 | (edt-bind-function-key-default "FIND" 'edt-find-next 'edt-find) | |
2377 | (edt-bind-function-key-default "INSERT" 'yank 'edt-key-not-assigned) | |
2378 | (edt-bind-function-key-default "REMOVE" 'edt-cut 'edt-copy) | |
2379 | (edt-bind-function-key-default "SELECT" | |
2380 | 'edt-toggle-select 'edt-key-not-assigned) | |
2381 | (edt-bind-function-key-default "NEXT" | |
2382 | 'edt-sect-forward 'edt-key-not-assigned) | |
2383 | (edt-bind-function-key-default "PREVIOUS" | |
2384 | 'edt-sect-backward 'edt-key-not-assigned) | |
2385 | (edt-bind-function-key-default "F6" | |
2386 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2387 | (edt-bind-function-key-default "F7" | |
2388 | 'edt-copy-rectangle 'edt-key-not-assigned) | |
2389 | (edt-bind-function-key-default "F8" | |
2390 | 'edt-cut-rectangle-overstrike-mode 'edt-paste-rectangle-overstrike-mode) | |
2391 | (edt-bind-function-key-default "F9" | |
2392 | 'edt-cut-rectangle-insert-mode 'edt-paste-rectangle-insert-mode) | |
2393 | (edt-bind-function-key-default "F10" 'edt-cut-rectangle 'edt-paste-rectangle) | |
3bef4fb9 | 2394 | ;; Under X, the F11 key can be bound. If using a VT-200 or higher terminal, |
f3e03a42 | 2395 | ;; the default emacs terminal support causes the VT F11 key to seem as if it |
3bef4fb9 | 2396 | ;; is an ESC key when in emacs. |
f3e03a42 GM |
2397 | (edt-bind-function-key-default "F11" |
2398 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2399 | (edt-bind-function-key-default "F12" | |
2400 | 'edt-beginning-of-line 'delete-other-windows) ;BS | |
2401 | (edt-bind-function-key-default "F13" | |
2402 | 'edt-delete-to-beginning-of-word 'edt-key-not-assigned) ;LF | |
2403 | (edt-bind-function-key-default "F14" | |
2404 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2405 | (edt-bind-function-key-default "HELP" | |
2406 | 'edt-electric-keypad-help 'edt-key-not-assigned) | |
2407 | (edt-bind-function-key-default "DO" | |
2408 | 'execute-extended-command 'edt-key-not-assigned) | |
2409 | (edt-bind-function-key-default "F17" | |
2410 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2411 | (edt-bind-function-key-default "F18" | |
2412 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2413 | (edt-bind-function-key-default "F19" | |
2414 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
2415 | (edt-bind-function-key-default "F20" | |
2416 | 'edt-key-not-assigned 'edt-key-not-assigned) | |
3bef4fb9 KH |
2417 | |
2418 | ;; Control key bindings: Regular and GOLD | |
a1506d29 | 2419 | ;; |
3bef4fb9 KH |
2420 | ;; Standard EDT control key bindings conflict with standard Emacs |
2421 | ;; control key bindings. Normally, the standard Emacs control key | |
2422 | ;; bindings are left unchanged in the default EDT mode. However, if | |
2423 | ;; the variable edt-use-EDT-control-key-bindings is set to true | |
2424 | ;; before invoking edt-emulation-on for the first time, then the | |
2425 | ;; standard EDT bindings (with some enhancements) as defined here are | |
2426 | ;; used, instead. | |
2427 | (if edt-use-EDT-control-key-bindings | |
2428 | (progn | |
f3e03a42 GM |
2429 | (edt-bind-key-default "\C-a" 'edt-key-not-assigned) |
2430 | (edt-bind-key-default "\C-b" 'edt-key-not-assigned) | |
2431 | ;; Leave binding of C-c to an Emacs prefix key. | |
2432 | (edt-bind-key-default "\C-d" 'edt-key-not-assigned) | |
2433 | (edt-bind-key-default "\C-e" 'edt-key-not-assigned) | |
2434 | (edt-bind-key-default "\C-f" 'edt-key-not-assigned) | |
2435 | ;; Leave binding of C-g to the Emacs keyboard-quit | |
2436 | (edt-bind-key-default "\C-h" 'edt-beginning-of-line) | |
2437 | (edt-bind-key-default "\C-i" 'edt-tab-insert) | |
2438 | (edt-bind-key-default "\C-j" 'edt-delete-to-beginning-of-word) | |
2439 | (edt-bind-key-default "\C-k" 'edt-define-key) | |
2440 | (edt-bind-gold-key-default "\C-k" 'edt-restore-key) | |
2441 | (edt-bind-key-default "\C-l" 'edt-form-feed-insert) | |
3bef4fb9 | 2442 | ;; Leave binding of C-m to newline. |
f3e03a42 GM |
2443 | (edt-bind-key-default "\C-n" 'edt-set-screen-width-80) |
2444 | (edt-bind-key-default "\C-o" 'edt-key-not-assigned) | |
2445 | (edt-bind-key-default "\C-p" 'edt-key-not-assigned) | |
2446 | (edt-bind-key-default "\C-q" 'edt-key-not-assigned) | |
3bef4fb9 KH |
2447 | ;; Leave binding of C-r to isearch-backward. |
2448 | ;; Leave binding of C-s to isearch-forward. | |
f3e03a42 GM |
2449 | (edt-bind-key-default "\C-t" 'edt-display-the-time) |
2450 | (edt-bind-key-default "\C-u" 'edt-delete-to-beginning-of-line) | |
2451 | (edt-bind-key-default "\C-v" 'redraw-display) | |
2452 | (edt-bind-key-default "\C-w" 'edt-set-screen-width-132) | |
3bef4fb9 | 2453 | ;; Leave binding of C-x as original prefix key. |
f3e03a42 GM |
2454 | (edt-bind-key-default "\C-y" 'edt-key-not-assigned) |
2455 | ;; Leave binding of C-z to suspend-emacs. | |
3bef4fb9 KH |
2456 | ) |
2457 | ) | |
2458 | ||
f3e03a42 GM |
2459 | ;; GOLD bindings for a few keys. |
2460 | (edt-bind-gold-key-default "\C-g" 'keyboard-quit); Just in case. | |
2461 | (edt-bind-gold-key-default "\C-h" 'help-for-help); Just in case. | |
2462 | (edt-bind-gold-key-default [f1] 'help-for-help) | |
2463 | (edt-bind-gold-key-default [help] 'help-for-help) | |
2464 | (edt-bind-gold-key-default "\C-\\" 'split-window-vertically) | |
3bef4fb9 KH |
2465 | |
2466 | ;; GOLD bindings for regular keys. | |
f3e03a42 GM |
2467 | (edt-bind-gold-key-default "a" 'edt-key-not-assigned) |
2468 | (edt-bind-gold-key-default "A" 'edt-key-not-assigned) | |
2469 | (edt-bind-gold-key-default "b" 'buffer-menu) | |
2470 | (edt-bind-gold-key-default "B" 'buffer-menu) | |
2471 | (edt-bind-gold-key-default "c" 'compile) | |
2472 | (edt-bind-gold-key-default "C" 'compile) | |
2473 | (edt-bind-gold-key-default "d" 'delete-window) | |
2474 | (edt-bind-gold-key-default "D" 'delete-window) | |
2475 | (edt-bind-gold-key-default "e" 'edt-exit) | |
2476 | (edt-bind-gold-key-default "E" 'edt-exit) | |
2477 | (edt-bind-gold-key-default "f" 'find-file) | |
2478 | (edt-bind-gold-key-default "F" 'find-file) | |
2479 | (edt-bind-gold-key-default "g" 'find-file-other-window) | |
2480 | (edt-bind-gold-key-default "G" 'find-file-other-window) | |
2481 | (edt-bind-gold-key-default "h" 'edt-electric-keypad-help) | |
2482 | (edt-bind-gold-key-default "H" 'edt-electric-keypad-help) | |
2483 | (edt-bind-gold-key-default "i" 'insert-file) | |
2484 | (edt-bind-gold-key-default "I" 'insert-file) | |
2485 | (edt-bind-gold-key-default "j" 'edt-key-not-assigned) | |
2486 | (edt-bind-gold-key-default "J" 'edt-key-not-assigned) | |
2487 | (edt-bind-gold-key-default "k" 'edt-toggle-capitalization-of-word) | |
2488 | (edt-bind-gold-key-default "K" 'edt-toggle-capitalization-of-word) | |
2489 | (edt-bind-gold-key-default "l" 'edt-lowercase) | |
2490 | (edt-bind-gold-key-default "L" 'edt-lowercase) | |
2491 | (edt-bind-gold-key-default "m" 'save-some-buffers) | |
2492 | (edt-bind-gold-key-default "M" 'save-some-buffers) | |
2493 | (edt-bind-gold-key-default "n" 'next-error) | |
2494 | (edt-bind-gold-key-default "N" 'next-error) | |
2495 | (edt-bind-gold-key-default "o" 'switch-to-buffer-other-window) | |
2496 | (edt-bind-gold-key-default "O" 'switch-to-buffer-other-window) | |
2497 | (edt-bind-gold-key-default "p" 'edt-key-not-assigned) | |
2498 | (edt-bind-gold-key-default "P" 'edt-key-not-assigned) | |
2499 | (edt-bind-gold-key-default "q" 'edt-quit) | |
2500 | (edt-bind-gold-key-default "Q" 'edt-quit) | |
2501 | (edt-bind-gold-key-default "r" 'revert-buffer) | |
2502 | (edt-bind-gold-key-default "R" 'revert-buffer) | |
2503 | (edt-bind-gold-key-default "s" 'save-buffer) | |
2504 | (edt-bind-gold-key-default "S" 'save-buffer) | |
2505 | (edt-bind-gold-key-default "t" 'edt-key-not-assigned) | |
2506 | (edt-bind-gold-key-default "T" 'edt-key-not-assigned) | |
2507 | (edt-bind-gold-key-default "u" 'edt-uppercase) | |
2508 | (edt-bind-gold-key-default "U" 'edt-uppercase) | |
2509 | (edt-bind-gold-key-default "v" 'find-file-other-window) | |
2510 | (edt-bind-gold-key-default "V" 'find-file-other-window) | |
2511 | (edt-bind-gold-key-default "w" 'write-file) | |
2512 | (edt-bind-gold-key-default "W" 'write-file) | |
2513 | (edt-bind-gold-key-default "x" 'edt-key-not-assigned) | |
2514 | (edt-bind-gold-key-default "X" 'edt-key-not-assigned) | |
2515 | (edt-bind-gold-key-default "y" 'edt-emulation-off) | |
2516 | (edt-bind-gold-key-default "Y" 'edt-emulation-off) | |
2517 | (edt-bind-gold-key-default "z" 'edt-switch-global-maps) | |
2518 | (edt-bind-gold-key-default "Z" 'edt-switch-global-maps) | |
2519 | (edt-bind-gold-key-default "1" 'delete-other-windows) | |
2520 | (edt-bind-gold-key-default "!" 'edt-key-not-assigned) | |
2521 | (edt-bind-gold-key-default "2" 'edt-split-window) | |
2522 | (edt-bind-gold-key-default "@" 'edt-key-not-assigned) | |
2523 | (edt-bind-gold-key-default "3" 'edt-key-not-assigned) | |
2524 | (edt-bind-gold-key-default "#" 'edt-key-not-assigned) | |
2525 | (edt-bind-gold-key-default "4" 'edt-key-not-assigned) | |
2526 | (edt-bind-gold-key-default "$" 'edt-key-not-assigned) | |
2527 | (edt-bind-gold-key-default "5" 'edt-key-not-assigned) | |
2528 | (edt-bind-gold-key-default "%" 'edt-goto-percentage) | |
2529 | (edt-bind-gold-key-default "6" 'edt-key-not-assigned) | |
2530 | (edt-bind-gold-key-default "^" 'edt-key-not-assigned) | |
2531 | (edt-bind-gold-key-default "7" 'edt-key-not-assigned) | |
2532 | (edt-bind-gold-key-default "&" 'edt-key-not-assigned) | |
2533 | (edt-bind-gold-key-default "8" 'edt-key-not-assigned) | |
2534 | (edt-bind-gold-key-default "*" 'edt-key-not-assigned) | |
2535 | (edt-bind-gold-key-default "9" 'edt-key-not-assigned) | |
2536 | (edt-bind-gold-key-default "(" 'edt-key-not-assigned) | |
2537 | (edt-bind-gold-key-default "0" 'edt-key-not-assigned) | |
2538 | (edt-bind-gold-key-default ")" 'edt-key-not-assigned) | |
2539 | (edt-bind-gold-key-default " " 'undo) | |
2540 | (edt-bind-gold-key-default "," 'edt-key-not-assigned) | |
2541 | (edt-bind-gold-key-default "<" 'edt-key-not-assigned) | |
2542 | (edt-bind-gold-key-default "." 'edt-key-not-assigned) | |
2543 | (edt-bind-gold-key-default ">" 'edt-key-not-assigned) | |
2544 | (edt-bind-gold-key-default "/" 'query-replace) | |
2545 | (edt-bind-gold-key-default "?" 'edt-key-not-assigned) | |
2546 | (edt-bind-gold-key-default "\\" 'edt-key-not-assigned) | |
2547 | (edt-bind-gold-key-default "|" 'edt-key-not-assigned) | |
2548 | (edt-bind-gold-key-default ";" 'edt-key-not-assigned) | |
2549 | (edt-bind-gold-key-default ":" 'edt-key-not-assigned) | |
2550 | (edt-bind-gold-key-default "'" 'edt-key-not-assigned) | |
2551 | (edt-bind-gold-key-default "\"" 'edt-key-not-assigned) | |
2552 | (edt-bind-gold-key-default "-" 'edt-key-not-assigned) | |
2553 | (edt-bind-gold-key-default "_" 'edt-key-not-assigned) | |
2554 | (edt-bind-gold-key-default "=" 'goto-line) | |
2555 | (edt-bind-gold-key-default "+" 'edt-key-not-assigned) | |
2556 | (edt-bind-gold-key-default "[" 'edt-key-not-assigned) | |
2557 | (edt-bind-gold-key-default "{" 'edt-key-not-assigned) | |
2558 | (edt-bind-gold-key-default "]" 'edt-key-not-assigned) | |
2559 | (edt-bind-gold-key-default "}" 'edt-key-not-assigned) | |
2560 | (edt-bind-gold-key-default "`" 'what-line) | |
2561 | (edt-bind-gold-key-default "~" 'edt-key-not-assigned) | |
3bef4fb9 KH |
2562 | ) |
2563 | \f | |
2564 | ;;; | |
2565 | ;;; DEFAULT EDT KEYPAD HELP | |
2566 | ;;; | |
2567 | ||
2568 | ;;; | |
2569 | ;;; Upper case commands in the keypad diagram below indicate that the | |
2570 | ;;; emulation should look and feel very much like EDT. Lower case | |
2571 | ;;; commands are enhancements and/or additions to the EDT keypad | |
2572 | ;;; commands or are native Emacs commands. | |
2573 | ;;; | |
2574 | ||
2575 | (defun edt-keypad-help () | |
f3e03a42 | 2576 | "DEFAULT EDT Keypad Active. |
3bef4fb9 KH |
2577 | |
2578 | F7: Copy Rectangle +----------+----------+----------+----------+ | |
2579 | F8: Cut Rect Overstrike |Prev Line |Next Line |Bkwd Char |Frwd Char | | |
2580 | G-F8: Paste Rect Overstrike | (UP) | (DOWN) | (LEFT) | (RIGHT) | | |
2581 | F9: Cut Rect Insert |Window Top|Window Bot|Bkwd Sent |Frwd Sent | | |
2582 | G-F9: Paste Rect Insert +----------+----------+----------+----------+ | |
2583 | F10: Cut Rectangle | |
2584 | G-F10: Paste Rectangle | |
a1506d29 | 2585 | F11: ESC |
3bef4fb9 KH |
2586 | F12: Begining of Line +----------+----------+----------+----------+ |
2587 | G-F12: Delete Other Windows | GOLD | HELP | FNDNXT | DEL L | | |
2588 | F13: Delete to Begin of Word | (PF1) | (PF2) | (PF3) | (PF4) | | |
2589 | HELP: Keypad Help |Mark Wisel|Desc Funct| FIND | UND L | | |
f3e03a42 GM |
2590 | G-HELP: Emacs Help +----------+----------+----------+----------+ |
2591 | DO: Execute extended command | PAGE | SECT | APPEND | DEL W | | |
3bef4fb9 KH |
2592 | C-g: Keyboard Quit | (7) | (8) | (9) | (-) | |
2593 | G-C-g: Keyboard Quit |Ex Ext Cmd|Fill Regio| REPLACE | UND W | | |
2594 | C-h: Beginning of Line +----------+----------+----------+----------+ | |
2595 | G-C-h: Emacs Help | ADVANCE | BACKUP | CUT | DEL C | | |
2596 | C-i: Tab Insert | (4) | (5) | (6) | (,) | | |
2597 | C-j: Delete to Begin of Word | BOTTOM | TOP | Yank | UND C | | |
2598 | C-k: Define Key +----------+----------+----------+----------+ | |
2599 | G-C-k: Restore Key | WORD | EOL | CHAR | Next | | |
2600 | C-l: Form Feed Insert | (1) | (2) | (3) | Window | | |
2601 | C-n: Set Screen Width 80 | CHNGCASE | DEL EOL |Quoted Ins| ! | |
2602 | C-r: Isearch Backward +---------------------+----------+ (ENTER) | | |
2603 | C-s: Isearch Forward | LINE | SELECT | ! | |
f3e03a42 GM |
2604 | C-t: Display the Time | (0) | (.) | SUBS | |
2605 | C-u: Delete to Begin of Line | Open Line | RESET | | | |
3bef4fb9 | 2606 | C-v: Redraw Display +---------------------+----------+----------+ |
a1506d29 | 2607 | C-w: Set Screen Width 132 |
3bef4fb9 KH |
2608 | C-z: Suspend Emacs +----------+----------+----------+ |
2609 | G-C-\\: Split Window | FNDNXT | Yank | CUT | | |
2610 | | (FIND) | (INSERT) | (REMOVE) | | |
2611 | G-b: Buffer Menu | FIND | | COPY | | |
2612 | G-c: Compile +----------+----------+----------+ | |
2613 | G-d: Delete Window |SELECT/RES|SECT BACKW|SECT FORWA| | |
2614 | G-e: Exit | (SELECT) |(PREVIOUS)| (NEXT) | | |
2615 | G-f: Find File | | | | | |
2616 | G-g: Find File Other Window +----------+----------+----------+ | |
a1506d29 JB |
2617 | G-h: Keypad Help |
2618 | G-i: Insert File | |
2619 | G-k: Toggle Capitalization Word | |
2620 | G-l: Downcase Region | |
2621 | G-m: Save Some Buffers | |
2622 | G-n: Next Error | |
3bef4fb9 | 2623 | G-o: Switch to Next Window |
a1506d29 JB |
2624 | G-q: Quit |
2625 | G-r: Revert File | |
2626 | G-s: Save Buffer | |
2627 | G-u: Upcase Region | |
2628 | G-v: Find File Other Window | |
2629 | G-w: Write file | |
2630 | G-y: EDT Emulation OFF | |
3bef4fb9 | 2631 | G-z: Switch to User EDT Key Bindings |
a1506d29 JB |
2632 | G-1: Delete Other Windows |
2633 | G-2: Split Window | |
2634 | G-%: Go to Percentage | |
2635 | G- : Undo (GOLD Spacebar) | |
2636 | G-=: Go to Line | |
f3e03a42 GM |
2637 | G-`: What line |
2638 | G-/: Query-Replace" | |
3bef4fb9 KH |
2639 | |
2640 | (interactive) | |
2641 | (describe-function 'edt-keypad-help)) | |
2642 | ||
2643 | (defun edt-electric-helpify (fun) | |
2644 | (let ((name "*Help*")) | |
2645 | (if (save-window-excursion | |
2646 | (let* ((p (symbol-function 'print-help-return-message)) | |
2647 | (b (get-buffer name)) | |
2648 | (m (buffer-modified-p b))) | |
2649 | (and b (not (get-buffer-window b)) | |
2650 | (setq b nil)) | |
2651 | (unwind-protect | |
2652 | (progn | |
2653 | (message "%s..." (capitalize (symbol-name fun))) | |
2654 | (and b | |
2655 | (save-excursion | |
2656 | (set-buffer b) | |
2657 | (set-buffer-modified-p t))) | |
2658 | (fset 'print-help-return-message 'ignore) | |
2659 | (call-interactively fun) | |
2660 | (and (get-buffer name) | |
2661 | (get-buffer-window (get-buffer name)) | |
2662 | (or (not b) | |
2663 | (not (eq b (get-buffer name))) | |
2664 | (not (buffer-modified-p b))))) | |
2665 | (fset 'print-help-return-message p) | |
2666 | (and b (buffer-name b) | |
2667 | (save-excursion | |
2668 | (set-buffer b) | |
2669 | (set-buffer-modified-p m)))))) | |
2670 | (with-electric-help 'delete-other-windows name t)))) | |
2671 | ||
2672 | (defun edt-electric-keypad-help () | |
e4360875 | 2673 | "Display default EDT bindings." |
3bef4fb9 KH |
2674 | (interactive) |
2675 | (edt-electric-helpify 'edt-keypad-help)) | |
2676 | ||
2677 | (defun edt-electric-user-keypad-help () | |
e4360875 | 2678 | "Display user custom EDT bindings." |
3bef4fb9 KH |
2679 | (interactive) |
2680 | (edt-electric-helpify 'edt-user-keypad-help)) | |
2681 | ||
2682 | ;;; | |
a0ac0c19 | 2683 | ;;; EDT emulation screen width commands. |
3bef4fb9 | 2684 | ;;; |
f3e03a42 GM |
2685 | ;; Some terminals require modification of terminal attributes when |
2686 | ;; changing the number of columns displayed, hence the fboundp tests | |
2687 | ;; below. These functions are defined in the corresponding terminal | |
2688 | ;; specific file, if needed. | |
3bef4fb9 KH |
2689 | |
2690 | (defun edt-set-screen-width-80 () | |
2691 | "Set screen width to 80 columns." | |
2692 | (interactive) | |
a0ac0c19 KH |
2693 | (if (fboundp 'edt-set-term-width-80) |
2694 | (edt-set-term-width-80)) | |
f3e03a42 GM |
2695 | (set-frame-width nil 80) |
2696 | (message "Terminal width 80")) | |
3bef4fb9 KH |
2697 | |
2698 | (defun edt-set-screen-width-132 () | |
2699 | "Set screen width to 132 columns." | |
2700 | (interactive) | |
a0ac0c19 KH |
2701 | (if (fboundp 'edt-set-term-width-132) |
2702 | (edt-set-term-width-132)) | |
f3e03a42 GM |
2703 | (set-frame-width nil 132) |
2704 | (message "Terminal width 132")) | |
3bef4fb9 KH |
2705 | |
2706 | (provide 'edt) | |
1a06eabd | 2707 | |
ab5796a9 | 2708 | ;;; arch-tag: 18d1c54f-6900-4078-8bbc-7c2292f48941 |
1a06eabd | 2709 | ;;; edt.el ends here |