annotate lisp/emulators/edt.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents b82b59fe008d
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
1 ;;; edt.el --- EDT emulation in Emacs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
2 ;; Keywords: emulations
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
4 ;; Copyright (C) 1986 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
5 ;; It started from public domain code by Mike Clarkson
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
6 ;; but has been greatly altered.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
24
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
25 ;; From mike@yetti.UUCP Fri Aug 29 12:49:28 1986
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
26 ;; Path: mit-prep!mit-hermes!mit-eddie!genrad!panda!husc6!seismo!mnetor!yetti!mike
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
27 ;; From: mike@yetti.UUCP (Mike Clarkson )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
28 ;; Newsgroups: net.sources
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
29 ;; Subject: Gnu Emacs EDT Emulation - Introduction - 1/3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
30 ;; Date: 27 Aug 86 23:30:33 GMT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
31 ;; Reply-To: mike@yetti.UUCP (Mike Clarkson )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
32 ;; Organization: York University Computer Science
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
33 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
34 ;; Here's my EDT emulation for GNU Emacs that is based on the EDT emulation
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
35 ;; for Gosling's Emacs sent out on the net a couple of years ago by Lynn Olson
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
36 ;; at Tektronics. This emulation was widely distributed as the file edt.ml
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
37 ;; in the maclib directory of most Emacs distributions.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
38 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
39 ;; My emulation consists of two files: edt.el and edtdoc.el. The edtdoc.el file
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
40 ;; is the documentation, that you can add to the beginning of edt.el if you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
41 ;; want. I have split them because I have been loading the edt.el file a lot
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
42 ;; during debugging.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
43 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
44 ;; I will gladly take all criticisms and complaints to heart, and will fix
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
45 ;; what bugs I can find. As this is my first elisp hack, you may have to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
46 ;; root out a few nasties hidden in the code. Please let me know if you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
47 ;; find any (sorry,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
48 ;; no rewards :-). I would also be interested if there are better,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
49 ;; cleaner, faster ways of doing some of the things that I have done.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
50 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
51 ;; You must understand some design considerations that I had in mind.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
52 ;; The intention was not really to "emulate" EDT, but rather to take advantage
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
53 ;; of the years of EDT experience that had accumulated in my right hand,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
54 ;; while at the same time taking advantage of EMACS.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
55 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
56 ;; Some major differences are:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
57 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
58 ;; HELP is describe-key;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
59 ;; GOLD/HELP is describe-function;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
60 ;; FIND is isearch-forward/backward;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
61 ;; GOLD/HELP is occur-menu, which finds all occurrences of a search string;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
62 ;; ENTER is other-window;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
63 ;; SUBS is subprocess-command. Note that you will have to change this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
64 ;; yourself to shell if you are running Un*x;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
65 ;; PAGE is next-paragraph, because that's more useful than page.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
66 ;; SPECINS is copy-to-killring;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
67 ;; GOLD/GOLD is mark-section-wisely, which is my command to mark the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
68 ;; section in a manner consistent with the major-mode. It
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
69 ;; uses mark-defun for emacs-lisp, lisp, mark-c-function for C,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
70 ;; and mark-paragraph for other modes.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
71 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
72 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
73 ;; Some subtle differences are:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
74 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
75 ;; APPEND is append-to-buffer. One doesn't append to the kill ring much
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
76 ;; and SPECINS is now copy-to-killring;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
77 ;; REPLACE is replace-regexp;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
78 ;; FILL is fill-region-wisely, which uses indent-region for C, lisp
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
79 ;; emacs-lisp, and fill-region for others. It asks if you really
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
80 ;; want to fill-region in TeX-mode, because I find this to be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
81 ;; very dangerous.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
82 ;; CHNGCASE is case-flip for the character under the cursor only.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
83 ;; I felt that case-flip region is unlikely, as usually you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
84 ;; upcase-region or downcase region. Also, unlike EDT it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
85 ;; is independent of the direction you are going, as that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
86 ;; drives me nuts.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
87 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
88 ;; I use Emacs definition of what a word is. This is considerably different from
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
89 ;; what EDT thinks a word is. This is not good for dyed-in-the-wool EDT fans,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
90 ;; but is probably preferable for experienced Emacs users. My assumption is that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
91 ;; the former are a dying breed now that GNU Emacs has made it to VMS, but let me
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
92 ;; know how you feel. Also, when you undelete a word it leave the point at the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
93 ;; end of the undeleted text, rather than the beginning. I might change this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
94 ;; as I'm not sure if I like this or not. I'm also not sure if I want it to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
95 ;; set the mark each time you delete a character or word.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
96 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
97 ;; Backspace does not invoke beginning-of-line, because ^H is the help prefix,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
98 ;; and I felt it should be left as such. You can change this if you like.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
99 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
100 ;; The ADVANCE and BACKUP keys do not work as terminators for forward or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
101 ;; backward searches. In Emacs, all search strings are terminated by return.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
102 ;; The searches will however go forward or backward depending on your current
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
103 ;; direction. Also, when you change directions, the mode line will not be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
104 ;; updated immediately, but only when you next execute an emacs function.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
105 ;; Personally, I consider this to be a bug, not a feature.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
106 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
107 ;; This should also work with VT-2xx's, though I haven't tested it extensively
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
108 ;; on those terminals. It assumes that the CSI-map of vt_200.el has been defined.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
109 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
110 ;; There are also a whole bunch of GOLD letter, and GOLD character bindings:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
111 ;; look at edtdoc.el for them, or better still, look at the edt.el lisp code,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
112 ;; because after all, in the true Lisp tradition, the source code is *assumed*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
113 ;; to be self-documenting :-)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
114 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
115 ;; Mike Clarkson, ...!allegra \ BITNET: mike@YUYETTI or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
116 ;; CRESS, York University, ...!decvax \ SYMALG@YUSOL
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
117 ;; 4700 Keele Street, ...!ihnp4 > !utzoo!yetti!mike
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
118 ;; North York, Ontario, ...!linus /
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
119 ;; CANADA M3J 1P3. ...!watmath / Phone: +1 (416) 736-2100 x 7767
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
120 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
121 ;; Note that I am not on ARPA, and must gateway any ARPA mail through BITNET or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
122 ;; UUCP. If you have a UUCP or BITNET address please use it for communication
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
123 ;; so that I can reach you directly. If you have both, the BITNET address
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
124 ;; is preferred.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
125 ;; --
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
126 ;; Mike Clarkson, ...!allegra \ BITNET: mike@YUYETTI or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
127 ;; CRESS, York University, ...!decvax \ SYMALG@YUSOL
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
128 ;; 4700 Keele Street, ...!ihnp4 > !utzoo!yetti!mike
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
129 ;; North York, Ontario, ...!linus /
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
130 ;; CANADA M3J 1P3. ...!watmath / Phone: +1 (416) 737-2100 x 7767
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
131
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
132
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
133 (require 'keypad)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
134
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
135 (defvar edt-last-deleted-lines ""
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
136 "Last text deleted by an EDT emulation line-delete command.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
137 (defvar edt-last-deleted-words ""
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
138 "Last text deleted by an EDT emulation word-delete command.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
139 (defvar edt-last-deleted-chars ""
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
140 "Last text deleted by an EDT emulation character-delete command.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
141
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
142 (defun delete-current-line (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
143 "Delete one or specified number of lines after point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
144 This includes the newline character at the end of each line.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
145 They are saved for the EDT undelete-lines command."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
146 (interactive "p")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (forward-line num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (if (not (eq (preceding-char) ?\n))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
150 (insert "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq edt-last-deleted-lines
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
152 (buffer-substring beg (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (delete-region beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
155 (defun delete-to-eol (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
156 "Delete text up to end of line.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
157 With argument, delete up to to Nth line-end past point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
158 They are saved for the EDT undelete-lines command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
159 (interactive "p")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (end-of-line num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (setq edt-last-deleted-lines
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
164 (buffer-substring beg (point)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
165 (delete-region beg (point))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
166
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
167 (defun delete-current-word (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
168 "Delete one or specified number of words after point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
169 They are saved for the EDT undelete-words command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
170 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
171 (let ((beg (point)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
172 (forward-word num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
173 (setq edt-last-deleted-words
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
174 (buffer-substring beg (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (delete-region beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
177 (defun edt-delete-previous-word (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
178 "Delete one or specified number of words before point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
179 They are saved for the EDT undelete-words command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
180 (interactive "p")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (let ((beg (point)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
182 (forward-word (- num))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
183 (setq edt-last-deleted-words
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
184 (buffer-substring (point) beg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (delete-region beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
187 (defun delete-current-char (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
188 "Delete one or specified number of characters after point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
189 They are saved for the EDT undelete-chars command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
190 (interactive "p")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq edt-last-deleted-chars
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
192 (buffer-substring (point) (min (point-max) (+ (point) num))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (delete-region (point) (min (point-max) (+ (point) num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
195 (defun delete-previous-char (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
196 "Delete one or specified number of characters before point.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
197 They are saved for the EDT undelete-chars command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
198 (interactive "p")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq edt-last-deleted-chars
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
200 (buffer-substring (max (point-min) (- (point) num)) (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (delete-region (max (point-min) (- (point) num)) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
203 (defun undelete-lines ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
204 "Yank lines deleted by last EDT line-deletion command."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
206 (insert edt-last-deleted-lines))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
208 (defun undelete-words ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
209 "Yank words deleted by last EDT word-deletion command."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
210 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
211 (insert edt-last-deleted-words))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
212
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
213 (defun undelete-chars ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
214 "Yank characters deleted by last EDT character-deletion command."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
215 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
216 (insert edt-last-deleted-chars))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
217
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
218 (defun next-end-of-line (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
219 "Move to end of line; if at end, move to end of next line.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
220 Accepts a prefix argument for the number of lines to move."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
221 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
222 (forward-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
223 (end-of-line num))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
225 (defun previous-end-of-line (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
226 "Move EOL upward.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
227 Accepts a prefix argument for the number of lines to move."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
228 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
229 (end-of-line (- 1 num)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
230
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
231 (defun forward-to-word (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
232 "Move to next word-beginning, or to Nth following word-beginning."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
233 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
234 (forward-word (1+ num))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
235 (forward-word -1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
237 (defun backward-to-word (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
238 "Move back to word-end, or to Nth word-end seen."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
239 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
240 (forward-word (- (1+ num)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
241 (forward-word 1))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
242
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
243 (defun backward-line (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
244 "Move point to start of previous line.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
245 Prefix argument serves as repeat-count."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (interactive "p")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
247 (forward-line (- num)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
249 (defun scroll-window-down (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
250 "Scroll the display down a window-full.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
251 Accepts a prefix argument for the number of window-fulls to scroll."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (interactive "p")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
253 (scroll-down (- (* (window-height) num) 2)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
255 (defun scroll-window-up (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
256 "Scroll the display up a window-full.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
257 Accepts a prefix argument for the number of window-fulls to scroll."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (interactive "p")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
259 (scroll-up (- (* (window-height) num) 2)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
261 (defun next-paragraph (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
262 "Move to beginning of the next indented paragraph.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
263 Accepts a prefix argument for the number of paragraphs."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (while (> num 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (forward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (previous-line 1)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
269 (if (eolp) (next-line 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq num (1- num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
272 (defun previous-paragraph (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
273 "Move to beginning of previous indented paragraph.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
274 Accepts a prefix argument for the number of paragraphs."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (while (> num 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (backward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (previous-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (eolp) (next-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq num (1- num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
282 (defun move-to-beginning ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
283 "Move cursor to the beginning of buffer, but don't set the mark."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
284 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
285 (goto-char (point-min)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
287 (defun move-to-end ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
288 "Move cursor to the end of buffer, but don't set the mark."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
289 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
290 (goto-char (point-max)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
292 (defun goto-percent (perc)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
293 "Move point to ARG percentage of the buffer."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
294 (interactive "NGoto-percentage: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
295 (if (or (> perc 100) (< perc 0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
296 (error "Percentage %d out of range 0 < percent < 100" perc)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
297 (goto-char (/ (* (point-max) perc) 100))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
298
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
299 (defun update-mode-line ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
300 "Make sure mode-line in the current buffer reflects all changes."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
301 (set-buffer-modified-p (buffer-modified-p))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
302 (sit-for 0))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
303
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
304 (defun advance-direction ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
305 "Set EDT Advance mode so keypad commands move forward."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
306 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
307 (setq edt-direction-string " ADVANCE")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
308 (define-key function-keymap "\C-c" 'isearch-forward) ; PF3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
309 (define-key function-keymap "8" 'scroll-window-up) ; "8"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
310 (define-key function-keymap "7" 'next-paragraph) ; "7"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
311 (define-key function-keymap "1" 'forward-to-word) ; "1"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
312 (define-key function-keymap "2" 'next-end-of-line) ; "2"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
313 (define-key function-keymap "3" 'forward-char) ; "3"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
314 (define-key function-keymap "0" 'forward-line) ; "0"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
315 (update-mode-line))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
316
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
317 (defun backup-direction ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
318 "Set EDT Backup mode so keypad commands move backward."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
319 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
320 (setq edt-direction-string " BACKUP")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
321 (define-key function-keymap "\C-c" 'isearch-backward) ; PF3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
322 (define-key function-keymap "8" 'scroll-window-down) ; "8"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
323 (define-key function-keymap "7" 'previous-paragraph) ; "7"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
324 (define-key function-keymap "1" 'backward-to-word) ; "1"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
325 (define-key function-keymap "2" 'previous-end-of-line) ; "2"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
326 (define-key function-keymap "3" 'backward-char) ; "3"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
327 (define-key function-keymap "0" 'backward-line) ; "0"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
328 (update-mode-line))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
330 (defun edt-beginning-of-window ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
331 "Home cursor to top of window."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
332 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
333 (move-to-window-line 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (defun edt-line-to-bottom-of-window ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
336 "Move the current line to the top of the window."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (recenter -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defun edt-line-to-top-of-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "Move the current line to the top of the window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (recenter 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
345 (defun case-flip-character (num)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
346 "Change the case of the character under the cursor.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
347 Accepts a prefix argument of the number of characters to invert."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
348 (interactive "p")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
349 (while (> num 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
350 (funcall (if (<= ?a (following-char))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
351 'upcase-region 'downcase-region)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
352 (point) (1+ (point)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
353 (forward-char 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
354 (setq num (1- num))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
356 (defun indent-or-fill-region ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "Fill region in text modes, indent region in programming language modes."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
358 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
359 (if (string= paragraph-start "^$\\|^ ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (indent-region (point) (mark) nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
361 (fill-region (point) (mark))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
362
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
363 (defun mark-section-wisely ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Mark the section in a manner consistent with the major-mode.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
365 Uses mark-defun for emacs-lisp, lisp,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 mark-c-function for C,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 and mark-paragraph for other modes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
369 (cond ((eq major-mode 'emacs-lisp-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
370 (mark-defun))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
371 ((eq major-mode 'lisp-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
372 (mark-defun))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
373 ((eq major-mode 'c-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
374 (mark-c-function))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
375 (t (mark-paragraph))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
376
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
377 ;;; Key Bindings
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
378 (defun edt-emulation-on ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
379 "Begin emulating DEC's EDT editor.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
380 Certain keys are rebound; including nearly all keypad keys.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
381 Use \\[edt-emulation-off] to undo all rebindings except the keypad keys.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
382 Note that this function does not work if called directly from the .emacs file.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
383 Instead, the .emacs file should do (setq term-setup-hook 'edt-emulation-on)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
384 Then this function will be called at the time when it will work."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
385 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
386 (advance-direction)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
387 (edt-bind-gold-keypad) ;Must do this *after* $TERM.el is loaded
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
388 (setq edt-mode-old-c-\\ (lookup-key global-map "\C-\\"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
389 (global-set-key "\C-\\" 'quoted-insert)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
390 (setq edt-mode-old-delete (lookup-key global-map "\177"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
391 (global-set-key "\177" 'delete-previous-char) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
392 (setq edt-mode-old-lisp-delete (lookup-key emacs-lisp-mode-map "\177"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
393 (define-key emacs-lisp-mode-map "\177" 'delete-previous-char) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
394 (define-key lisp-mode-map "\177" 'delete-previous-char) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
395 (setq edt-mode-old-linefeed (lookup-key global-map "\C-j"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
396 (global-set-key "\C-j" 'edt-delete-previous-word) ;"LineFeed"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
397 (define-key esc-map "?" 'apropos)) ;"<ESC>?"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
398
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
399 (defun edt-emulation-off ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
400 "Return from EDT emulation to normal Emacs key bindings.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
401 The keys redefined by \\[edt-emulation-on] are given their old definitions."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
402 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
403 (setq edt-direction-string nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
404 (global-set-key "\C-\\" edt-mode-old-c-\\)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
405 (global-set-key "\177" edt-mode-old-delete) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
406 (define-key emacs-lisp-mode-map "\177" edt-mode-old-lisp-delete) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
407 (define-key lisp-mode-map "\177" edt-mode-old-lisp-delete) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
408 (global-set-key "\C-j" edt-mode-old-linefeed)) ;"LineFeed"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
409
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
410 (define-key function-keymap "u" 'previous-line) ;Up arrow
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
411 (define-key function-keymap "d" 'next-line) ;down arrow
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
412 (define-key function-keymap "l" 'backward-char) ;right arrow
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
413 (define-key function-keymap "r" 'forward-char) ;left arrow
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
414 (define-key function-keymap "h" 'edt-beginning-of-window) ;home
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
415 (define-key function-keymap "\C-b" 'describe-key) ;PF2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
416 (define-key function-keymap "\C-d" 'delete-current-line);PF4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
417 (define-key function-keymap "9" 'append-to-buffer) ;9 keypad key, etc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
418 (define-key function-keymap "-" 'delete-current-word)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
419 (define-key function-keymap "4" 'advance-direction)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
420 (define-key function-keymap "5" 'backup-direction)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
421 (define-key function-keymap "6" 'kill-region)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
422 (define-key function-keymap "," 'delete-current-char)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
423 (define-key function-keymap "." 'set-mark-command)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
424 (define-key function-keymap "e" 'other-window) ;enter key
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
425 (define-key function-keymap "\C-a" 'GOLD-prefix) ;PF1 ("gold")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
427 (fset 'GOLD-prefix GOLD-map)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
428
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
429 (defvar GOLD-map (make-keymap)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
430 "GOLD-map maps the function keys on the VT100 keyboard preceeded
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
431 by the PF1 key. GOLD is the ASCII the 7-bit escape sequence <ESC>OP.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
433 (defun define-keypad-key (keymap function-keymap-slot definition)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
434 (let ((function-key-sequence (function-key-sequence function-keymap-slot)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
435 (if function-key-sequence
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
436 (define-key keymap function-key-sequence definition))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
438 ;;Bind GOLD/Keyboard keys
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
440 (define-key GOLD-map "\C-g" 'keyboard-quit) ; just for safety
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
441 (define-key GOLD-map "\177" 'delete-window) ;"Delete"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
442 (define-key GOLD-map "\C-h" 'delete-other-windows) ;"BackSpace"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
443 (define-key GOLD-map "\C-m" 'newline-and-indent) ;"Return"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
444 (define-key GOLD-map " " 'undo) ;"Spacebar"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
445 (define-key GOLD-map "%" 'goto-percent) ; "%"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
446 (define-key GOLD-map "=" 'goto-line) ; "="
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
447 (define-key GOLD-map "`" 'what-line) ; "`"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
448 (define-key GOLD-map "\C-\\" 'split-window-vertically) ; "Control-\"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
450 ; GOLD letter combinations:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
451 (define-key GOLD-map "b" 'buffer-menu) ; "b"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
452 (define-key GOLD-map "B" 'buffer-menu) ; "B"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
453 (define-key GOLD-map "d" 'delete-window) ; "d"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
454 (define-key GOLD-map "D" 'delete-window) ; "D"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
455 (define-key GOLD-map "e" 'compile) ; "e"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
456 (define-key GOLD-map "E" 'compile) ; "E"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
457 (define-key GOLD-map "i" 'insert-file) ; "i"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
458 (define-key GOLD-map "I" 'insert-file) ; "I"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
459 (define-key GOLD-map "l" 'goto-line) ; "l"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
460 (define-key GOLD-map "L" 'goto-line) ; "L"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
461 (define-key GOLD-map "m" 'save-some-buffers) ; "m"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
462 (define-key GOLD-map "M" 'save-some-buffers) ; "m"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
463 (define-key GOLD-map "n" 'next-error) ; "n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
464 (define-key GOLD-map "N" 'next-error) ; "N"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
465 (define-key GOLD-map "o" 'switch-to-buffer-other-window) ; "o"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
466 (define-key GOLD-map "O" 'switch-to-buffer-other-window) ; "O"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
467 (define-key GOLD-map "r" 'revert-file) ; "r"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
468 (define-key GOLD-map "r" 'revert-file) ; "R"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
469 (define-key GOLD-map "s" 'save-buffer) ; "s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
470 (define-key GOLD-map "S" 'save-buffer) ; "S"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
471 (define-key GOLD-map "v" 'find-file-other-window) ; "v"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
472 (define-key GOLD-map "V" 'find-file-other-window) ; "V"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
473 (define-key GOLD-map "w" 'write-file) ; "w"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
474 (define-key GOLD-map "w" 'write-file) ; "W"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
475 ;(define-key GOLD-map "z" 'shrink-window) ; "z"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
476 ;(define-key GOLD-map "Z" 'shrink-window) ; "z"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
478 ;Bind GOLD/Keypad keys
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
479 (defun edt-bind-gold-keypad ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
480 (define-keypad-key GOLD-map ?u 'edt-line-to-top-of-window) ;"up-arrow"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
481 (define-keypad-key GOLD-map ?d 'edt-line-to-bottom-of-window) ;"down-arrow"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
482 (define-keypad-key GOLD-map ?l 'backward-sentence) ;"left-arrow"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
483 (define-keypad-key GOLD-map ?r 'forward-sentence) ;"right-arrow"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
484 (define-keypad-key GOLD-map ?\C-a 'mark-section-wisely) ;Gold "PF1"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
485 (define-keypad-key GOLD-map ?\C-b 'describe-function) ;Help "PF2"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
486 (define-keypad-key GOLD-map ?\C-c 'occur) ;Find "PF3"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
487 (define-keypad-key GOLD-map ?\C-d 'undelete-lines) ;Und Line "PF4"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
488 (define-keypad-key GOLD-map ?0 'open-line) ;Open L "0"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
489 (define-keypad-key GOLD-map ?1 'case-flip-character) ;Chgcase "1"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
490 (define-keypad-key GOLD-map ?2 'delete-to-eol) ;Del EOL "2"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
491 (define-keypad-key GOLD-map ?3 'copy-region-as-kill) ;Copy "3"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
492 (define-keypad-key GOLD-map ?4 'move-to-end) ;Bottom "4"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
493 (define-keypad-key GOLD-map ?5 'move-to-beginning) ;Top "5"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
494 (define-keypad-key GOLD-map ?6 'yank) ;Paste "6"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
495 (define-keypad-key GOLD-map ?7 'execute-extended-command) ;Command "7"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
496 (define-keypad-key GOLD-map ?8 'indent-or-fill-region) ;Fill "8"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
497 (define-keypad-key GOLD-map ?9 'replace-regexp) ;Replace "9"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
498 (define-keypad-key GOLD-map ?- 'undelete-words) ;UND word "-"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
499 (define-keypad-key GOLD-map ?, 'undelete-chars) ;UND Char ","
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
500 (define-keypad-key GOLD-map ?. 'redraw-display) ;Reset Window "."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
501 (define-keypad-key GOLD-map ?e 'shell-command)) ;"ENTER"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
503 ;; Make direction of motion show in mode line
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
504 ;; while EDT emulation is turned on.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
505 ;; Note that the keypad is always turned on when in Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
507 (or (assq 'edt-direction-string minor-mode-alist)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
508 (setq minor-mode-alist (cons '(edt-direction-string edt-direction-string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
509 minor-mode-alist)))