]> git.eshelyaron.com Git - emacs.git/commitdiff
new version
authorMichael Kifer <kifer@cs.stonybrook.edu>
Mon, 9 Jun 1997 04:00:50 +0000 (04:00 +0000)
committerMichael Kifer <kifer@cs.stonybrook.edu>
Mon, 9 Jun 1997 04:00:50 +0000 (04:00 +0000)
lisp/emulation/viper-cmd.el
lisp/emulation/viper-ex.el
lisp/emulation/viper-init.el
lisp/emulation/viper-keym.el
lisp/emulation/viper-macs.el
lisp/emulation/viper-mous.el
lisp/emulation/viper-util.el
lisp/emulation/viper.el

index 644b73fa6bca5eeebf0a501fc01c2646a0607b07..2e25a44a7e5c943d3637d5752e6f9f34b762985c 100644 (file)
@@ -1,30 +1,11 @@
 ;;; viper-cmd.el --- Vi command support for Viper
-
 ;; Copyright (C) 1997 Free Software Foundation, Inc.
 
-;; Keywords: emulations
-;; Author: Michael Kifer <kifer@cs.sunysb.edu>
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
 
 ;; Code
 
 (provide 'viper-cmd)
+(require 'advice)
 
 ;; Compiler pacifier
 (defvar vip-minibuffer-current-face)
 (defvar zmacs-region-stays)
 (defvar mark-even-if-inactive)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-util)
-       (load "viper-util.el" nil nil 'nosuffix))
-    (or (featurep 'viper-keym)
-       (load "viper-keym.el" nil nil 'nosuffix))
-    (or (featurep 'viper-mous)
-       (load "viper-mous.el" nil nil 'nosuffix))
-    (or (featurep 'viper-macs)
-       (load "viper-macs.el" nil nil 'nosuffix))
-    (or (featurep 'viper-ex)
-       (load "viper-ex.el" nil nil 'nosuffix))
-    ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-util)
+           (load "viper-util.el" nil nil 'nosuffix))
+       (or (featurep 'viper-keym)
+           (load "viper-keym.el" nil nil 'nosuffix))
+       (or (featurep 'viper-mous)
+           (load "viper-mous.el" nil nil 'nosuffix))
+       (or (featurep 'viper-macs)
+           (load "viper-macs.el" nil nil 'nosuffix))
+       (or (featurep 'viper-ex)
+           (load "viper-ex.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 
@@ -937,36 +921,6 @@ as a Meta key and any number of multiple escapes is allowed."
     keyseq))
 
     
-    
-(defadvice read-key-sequence (around vip-read-keyseq-ad activate)
-  "Harness to work for Viper. This advice is harmless---don't worry!"
-  (let (inhibit-quit event keyseq)
-    (setq keyseq ad-do-it)
-    (setq event (if vip-xemacs-p
-                   (elt keyseq 0) ; XEmacs returns vector of events
-                 (elt (listify-key-sequence keyseq) 0)))
-    (if (vip-ESC-event-p event)
-       (let (unread-command-events)
-         (vip-set-unread-command-events keyseq)
-         (if (vip-fast-keysequence-p)
-             (let ((vip-vi-global-user-minor-mode  nil)
-                   (vip-vi-local-user-minor-mode  nil)
-                   (vip-replace-minor-mode nil) ; actually unnecessary
-                   (vip-insert-global-user-minor-mode  nil)
-                   (vip-insert-local-user-minor-mode  nil))
-               (setq keyseq ad-do-it)) 
-           (setq keyseq ad-do-it))))
-    keyseq))
-    
-(defadvice describe-key (before vip-read-keyseq-ad protect activate)
-  "Force to read key via `read-key-sequence'."
-  (interactive (list (vip-events-to-keys
-                     (read-key-sequence "Describe key: ")))))
-
-(defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate)
-  "Force to read key via `read-key-sequence'."
-  (interactive (list (vip-events-to-keys
-                     (read-key-sequence "Describe key briefly: ")))))
 
 ;; Listen to ESC key.
 ;; If a sequence of keys starting with ESC is issued with very short delays,
@@ -3188,8 +3142,6 @@ controlled by the sign of prefix numeric value."
 \f
 ;; scrolling
 
-(setq scroll-step 1)
-
 (defun vip-scroll-screen (arg)
   "Scroll to next screen."
   (interactive "p")
@@ -3628,51 +3580,6 @@ To turn this feature off, set this variable to nil.")
     ))
 
 
-;; Advice for use in find-file and read-file-name commands.
-(defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate)
-  "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
-  (run-hooks 'vip-minibuffer-exit-hook))
-
-(defadvice find-file (before vip-add-suffix-advice activate)
-  "Use `read-file-name' for reading arguments."
-  (interactive (cons (read-file-name "Find file: " nil default-directory)
-                    ;; if Mule and prefix argument, ask for coding system
-                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
-                            (featurep 'mule)) ; mule integrated XEmacs 20
-                        (list
-                         (and current-prefix-arg
-                              (read-coding-system "Coding-system: "))))
-                    )))
-    
-(defadvice find-file-other-window (before vip-add-suffix-advice activate)
-  "Use `read-file-name' for reading arguments."
-  (interactive (cons (read-file-name "Find file in other window: "
-                                    nil default-directory)
-                    ;; if Mule and prefix argument, ask for coding system
-                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
-                            (featurep 'mule)) ; mule integrated XEmacs 20
-                        (list
-                         (and current-prefix-arg
-                              (read-coding-system "Coding-system: "))))
-                    )))
-    
-(defadvice find-file-other-frame (before vip-add-suffix-advice activate)
-  "Use `read-file-name' for reading arguments."
-  (interactive (cons (read-file-name "Find file in other frame: "
-                                    nil default-directory)
-                    ;; if Mule and prefix argument, ask for coding system
-                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
-                            (featurep 'mule)) ; mule integrated XEmacs 20
-                        (list
-                         (and current-prefix-arg
-                              (read-coding-system "Coding-system: "))))
-                    )))
-
-(defadvice read-file-name (around vip-suffix-advice activate)
-  "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
-  (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
-    ad-do-it))
-
      
 \f
 ;; yank and pop
index 4c64b7b3c708f2c522a59ea788e64b6451f31a4b..4a81df559e05a7851826b68b4911bd55c8e71791 100644 (file)
 (defvar vip-custom-file-name)
 (defvar vip-case-fold-search)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-util)
-       (load "viper-util.el" nil nil 'nosuffix))
-    (or (featurep 'viper-keym)
-       (load "viper-keym.el" nil nil 'nosuffix))
-    (or (featurep 'viper-cmd)
-       (load "viper-cmd.el" nil nil 'nosuffix))
-    ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-util)
+           (load "viper-util.el" nil nil 'nosuffix))
+       (or (featurep 'viper-keym)
+           (load "viper-keym.el" nil nil 'nosuffix))
+       (or (featurep 'viper-cmd)
+           (load "viper-cmd.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 (require 'viper-util)
index b8fa5d1d84b40d9a4b13982d744d372b3074333a..84a40193cb51199a75bef6c8e9a931a6a5456f07 100644 (file)
 
 ;; compiler pacifier
 (defvar mark-even-if-inactive)
+(defvar viper-version)
 ;; end pacifier
 
+
+;; Viper version
+(defun viper-version ()
+  (interactive)
+  (message "Viper version is %s" viper-version)) 
+(defalias 'vip-version 'viper-version)
+
 ;; Is it XEmacs?
 (defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
 ;; Is it Emacs?
@@ -122,15 +130,6 @@ that Viper doesn't know about.")
 \f
 ;;; Viper minor modes
 
-;; This is not local in Emacs, so we make it local.
-;; This must be local because although the stack of minor modes can be the same
-;; for all buffers, the associated *keymaps* can be different. In Viper,
-;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
-;; different keymaps for different buffers.
-;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
-;; can be different.
-(make-variable-buffer-local 'minor-mode-map-alist)
-
 ;; Mode for vital things like \e, C-z.
 (vip-deflocalvar vip-vi-intercept-minor-mode nil)
 
@@ -597,9 +596,6 @@ These buffers can be cycled through via :R and :P commands.")
 \f
 ;;; Miscellaneous
 
-;; don't bark when mark is inactive
-(setq mark-even-if-inactive t)
-
 (defvar vip-inhibit-startup-message nil
   "Whether Viper startup message should be inhibited.")
 
@@ -634,12 +630,6 @@ Should be set in `~/.vip' file.")
 ;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run
 ;; *after* exiting the minibuffer
 (defvar vip-minibuffer-exit-hook nil)
-
-;; setup emacs-supported vi-style feel
-(setq next-line-add-newlines nil
-      require-final-newline t)
-
-(make-variable-buffer-local 'require-final-newline)
        
 
 ;; Mode line
index 2ff89a7f6df4a2b331b2c53b8e8578d215d0e85b..370ae3de291f5dbaa09b31d24c7cd3af63d19f89 100644 (file)
 (defvar vip-ex-style-editing-in-insert)
 (defvar vip-ex-style-motion)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-util)
-       (load "viper-util.el" nil nil 'nosuffix))
-    ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-util)
+           (load "viper-util.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 (require 'viper-util)
index 3328eacd527106200f3b8f721adaa086718e6fde..07e39038b472e6ff903055ff4acd5a176b508d7e 100644 (file)
 (defvar vip-custom-file-name)
 (defvar vip-current-state)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-util)
-       (load "viper-util.el" nil nil 'nosuffix))
-    (or (featurep 'viper-keym)
-       (load "viper-keym.el" nil nil 'nosuffix))
-    (or (featurep 'viper-mous)
-       (load "viper-mous.el" nil nil 'nosuffix))
-    (or (featurep 'viper-cmd)
-       (load "viper-cmd.el" nil nil 'nosuffix))
-    ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-util)
+           (load "viper-util.el" nil nil 'nosuffix))
+       (or (featurep 'viper-keym)
+           (load "viper-keym.el" nil nil 'nosuffix))
+       (or (featurep 'viper-mous)
+           (load "viper-mous.el" nil nil 'nosuffix))
+       (or (featurep 'viper-cmd)
+           (load "viper-cmd.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 (require 'viper-util)
@@ -317,14 +320,6 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
 
 
 
-(defadvice start-kbd-macro (after vip-kbd-advice activate)
-  "Remove Viper's intercepting bindings for C-x ).
-This may be needed if the previous `:map' command terminated abnormally."
-  (define-key vip-vi-intercept-map "\C-x)" nil)
-  (define-key vip-insert-intercept-map "\C-x)" nil)
-  (define-key vip-emacs-intercept-map "\C-x)" nil))
-
-
 \f
 ;;; Recording, unrecording, executing
 
index b9638175e02a89912c7fdc570ff91fac972b570c..d7e617f879658f18e707a00f787f147409f6056c 100644 (file)
 (defvar vip-s-string)
 (defvar vip-re-search)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-util)
-       (load "viper-util.el" nil nil 'nosuffix))
-    (or (featurep 'viper-cmd)
-       (load "viper-cmd.el" nil nil 'nosuffix))
-    ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-util)
+           (load "viper-util.el" nil nil 'nosuffix))
+       (or (featurep 'viper-cmd)
+           (load "viper-cmd.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 (require 'viper-util)
@@ -427,46 +430,5 @@ bindings in the Viper manual."
        vip-current-frame-saved (selected-frame)))
 
 
-(cond ((vip-window-display-p)
-       (let* ((search-key (if vip-xemacs-p
-                             [(meta shift button1up)] [M-S-mouse-1]))
-             (search-key-catch (if vip-xemacs-p
-                                   [(meta shift button1)] [M-S-down-mouse-1]))
-             (insert-key (if vip-xemacs-p
-                             [(meta shift button2up)] [M-S-mouse-2]))
-             (insert-key-catch (if vip-xemacs-p
-                                   [(meta shift button2)] [M-S-down-mouse-2]))
-             (search-key-unbound (and (not (key-binding search-key))
-                                      (not (key-binding search-key-catch))))
-             (insert-key-unbound (and (not (key-binding insert-key))
-                                      (not (key-binding insert-key-catch))))
-             )
-            
-        (if search-key-unbound
-            (global-set-key search-key 'vip-mouse-click-search-word))
-        (if insert-key-unbound
-            (global-set-key insert-key 'vip-mouse-click-insert-word))
-    
-        ;; The following would be needed if you want to use the above two
-        ;; while clicking in another frame. If you only want to use them
-        ;; by clicking in another window, not frame, the bindings below
-        ;; aren't necessary.
-        
-        ;; These must be bound to mouse-down event for the same mouse
-        ;; buttons as 'vip-mouse-click-search-word and
-        ;; 'vip-mouse-click-insert-word
-        (if search-key-unbound
-            (global-set-key search-key-catch   'vip-mouse-catch-frame-switch))
-        (if insert-key-unbound
-            (global-set-key insert-key-catch   'vip-mouse-catch-frame-switch))
-        
-        (if vip-xemacs-p
-            (add-hook 'mouse-leave-frame-hook
-                      'vip-remember-current-frame)
-          (defadvice handle-switch-frame (before vip-frame-advice activate)
-            "Remember the selected frame before the switch-frame event." 
-            (vip-remember-current-frame (selected-frame))))
-       )))
-
 
 ;;;  viper-mous.el ends here
index 95ac4476a35b17bcec167256dd15d2a4930d3b51..efcb637fe25c0f78f5d11d8e312562f5c52a4bcb 100644 (file)
 (require 'cl)
 (require 'ring)
 
-(and noninteractive
-     (eval-when-compile
-       (let ((load-path (cons (expand-file-name ".") load-path)))
-        (or (featurep 'viper-init)
-            (load "viper-init.el" nil nil 'nosuffix))
-        )))
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-init)
+           (load "viper-init.el" nil nil 'nosuffix))
+       )))
 ;; end pacifier
 
 (require 'viper-init)
index 6a8e9e4e717bf2b84f6df76298af919361a12156..2e33a428ad85f6c7f63d53ce5dab1fd55cb5790f 100644 (file)
@@ -8,7 +8,7 @@
 
 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
-(defconst viper-version "2.94 of June 2, 1997"
+(defconst viper-version "2.94 of June 9, 1997"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
 (require 'cl)
 (require 'ring)
 
-(eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (or (featurep 'viper-cmd)
-       (load "viper-cmd.el" nil nil 'nosuffix))
-    ))
+;; compiler pacifier
+(defvar mark-even-if-inactive)
 
-(require 'viper-cmd)
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+    (eval-when-compile
+      (let ((load-path (cons (expand-file-name ".") load-path)))
+       (or (featurep 'viper-cmd)
+           (load "viper-cmd.el" nil nil 'nosuffix))
+       )))
+;; end pacifier
 
-;; Viper version
-(defun viper-version ()
-  (interactive)
-  (message "Viper version is %s" viper-version)) 
-  
-(defalias 'vip-version 'viper-version)
+(require 'viper-cmd)
 
 
 ;; The following is provided for compatibility with older VIP's
 (defalias 'vip-change-mode-to-emacs 'vip-change-state-to-emacs)
    
 \f
+;;; Here we put things that may affect global emacs behavior.
+;;; This file is not loaded during compilation, so this makes 
+;;; interactive compilation of Viper safe for non-viper users.
+
+
+;; This is not local in Emacs, so we make it local.
+;; This must be local because although the stack of minor modes can be the same
+;; for all buffers, the associated *keymaps* can be different. In Viper,
+;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
+;; different keymaps for different buffers.
+;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
+;; can be different.
+(make-variable-buffer-local 'minor-mode-map-alist)
+
 ;; Viper changes the default mode-line-buffer-identification
 (setq-default mode-line-buffer-identification '(" %b"))
 
+;; setup emacs-supported vi-style feel
+(setq next-line-add-newlines nil
+      require-final-newline t)
+
+(make-variable-buffer-local 'require-final-newline)
+
+;; don't bark when mark is inactive
+(setq mark-even-if-inactive t)
+
+(setq scroll-step 1)
+
 ;; Variable displaying the current Viper state in the mode line.
 (vip-deflocalvar vip-mode-string vip-emacs-state-id)
 (or (memq 'vip-mode-string global-mode-string)
          (append '("" vip-mode-string) (cdr global-mode-string))))
 
 
+
 \f
 ;;; Load set up hooks then load .vip
 
     "Switch to emacs state when done editing message."
     (vip-change-state-to-emacs))
   ) ; vip-set-hooks
+
+\f
+;; Defadvices
+
+(defadvice read-key-sequence (around vip-read-keyseq-ad activate)
+  "Harness to work for Viper. This advice is harmless---don't worry!"
+  (let (inhibit-quit event keyseq)
+    (setq keyseq ad-do-it)
+    (setq event (if vip-xemacs-p
+                   (elt keyseq 0) ; XEmacs returns vector of events
+                 (elt (listify-key-sequence keyseq) 0)))
+    (if (vip-ESC-event-p event)
+       (let (unread-command-events)
+         (vip-set-unread-command-events keyseq)
+         (if (vip-fast-keysequence-p)
+             (let ((vip-vi-global-user-minor-mode  nil)
+                   (vip-vi-local-user-minor-mode  nil)
+                   (vip-replace-minor-mode nil) ; actually unnecessary
+                   (vip-insert-global-user-minor-mode  nil)
+                   (vip-insert-local-user-minor-mode  nil))
+               (setq keyseq ad-do-it)) 
+           (setq keyseq ad-do-it))))
+    keyseq))
+    
+(defadvice describe-key (before vip-read-keyseq-ad protect activate)
+  "Force to read key via `read-key-sequence'."
+  (interactive (list (vip-events-to-keys
+                     (read-key-sequence "Describe key: ")))))
+
+(defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate)
+  "Force to read key via `read-key-sequence'."
+  (interactive (list (vip-events-to-keys
+                     (read-key-sequence "Describe key briefly: ")))))
+
+
+;; Advice for use in find-file and read-file-name commands.
+(defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate)
+  "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
+  (run-hooks 'vip-minibuffer-exit-hook))
+
+(defadvice find-file (before vip-add-suffix-advice activate)
+  "Use `read-file-name' for reading arguments."
+  (interactive (cons (read-file-name "Find file: " nil default-directory)
+                    ;; if Mule and prefix argument, ask for coding system
+                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
+                            (featurep 'mule)) ; mule integrated XEmacs 20
+                        (list
+                         (and current-prefix-arg
+                              (read-coding-system "Coding-system: "))))
+                    )))
+    
+(defadvice find-file-other-window (before vip-add-suffix-advice activate)
+  "Use `read-file-name' for reading arguments."
+  (interactive (cons (read-file-name "Find file in other window: "
+                                    nil default-directory)
+                    ;; if Mule and prefix argument, ask for coding system
+                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
+                            (featurep 'mule)) ; mule integrated XEmacs 20
+                        (list
+                         (and current-prefix-arg
+                              (read-coding-system "Coding-system: "))))
+                    )))
+    
+(defadvice find-file-other-frame (before vip-add-suffix-advice activate)
+  "Use `read-file-name' for reading arguments."
+  (interactive (cons (read-file-name "Find file in other frame: "
+                                    nil default-directory)
+                    ;; if Mule and prefix argument, ask for coding system
+                    (if (or (boundp 'MULE)    ; mule integrated Emacs 19
+                            (featurep 'mule)) ; mule integrated XEmacs 20
+                        (list
+                         (and current-prefix-arg
+                              (read-coding-system "Coding-system: "))))
+                    )))
+
+(defadvice read-file-name (around vip-suffix-advice activate)
+  "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
+  (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
+    ad-do-it))
+
+(defadvice start-kbd-macro (after vip-kbd-advice activate)
+  "Remove Viper's intercepting bindings for C-x ).
+This may be needed if the previous `:map' command terminated abnormally."
+  (define-key vip-vi-intercept-map "\C-x)" nil)
+  (define-key vip-insert-intercept-map "\C-x)" nil)
+  (define-key vip-emacs-intercept-map "\C-x)" nil))
+
+(cond ((vip-window-display-p)
+       (let* ((search-key (if vip-xemacs-p
+                             [(meta shift button1up)] [M-S-mouse-1]))
+             (search-key-catch (if vip-xemacs-p
+                                   [(meta shift button1)] [M-S-down-mouse-1]))
+             (insert-key (if vip-xemacs-p
+                             [(meta shift button2up)] [M-S-mouse-2]))
+             (insert-key-catch (if vip-xemacs-p
+                                   [(meta shift button2)] [M-S-down-mouse-2]))
+             (search-key-unbound (and (not (key-binding search-key))
+                                      (not (key-binding search-key-catch))))
+             (insert-key-unbound (and (not (key-binding insert-key))
+                                      (not (key-binding insert-key-catch))))
+             )
+            
+        (if search-key-unbound
+            (global-set-key search-key 'vip-mouse-click-search-word))
+        (if insert-key-unbound
+            (global-set-key insert-key 'vip-mouse-click-insert-word))
+    
+        ;; The following would be needed if you want to use the above two
+        ;; while clicking in another frame. If you only want to use them
+        ;; by clicking in another window, not frame, the bindings below
+        ;; aren't necessary.
+        
+        ;; These must be bound to mouse-down event for the same mouse
+        ;; buttons as 'vip-mouse-click-search-word and
+        ;; 'vip-mouse-click-insert-word
+        (if search-key-unbound
+            (global-set-key search-key-catch   'vip-mouse-catch-frame-switch))
+        (if insert-key-unbound
+            (global-set-key insert-key-catch   'vip-mouse-catch-frame-switch))
+        
+        (if vip-xemacs-p
+            (add-hook 'mouse-leave-frame-hook
+                      'vip-remember-current-frame)
+          (defadvice handle-switch-frame (before vip-frame-advice activate)
+            "Remember the selected frame before the switch-frame event." 
+            (vip-remember-current-frame (selected-frame))))
+       )))
+
+
+\f
       
 ;; Set some useful macros
 ;; These must be before we load .vip, so the user could unrecord them.