aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-30 07:05:40 +0000
committerRichard M. Stallman1998-06-30 07:05:40 +0000
commit2d6a47330e9866bf44eddd1a89245a9dbb70fd85 (patch)
treece53548ccec1493bc28b9db4366f838da5604b88
parente326384cdaf490940cb472b26257a299ee109bad (diff)
downloademacs-2d6a47330e9866bf44eddd1a89245a9dbb70fd85.tar.gz
emacs-2d6a47330e9866bf44eddd1a89245a9dbb70fd85.zip
Use defcustom to define faces.
(vcursor-bind-keys): New function. (vcursor-key-bindings): Use vcursor-bind-keys for :set. (vcursor-cs-binding): Function to handle bindings, handles differences between Emacs and XEmacs. (vcursor-post-command): Handle vcursor-auto-disable non-nil and not t to toggle off copying.
-rw-r--r--lisp/vcursor.el309
1 files changed, 179 insertions, 130 deletions
diff --git a/lisp/vcursor.el b/lisp/vcursor.el
index d4c13f46103..89ae105b7fa 100644
--- a/lisp/vcursor.el
+++ b/lisp/vcursor.el
@@ -2,7 +2,7 @@
2 2
3;; Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Peter Stephenson <pws@ifh.de> 5;; Author: Peter Stephenson <pws@ibmth.df.unipi.it>
6;; Keywords: virtual cursor, display, copying 6;; Keywords: virtual cursor, display, copying
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
@@ -24,9 +24,21 @@
24 24
25;;; Commentary: 25;;; Commentary:
26 26
27;; Latest changes (1.6) 27;; Latest changes
28;; ==================== 28;; ==============
29;; 29;;
30;; - *IMPORTANT* vcursor-key-bindings is now nil by default, to avoid
31;; side-effects when the package is loaded. This means no keys are
32;; bound by default. Use customize to change it to t to restore
33;; the old behaviour. (If you do it by hand in .emacs, it
34;; must come before vcursor is loaded.)
35;; - You can alter the main variables and the vcursor face via
36;; M-x customize: go to the Editing group and find Vcursor.
37;; - vcursor-auto-disable can now be 'copy (actually any value not nil
38;; or t), which means that copying from the vcursor will be turned
39;; off after any operation not involving the vcursor, but the
40;; vcursor itself will be left alone.
41;; - should now work unmodified under XEmacs
30;; - works on dumb terminals with Emacs 19.29 and later 42;; - works on dumb terminals with Emacs 19.29 and later
31;; - new keymap vcursor-map for binding to a prefix key 43;; - new keymap vcursor-map for binding to a prefix key
32;; - vcursor-compare-windows substantially improved 44;; - vcursor-compare-windows substantially improved
@@ -46,10 +58,13 @@
46;; for more information. 58;; for more information.
47;; 59;;
48;; This is much easier to use than the instructions are to read. 60;; This is much easier to use than the instructions are to read.
49;; I suggest you simply load it and play around with holding down Ctrl 61;; First, you need to let vcursor define some keys: setting
50;; and Shift and pressing up, down, left, right, tab, return, and see 62;; vcursor-key-bindings to t before loading, or by customize, will
51;; what happens. (Find a scratch buffer before using C-S-tab: that 63;; define various keys with the prefix C-S. You'll have to read
52;; toggles copying.) 64;; further if you don't want this. Then I suggest you simply load it
65;; and play around with holding down Ctrl and Shift and pressing up,
66;; down, left, right, tab, return, and see what happens. (Find a
67;; scratch buffer before using C-S-tab: that toggles copying.)
53;; 68;;
54;; Most of the functions described in this documentation are in 69;; Most of the functions described in this documentation are in
55;; parentheses so that if you have the package loaded you can type C-h 70;; parentheses so that if you have the package loaded you can type C-h
@@ -157,12 +172,16 @@
157;; 172;;
158;; If you set the variable vcursor-auto-disable, then any command 173;; If you set the variable vcursor-auto-disable, then any command
159;; which does not involve moving or copying from the virtual cursor 174;; which does not involve moving or copying from the virtual cursor
160;; causes the virtual cursor to be disabled. If you don't intend to 175;; causes the virtual cursor to be disabled. If you set it to non-nil
161;; use this, you can comment out the `add-hook' line at the bottom of 176;; but not t, then the vcursor itself will remain active, but copying
162;; this file. (This feature partially emulates the way the "copy" key 177;; will be turned off, so that the next time the vcursor is moved no
163;; on the BBC micro worked; actually, the copy cursor was homed when 178;; text is copied over. Experience shows that this setting is
164;; you hit return. This was in keeping with the line-by-line way of 179;; particularly useful. If you don't intend to use this, you can
165;; entering BASIC, but is less appropriate here.) 180;; comment out the `add-hook' line at the bottom of this file. (This
181;; feature partially emulates the way the "copy" key on the BBC micro
182;; worked; actually, the copy cursor was homed when you hit return.
183;; This was in keeping with the line-by-line way of entering BASIC,
184;; but is less appropriate here.)
166;; 185;;
167;; vcursor-compare-windows is now a reliable adaption of 186;; vcursor-compare-windows is now a reliable adaption of
168;; compare-windows, which compares between point in the current buffer 187;; compare-windows, which compares between point in the current buffer
@@ -307,29 +326,149 @@
307 :prefix "vcursor-" 326 :prefix "vcursor-"
308 :group 'display) 327 :group 'display)
309 328
310(or (memq 'vcursor (face-list)) 329(defface vcursor
311 (progn 330 '((((class color)) (:foreground "blue" :background "cyan" :underline t))
312 (copy-face 'modeline 'vcursor) 331 (t (:inverse-video t :underline t)))
313 (if (or (fboundp 'oemacs-version) 332 "Face for the virtual cursor."
314 (and (eq window-system 'x) (x-display-color-p))) 333 :group 'vcursor)
315 (progn
316 (set-face-foreground 'vcursor "blue")
317 (set-face-background 'vcursor "cyan")))
318 (set-face-underline-p 'vcursor t)))
319 334
320(defcustom vcursor-auto-disable nil 335(defcustom vcursor-auto-disable nil
321 "*If non-nil, disable the virtual cursor after use. 336 "*If non-nil, disable the virtual cursor after use.
322Any non-vcursor command will force `vcursor-disable' to be called." 337Any non-vcursor command will force `vcursor-disable' to be called.
323 :type 'boolean 338If non-nil but not t, just make sure copying is toggled off, but don't
339disable the vcursor."
340 :type '(choice (const t) (const nil) (const copy))
324 :group 'vcursor) 341 :group 'vcursor)
325 342
326(defcustom vcursor-key-bindings t 343;; Needed for defcustom, must be up here
344(if (not (string-match "XEmacs" emacs-version))
345 (defun vcursor-cs-binding (base &optional meta)
346 (read (concat "[" (if meta "M-" "") "C-S-" base "]")))
347 (require 'overlay)
348 (defun vcursor-cs-binding (base &optional meta)
349 (read (concat "[(" (if meta "meta " "") "control shift "
350 base ")]")))
351 )
352
353(defun vcursor-bind-keys (var value)
354 "Alter the value of the variable VAR to VALUE, binding keys as required.
355VAR is usually vcursor-key-bindings. Normally this function is called
356on loading vcursor and from the customize package."
357 (set var value)
358 (cond
359 ((not value));; don't set any key bindings
360 ((or (eq value 'oemacs)
361 (and (eq value t) (fboundp 'oemacs-version)))
362 (global-set-key [C-f1] 'vcursor-toggle-copy)
363 (global-set-key [C-f2] 'vcursor-copy)
364 (global-set-key [C-f3] 'vcursor-copy-word)
365 (global-set-key [C-f4] 'vcursor-copy-line)
366
367 (global-set-key [S-f1] 'vcursor-disable)
368 (global-set-key [S-f2] 'vcursor-other-window)
369 (global-set-key [S-f3] 'vcursor-goto)
370 (global-set-key [S-f4] 'vcursor-swap-point)
371
372 (global-set-key [C-f5] 'vcursor-backward-char)
373 (global-set-key [C-f6] 'vcursor-previous-line)
374 (global-set-key [C-f7] 'vcursor-next-line)
375 (global-set-key [C-f8] 'vcursor-forward-char)
376
377 (global-set-key [M-f5] 'vcursor-beginning-of-line)
378 (global-set-key [M-f6] 'vcursor-backward-word)
379 (global-set-key [M-f6] 'vcursor-forward-word)
380 (global-set-key [M-f8] 'vcursor-end-of-line)
381
382 (global-set-key [S-f5] 'vcursor-beginning-of-buffer)
383 (global-set-key [S-f6] 'vcursor-scroll-down)
384 (global-set-key [S-f7] 'vcursor-scroll-up)
385 (global-set-key [S-f8] 'vcursor-end-of-buffer)
386
387 (global-set-key [C-f9] 'vcursor-isearch-forward)
388
389 (global-set-key [S-f9] 'vcursor-execute-key)
390 (global-set-key [S-f10] 'vcursor-execute-command)
391
392;;; Partial dictionary of Oemacs key sequences for you to roll your own,
393;;; e.g C-S-up: (global-set-key "\M-[\C-f\M-\C-m" 'vcursor-previous-line)
394;;; Sequence: Sends:
395;;; "\M-[\C-f\M-\C-m" C-S-up
396;;; "\M-[\C-f\M-\C-q" C-S-down
397;;; "\M-[\C-fs" C-S-left
398;;; "\M-[\C-ft" C-S-right
399;;;
400;;; "\M-[\C-fw" C-S-home
401;;; "\M-[\C-b\C-o" S-tab
402;;; "\M-[\C-f\M-\C-r" C-S-insert
403;;; "\M-[\C-fu" C-S-end
404;;; "\M-[\C-f\M-\C-s" C-S-delete
405;;; "\M-[\C-f\M-\C-d" C-S-prior
406;;; "\M-[\C-fv" C-S-next
407;;;
408;;; "\M-[\C-f^" C-S-f1
409;;; "\M-[\C-f_" C-S-f2
410;;; "\M-[\C-f`" C-S-f3
411;;; "\M-[\C-fa" C-S-f4
412;;; "\M-[\C-fb" C-S-f5
413;;; "\M-[\C-fc" C-S-f6
414;;; "\M-[\C-fd" C-S-f7
415;;; "\M-[\C-fe" C-S-f8
416;;; "\M-[\C-ff" C-S-f9
417;;; "\M-[\C-fg" C-S-f10
418 )
419 (t
420 (global-set-key (vcursor-cs-binding "up") 'vcursor-previous-line)
421 (global-set-key (vcursor-cs-binding "down") 'vcursor-next-line)
422 (global-set-key (vcursor-cs-binding "left") 'vcursor-backward-char)
423 (global-set-key (vcursor-cs-binding "right") 'vcursor-forward-char)
424
425 (global-set-key (vcursor-cs-binding "return") 'vcursor-disable)
426 (global-set-key (vcursor-cs-binding "insert") 'vcursor-copy)
427 (global-set-key (vcursor-cs-binding "delete") 'vcursor-copy-word)
428 (global-set-key (vcursor-cs-binding "remove") 'vcursor-copy-word)
429 (global-set-key (vcursor-cs-binding "tab") 'vcursor-toggle-copy)
430 (global-set-key (vcursor-cs-binding "backtab") 'vcursor-toggle-copy)
431 (global-set-key (vcursor-cs-binding "home") 'vcursor-beginning-of-buffer)
432 (global-set-key (vcursor-cs-binding "up" t) 'vcursor-beginning-of-buffer)
433 (global-set-key (vcursor-cs-binding "end") 'vcursor-end-of-buffer)
434 (global-set-key (vcursor-cs-binding "down" t) 'vcursor-end-of-buffer)
435 (global-set-key (vcursor-cs-binding "prior") 'vcursor-scroll-down)
436 (global-set-key (vcursor-cs-binding "next") 'vcursor-scroll-up)
437
438 (global-set-key (vcursor-cs-binding "f6") 'vcursor-other-window)
439 (global-set-key (vcursor-cs-binding "f7") 'vcursor-goto)
440
441 (global-set-key (vcursor-cs-binding "select")
442 'vcursor-swap-point) ; DEC keyboards
443 (global-set-key (vcursor-cs-binding "tab" t) 'vcursor-swap-point)
444
445 (global-set-key (vcursor-cs-binding "find")
446 'vcursor-isearch-forward) ; DEC keyboards
447 (global-set-key (vcursor-cs-binding "f8") 'vcursor-isearch-forward)
448
449 (global-set-key (vcursor-cs-binding "left" t) 'vcursor-beginning-of-line)
450 (global-set-key (vcursor-cs-binding "right" t) 'vcursor-end-of-line)
451
452 (global-set-key (vcursor-cs-binding "prior" t) 'vcursor-backward-word)
453 (global-set-key (vcursor-cs-binding "next" t) 'vcursor-forward-word)
454
455 (global-set-key (vcursor-cs-binding "return" t) 'vcursor-copy-line)
456
457 (global-set-key (vcursor-cs-binding "f9") 'vcursor-execute-key)
458 (global-set-key (vcursor-cs-binding "f10") 'vcursor-execute-command)
459 )))
460
461(defcustom vcursor-key-bindings nil
327 "*How to bind keys when vcursor is loaded. 462 "*How to bind keys when vcursor is loaded.
328If t (the default), guess; if xterm, use bindings suitable for an 463If t, guess; if xterm, use bindings suitable for an X terminal; if
329X terminal; if oemacs, use bindings which work on a PC with Oemacs. 464oemacs, use bindings which work on a PC with Oemacs. If nil, don't
330If nil, don't define any key bindings." 465define any key bindings.
331 :type '(choice (const t) (const xterm) (const oemacs) (const nil)) 466
332 :group 'vcursor) 467Default is nil."
468 :type '(choice (const t) (const nil) (const xterm) (const oemacs))
469 :group 'vcursor
470 :set 'vcursor-bind-keys
471 :version "20.3")
333 472
334(defcustom vcursor-interpret-input nil 473(defcustom vcursor-interpret-input nil
335 "*If non-nil, input from the vcursor is treated as interactive input. 474 "*If non-nil, input from the vcursor is treated as interactive input.
@@ -406,105 +545,11 @@ See vcursor-toggle-vcursor-map.")
406(define-key vcursor-map "k" 'vcursor-execute-key) 545(define-key vcursor-map "k" 'vcursor-execute-key)
407(define-key vcursor-map "\M-x" 'vcursor-execute-command) 546(define-key vcursor-map "\M-x" 'vcursor-execute-command)
408 547
409(cond 548;; If vcursor-key-bindings is already set on loading, bind the keys now.
410 ((not vcursor-key-bindings)) ;; don't set any key bindings 549;; This hybrid way of doing it retains compatibility while allowing
411 ((or (eq vcursor-key-bindings 'oemacs) 550;; customize to work smoothly.
412 (and (eq vcursor-key-bindings t) (fboundp 'oemacs-version))) 551(if vcursor-key-bindings
413 (global-set-key [C-f1] 'vcursor-toggle-copy) 552 (vcursor-bind-keys 'vcursor-key-bindings vcursor-key-bindings))
414 (global-set-key [C-f2] 'vcursor-copy)
415 (global-set-key [C-f3] 'vcursor-copy-word)
416 (global-set-key [C-f4] 'vcursor-copy-line)
417
418 (global-set-key [S-f1] 'vcursor-disable)
419 (global-set-key [S-f2] 'vcursor-other-window)
420 (global-set-key [S-f3] 'vcursor-goto)
421 (global-set-key [S-f4] 'vcursor-swap-point)
422
423 (global-set-key [C-f5] 'vcursor-backward-char)
424 (global-set-key [C-f6] 'vcursor-previous-line)
425 (global-set-key [C-f7] 'vcursor-next-line)
426 (global-set-key [C-f8] 'vcursor-forward-char)
427
428 (global-set-key [M-f5] 'vcursor-beginning-of-line)
429 (global-set-key [M-f6] 'vcursor-backward-word)
430 (global-set-key [M-f6] 'vcursor-forward-word)
431 (global-set-key [M-f8] 'vcursor-end-of-line)
432
433 (global-set-key [S-f5] 'vcursor-beginning-of-buffer)
434 (global-set-key [S-f6] 'vcursor-scroll-down)
435 (global-set-key [S-f7] 'vcursor-scroll-up)
436 (global-set-key [S-f8] 'vcursor-end-of-buffer)
437
438 (global-set-key [C-f9] 'vcursor-isearch-forward)
439
440 (global-set-key [S-f9] 'vcursor-execute-key)
441 (global-set-key [S-f10] 'vcursor-execute-command)
442
443;;; Partial dictionary of Oemacs key sequences for you to roll your own,
444;;; e.g C-S-up: (global-set-key "\M-[\C-f\M-\C-m" 'vcursor-previous-line)
445;;; Sequence: Sends:
446;;; "\M-[\C-f\M-\C-m" C-S-up
447;;; "\M-[\C-f\M-\C-q" C-S-down
448;;; "\M-[\C-fs" C-S-left
449;;; "\M-[\C-ft" C-S-right
450;;;
451;;; "\M-[\C-fw" C-S-home
452;;; "\M-[\C-b\C-o" S-tab
453;;; "\M-[\C-f\M-\C-r" C-S-insert
454;;; "\M-[\C-fu" C-S-end
455;;; "\M-[\C-f\M-\C-s" C-S-delete
456;;; "\M-[\C-f\M-\C-d" C-S-prior
457;;; "\M-[\C-fv" C-S-next
458;;;
459;;; "\M-[\C-f^" C-S-f1
460;;; "\M-[\C-f_" C-S-f2
461;;; "\M-[\C-f`" C-S-f3
462;;; "\M-[\C-fa" C-S-f4
463;;; "\M-[\C-fb" C-S-f5
464;;; "\M-[\C-fc" C-S-f6
465;;; "\M-[\C-fd" C-S-f7
466;;; "\M-[\C-fe" C-S-f8
467;;; "\M-[\C-ff" C-S-f9
468;;; "\M-[\C-fg" C-S-f10
469 )
470 (t
471 (global-set-key [C-S-up] 'vcursor-previous-line)
472 (global-set-key [C-S-down] 'vcursor-next-line)
473 (global-set-key [C-S-left] 'vcursor-backward-char)
474 (global-set-key [C-S-right] 'vcursor-forward-char)
475
476 (global-set-key [C-S-return] 'vcursor-disable)
477 (global-set-key [C-S-insert] 'vcursor-copy)
478 (global-set-key [C-S-delete] 'vcursor-copy-word)
479 (global-set-key [C-S-remove] 'vcursor-copy-word)
480 (global-set-key [C-S-tab] 'vcursor-toggle-copy)
481 (global-set-key [C-S-home] 'vcursor-beginning-of-buffer)
482 (global-set-key [M-C-S-up] 'vcursor-beginning-of-buffer)
483 (global-set-key [C-S-end] 'vcursor-end-of-buffer)
484 (global-set-key [M-C-S-down] 'vcursor-end-of-buffer)
485 (global-set-key [C-S-prior] 'vcursor-scroll-down)
486 (global-set-key [C-S-next] 'vcursor-scroll-up)
487
488 (global-set-key [C-S-f6] 'vcursor-other-window)
489 (global-set-key [C-S-f7] 'vcursor-goto)
490
491 (global-set-key [C-S-select] 'vcursor-swap-point) ; DEC keyboards
492 (global-set-key [M-C-S-tab] 'vcursor-swap-point)
493
494 (global-set-key [C-S-find] 'vcursor-isearch-forward) ; DEC keyboards
495 (global-set-key [C-S-f8] 'vcursor-isearch-forward)
496
497 (global-set-key [M-C-S-left] 'vcursor-beginning-of-line)
498 (global-set-key [M-C-S-right] 'vcursor-end-of-line)
499
500 (global-set-key [M-C-S-prior] 'vcursor-backward-word)
501 (global-set-key [M-C-S-next] 'vcursor-forward-word)
502
503 (global-set-key [M-C-S-return] 'vcursor-copy-line)
504
505 (global-set-key [C-S-f9] 'vcursor-execute-key)
506 (global-set-key [C-S-f10] 'vcursor-execute-command)
507 ))
508 553
509(defun vcursor-locate () 554(defun vcursor-locate ()
510 "Go to the starting point of the virtual cursor. 555 "Go to the starting point of the virtual cursor.
@@ -515,6 +560,7 @@ If that's disabled, don't go anywhere but don't complain."
515 (and (overlayp vcursor-overlay) 560 (and (overlayp vcursor-overlay)
516 (overlay-buffer vcursor-overlay) 561 (overlay-buffer vcursor-overlay)
517 (set-buffer (overlay-buffer vcursor-overlay)) 562 (set-buffer (overlay-buffer vcursor-overlay))
563 (overlay-start vcursor-overlay) ; needed for XEmacs
518 (goto-char (overlay-start vcursor-overlay))) 564 (goto-char (overlay-start vcursor-overlay)))
519 ) 565 )
520 566
@@ -1105,7 +1151,10 @@ Disabling the vcursor automatically turns this off."
1105 1151
1106(defun vcursor-post-command () 1152(defun vcursor-post-command ()
1107 (and vcursor-auto-disable (not vcursor-last-command) 1153 (and vcursor-auto-disable (not vcursor-last-command)
1108 vcursor-overlay (vcursor-disable)) 1154 vcursor-overlay
1155 (if (eq vcursor-auto-disable t)
1156 (vcursor-disable)
1157 (vcursor-toggle-copy -1 t)))
1109 (setq vcursor-last-command nil) 1158 (setq vcursor-last-command nil)
1110 ) 1159 )
1111 1160