annotate lisp/vcursor.el @ 21888:6ce89105f98f

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