comparison lisp/vcursor.el @ 90203:187d6a1f84f7

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-71 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 485-492) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 92-94) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 22 Jul 2005 08:27:27 +0000
parents f9a65d7ebd29 4b552d6938e8
children 2d92f5c9d6ae
comparison
equal deleted inserted replaced
90202:7597b4a23c3b 90203:187d6a1f84f7
354 (cons 'meta key) 354 (cons 'meta key)
355 key)))) 355 key))))
356 356
357 (defun vcursor-bind-keys (var value) 357 (defun vcursor-bind-keys (var value)
358 "Alter the value of the variable VAR to VALUE, binding keys as required. 358 "Alter the value of the variable VAR to VALUE, binding keys as required.
359 VAR is usually vcursor-key-bindings. Normally this function is called 359 VAR is usually `vcursor-key-bindings'. Normally this function is called
360 on loading vcursor and from the customize package." 360 on loading vcursor and from the customize package."
361 (set var value) 361 (set var value)
362 (cond 362 (cond
363 ((not value));; don't set any key bindings 363 ((not value));; don't set any key bindings
364 ((or (eq value 'oemacs) 364 ((or (eq value 'oemacs)
462 (global-set-key (vcursor-cs-binding "f10") 'vcursor-execute-command) 462 (global-set-key (vcursor-cs-binding "f10") 'vcursor-execute-command)
463 ))) 463 )))
464 464
465 (defcustom vcursor-key-bindings nil 465 (defcustom vcursor-key-bindings nil
466 "*How to bind keys when vcursor is loaded. 466 "*How to bind keys when vcursor is loaded.
467 If t, guess; if xterm, use bindings suitable for an X terminal; if 467 If t, guess; if `xterm', use bindings suitable for an X terminal; if
468 oemacs, use bindings which work on a PC with Oemacs. If nil, don't 468 `oemacs', use bindings which work on a PC with Oemacs. If nil, don't
469 define any key bindings. 469 define any key bindings.
470 470
471 Default is nil." 471 Default is nil."
472 :type '(choice (const t) (const nil) (const xterm) (const oemacs)) 472 :type '(choice (const t) (const nil) (const xterm) (const oemacs))
473 :group 'vcursor 473 :group 'vcursor
512 (defvar vcursor-temp-goal-column nil 512 (defvar vcursor-temp-goal-column nil
513 "Keeps track of temporary goal columns for the virtual cursor.") 513 "Keeps track of temporary goal columns for the virtual cursor.")
514 514
515 (defvar vcursor-use-vcursor-map nil 515 (defvar vcursor-use-vcursor-map nil
516 "Non-nil if the vcursor map is mapped directly onto the main keymap. 516 "Non-nil if the vcursor map is mapped directly onto the main keymap.
517 See vcursor-toggle-vcursor-map.") 517 See `vcursor-toggle-vcursor-map'.")
518 (make-variable-buffer-local 'vcursor-use-vcursor-map) 518 (make-variable-buffer-local 'vcursor-use-vcursor-map)
519 519
520 (defvar vcursor-map nil "Keymap for vcursor command.") 520 (defvar vcursor-map nil "Keymap for vcursor command.")
521 (define-prefix-command 'vcursor-map) 521 (define-prefix-command 'vcursor-map)
522 522
573 573
574 With optional NOT-THIS non-nil never return the current window. 574 With optional NOT-THIS non-nil never return the current window.
575 575
576 With NEW-WIN non-nil, display the virtual cursor buffer in another 576 With NEW-WIN non-nil, display the virtual cursor buffer in another
577 window if the virtual cursor is not currently visible \(note, however, 577 window if the virtual cursor is not currently visible \(note, however,
578 that this function never changes window-point\). 578 that this function never changes `window-point'\).
579 579
580 With THIS-FRAME non-nil, don't search other frames for a new window 580 With THIS-FRAME non-nil, don't search other frames for a new window
581 \(though if the vcursor is already off-frame then its current window is 581 \(though if the vcursor is already off-frame then its current window is
582 always considered, and the value of `pop-up-frames' is always respected\). 582 always considered, and the value of `pop-up-frames' is always respected\).
583 583
672 (setq unread-command-events 672 (setq unread-command-events
673 (append (listify-key-sequence text) unread-command-events)) 673 (append (listify-key-sequence text) unread-command-events))
674 (insert text)) 674 (insert text))
675 ) 675 )
676 676
677 (defun vcursor-relative-move (fn &rest args) 677 (defun vcursor-relative-move (func &rest args)
678 "Use FUNCTION with arbitrary ARG1 ... to move the virtual cursor. 678 "Call FUNC with arbitrary ARGS ... to move the virtual cursor.
679 679
680 This is called by most of the virtual-cursor motion commands." 680 This is called by most of the virtual-cursor motion commands."
681 (let (text opoint) 681 (let (text opoint)
682 (save-excursion 682 (save-excursion
683 (vcursor-locate) 683 (vcursor-locate)
684 (setq opoint (point)) 684 (setq opoint (point))
685 (apply fn args) 685 (apply func args)
686 (and (eq opoint (point-max)) (eq opoint (point)) 686 (and (eq opoint (point-max)) (eq opoint (point))
687 (signal 'end-of-buffer nil)) 687 (signal 'end-of-buffer nil))
688 (vcursor-move (point)) 688 (vcursor-move (point))
689 (if vcursor-copy-flag (setq text (buffer-substring opoint (point))))) 689 (if vcursor-copy-flag (setq text (buffer-substring opoint (point)))))
690 (if text (vcursor-insert text))) 690 (if text (vcursor-insert text)))
728 (interactive "P") 728 (interactive "P")
729 (vcursor-window-funcall 'scroll-up n) 729 (vcursor-window-funcall 'scroll-up n)
730 ) 730 )
731 731
732 (defun vcursor-scroll-down (&optional n) 732 (defun vcursor-scroll-down (&optional n)
733 "Scroll down the vcursor window ARG lines or near-full screen if none. 733 "Scroll down the vcursor window ARG lines or near full screen if none.
734 The vcursor will always appear in an unselected window." 734 The vcursor will always appear in an unselected window."
735 735
736 (interactive "P") 736 (interactive "P")
737 (vcursor-window-funcall 'scroll-down n) 737 (vcursor-window-funcall 'scroll-down n)
738 ) 738 )
789 (select-window sw)) 789 (select-window sw))
790 (if text (vcursor-insert text)))) 790 (if text (vcursor-insert text))))
791 (setq vcursor-last-command t) 791 (setq vcursor-last-command t)
792 ) 792 )
793 793
794 (defun vcursor-get-char-count (fn &rest args) 794 (defun vcursor-get-char-count (func &rest args)
795 "Apply FN to ARG1 ... and return the number of characters moved. 795 "Apply FUNC to ARGS ... and return the number of characters moved.
796 Point is temporarily set to the virtual cursor position before FN is 796 Point is temporarily set to the virtual cursor position before FUNC
797 called. 797 is called.
798 798
799 This is called by most of the virtual-cursor copying commands to find 799 This is called by most of the virtual-cursor copying commands to find
800 out how much to copy." 800 out how much to copy."
801 801
802 (vcursor-check) 802 (vcursor-check)
803 (save-excursion 803 (save-excursion
804 (set-buffer (overlay-buffer vcursor-overlay)) 804 (set-buffer (overlay-buffer vcursor-overlay))
805 (let ((start (goto-char (overlay-start vcursor-overlay)))) 805 (let ((start (goto-char (overlay-start vcursor-overlay))))
806 (- (progn (apply fn args) (point)) start))) 806 (- (progn (apply func args) (point)) start)))
807 ) 807 )
808 808
809 ;; Make sure the virtual cursor is active. Unless arg is non-nil, 809 ;; Make sure the virtual cursor is active. Unless arg is non-nil,
810 ;; report an error if it is not. 810 ;; report an error if it is not.
811 (defun vcursor-check (&optional arg) 811 (defun vcursor-check (&optional arg)
820 "Disable the virtual cursor. 820 "Disable the virtual cursor.
821 Next time you use it, it will start from point. 821 Next time you use it, it will start from point.
822 822
823 With a positive prefix ARG, the first window in cyclic order 823 With a positive prefix ARG, the first window in cyclic order
824 displaying the virtual cursor (or which was recently displaying the 824 displaying the virtual cursor (or which was recently displaying the
825 virtual cursor) will be deleted unless it's the selected 825 virtual cursor) will be deleted unless it's the selected window.
826 window.
827 826
828 With a negative prefix argument, enable the virtual cursor: make it 827 With a negative prefix argument, enable the virtual cursor: make it
829 active at the same point as the real cursor. 828 active at the same point as the real cursor.
830 829
831 Copying mode is always turned off: the next use of the vcursor will 830 Copying mode is always turned off: the next use of the vcursor will
832 not copy text until you turn it on again." 831 not copy text until you turn it on again."
833 832
834 (interactive "P") 833 (interactive "P")
835 (if (overlayp vcursor-overlay) 834 (if (overlayp vcursor-overlay)
836 (progn 835 (progn
852 "Activate the virtual cursor in another window. 851 "Activate the virtual cursor in another window.
853 This is the next window cyclically after one currently showing the 852 This is the next window cyclically after one currently showing the
854 virtual cursor, or else after the current selected window. If there 853 virtual cursor, or else after the current selected window. If there
855 is no other window, the current window is split. 854 is no other window, the current window is split.
856 855
857 Arguments N and optional ALL-FRAMES are the same as with other-window. 856 Arguments N and optional ALL-FRAMES are the same as with `other-window'.
858 ALL-FRAMES is also used to decide whether to split the window." 857 ALL-FRAMES is also used to decide whether to split the window."
859 858
860 (interactive "p") 859 (interactive "p")
861 (if (if (fboundp 'oemacs-version) 860 (if (if (fboundp 'oemacs-version)
862 (one-window-p nil) 861 (one-window-p nil)
1040 (if arg (prefix-numeric-value arg))) 1039 (if arg (prefix-numeric-value arg)))
1041 ) 1040 )
1042 1041
1043 (defun vcursor-beginning-of-buffer (&optional arg) 1042 (defun vcursor-beginning-of-buffer (&optional arg)
1044 "Move the virtual cursor to the beginning of its buffer. 1043 "Move the virtual cursor to the beginning of its buffer.
1045 ARG is as for beginning-of-buffer." 1044 ARG is as for `beginning-of-buffer'."
1046 (interactive "P") 1045 (interactive "P")
1047 (vcursor-relative-move 1046 (vcursor-relative-move
1048 (lambda (arg) 1047 (lambda (arg)
1049 (goto-char (if arg (/ (* arg (- (point-max) (point-min))) 10) 1048 (goto-char (if arg (/ (* arg (- (point-max) (point-min))) 10)
1050 (point-min)))) 1049 (point-min))))
1051 (if arg (prefix-numeric-value arg))) 1050 (if arg (prefix-numeric-value arg)))
1052 ) 1051 )
1053 1052
1054 (defun vcursor-end-of-buffer (&optional arg) 1053 (defun vcursor-end-of-buffer (&optional arg)
1055 "Move the virtual cursor to the end of its buffer. 1054 "Move the virtual cursor to the end of its buffer.
1056 ARG is as for end-of-buffer. 1055 ARG is as for `end-of-buffer'.
1057 1056
1058 Actually, the vcursor is moved to the second from last character or it 1057 Actually, the vcursor is moved to the second from last character or it
1059 would be invisible." 1058 would be invisible."
1060 (interactive "P") 1059 (interactive "P")
1061 (vcursor-relative-move 1060 (vcursor-relative-move