Mercurial > emacs
comparison lisp/vcursor.el @ 47941:df5fb1f2c113
(vcursor-other-window): Fix typo.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 18 Oct 2002 09:07:18 +0000 |
parents | 5fe58e600ed7 |
children | f1030525c96d |
comparison
equal
deleted
inserted
replaced
47940:c6a3d10a0675 | 47941:df5fb1f2c113 |
---|---|
91 ;; Inevitably it will clash with some other packages, but I can't help | 91 ;; Inevitably it will clash with some other packages, but I can't help |
92 ;; that: an intuitive binding is a prerequisite here. See below for | 92 ;; that: an intuitive binding is a prerequisite here. See below for |
93 ;; other alternatives (search for "Oemacs"). There is also a keymap | 93 ;; other alternatives (search for "Oemacs"). There is also a keymap |
94 ;; which you can bind to a prefix key, which may give some more | 94 ;; which you can bind to a prefix key, which may give some more |
95 ;; intuitive alternatives in some cases, see `The vcursor keymap' below. | 95 ;; intuitive alternatives in some cases, see `The vcursor keymap' below. |
96 ;; | 96 ;; |
97 ;; Holding down control and shift and pressing insert (vcursor-copy) | 97 ;; Holding down control and shift and pressing insert (vcursor-copy) |
98 ;; copies one character from wherever the virtual cursor is to point; | 98 ;; copies one character from wherever the virtual cursor is to point; |
99 ;; point and the virtual cursor advance in the separate and equal | 99 ;; point and the virtual cursor advance in the separate and equal |
100 ;; station to which... (etc.). M-C-S-return (vcursor-copy-line) | 100 ;; station to which... (etc.). M-C-S-return (vcursor-copy-line) |
101 ;; copies to the end of the line instead of just one character, | 101 ;; copies to the end of the line instead of just one character, |
102 ;; C-S-delete or C-S-remove (vcursor-copy-word) copies a word. | 102 ;; C-S-delete or C-S-remove (vcursor-copy-word) copies a word. |
103 ;; | 103 ;; |
104 ;; A more general way of copying is to use C-S-tab, which is a toggle. | 104 ;; A more general way of copying is to use C-S-tab, which is a toggle. |
105 ;; In the "on" state, moving the virtual cursor will copy the | 105 ;; In the "on" state, moving the virtual cursor will copy the |
106 ;; moved-over text to the normal cursor position (including when going | 106 ;; moved-over text to the normal cursor position (including when going |
107 ;; backwards, though each piece of text moved over is copied forwards: | 107 ;; backwards, though each piece of text moved over is copied forwards: |
108 ;; compare the behaviour of C-S-up and C-S-left). | 108 ;; compare the behaviour of C-S-up and C-S-left). |
110 ;; However, that's just a small part of the magic. If the virtual | 110 ;; However, that's just a small part of the magic. If the virtual |
111 ;; cursor goes off the display, it will be redisplayed in some other | 111 ;; cursor goes off the display, it will be redisplayed in some other |
112 ;; window. (See the function (vcursor-find-window) for details of how | 112 ;; window. (See the function (vcursor-find-window) for details of how |
113 ;; this window is chosen.) This gives you fingertip control over two | 113 ;; this window is chosen.) This gives you fingertip control over two |
114 ;; windows at once. | 114 ;; windows at once. |
115 ;; | 115 ;; |
116 ;; C-S-return (vcursor-disable) disables the virtual cursor, removing | 116 ;; C-S-return (vcursor-disable) disables the virtual cursor, removing |
117 ;; it so that it starts from point whenever you move it again --- note | 117 ;; it so that it starts from point whenever you move it again --- note |
118 ;; that simply moving the cursor and virtual cursor on top of one | 118 ;; that simply moving the cursor and virtual cursor on top of one |
119 ;; another does not have this effect. | 119 ;; another does not have this effect. |
120 ;; | 120 ;; |
121 ;; If you give C-S-return a positive prefix arg, it will also delete the | 121 ;; If you give C-S-return a positive prefix arg, it will also delete the |
122 ;; window (unless it's the current one). Whenever the virtual cursor | 122 ;; window (unless it's the current one). Whenever the virtual cursor |
123 ;; goes off-screen in its own window, point in that window is moved as | 123 ;; goes off-screen in its own window, point in that window is moved as |
124 ;; well to restore it to view. (It's easier that way, that's why. | 124 ;; well to restore it to view. (It's easier that way, that's why. |
125 ;; However, point doesn't move unless the view in the window does, so | 125 ;; However, point doesn't move unless the view in the window does, so |
129 ;; forces the vcursor to appear at point. This is particularly useful if | 129 ;; forces the vcursor to appear at point. This is particularly useful if |
130 ;; you actually want to edit in another window but would like to | 130 ;; you actually want to edit in another window but would like to |
131 ;; remember the current cursor location for examining or copying from | 131 ;; remember the current cursor location for examining or copying from |
132 ;; that buffer. (I just hit C-S-right C-S-left, but I'm a hopeless | 132 ;; that buffer. (I just hit C-S-right C-S-left, but I'm a hopeless |
133 ;; lowbrow.) | 133 ;; lowbrow.) |
134 ;; | 134 ;; |
135 ;; There is also C-S-f6 (vcursor-other-window) which behaves like | 135 ;; There is also C-S-f6 (vcursor-other-window) which behaves like |
136 ;; C-x o on the virtual rather than the real cursor, except that it | 136 ;; C-x o on the virtual rather than the real cursor, except that it |
137 ;; will create another window if necessary. | 137 ;; will create another window if necessary. |
138 ;; | 138 ;; |
139 ;; The keys C-S-prior (vcursor-scroll-down) and C-S-next | 139 ;; The keys C-S-prior (vcursor-scroll-down) and C-S-next |
218 ;; (vcursor-copy) together with (vcursor-get-char-count). If you want to | 218 ;; (vcursor-copy) together with (vcursor-get-char-count). If you want to |
219 ;; do something in a different window, use (vcursor-window-funcall). | 219 ;; do something in a different window, use (vcursor-window-funcall). |
220 ;; | 220 ;; |
221 ;; Key bindings | 221 ;; Key bindings |
222 ;; ============ | 222 ;; ============ |
223 ;; | 223 ;; |
224 ;; There is an alternative set of key bindings which will be used | 224 ;; There is an alternative set of key bindings which will be used |
225 ;; automatically for a PC if Oemacs is detected. This set uses separate | 225 ;; automatically for a PC if Oemacs is detected. This set uses separate |
226 ;; control, shift and meta keys with function keys 1 to 10. In | 226 ;; control, shift and meta keys with function keys 1 to 10. In |
227 ;; particular, movement keys are concentrated on f5 to f8 with (in | 227 ;; particular, movement keys are concentrated on f5 to f8 with (in |
228 ;; increasing order of distance travelled) C-, M- and S- as prefixes. | 228 ;; increasing order of distance travelled) C-, M- and S- as prefixes. |
242 ;; Usage on dumb terminals | 242 ;; Usage on dumb terminals |
243 ;; ======================= | 243 ;; ======================= |
244 ;; | 244 ;; |
245 ;; If Emacs has set the variable window-system to nil, vcursor will | 245 ;; If Emacs has set the variable window-system to nil, vcursor will |
246 ;; assume that overlays cannot be displayed in a different face, | 246 ;; assume that overlays cannot be displayed in a different face, |
247 ;; and will instead use an string (the variable vcursor-string, by | 247 ;; and will instead use a string (the variable vcursor-string, by |
248 ;; default "**>") to show its position. This was first implemented | 248 ;; default "**>") to show its position. This was first implemented |
249 ;; in Emacs 19.29. Unlike the old-fashioned overlay arrow (as used | 249 ;; in Emacs 19.29. Unlike the old-fashioned overlay arrow (as used |
250 ;; by debuggers), this appears between existing text, which can | 250 ;; by debuggers), this appears between existing text, which can |
251 ;; make it hard to read if you're not used to it. (This seemed the | 251 ;; make it hard to read if you're not used to it. (This seemed the |
252 ;; better option here.) This means moving the vcursor up and down is | 252 ;; better option here.) This means moving the vcursor up and down is |
254 ;; | 254 ;; |
255 ;; Everything else should function as expected, but there is no way to | 255 ;; Everything else should function as expected, but there is no way to |
256 ;; get an easy key binding for the vcursor keys on a generic terminal. | 256 ;; get an easy key binding for the vcursor keys on a generic terminal. |
257 ;; Consequently a special keymap is defined for you to use traditional | 257 ;; Consequently a special keymap is defined for you to use traditional |
258 ;; methods: the keymap, however, is available on any terminal type. | 258 ;; methods: the keymap, however, is available on any terminal type. |
259 ;; | 259 ;; |
260 ;; The vcursor keymap | 260 ;; The vcursor keymap |
261 ;; ================== | 261 ;; ================== |
262 ;; | 262 ;; |
263 ;; In addition to any other bindings, vcursor-map contains key definitions | 263 ;; In addition to any other bindings, vcursor-map contains key definitions |
264 ;; for handling the vcursor. You should assign this to a prefix key | 264 ;; for handling the vcursor. You should assign this to a prefix key |
283 ;; from the keyboard. Normally, they will just insert themselves anyway, | 283 ;; from the keyboard. Normally, they will just insert themselves anyway, |
284 ;; but in some modes (Info and calc for example) typing ordinary characters | 284 ;; but in some modes (Info and calc for example) typing ordinary characters |
285 ;; does something else. To get this effect, set | 285 ;; does something else. To get this effect, set |
286 ;; vcursor-interpret-input to t. This is normally not a good idea as | 286 ;; vcursor-interpret-input to t. This is normally not a good idea as |
287 ;; interpreting input is very much slower than copying text. | 287 ;; interpreting input is very much slower than copying text. |
288 ;; | 288 ;; |
289 ;; Un-features | 289 ;; Un-features |
290 ;; =========== | 290 ;; =========== |
291 ;; | 291 ;; |
292 ;; - The vcursor will not move to point-max, since otherwise it would | 292 ;; - The vcursor will not move to point-max, since otherwise it would |
293 ;; disappear. However, no error is flagged as point-max is a valid | 293 ;; disappear. However, no error is flagged as point-max is a valid |
401 ;;; "\M-[\C-f\M-\C-r" C-S-insert | 401 ;;; "\M-[\C-f\M-\C-r" C-S-insert |
402 ;;; "\M-[\C-fu" C-S-end | 402 ;;; "\M-[\C-fu" C-S-end |
403 ;;; "\M-[\C-f\M-\C-s" C-S-delete | 403 ;;; "\M-[\C-f\M-\C-s" C-S-delete |
404 ;;; "\M-[\C-f\M-\C-d" C-S-prior | 404 ;;; "\M-[\C-f\M-\C-d" C-S-prior |
405 ;;; "\M-[\C-fv" C-S-next | 405 ;;; "\M-[\C-fv" C-S-next |
406 ;;; | 406 ;;; |
407 ;;; "\M-[\C-f^" C-S-f1 | 407 ;;; "\M-[\C-f^" C-S-f1 |
408 ;;; "\M-[\C-f_" C-S-f2 | 408 ;;; "\M-[\C-f_" C-S-f2 |
409 ;;; "\M-[\C-f`" C-S-f3 | 409 ;;; "\M-[\C-f`" C-S-f3 |
410 ;;; "\M-[\C-fa" C-S-f4 | 410 ;;; "\M-[\C-fa" C-S-f4 |
411 ;;; "\M-[\C-fb" C-S-f5 | 411 ;;; "\M-[\C-fb" C-S-f5 |
418 (t | 418 (t |
419 (global-set-key (vcursor-cs-binding "up") 'vcursor-previous-line) | 419 (global-set-key (vcursor-cs-binding "up") 'vcursor-previous-line) |
420 (global-set-key (vcursor-cs-binding "down") 'vcursor-next-line) | 420 (global-set-key (vcursor-cs-binding "down") 'vcursor-next-line) |
421 (global-set-key (vcursor-cs-binding "left") 'vcursor-backward-char) | 421 (global-set-key (vcursor-cs-binding "left") 'vcursor-backward-char) |
422 (global-set-key (vcursor-cs-binding "right") 'vcursor-forward-char) | 422 (global-set-key (vcursor-cs-binding "right") 'vcursor-forward-char) |
423 | 423 |
424 (global-set-key (vcursor-cs-binding "return") 'vcursor-disable) | 424 (global-set-key (vcursor-cs-binding "return") 'vcursor-disable) |
425 (global-set-key (vcursor-cs-binding "insert") 'vcursor-copy) | 425 (global-set-key (vcursor-cs-binding "insert") 'vcursor-copy) |
426 (global-set-key (vcursor-cs-binding "delete") 'vcursor-copy-word) | 426 (global-set-key (vcursor-cs-binding "delete") 'vcursor-copy-word) |
427 (global-set-key (vcursor-cs-binding "remove") 'vcursor-copy-word) | 427 (global-set-key (vcursor-cs-binding "remove") 'vcursor-copy-word) |
428 (global-set-key (vcursor-cs-binding "tab") 'vcursor-toggle-copy) | 428 (global-set-key (vcursor-cs-binding "tab") 'vcursor-toggle-copy) |
431 (global-set-key (vcursor-cs-binding "up" t) 'vcursor-beginning-of-buffer) | 431 (global-set-key (vcursor-cs-binding "up" t) 'vcursor-beginning-of-buffer) |
432 (global-set-key (vcursor-cs-binding "end") 'vcursor-end-of-buffer) | 432 (global-set-key (vcursor-cs-binding "end") 'vcursor-end-of-buffer) |
433 (global-set-key (vcursor-cs-binding "down" t) 'vcursor-end-of-buffer) | 433 (global-set-key (vcursor-cs-binding "down" t) 'vcursor-end-of-buffer) |
434 (global-set-key (vcursor-cs-binding "prior") 'vcursor-scroll-down) | 434 (global-set-key (vcursor-cs-binding "prior") 'vcursor-scroll-down) |
435 (global-set-key (vcursor-cs-binding "next") 'vcursor-scroll-up) | 435 (global-set-key (vcursor-cs-binding "next") 'vcursor-scroll-up) |
436 | 436 |
437 (global-set-key (vcursor-cs-binding "f6") 'vcursor-other-window) | 437 (global-set-key (vcursor-cs-binding "f6") 'vcursor-other-window) |
438 (global-set-key (vcursor-cs-binding "f7") 'vcursor-goto) | 438 (global-set-key (vcursor-cs-binding "f7") 'vcursor-goto) |
439 | 439 |
440 (global-set-key (vcursor-cs-binding "select") | 440 (global-set-key (vcursor-cs-binding "select") |
441 'vcursor-swap-point) ; DEC keyboards | 441 'vcursor-swap-point) ; DEC keyboards |
442 (global-set-key (vcursor-cs-binding "tab" t) 'vcursor-swap-point) | 442 (global-set-key (vcursor-cs-binding "tab" t) 'vcursor-swap-point) |
443 | 443 |
444 (global-set-key (vcursor-cs-binding "find") | 444 (global-set-key (vcursor-cs-binding "find") |
445 'vcursor-isearch-forward) ; DEC keyboards | 445 'vcursor-isearch-forward) ; DEC keyboards |
446 (global-set-key (vcursor-cs-binding "f8") 'vcursor-isearch-forward) | 446 (global-set-key (vcursor-cs-binding "f8") 'vcursor-isearch-forward) |
447 | 447 |
448 (global-set-key (vcursor-cs-binding "left" t) 'vcursor-beginning-of-line) | 448 (global-set-key (vcursor-cs-binding "left" t) 'vcursor-beginning-of-line) |
449 (global-set-key (vcursor-cs-binding "right" t) 'vcursor-end-of-line) | 449 (global-set-key (vcursor-cs-binding "right" t) 'vcursor-end-of-line) |
482 "String used to show the vcursor position on dumb terminals." | 482 "String used to show the vcursor position on dumb terminals." |
483 :type 'string | 483 :type 'string |
484 :group 'vcursor | 484 :group 'vcursor |
485 :version "20.3") | 485 :version "20.3") |
486 | 486 |
487 (defvar vcursor-overlay nil | 487 (defvar vcursor-overlay nil |
488 "Overlay for the virtual cursor. | 488 "Overlay for the virtual cursor. |
489 It is nil if that is not enabled.") | 489 It is nil if that is not enabled.") |
490 | 490 |
491 (defvar vcursor-window nil | 491 (defvar vcursor-window nil |
492 "Last window to have displayed the virtual cursor. | 492 "Last window to have displayed the virtual cursor. |
497 The commands `vcursor-copy', `vcursor-relative-move' and the ones for | 497 The commands `vcursor-copy', `vcursor-relative-move' and the ones for |
498 scrolling set this. It is used by the `vcursor-auto-disable' code.") | 498 scrolling set this. It is used by the `vcursor-auto-disable' code.") |
499 ;; could do some memq-ing with last-command instead, but this will | 499 ;; could do some memq-ing with last-command instead, but this will |
500 ;; automatically handle any new commands using the primitives. | 500 ;; automatically handle any new commands using the primitives. |
501 | 501 |
502 (defcustom vcursor-copy-flag nil | 502 (defcustom vcursor-copy-flag nil |
503 "*Non-nil means moving vcursor should copy characters moved over to point." | 503 "*Non-nil means moving vcursor should copy characters moved over to point." |
504 :type 'boolean | 504 :type 'boolean |
505 :group 'vcursor) | 505 :group 'vcursor) |
506 | 506 |
507 (defvar vcursor-temp-goal-column nil | 507 (defvar vcursor-temp-goal-column nil |
545 (define-key vcursor-map "\M-x" 'vcursor-execute-command) | 545 (define-key vcursor-map "\M-x" 'vcursor-execute-command) |
546 | 546 |
547 ;; If vcursor-key-bindings is already set on loading, bind the keys now. | 547 ;; If vcursor-key-bindings is already set on loading, bind the keys now. |
548 ;; This hybrid way of doing it retains compatibility while allowing | 548 ;; This hybrid way of doing it retains compatibility while allowing |
549 ;; customize to work smoothly. | 549 ;; customize to work smoothly. |
550 (if vcursor-key-bindings | 550 (if vcursor-key-bindings |
551 (vcursor-bind-keys 'vcursor-key-bindings vcursor-key-bindings)) | 551 (vcursor-bind-keys 'vcursor-key-bindings vcursor-key-bindings)) |
552 | 552 |
553 (defun vcursor-locate () | 553 (defun vcursor-locate () |
554 "Go to the starting point of the virtual cursor. | 554 "Go to the starting point of the virtual cursor. |
555 If that's disabled, don't go anywhere but don't complain." | 555 If that's disabled, don't go anywhere but don't complain." |
597 (setq vcursor-window nil)) | 597 (setq vcursor-window nil)) |
598 (or (and vcursor-window ; choice 1 | 598 (or (and vcursor-window ; choice 1 |
599 (pos-visible-in-window-p (point) vcursor-window)) | 599 (pos-visible-in-window-p (point) vcursor-window)) |
600 (progn | 600 (progn |
601 (walk-windows | 601 (walk-windows |
602 (function | 602 (function |
603 (lambda (win) | 603 (lambda (win) |
604 (and (not winok) | 604 (and (not winok) |
605 (eq (current-buffer) (window-buffer win)) | 605 (eq (current-buffer) (window-buffer win)) |
606 (not (and not-this (eq thiswin win))) | 606 (not (and not-this (eq thiswin win))) |
607 (cond | 607 (cond |
843 (setq vcursor-copy-flag nil) | 843 (setq vcursor-copy-flag nil) |
844 ) | 844 ) |
845 | 845 |
846 (defun vcursor-other-window (n &optional all-frames) | 846 (defun vcursor-other-window (n &optional all-frames) |
847 "Activate the virtual cursor in another window. | 847 "Activate the virtual cursor in another window. |
848 This is the next window cylically after one currently showing the | 848 This is the next window cyclically after one currently showing the |
849 virtual cursor, or else after the current selected window. If there | 849 virtual cursor, or else after the current selected window. If there |
850 is no other window, the current window is split. | 850 is no other window, the current window is split. |
851 | 851 |
852 Arguments N and optional ALL-FRAMES are the same as with other-window. | 852 Arguments N and optional ALL-FRAMES are the same as with other-window. |
853 ALL-FRAMES is also used to decide whether to split the window." | 853 ALL-FRAMES is also used to decide whether to split the window." |