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