Mercurial > emacs
annotate lisp/vcursor.el @ 50680:ae1e2c38d746
(byte-compile-defun): Generate and compile a defalias form,
unless byte-compile-compatibility.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 24 Apr 2003 01:51:54 +0000 |
parents | f1030525c96d |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
32291
diff
changeset
|
1 ;;; vcursor.el --- manipulate an alternative ("virtual") cursor |
17450 | 2 |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
3 ;; Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. |
17450 | 4 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
5 ;; Author: Peter Stephenson <pws@ibmth.df.unipi.it> |
30430
c3586624fa51
Set maintainer to FSF, since author cannot
Gerd Moellmann <gerd@gnu.org>
parents:
28459
diff
changeset
|
6 ;; Maintainer: FSF |
22901
12fca8181eca
(vcursor group): Move this to `editing' group.
Richard M. Stallman <rms@gnu.org>
parents:
22650
diff
changeset
|
7 ;; Keywords: virtual cursor, convenience |
17450 | 8 |
17902
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
10 |
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17450 | 12 ;; it under the terms of the GNU General Public License as published by |
17902
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
14 ;; any later version. |
17450 | 15 |
17902
e4a7b81d6c10
Fix copyright and permission notice.
Richard M. Stallman <rms@gnu.org>
parents:
17450
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
17450 | 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
28 ;; Latest changes |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
29 ;; ============== |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
30 ;; |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
31 ;; - *IMPORTANT* vcursor-key-bindings is now nil by default, to avoid |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
32 ;; side-effects when the package is loaded. This means no keys are |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
33 ;; bound by default. Use customize to change it to t to restore |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
34 ;; the old behaviour. (If you do it by hand in .emacs, it |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
35 ;; must come before vcursor is loaded.) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
36 ;; - You can alter the main variables and the vcursor face via |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
37 ;; M-x customize: go to the Editing group and find Vcursor. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
38 ;; - vcursor-auto-disable can now be 'copy (actually any value not nil |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
39 ;; or t), which means that copying from the vcursor will be turned |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
40 ;; off after any operation not involving the vcursor, but the |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
41 ;; vcursor itself will be left alone. |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
42 ;; - works on dumb terminals with Emacs 19.29 and later |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
43 ;; - new keymap vcursor-map for binding to a prefix key |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
44 ;; - vcursor-compare-windows substantially improved |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
45 ;; - vcursor-execute-{key,command} much better about using the |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
46 ;; right keymaps and arranging for the correct windows to be used |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
47 ;; - vcursor-window-funcall can call functions interactively |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
48 ;; - vcursor-interpret-input for special effects |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
49 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
50 ;; Introduction |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
51 ;; ============ |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
52 ;; |
17450 | 53 ;; Virtual cursor commands. I got this idea from the old BBC micro. |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
54 ;; You need Emacs 19 or 20 and a window system for the best effects. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
55 ;; For character terminals, at least Emacs 19.29 is required |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
56 ;; (special behaviour for the overlay property |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
57 ;; "before-string" must be implemented). Search for "dumb terminals" |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
58 ;; for more information. |
17450 | 59 ;; |
60 ;; This is much easier to use than the instructions are to read. | |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
61 ;; First, you need to let vcursor define some keys: setting |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
62 ;; vcursor-key-bindings to t before loading, or by customize, will |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
63 ;; define various keys with the prefix C-S. You'll have to read |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
64 ;; further if you don't want this. Then I suggest you simply load it |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
65 ;; and play around with holding down Ctrl and Shift and pressing up, |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
66 ;; down, left, right, tab, return, and see what happens. (Find a |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
67 ;; scratch buffer before using C-S-tab: that toggles copying.) |
17450 | 68 ;; |
69 ;; Most of the functions described in this documentation are in | |
70 ;; parentheses so that if you have the package loaded you can type C-h | |
71 ;; f on top of them for help. | |
72 ;; | |
73 ;; Using the cursor keys with both control and shift held down moves | |
74 ;; around a virtual cursor, which is initially at point. When active, | |
75 ;; it appears with an underline through it to distinguish it from the | |
76 ;; normal cursor. You can then use one of the other commands to copy | |
77 ;; characters from the location of the virtual cursor to point. This | |
78 ;; is very useful, for example, when copying some previous text while | |
79 ;; making changes to it at the same time, since you never have to move | |
80 ;; the "real" cursor away from where you are inserting. | |
81 ;; | |
82 ;; The remaining default key bindings are based around the PC-type | |
83 ;; cluster found above the cursor keys on a lot of keyboards, the | |
84 ;; function keys which my limited knowledge of X terminals expects to | |
85 ;; find at the top. Some functions are duplicated in more obvious | |
86 ;; places for the X version. | |
87 ;; | |
88 ;; All the keybindings require you to hold down control and shift at | |
89 ;; once. I assumed this combination wouldn't be heavily bound by most | |
90 ;; people and that it would be easy to type with the left hand. | |
91 ;; Inevitably it will clash with some other packages, but I can't help | |
92 ;; that: an intuitive binding is a prerequisite here. See below for | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
93 ;; other alternatives (search for "Oemacs"). There is also a keymap |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
94 ;; which you can bind to a prefix key, which may give some more |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
95 ;; intuitive alternatives in some cases, see `The vcursor keymap' below. |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
96 ;; |
17450 | 97 ;; Holding down control and shift and pressing insert (vcursor-copy) |
98 ;; copies one character from wherever the virtual cursor is to point; | |
99 ;; point and the virtual cursor advance in the separate and equal | |
100 ;; station to which... (etc.). M-C-S-return (vcursor-copy-line) | |
101 ;; copies to the end of the line instead of just one character, | |
102 ;; C-S-delete or C-S-remove (vcursor-copy-word) copies a word. | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
103 ;; |
17450 | 104 ;; A more general way of copying is to use C-S-tab, which is a toggle. |
105 ;; In the "on" state, moving the virtual cursor will copy the | |
106 ;; moved-over text to the normal cursor position (including when going | |
107 ;; backwards, though each piece of text moved over is copied forwards: | |
108 ;; compare the behaviour of C-S-up and C-S-left). | |
109 ;; | |
110 ;; However, that's just a small part of the magic. If the virtual | |
111 ;; cursor goes off the display, it will be redisplayed in some other | |
112 ;; window. (See the function (vcursor-find-window) for details of how | |
113 ;; this window is chosen.) This gives you fingertip control over two | |
114 ;; windows at once. | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
115 ;; |
17450 | 116 ;; C-S-return (vcursor-disable) disables the virtual cursor, removing |
117 ;; it so that it starts from point whenever you move it again --- note | |
118 ;; that simply moving the cursor and virtual cursor on top of one | |
119 ;; another does not have this effect. | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
120 ;; |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
121 ;; If you give C-S-return a positive prefix arg, it will also delete the |
17450 | 122 ;; window (unless it's the current one). Whenever the virtual cursor |
123 ;; goes off-screen in its own window, point in that window is moved as | |
124 ;; well to restore it to view. (It's easier that way, that's why. | |
125 ;; However, point doesn't move unless the view in the window does, so | |
126 ;; it's not tied to the virtual cursor location.) | |
127 ;; | |
128 ;; You can also use C-S-return with a negative prefix argument which | |
129 ;; forces the vcursor to appear at point. This is particularly useful if | |
130 ;; you actually want to edit in another window but would like to | |
131 ;; remember the current cursor location for examining or copying from | |
132 ;; that buffer. (I just hit C-S-right C-S-left, but I'm a hopeless | |
133 ;; lowbrow.) | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
134 ;; |
17450 | 135 ;; There is also C-S-f6 (vcursor-other-window) which behaves like |
136 ;; C-x o on the virtual rather than the real cursor, except that it | |
137 ;; will create another window if necessary. | |
138 ;; | |
139 ;; The keys C-S-prior (vcursor-scroll-down) and C-S-next | |
140 ;; (vcursor-scroll-up) (i.e., PageUp and PageDown) will scroll the | |
141 ;; virtual cursor window, appropriately chosen. They will always | |
142 ;; create a new window or take over an old one if necessary. | |
143 ;; Likewise, M-C-S-left and M-C-S-right move you to the | |
144 ;; beginning or end of a line, C-S-home and C-S-end the | |
145 ;; beginning or end of a buffer (these are also on M-C-S-up and | |
146 ;; M-C-S-down for those of us stuck with DEC keyboards). | |
147 ;; | |
148 ;; C-S-f7 (vcursor-goto) will take you to the vcursor position | |
149 ;; (swapping windows if it seems sensible) and (unless you give it a | |
150 ;; prefix argument) delete the virtual cursor, so this is useful for | |
151 ;; you to take over editing at the virtual cursor position. It is not | |
152 ;; an error if the virtual cursor is not active; it simply leaves you | |
153 ;; at point, because that is where the virtual cursor would start | |
154 ;; from. | |
155 ;; | |
156 ;; In a similar vein, M-C-S-tab (hope your left hand's flexible; | |
157 ;; C-S-select on DEC keyboards) (vcursor-swap-point) will take you to | |
158 ;; the virtual cursor position but simultaneously put the virtual | |
159 ;; cursor at the old cursor position. It is also supposed to ensure | |
160 ;; that both are visible. | |
161 ;; | |
162 ;; C-S-f8 (C-S-find on DEC keyboards) (vcursor-isearch-forward) | |
163 ;; allows you to do an isearch in another window. It works a bit like | |
164 ;; vcursor-scroll-*; it moves into another window, calls isearch | |
165 ;; there, and sets the virtual cursor position to the point found. In | |
166 ;; other words, it works just like isearch but with the virtual cursor | |
167 ;; instead of the real one (that's why it's called a "virtual | |
168 ;; cursor"). While you are isearching, you are editing in the virtual | |
169 ;; cursor window, but when you have finished you return to where you | |
170 ;; started. Note that once you are in isearch all the keys are normal | |
171 ;; --- use C-s, not C-S-f8, to search for the next occurrence. | |
172 ;; | |
173 ;; If you set the variable vcursor-auto-disable, then any command | |
174 ;; which does not involve moving or copying from the virtual cursor | |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
175 ;; causes the virtual cursor to be disabled. If you set it to non-nil |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
176 ;; but not t, then the vcursor itself will remain active, but copying |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
177 ;; will be turned off, so that the next time the vcursor is moved no |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
178 ;; text is copied over. Experience shows that this setting is |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
179 ;; particularly useful. If you don't intend to use this, you can |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
180 ;; comment out the `add-hook' line at the bottom of this file. (This |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
181 ;; feature partially emulates the way the "copy" key on the BBC micro |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
182 ;; worked; actually, the copy cursor was homed when you hit return. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
183 ;; This was in keeping with the line-by-line way of entering BASIC, |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
184 ;; but is less appropriate here.) |
17450 | 185 ;; |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
186 ;; vcursor-compare-windows is now a reliable adaption of |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
187 ;; compare-windows, which compares between point in the current buffer |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
188 ;; and the vcursor location in the other one. It is an error if |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
189 ;; vcursor is not set, however it will be brought up in another window |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
190 ;; if it is not currently visible. The prefix argument acts just like |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
191 ;; compare-windows, ignoring whitespace if set. (In versions before |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
192 ;; 1.6, this simply called compare-windows, which was much less likely |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
193 ;; to pick the two windows you wanted.) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
194 ;; |
17450 | 195 ;; There is a way of moving the virtual cursor using ordinary |
196 ;; commands: C-S-f9 (vcursor-execute-key) reads a key string, | |
197 ;; moves to the virtual cursor position, executes the command bound to | |
198 ;; the string, then returns to the original point. Thus C-S-f9 M-m | |
199 ;; moves the virtual cursor back to the first non-whitespace character | |
200 ;; on its line. As the command is called interactively all the usual | |
201 ;; ways of passing information to the command called, such as by a | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
202 ;; prefix argument, are available. This has many uses not necessarily |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
203 ;; related to moving the vcursor itself; it can do essentially |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
204 ;; everything that the \C-x 4 series of commands can do and a lot |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
205 ;; more. Note, however, that a new window is not used if the vcursor |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
206 ;; is visible in the current one: this can lead to some strange effects, |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
207 ;; but it is preferable to making a new window every time the vcursor |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
208 ;; is moved in this may. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
209 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
210 ;; C-S-f10 (C-S-x) (vcursor-execute-command) behaves the same way but |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
211 ;; you enter the name of the command. To do anything really |
17450 | 212 ;; complicated, you are better off using M-C-S-tab |
213 ;; (vcursor-swap-point), doing whatever it is, then calling M-C-S-tab | |
214 ;; again. | |
215 ;; | |
216 ;; If you want to add your own moving or copying functions you should | |
217 ;; be able to do this fairly easily with (vcursor-relative-move) and | |
218 ;; (vcursor-copy) together with (vcursor-get-char-count). If you want to | |
219 ;; do something in a different window, use (vcursor-window-funcall). | |
220 ;; | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
221 ;; Key bindings |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
222 ;; ============ |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
223 ;; |
17450 | 224 ;; There is an alternative set of key bindings which will be used |
225 ;; automatically for a PC if Oemacs is detected. This set uses separate | |
226 ;; control, shift and meta keys with function keys 1 to 10. In | |
227 ;; particular, movement keys are concentrated on f5 to f8 with (in | |
228 ;; increasing order of distance travelled) C-, M- and S- as prefixes. | |
229 ;; See the actual bindings below (search for C-f1). This is because the | |
230 ;; C-S- prefix is represented by weird key sequences and the set is | |
231 ;; incomplete; if you don't mind that, some hints are given in comments | |
232 ;; below. | |
233 ;; | |
234 ;; You can specify the usual or the Oemacs bindings by setting the | |
235 ;; variable vcursor-key-bindings to `xterm' or `oemacs'. You can also set | |
236 ;; it to nil, in which case vcursor will not make any key bindings | |
237 ;; and you can define your own. The default is t, which makes vcursor | |
238 ;; guess (it will use xterm unless it thinks Oemacs is running). The | |
239 ;; oemacs set will work on an X terminal with function keys, but the | |
240 ;; xterm set will not work under Oemacs. | |
241 ;; | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
242 ;; Usage on dumb terminals |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
243 ;; ======================= |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
244 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
245 ;; If Emacs has set the variable window-system to nil, vcursor will |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
246 ;; assume that overlays cannot be displayed in a different face, |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
247 ;; and will instead use a string (the variable vcursor-string, by |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
248 ;; default "**>") to show its position. This was first implemented |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
249 ;; in Emacs 19.29. Unlike the old-fashioned overlay arrow (as used |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
250 ;; by debuggers), this appears between existing text, which can |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
251 ;; make it hard to read if you're not used to it. (This seemed the |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
252 ;; better option here.) This means moving the vcursor up and down is |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
253 ;; a very efficient way of locating it! |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
254 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
255 ;; Everything else should function as expected, but there is no way to |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
256 ;; get an easy key binding for the vcursor keys on a generic terminal. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
257 ;; Consequently a special keymap is defined for you to use traditional |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
258 ;; methods: the keymap, however, is available on any terminal type. |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
259 ;; |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
260 ;; The vcursor keymap |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
261 ;; ================== |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
262 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
263 ;; In addition to any other bindings, vcursor-map contains key definitions |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
264 ;; for handling the vcursor. You should assign this to a prefix key |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
265 ;; in the usual way, e.g. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
266 ;; (global-set-key [f14] vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
267 ;; and also as usual \C-h in this map will list the key definitions, which |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
268 ;; are designed to be easy to remember. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
269 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
270 ;; A special feature is provided by (vcursor-toggle-vcursor-map), bound |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
271 ;; to t in that keymap. With this in effect, the main keymap |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
272 ;; is overridden by the vcursor map, so keys like \C-p and so on |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
273 ;; move the vcursor instead. Remember how to turn it off (type t), |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
274 ;; or you are in serious trouble! Note that the cursor keys are not |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
275 ;; bound by default in this keymap and will continue to move the |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
276 ;; ordinary cursor. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
277 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
278 ;; Interpreted input |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
279 ;; ================= |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
280 ;; |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
281 ;; Just occasionally, you may want to pretend the strings copied from |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
282 ;; the vcursor position are to be interpreted as if you had typed them |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
283 ;; from the keyboard. Normally, they will just insert themselves anyway, |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
284 ;; but in some modes (Info and calc for example) typing ordinary characters |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
285 ;; does something else. To get this effect, set |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
286 ;; vcursor-interpret-input to t. This is normally not a good idea as |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
287 ;; interpreting input is very much slower than copying text. |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
288 ;; |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
289 ;; Un-features |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
290 ;; =========== |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
291 ;; |
17450 | 292 ;; - The vcursor will not move to point-max, since otherwise it would |
293 ;; disappear. However, no error is flagged as point-max is a valid | |
294 ;; point in the buffer. Thus cursor right or down at the second | |
295 ;; last point in the file does not flag an error, which is inconsistent, | |
296 ;; and if copying is on the last character (typically newline) will | |
297 ;; be repeatedly copied. (I've tried making it flag an error | |
298 ;; instead and that's worse since often the vcursor is sent to | |
299 ;; point in some other window, which may be point-max.) | |
300 ;; - The vcursor widens when over a tab character or right at the | |
301 ;; end of the line. You're welcome to consider this a feature; | |
302 ;; it's just a part of how overlays work. | |
303 ;; - The vcursor obscures the real cursor. Creative use of overlays | |
304 ;; could cure this. | |
305 ;; - The vcursor does not remember its own previous positions. If | |
306 ;; you cycle it back into a window it was in before, it will be at | |
307 ;; point in that window. Often, that is where a previous recenter | |
308 ;; left point, not where the vcursor was before. | |
309 ;; (Note, however, that the vcursor does remember where it *is*, | |
310 ;; even if it's off-screen. This can also lead to surprises, but I | |
311 ;; don't think it's a bug.) | |
312 ;; - vcursor-window-funcall could perhaps be smarter about restoring | |
313 ;; the previous window state on failure. | |
314 ;; - The logic in vcursor-find-window is rather complicated and | |
315 ;; therefore bug-prone, though in practice it seems to work OK. | |
316 ;; | |
317 ;; Possible enhnacements: | |
318 ;; It would be easy to implement vcursor-push (save vcursor position | |
319 ;; as mark and deactivate) and vcursor-pop (deactivate vcursor and | |
320 ;; move to last pushed position) functions. | |
321 | |
322 ;;; Code: | |
323 | |
28459
d3c34ba6d095
(vcursor-move): Use display-color-p.
Dave Love <fx@gnu.org>
parents:
22901
diff
changeset
|
324 (eval-when-compile (require 'compare-w)) |
d3c34ba6d095
(vcursor-move): Use display-color-p.
Dave Love <fx@gnu.org>
parents:
22901
diff
changeset
|
325 |
21088 | 326 (defgroup vcursor nil |
327 "Manipulate an alternative (\"virtual\") cursor." | |
328 :prefix "vcursor-" | |
22901
12fca8181eca
(vcursor group): Move this to `editing' group.
Richard M. Stallman <rms@gnu.org>
parents:
22650
diff
changeset
|
329 :group 'editing) |
21088 | 330 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
331 (defface vcursor |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
332 '((((class color)) (:foreground "blue" :background "cyan" :underline t)) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
333 (t (:inverse-video t :underline t))) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
334 "Face for the virtual cursor." |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
335 :group 'vcursor) |
17450 | 336 |
21088 | 337 (defcustom vcursor-auto-disable nil |
17450 | 338 "*If non-nil, disable the virtual cursor after use. |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
339 Any non-vcursor command will force `vcursor-disable' to be called. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
340 If non-nil but not t, just make sure copying is toggled off, but don't |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
341 disable the vcursor." |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
342 :type '(choice (const t) (const nil) (const copy)) |
21088 | 343 :group 'vcursor) |
17450 | 344 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
345 ;; Needed for defcustom, must be up here |
32291
ad4a568e556a
(vcursor-cs-binding): Remove compatibility code.
Dave Love <fx@gnu.org>
parents:
30430
diff
changeset
|
346 (defun vcursor-cs-binding (base &optional meta) |
ad4a568e556a
(vcursor-cs-binding): Remove compatibility code.
Dave Love <fx@gnu.org>
parents:
30430
diff
changeset
|
347 (vector (let ((key (list 'control 'shift (intern base)))) |
ad4a568e556a
(vcursor-cs-binding): Remove compatibility code.
Dave Love <fx@gnu.org>
parents:
30430
diff
changeset
|
348 (if meta |
ad4a568e556a
(vcursor-cs-binding): Remove compatibility code.
Dave Love <fx@gnu.org>
parents:
30430
diff
changeset
|
349 (cons 'meta key) |
ad4a568e556a
(vcursor-cs-binding): Remove compatibility code.
Dave Love <fx@gnu.org>
parents:
30430
diff
changeset
|
350 key)))) |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
351 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
352 (defun vcursor-bind-keys (var value) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
353 "Alter the value of the variable VAR to VALUE, binding keys as required. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
354 VAR is usually vcursor-key-bindings. Normally this function is called |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
355 on loading vcursor and from the customize package." |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
356 (set var value) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
357 (cond |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
358 ((not value));; don't set any key bindings |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
359 ((or (eq value 'oemacs) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
360 (and (eq value t) (fboundp 'oemacs-version))) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
361 (global-set-key [C-f1] 'vcursor-toggle-copy) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
362 (global-set-key [C-f2] 'vcursor-copy) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
363 (global-set-key [C-f3] 'vcursor-copy-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
364 (global-set-key [C-f4] 'vcursor-copy-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
365 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
366 (global-set-key [S-f1] 'vcursor-disable) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
367 (global-set-key [S-f2] 'vcursor-other-window) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
368 (global-set-key [S-f3] 'vcursor-goto) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
369 (global-set-key [S-f4] 'vcursor-swap-point) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
370 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
371 (global-set-key [C-f5] 'vcursor-backward-char) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
372 (global-set-key [C-f6] 'vcursor-previous-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
373 (global-set-key [C-f7] 'vcursor-next-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
374 (global-set-key [C-f8] 'vcursor-forward-char) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
375 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
376 (global-set-key [M-f5] 'vcursor-beginning-of-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
377 (global-set-key [M-f6] 'vcursor-backward-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
378 (global-set-key [M-f6] 'vcursor-forward-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
379 (global-set-key [M-f8] 'vcursor-end-of-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
380 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
381 (global-set-key [S-f5] 'vcursor-beginning-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
382 (global-set-key [S-f6] 'vcursor-scroll-down) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
383 (global-set-key [S-f7] 'vcursor-scroll-up) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
384 (global-set-key [S-f8] 'vcursor-end-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
385 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
386 (global-set-key [C-f9] 'vcursor-isearch-forward) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
387 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
388 (global-set-key [S-f9] 'vcursor-execute-key) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
389 (global-set-key [S-f10] 'vcursor-execute-command) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
390 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
391 ;;; Partial dictionary of Oemacs key sequences for you to roll your own, |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
392 ;;; e.g C-S-up: (global-set-key "\M-[\C-f\M-\C-m" 'vcursor-previous-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
393 ;;; Sequence: Sends: |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
394 ;;; "\M-[\C-f\M-\C-m" C-S-up |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
395 ;;; "\M-[\C-f\M-\C-q" C-S-down |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
396 ;;; "\M-[\C-fs" C-S-left |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
397 ;;; "\M-[\C-ft" C-S-right |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
398 ;;; |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
399 ;;; "\M-[\C-fw" C-S-home |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
400 ;;; "\M-[\C-b\C-o" S-tab |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
401 ;;; "\M-[\C-f\M-\C-r" C-S-insert |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
402 ;;; "\M-[\C-fu" C-S-end |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
403 ;;; "\M-[\C-f\M-\C-s" C-S-delete |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
404 ;;; "\M-[\C-f\M-\C-d" C-S-prior |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
405 ;;; "\M-[\C-fv" C-S-next |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
406 ;;; |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
407 ;;; "\M-[\C-f^" C-S-f1 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
408 ;;; "\M-[\C-f_" C-S-f2 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
409 ;;; "\M-[\C-f`" C-S-f3 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
410 ;;; "\M-[\C-fa" C-S-f4 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
411 ;;; "\M-[\C-fb" C-S-f5 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
412 ;;; "\M-[\C-fc" C-S-f6 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
413 ;;; "\M-[\C-fd" C-S-f7 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
414 ;;; "\M-[\C-fe" C-S-f8 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
415 ;;; "\M-[\C-ff" C-S-f9 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
416 ;;; "\M-[\C-fg" C-S-f10 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
417 ) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
418 (t |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
419 (global-set-key (vcursor-cs-binding "up") 'vcursor-previous-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
420 (global-set-key (vcursor-cs-binding "down") 'vcursor-next-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
421 (global-set-key (vcursor-cs-binding "left") 'vcursor-backward-char) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
422 (global-set-key (vcursor-cs-binding "right") 'vcursor-forward-char) |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
423 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
424 (global-set-key (vcursor-cs-binding "return") 'vcursor-disable) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
425 (global-set-key (vcursor-cs-binding "insert") 'vcursor-copy) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
426 (global-set-key (vcursor-cs-binding "delete") 'vcursor-copy-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
427 (global-set-key (vcursor-cs-binding "remove") 'vcursor-copy-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
428 (global-set-key (vcursor-cs-binding "tab") 'vcursor-toggle-copy) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
429 (global-set-key (vcursor-cs-binding "backtab") 'vcursor-toggle-copy) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
430 (global-set-key (vcursor-cs-binding "home") 'vcursor-beginning-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
431 (global-set-key (vcursor-cs-binding "up" t) 'vcursor-beginning-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
432 (global-set-key (vcursor-cs-binding "end") 'vcursor-end-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
433 (global-set-key (vcursor-cs-binding "down" t) 'vcursor-end-of-buffer) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
434 (global-set-key (vcursor-cs-binding "prior") 'vcursor-scroll-down) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
435 (global-set-key (vcursor-cs-binding "next") 'vcursor-scroll-up) |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
436 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
437 (global-set-key (vcursor-cs-binding "f6") 'vcursor-other-window) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
438 (global-set-key (vcursor-cs-binding "f7") 'vcursor-goto) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
439 |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
440 (global-set-key (vcursor-cs-binding "select") |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
441 'vcursor-swap-point) ; DEC keyboards |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
442 (global-set-key (vcursor-cs-binding "tab" t) 'vcursor-swap-point) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
443 |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
444 (global-set-key (vcursor-cs-binding "find") |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
445 'vcursor-isearch-forward) ; DEC keyboards |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
446 (global-set-key (vcursor-cs-binding "f8") 'vcursor-isearch-forward) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
447 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
448 (global-set-key (vcursor-cs-binding "left" t) 'vcursor-beginning-of-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
449 (global-set-key (vcursor-cs-binding "right" t) 'vcursor-end-of-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
450 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
451 (global-set-key (vcursor-cs-binding "prior" t) 'vcursor-backward-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
452 (global-set-key (vcursor-cs-binding "next" t) 'vcursor-forward-word) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
453 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
454 (global-set-key (vcursor-cs-binding "return" t) 'vcursor-copy-line) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
455 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
456 (global-set-key (vcursor-cs-binding "f9") 'vcursor-execute-key) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
457 (global-set-key (vcursor-cs-binding "f10") 'vcursor-execute-command) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
458 ))) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
459 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
460 (defcustom vcursor-key-bindings nil |
17450 | 461 "*How to bind keys when vcursor is loaded. |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
462 If t, guess; if xterm, use bindings suitable for an X terminal; if |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
463 oemacs, use bindings which work on a PC with Oemacs. If nil, don't |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
464 define any key bindings. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
465 |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
466 Default is nil." |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
467 :type '(choice (const t) (const nil) (const xterm) (const oemacs)) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
468 :group 'vcursor |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
469 :set 'vcursor-bind-keys |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
470 :version "20.3") |
17450 | 471 |
21088 | 472 (defcustom vcursor-interpret-input nil |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
473 "*If non-nil, input from the vcursor is treated as interactive input. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
474 This will cause text insertion to be much slower. Note that no special |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
475 interpretation of strings is done: \"\C-x\" is a string of four |
21088 | 476 characters. The default is simply to copy strings." |
477 :type 'boolean | |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21088
diff
changeset
|
478 :group 'vcursor |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21088
diff
changeset
|
479 :version "20.3") |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
480 |
21088 | 481 (defcustom vcursor-string "**>" |
482 "String used to show the vcursor position on dumb terminals." | |
483 :type 'string | |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21088
diff
changeset
|
484 :group 'vcursor |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21088
diff
changeset
|
485 :version "20.3") |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
486 |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
487 (defvar vcursor-overlay nil |
17450 | 488 "Overlay for the virtual cursor. |
489 It is nil if that is not enabled.") | |
490 | |
491 (defvar vcursor-window nil | |
492 "Last window to have displayed the virtual cursor. | |
493 See the function `vcursor-find-window' for how this is used.") | |
494 | |
495 (defvar vcursor-last-command nil | |
496 "Non-nil if last command was a vcursor command. | |
497 The commands `vcursor-copy', `vcursor-relative-move' and the ones for | |
498 scrolling set this. It is used by the `vcursor-auto-disable' code.") | |
499 ;; could do some memq-ing with last-command instead, but this will | |
500 ;; automatically handle any new commands using the primitives. | |
501 | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
502 (defcustom vcursor-copy-flag nil |
21088 | 503 "*Non-nil means moving vcursor should copy characters moved over to point." |
504 :type 'boolean | |
505 :group 'vcursor) | |
17450 | 506 |
507 (defvar vcursor-temp-goal-column nil | |
508 "Keeps track of temporary goal columns for the virtual cursor.") | |
509 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
510 (defvar vcursor-use-vcursor-map nil |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
511 "Non-nil if the vcursor map is mapped directly onto the main keymap. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
512 See vcursor-toggle-vcursor-map.") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
513 (make-variable-buffer-local 'vcursor-use-vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
514 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
515 (defvar vcursor-map nil "Keymap for vcursor command.") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
516 (define-prefix-command 'vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
517 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
518 (define-key vcursor-map "t" 'vcursor-toggle-vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
519 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
520 (define-key vcursor-map "\C-p" 'vcursor-previous-line) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
521 (define-key vcursor-map "\C-n" 'vcursor-next-line) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
522 (define-key vcursor-map "\C-b" 'vcursor-backward-char) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
523 (define-key vcursor-map "\C-f" 'vcursor-forward-char) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
524 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
525 (define-key vcursor-map "\r" 'vcursor-disable) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
526 (define-key vcursor-map " " 'vcursor-copy) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
527 (define-key vcursor-map "\C-y" 'vcursor-copy-word) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
528 (define-key vcursor-map "\C-i" 'vcursor-toggle-copy) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
529 (define-key vcursor-map "<" 'vcursor-beginning-of-buffer) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
530 (define-key vcursor-map ">" 'vcursor-end-of-buffer) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
531 (define-key vcursor-map "\M-v" 'vcursor-scroll-down) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
532 (define-key vcursor-map "\C-v" 'vcursor-scroll-up) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
533 (define-key vcursor-map "o" 'vcursor-other-window) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
534 (define-key vcursor-map "g" 'vcursor-goto) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
535 (define-key vcursor-map "x" 'vcursor-swap-point) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
536 (define-key vcursor-map "\C-s" 'vcursor-isearch-forward) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
537 (define-key vcursor-map "\C-r" 'vcursor-isearch-backward) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
538 (define-key vcursor-map "\C-a" 'vcursor-beginning-of-line) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
539 (define-key vcursor-map "\C-e" 'vcursor-end-of-line) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
540 (define-key vcursor-map "\M-w" 'vcursor-forward-word) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
541 (define-key vcursor-map "\M-b" 'vcursor-backward-word) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
542 (define-key vcursor-map "\M-l" 'vcursor-copy-line) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
543 (define-key vcursor-map "c" 'vcursor-compare-windows) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
544 (define-key vcursor-map "k" 'vcursor-execute-key) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
545 (define-key vcursor-map "\M-x" 'vcursor-execute-command) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
546 |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
547 ;; If vcursor-key-bindings is already set on loading, bind the keys now. |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
548 ;; This hybrid way of doing it retains compatibility while allowing |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
549 ;; customize to work smoothly. |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
550 (if vcursor-key-bindings |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
551 (vcursor-bind-keys 'vcursor-key-bindings vcursor-key-bindings)) |
17450 | 552 |
553 (defun vcursor-locate () | |
554 "Go to the starting point of the virtual cursor. | |
555 If that's disabled, don't go anywhere but don't complain." | |
556 ;; This is where we go off-mass-shell. Assume there is a | |
557 ;; save-excursion to get us back to the pole, er, point. | |
558 | |
559 (and (overlayp vcursor-overlay) | |
560 (overlay-buffer vcursor-overlay) | |
561 (set-buffer (overlay-buffer vcursor-overlay)) | |
562 (goto-char (overlay-start vcursor-overlay))) | |
563 ) | |
564 | |
565 (defun vcursor-find-window (&optional not-this new-win this-frame) | |
566 "Return a suitable window for displaying the virtual cursor. | |
567 This is the first window in cyclic order where the vcursor is visible. | |
568 | |
569 With optional NOT-THIS non-nil never return the current window. | |
570 | |
571 With NEW-WIN non-nil, display the virtual cursor buffer in another | |
572 window if the virtual cursor is not currently visible \(note, however, | |
573 that this function never changes window-point\). | |
574 | |
575 With THIS-FRAME non-nil, don't search other frames for a new window | |
576 \(though if the vcursor is already off-frame then its current window is | |
577 always considered, and the value of `pop-up-frames' is always respected\). | |
578 | |
579 Returns nil if the virtual cursor is not visible anywhere suitable. | |
580 Set `vcursor-window' to the returned value as a side effect." | |
581 | |
582 ;; The order of priorities (respecting NOT-THIS) is (1) | |
583 ;; vcursor-window if the virtual cursor is visible there (2) any | |
584 ;; window displaying the virtual cursor (3) vcursor-window provided | |
585 ;; it is still displaying the buffer containing the virtual cursor and | |
586 ;; is not selected (4) any unselected window displaying the vcursor | |
587 ;; buffer (5) with NEW-WIN, a window selected by display-buffer (so | |
588 ;; the variables pop-up-windows and pop-up-frames are significant) | |
589 ;; (6) nil. | |
590 | |
591 (let ((thiswin (selected-window)) winok winbuf) | |
592 (save-excursion | |
593 (vcursor-locate) | |
594 (or (and (window-live-p vcursor-window) | |
595 (eq (current-buffer) (window-buffer vcursor-window)) | |
596 (not (and not-this (eq thiswin vcursor-window)))) | |
597 (setq vcursor-window nil)) | |
598 (or (and vcursor-window ; choice 1 | |
599 (pos-visible-in-window-p (point) vcursor-window)) | |
600 (progn | |
601 (walk-windows | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
602 (function |
17450 | 603 (lambda (win) |
604 (and (not winok) | |
605 (eq (current-buffer) (window-buffer win)) | |
606 (not (and not-this (eq thiswin win))) | |
607 (cond | |
608 ((pos-visible-in-window-p (point) win) (setq winok win)) | |
609 ((eq thiswin win)) | |
610 ((not winbuf) (setq winbuf win)))))) | |
611 nil (not this-frame)) | |
612 (setq vcursor-window | |
613 (cond | |
614 (winok) ; choice 2 | |
615 ((and vcursor-window ; choice 3 | |
616 (not (eq thiswin vcursor-window))) vcursor-window) | |
617 (winbuf) ; choice 4 | |
618 (new-win (display-buffer (current-buffer) t)) ; choice 5 | |
619 (t nil))))))) ; default (choice 6) | |
620 vcursor-window | |
621 ) | |
622 | |
623 (defun vcursor-toggle-copy (&optional arg nomsg) | |
624 "Toggle copying to point when the vcursor is moved. | |
625 With a prefix ARG, turn on if non-negative, off if negative. | |
626 Display a message unless optional NOMSG is non-nil." | |
627 (interactive "P") | |
628 (setq vcursor-copy-flag | |
629 (cond ((not arg) (not vcursor-copy-flag)) | |
630 ((< (prefix-numeric-value arg) 0) nil) | |
631 (t)) | |
632 vcursor-last-command t) | |
633 (or nomsg (message "Copying from the vcursor is now %s." | |
634 (if vcursor-copy-flag "on" "off"))) | |
635 ) | |
636 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
637 (defun vcursor-move (pt &optional leave-b leave-w) |
17450 | 638 "Move the virtual cursor to the character to the right of PT. |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
639 PT is an absolute location in the current buffer. With optional |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
640 LEAVE-B, PT is in the same buffer the vcursor is currently in. |
17450 | 641 |
642 If the new virtual cursor location would not be visible, display it in | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
643 another window. With LEAVE-W, use the current `vcursor-window'." |
17450 | 644 ;; this works even if we're on-mass-shell, but usually we won't be. |
645 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
646 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
647 (and leave-b (vcursor-check t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
648 (set-buffer (overlay-buffer vcursor-overlay))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
649 (if (eq pt (point-max)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
650 (setq pt (1- pt))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
651 (if (vcursor-check t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
652 (move-overlay vcursor-overlay pt (+ pt 1) (current-buffer)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
653 (setq vcursor-overlay (make-overlay pt (+ pt 1))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
654 (or window-system |
28459
d3c34ba6d095
(vcursor-move): Use display-color-p.
Dave Love <fx@gnu.org>
parents:
22901
diff
changeset
|
655 (display-color-p) |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
656 (overlay-put vcursor-overlay 'before-string vcursor-string)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
657 (overlay-put vcursor-overlay 'face 'vcursor)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
658 (or leave-w (vcursor-find-window nil t)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
659 ;; vcursor-window now contains the right buffer |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
660 (or (pos-visible-in-window-p pt vcursor-window) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
661 (set-window-point vcursor-window pt))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
662 ) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
663 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
664 (defun vcursor-insert (text) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
665 "Insert TEXT, respecting `vcursor-interpret-input'." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
666 (if vcursor-interpret-input |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
667 (setq unread-command-events |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
668 (append (listify-key-sequence text) unread-command-events)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
669 (insert text)) |
17450 | 670 ) |
671 | |
672 (defun vcursor-relative-move (fn &rest args) | |
673 "Use FUNCTION with arbitrary ARG1 ... to move the virtual cursor. | |
674 | |
675 This is called by most of the virtual-cursor motion commands." | |
676 (let (text opoint) | |
677 (save-excursion | |
678 (vcursor-locate) | |
679 (setq opoint (point)) | |
680 (apply fn args) | |
681 (and (eq opoint (point-max)) (eq opoint (point)) | |
682 (signal 'end-of-buffer nil)) | |
683 (vcursor-move (point)) | |
684 (if vcursor-copy-flag (setq text (buffer-substring opoint (point))))) | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
685 (if text (vcursor-insert text))) |
17450 | 686 (setq vcursor-last-command t) |
687 ) | |
688 | |
689 (defun vcursor-goto (&optional arg) | |
690 "Move the real cursor to the virtual cursor position. | |
691 If the virtual cursor is (or was recently) visible in another window, | |
692 switch to that first. Without a prefix ARG, disable the virtual | |
693 cursor as well." | |
694 | |
695 (interactive "P") | |
696 (and (vcursor-find-window) (select-window vcursor-window)) | |
697 (let ((buf (and vcursor-overlay (overlay-buffer vcursor-overlay)))) | |
698 (and buf (not (eq (current-buffer) buf)) (switch-to-buffer buf))) | |
699 (vcursor-locate) | |
700 (or arg (vcursor-disable)) | |
701 ) | |
702 | |
703 (defun vcursor-swap-point () | |
704 "Swap the location of point and that of the virtual cursor. | |
705 | |
706 The virtual cursor window becomes the selected window and the old | |
707 window becomes the virtual cursor window. If the virtual cursor would | |
708 not be visible otherwise, display it in another window." | |
709 | |
710 (interactive) | |
711 (let ((buf (current-buffer)) (here (point)) (win (selected-window))) | |
712 (vcursor-goto) ; will disable the vcursor | |
713 (save-excursion | |
714 (set-buffer buf) | |
715 (setq vcursor-window win) | |
716 (vcursor-move here))) | |
717 ) | |
718 | |
719 (defun vcursor-scroll-up (&optional n) | |
720 "Scroll up the vcursor window ARG lines or near full screen if none. | |
721 The vcursor will always appear in an unselected window." | |
722 | |
723 (interactive "P") | |
724 (vcursor-window-funcall 'scroll-up n) | |
725 ) | |
726 | |
727 (defun vcursor-scroll-down (&optional n) | |
728 "Scroll down the vcursor window ARG lines or near-full screen if none. | |
729 The vcursor will always appear in an unselected window." | |
730 | |
731 (interactive "P") | |
732 (vcursor-window-funcall 'scroll-down n) | |
733 ) | |
734 | |
735 (defun vcursor-isearch-forward (&optional rep norecurs) | |
736 "Perform forward incremental search in the virtual cursor window. | |
737 The virtual cursor is moved to the resulting point; the ordinary | |
738 cursor stays where it was." | |
739 | |
740 (interactive "P") | |
741 (vcursor-window-funcall 'isearch-forward rep norecurs) | |
742 ) | |
743 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
744 (defun vcursor-isearch-backward (&optional rep norecurs) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
745 "Perform backward incremental search in the virtual cursor window. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
746 The virtual cursor is moved to the resulting point; the ordinary |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
747 cursor stays where it was." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
748 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
749 (interactive "P") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
750 (vcursor-window-funcall 'isearch-backward rep norecurs) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
751 ) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
752 |
17450 | 753 (defun vcursor-window-funcall (func &rest args) |
754 "Call FUNC with ARGS ... in a virtual cursor window. | |
755 A window other than the currently-selected one will always be used. | |
756 The virtual cursor is moved to the value of point when the function | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
757 returns. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
758 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
759 If FUNC is a list, call the car of the list interactively, ignoring |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
760 ARGS. In this case, a new window will not be created if the vcursor |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
761 is visible in the current one." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
762 ;; that's to avoid messing up compatibility with old versions |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
763 ;; by introducing a new argument, which would have to come before ARGS. |
17450 | 764 |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
765 (vcursor-find-window (not (and (listp func) (vcursor-check t))) t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
766 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
767 (let ((sw (selected-window)) text) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
768 ;; We can't use save-window-excursion because that would restore |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
769 ;; the original display in the window we may want to alter. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
770 (unwind-protect |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
771 (let ((here (point))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
772 (select-window vcursor-window) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
773 (vcursor-locate) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
774 (if (listp func) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
775 (call-interactively (car func)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
776 (apply func args)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
777 (setq vcursor-window (selected-window)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
778 (and vcursor-copy-flag |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
779 (eq (current-buffer) (overlay-buffer vcursor-overlay)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
780 (setq text (buffer-substring here (point)))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
781 ;; vcursor-window and the current buffer are definitely |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
782 ;; right, so make sure vcursor-move doesn't pick others. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
783 (vcursor-move (point) nil t)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
784 (select-window sw)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
785 (if text (vcursor-insert text)))) |
17450 | 786 (setq vcursor-last-command t) |
787 ) | |
788 | |
789 (defun vcursor-get-char-count (fn &rest args) | |
790 "Apply FN to ARG1 ... and return the number of characters moved. | |
791 Point is temporarily set to the virtual cursor position before FN is | |
792 called. | |
793 | |
794 This is called by most of the virtual-cursor copying commands to find | |
795 out how much to copy." | |
796 | |
797 (vcursor-check) | |
798 (save-excursion | |
799 (set-buffer (overlay-buffer vcursor-overlay)) | |
800 (let ((start (goto-char (overlay-start vcursor-overlay)))) | |
801 (- (progn (apply fn args) (point)) start))) | |
802 ) | |
803 | |
804 ;; Make sure the virtual cursor is active. Unless arg is non-nil, | |
805 ;; report an error if it is not. | |
806 (defun vcursor-check (&optional arg) | |
807 (cond | |
808 ((and (overlayp vcursor-overlay) (overlay-start vcursor-overlay)) | |
809 t) | |
810 (arg nil) | |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
32291
diff
changeset
|
811 (t (error "The virtual cursor is not active now"))) |
17450 | 812 ) |
813 | |
814 (defun vcursor-disable (&optional arg) | |
815 "Disable the virtual cursor. | |
816 Next time you use it, it will start from point. | |
817 | |
818 With a positive prefix ARG, the first window in cyclic order | |
819 displaying the virtual cursor (or which was recently displaying the | |
49476
f1030525c96d
(vcursor-disable): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47941
diff
changeset
|
820 virtual cursor) will be deleted unless it's the selected |
17450 | 821 window. |
822 | |
823 With a negative prefix argument, enable the virtual cursor: make it | |
824 active at the same point as the real cursor. | |
825 | |
826 Copying mode is always turned off: the next use of the vcursor will | |
827 not copy text until you turn it on again." | |
828 | |
829 (interactive "P") | |
830 (if (overlayp vcursor-overlay) | |
831 (progn | |
832 (delete-overlay vcursor-overlay) | |
833 (setq vcursor-overlay nil))) | |
834 (cond | |
835 ((not (vcursor-find-window t))) | |
836 ((or (not arg) (< (prefix-numeric-value arg) 0))) | |
837 ((delete-window vcursor-window))) | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
838 (cond |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
839 ((and arg (< (prefix-numeric-value arg) 0)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
840 (vcursor-move (point)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
841 (setq vcursor-window (selected-window))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
842 (vcursor-use-vcursor-map (vcursor-toggle-vcursor-map 0))) |
17450 | 843 (setq vcursor-copy-flag nil) |
844 ) | |
845 | |
846 (defun vcursor-other-window (n &optional all-frames) | |
847 "Activate the virtual cursor in another window. | |
47941
df5fb1f2c113
(vcursor-other-window): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47270
diff
changeset
|
848 This is the next window cyclically after one currently showing the |
17450 | 849 virtual cursor, or else after the current selected window. If there |
850 is no other window, the current window is split. | |
851 | |
852 Arguments N and optional ALL-FRAMES are the same as with other-window. | |
853 ALL-FRAMES is also used to decide whether to split the window." | |
854 | |
855 (interactive "p") | |
856 (if (if (fboundp 'oemacs-version) | |
857 (one-window-p nil) | |
858 (one-window-p nil all-frames)) | |
859 (display-buffer (current-buffer) t)) | |
860 (save-excursion | |
861 (save-window-excursion | |
862 ;; We don't use fancy vcursor-find-window trickery, since we're | |
863 ;; quite happy to have the vcursor cycle back into the current | |
864 ;; window. | |
865 (let ((sw (selected-window)) | |
866 (win (vcursor-find-window nil nil (not all-frames)))) | |
867 (if win (select-window win)) | |
868 ;; else start from here | |
869 (other-window n all-frames) | |
870 (vcursor-disable -1)))) | |
871 ) | |
872 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
873 ;; vcursor-compare-windows is copied from compare-w.el with only |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
874 ;; minor modifications; these are too bound up with the function |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
875 ;; to make it really useful to call compare-windows itself. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
876 (defun vcursor-compare-windows (&optional ignore-whitespace) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
877 "Compare text in current window with text in window with vcursor. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
878 Compares the text starting at point in the current window and at the |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
879 vcursor position in the other window, moving over text in each one as |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
880 far as they match. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
881 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
882 A prefix argument, if any, means ignore changes in whitespace. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
883 The variable `compare-windows-whitespace' controls how whitespace is skipped. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
884 If `compare-ignore-case' is non-nil, changes in case are also ignored." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
885 (interactive "P") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
886 ;; (vcursor-window-funcall 'compare-windows arg) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
887 (require 'compare-w) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
888 (let* (p1 p2 maxp1 maxp2 b1 b2 w2 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
889 success size |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
890 (opoint1 (point)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
891 opoint2 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
892 (skip-whitespace (if ignore-whitespace |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
893 compare-windows-whitespace))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
894 (setq p1 (point) b1 (current-buffer)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
895 (setq w2 (vcursor-find-window t t)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
896 (if (or (eq w2 (selected-window)) (not w2)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
897 (error "No other window with vcursor")) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
898 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
899 (vcursor-locate) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
900 (setq p2 (point) b2 (current-buffer))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
901 (setq opoint2 p2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
902 (setq maxp1 (point-max)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
903 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
904 (set-buffer b2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
905 (setq maxp2 (point-max))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
906 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
907 (setq success t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
908 (while success |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
909 (setq success nil) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
910 ;; if interrupted, show how far we've gotten |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
911 (goto-char p1) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
912 (vcursor-move p2 t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
913 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
914 ;; If both buffers have whitespace next to point, |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
915 ;; optionally skip over it. |
17450 | 916 |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
917 (and skip-whitespace |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
918 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
919 (let (p1a p2a w1 w2 result1 result2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
920 (setq result1 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
921 (if (stringp skip-whitespace) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
922 (compare-windows-skip-whitespace opoint1) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
923 (funcall skip-whitespace opoint1))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
924 (setq p1a (point)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
925 (set-buffer b2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
926 (goto-char p2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
927 (setq result2 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
928 (if (stringp skip-whitespace) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
929 (compare-windows-skip-whitespace opoint2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
930 (funcall skip-whitespace opoint2))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
931 (setq p2a (point)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
932 (if (or (stringp skip-whitespace) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
933 (and result1 result2 (eq result1 result2))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
934 (setq p1 p1a |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
935 p2 p2a))))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
936 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
937 ;; Try advancing comparing 1000 chars at a time. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
938 ;; When that fails, go 500 chars at a time, and so on. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
939 (let ((size 1000) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
940 success-1 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
941 (case-fold-search compare-ignore-case)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
942 (while (> size 0) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
943 (setq success-1 t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
944 ;; Try comparing SIZE chars at a time, repeatedly, till that fails. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
945 (while success-1 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
946 (setq size (min size (- maxp1 p1) (- maxp2 p2))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
947 (setq success-1 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
948 (and (> size 0) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
949 (= 0 (compare-buffer-substrings b2 p2 (+ size p2) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
950 b1 p1 (+ size p1))))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
951 (if success-1 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
952 (setq p1 (+ p1 size) p2 (+ p2 size) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
953 success t))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
954 ;; If SIZE chars don't match, try fewer. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
955 (setq size (/ size 2))))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
956 |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
957 (goto-char p1) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
958 (vcursor-move p2 t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
959 (if (= (point) opoint1) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
960 (ding))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
961 ) |
17450 | 962 |
963 (defun vcursor-next-line (arg) | |
964 "Move the virtual cursor forward ARG lines." | |
965 ;; This is next-line rewritten for the vcursor. Maybe it would | |
966 ;; be easier simply to rewrite line-move. | |
967 (interactive "p") | |
968 (let (temporary-goal-column opoint text) | |
969 (save-excursion | |
970 (vcursor-locate) | |
971 (setq temporary-goal-column | |
972 (if (or (eq last-command 'vcursor-next-line) | |
973 (eq last-command 'vcursor-previous-line)) | |
974 (progn | |
975 (setq last-command 'next-line) ; trick line-move | |
976 vcursor-temp-goal-column) | |
977 (if (and track-eol (eolp) | |
978 (or (not (bolp)) (eq last-command 'end-of-line))) | |
979 9999 | |
980 (current-column))) | |
981 opoint (point)) | |
982 (line-move arg) | |
983 (and (eq opoint (point-max)) (eq opoint (point)) | |
984 (signal 'end-of-buffer nil)) | |
985 (if vcursor-copy-flag (setq text (buffer-substring opoint (point)))) | |
986 (vcursor-move (point)) | |
987 (setq vcursor-temp-goal-column temporary-goal-column | |
988 vcursor-last-command t)) | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
989 (if text (vcursor-insert text))) |
17450 | 990 ) |
991 | |
992 (defun vcursor-previous-line (arg) | |
993 "Move the virtual cursor back ARG lines." | |
994 (interactive "p") | |
995 (vcursor-next-line (- arg)) | |
996 ) | |
997 | |
998 (defun vcursor-forward-char (arg) | |
999 "Move the virtual cursor forward ARG characters." | |
1000 (interactive "p") | |
1001 (vcursor-relative-move 'forward-char arg) | |
1002 ) | |
1003 | |
1004 (defun vcursor-backward-char (arg) | |
1005 "Move the virtual cursor backward ARG characters." | |
1006 (interactive "p") | |
1007 (vcursor-relative-move 'backward-char arg) | |
1008 ) | |
1009 | |
1010 (defun vcursor-forward-word (arg) | |
1011 "Move the virtual cursor forward ARG words." | |
1012 (interactive "p") | |
1013 (vcursor-relative-move 'forward-word arg) | |
1014 ) | |
1015 | |
1016 (defun vcursor-backward-word (arg) | |
1017 "Move the virtual cursor backward ARG words." | |
1018 (interactive "p") | |
1019 (vcursor-relative-move 'backward-word arg) | |
1020 ) | |
1021 | |
1022 (defun vcursor-beginning-of-line (arg) | |
1023 "Move the virtual cursor to beginning of its current line. | |
1024 ARG is as for `beginning-of-line'." | |
1025 (interactive "P") | |
1026 (vcursor-relative-move 'beginning-of-line | |
1027 (if arg (prefix-numeric-value arg))) | |
1028 ) | |
1029 | |
1030 (defun vcursor-end-of-line (arg) | |
1031 "Move the virtual cursor to end of its current line. | |
1032 ARG is as for `end-of-line'." | |
1033 (interactive "P") | |
1034 (vcursor-relative-move 'end-of-line | |
1035 (if arg (prefix-numeric-value arg))) | |
1036 ) | |
1037 | |
1038 (defun vcursor-beginning-of-buffer (&optional arg) | |
1039 "Move the virtual cursor to the beginning of its buffer. | |
1040 ARG is as for beginning-of-buffer." | |
1041 (interactive "P") | |
1042 (vcursor-relative-move | |
1043 (lambda (arg) | |
1044 (goto-char (if arg (/ (* arg (- (point-max) (point-min))) 10) | |
1045 (point-min)))) | |
1046 (if arg (prefix-numeric-value arg))) | |
1047 ) | |
1048 | |
1049 (defun vcursor-end-of-buffer (&optional arg) | |
1050 "Move the virtual cursor to the end of its buffer. | |
1051 ARG is as for end-of-buffer. | |
1052 | |
1053 Actually, the vcursor is moved to the second from last character or it | |
1054 would be invisible." | |
1055 (interactive "P") | |
1056 (vcursor-relative-move | |
1057 (lambda (arg) | |
1058 (goto-char (if arg (- (point-max) | |
1059 (/ (* arg (- (point-max) (point-min))) 10)) | |
1060 (point-max)))) | |
1061 (if arg (prefix-numeric-value arg))) | |
1062 ) | |
1063 | |
1064 (defun vcursor-execute-command (cmd) | |
1065 "Execute COMMAND for the virtual cursor. | |
1066 COMMAND is called interactively. Not all commands (in fact, only a | |
1067 small subset) are useful." | |
1068 (interactive "CCommand: ") | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1069 (vcursor-window-funcall (list cmd)) |
17450 | 1070 ) |
1071 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1072 (defun vcursor-execute-key () |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1073 "Read a key sequence and execute the bound command for the virtual cursor. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1074 The key sequence is read at the vcursor location. The command found |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1075 is called interactively, so prefix argument etc. are usable." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1076 (interactive) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1077 (let (cmd) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1078 (save-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1079 ;; We'd like to avoid the display changing when we locate |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1080 ;; to the vcursor position and read a key sequence. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1081 (vcursor-find-window (not (vcursor-check t)) t) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1082 (save-window-excursion |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1083 (select-window vcursor-window) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1084 (vcursor-locate) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1085 (setq cmd (key-binding (read-key-sequence "Key sequence: "))))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1086 (vcursor-window-funcall (list cmd))) |
17450 | 1087 ) |
1088 | |
1089 (defun vcursor-copy (arg) | |
1090 "Copy ARG characters from the virtual cursor position to point." | |
1091 (interactive "p") | |
1092 (vcursor-check) | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1093 (vcursor-insert |
17450 | 1094 (save-excursion |
1095 (set-buffer (overlay-buffer vcursor-overlay)) | |
1096 (let* ((ostart (overlay-start vcursor-overlay)) | |
1097 (end (+ ostart arg))) | |
1098 (prog1 | |
1099 (buffer-substring ostart end) | |
1100 (vcursor-move end))))) | |
1101 (setq vcursor-last-command t) | |
1102 ) | |
1103 | |
1104 (defun vcursor-copy-word (arg) | |
1105 "Copy ARG words from the virtual cursor position to point." | |
1106 (interactive "p") | |
1107 (vcursor-copy (vcursor-get-char-count 'forward-word arg)) | |
1108 ) | |
1109 | |
1110 (defun vcursor-copy-line (arg) | |
1111 "Copy up to ARGth line after virtual cursor position. | |
1112 With no argument, copy to the end of the current line. | |
1113 | |
1114 Behaviour with regard to newlines is similar (but not identical) to | |
1115 `kill-line'; the main difference is that whitespace at the end of the | |
1116 line is treated like ordinary characters." | |
1117 | |
1118 (interactive "P") | |
1119 (let* ((num (prefix-numeric-value arg)) | |
1120 (count (vcursor-get-char-count 'end-of-line num))) | |
1121 (vcursor-copy (if (or (= count 0) arg) (1+ count) count))) | |
1122 ) | |
1123 | |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1124 (defun vcursor-toggle-vcursor-map (&optional force noredisp) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1125 "Toggle the state of the vcursor key map. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1126 When on, the keys defined in it are mapped directly on top of the main |
47270
5fe58e600ed7
(vcursor-toggle-vcursor-map): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
38412
diff
changeset
|
1127 keymap, allowing you to move the vcursor with ordinary motion keys. |
21061
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1128 An indication \"!VC\" appears in the mode list. The effect is |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1129 local to the current buffer. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1130 With prefix FORCE, turn on, or off if it is 0. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1131 With NOREDISP, don't force redisplay. |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1132 Disabling the vcursor automatically turns this off." |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1133 (interactive "P") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1134 (let ((new (cond ((not force) (not vcursor-use-vcursor-map)) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1135 ((eq force 0) nil) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1136 (t)))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1137 (or (eq new vcursor-use-vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1138 (progn |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1139 (setq vcursor-use-vcursor-map new) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1140 (or (assq 'vcursor-use-vcursor-map minor-mode-map-alist) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1141 (setq minor-mode-map-alist |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1142 (cons (cons 'vcursor-use-vcursor-map vcursor-map) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1143 minor-mode-map-alist))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1144 (or (assq 'vcursor-use-vcursor-map minor-mode-alist) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1145 (setq minor-mode-alist |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1146 (cons (list 'vcursor-use-vcursor-map " !VC") |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1147 minor-mode-alist))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1148 (or noredisp (redraw-display))))) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1149 ) |
7813d4b7bea5
Some support for character terminals provided.
Richard M. Stallman <rms@gnu.org>
parents:
17902
diff
changeset
|
1150 |
17450 | 1151 (defun vcursor-post-command () |
1152 (and vcursor-auto-disable (not vcursor-last-command) | |
22650
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
1153 vcursor-overlay |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
1154 (if (eq vcursor-auto-disable t) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
1155 (vcursor-disable) |
2809ce5a1a0a
Use defcustom to define faces.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
1156 (vcursor-toggle-copy -1 t))) |
17450 | 1157 (setq vcursor-last-command nil) |
1158 ) | |
1159 | |
1160 (add-hook 'post-command-hook 'vcursor-post-command) | |
1161 | |
1162 (provide 'vcursor) | |
1163 | |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
32291
diff
changeset
|
1164 ;;; vcursor.el ends here |